From: J. Shirley Date: Thu, 12 Jul 2007 15:33:41 +0000 (+0000) Subject: 0.02 patch thanks to dwc. X-Git-Tag: v0.14~39 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=25650747028b09cc100f79d4f456584ca7dc182c;p=catagits%2FCatalyst-View-Email.git 0.02 patch thanks to dwc. --- diff --git a/MANIFEST b/MANIFEST index 5435eb8..59e7aa6 100644 --- a/MANIFEST +++ b/MANIFEST @@ -1,3 +1,14 @@ +inc/Module/AutoInstall.pm +inc/Module/Install.pm +inc/Module/Install/AutoInstall.pm +inc/Module/Install/Base.pm +inc/Module/Install/Can.pm +inc/Module/Install/Fetch.pm +inc/Module/Install/Include.pm +inc/Module/Install/Makefile.pm +inc/Module/Install/Metadata.pm +inc/Module/Install/Win32.pm +inc/Module/Install/WriteAll.pm lib/Catalyst/Helper/View/Email.pm lib/Catalyst/Helper/View/Email/Template.pm lib/Catalyst/View/Email.pm @@ -5,3 +16,14 @@ lib/Catalyst/View/Email/Template.pm Makefile.PL MANIFEST This list of files META.yml +t/01use.t +t/02pod.t +t/04basic.t +t/05template.t +t/lib/TestApp.pm +t/lib/TestApp/Controller/Root.pm +t/lib/TestApp/View/Email.pm +t/lib/TestApp/View/Email/Template.pm +t/lib/TestApp/View/TT.pm +t/root/text_html/test.tt +t/root/text_plain/test.tt diff --git a/lib/Catalyst/View/Email.pm b/lib/Catalyst/View/Email.pm index 8098fde..fe9afca 100644 --- a/lib/Catalyst/View/Email.pm +++ b/lib/Catalyst/View/Email.pm @@ -11,7 +11,7 @@ use Email::MIME::Creator; use base qw|Catalyst::View|; -our $VERSION = '0.01'; +our $VERSION = '0.02'; __PACKAGE__->mk_accessors('mailer'); @@ -27,6 +27,7 @@ configuration settings. =head1 CONFIGURATION In your app configuration (example in L): + View::Email: stash_key: email content_type: text/plain @@ -96,20 +97,22 @@ your forward to the view, it is a good idea to check for errors: =head1 OTHER MAILERS -Now, it's no fun to just send out email using plain strings. We also have -L for use. You can also toggle this as being used -by setting up your configuration to look like this: +Now, it's no fun to just send out email using plain strings. We also +have L for use. You can also toggle +this as being used by setting up your configuration to look like this: View::Email: - default: TT + default_view: TT -Then, Catalyst::View::Email will forward to View::Email::TT by default. +Then, Catalyst::View::Email will forward to your View::TT by default. =cut sub new { - my ( $class ) = shift; - my $self = $class->next::method(@_); + my $self = shift->next::method(@_); + + my ( $c, $arguments ) = @_; + $self->config($arguments); my $mailer = Email::Send->new; @@ -193,6 +196,12 @@ sub process { J. Shirley +=head1 CONTRIBUTORS + +(Thanks!) + +Daniel Westermann-Clark + =head1 LICENSE This library is free software, you can redistribute it and/or modify it under diff --git a/lib/Catalyst/View/Email/Template.pm b/lib/Catalyst/View/Email/Template.pm index 2ee3080..87c8b54 100644 --- a/lib/Catalyst/View/Email/Template.pm +++ b/lib/Catalyst/View/Email/Template.pm @@ -10,7 +10,7 @@ use Email::MIME::Creator; use base qw|Catalyst::View::Email|; -our $VERSION = '0.01'; +our $VERSION = '0.02'; =head1 NAME @@ -149,6 +149,7 @@ sub process { There needs to be a method to support attachments. What I am thinking is something along these lines: + attachments => [ # Set the body to a file handle object, specify content_type and # the file name. (name is what it is sent at, not the file) diff --git a/t/lib/TestApp.pm b/t/lib/TestApp.pm index 1ef6b28..736e8cd 100644 --- a/t/lib/TestApp.pm +++ b/t/lib/TestApp.pm @@ -6,7 +6,12 @@ use FindBin; TestApp->config( root => "$FindBin::Bin/root", - default_view => 'TT' + default_view => 'TT', + 'View::Email::AppConfig' => { + sender => { + method => 'Test', + }, + }, ); TestApp->setup; diff --git a/t/lib/TestApp/Controller/Root.pm b/t/lib/TestApp/Controller/Root.pm index 737018e..79fb38c 100644 --- a/t/lib/TestApp/Controller/Root.pm +++ b/t/lib/TestApp/Controller/Root.pm @@ -31,6 +31,28 @@ sub email : Global('email') { } } +sub email_app_config : Global('email_app_config') { + my ($self, $c, @args) = @_; + + my $time = $c->req->params->{time} || time; + + $c->stash->{email} = { + to => 'test-email@example.com', + from => 'no-reply@example.com', + subject => 'Email Test', + body => "Email Sent at: $time" + }; + + $c->forward('TestApp::View::Email::AppConfig'); + + if ( scalar( @{ $c->error } ) ) { + $c->res->status(500); + $c->res->body('Email Failed'); + } else { + $c->res->body('Plain Email Ok'); + } +} + sub template_email : Global('template_email') { my ($self, $c, @args) = @_;