[Bast-commits] r9870 - in ironman/IronMan-Web/trunk: .
lib/IronMan/Web/Controller lib/IronMan/Web/View root t
dhoss at dev.catalyst.perl.org
dhoss at dev.catalyst.perl.org
Sat Apr 16 20:34:01 GMT 2011
Author: dhoss
Date: 2011-04-16 20:34:01 +0000 (Sat, 16 Apr 2011)
New Revision: 9870
Added:
ironman/IronMan-Web/trunk/lib/IronMan/Web/View/Email.pm
ironman/IronMan-Web/trunk/root/retrieve_key.tt
ironman/IronMan-Web/trunk/t/view_Email.t
Modified:
ironman/IronMan-Web/trunk/ironman_web.conf
ironman/IronMan-Web/trunk/lib/IronMan/Web/Controller/Root.pm
Log:
tested retrieve_key action
Modified: ironman/IronMan-Web/trunk/ironman_web.conf
===================================================================
--- ironman/IronMan-Web/trunk/ironman_web.conf 2011-04-16 20:33:46 UTC (rev 9869)
+++ ironman/IronMan-Web/trunk/ironman_web.conf 2011-04-16 20:34:01 UTC (rev 9870)
@@ -7,3 +7,13 @@
page_footer "Planet Perl Iron Man"
</branding>
default_view TT
+<View::Email>
+ stash_key email
+ <default>
+ content_type text/plain
+ charset utf-8
+ </default>
+ <sender>
+ mailer Sendmail
+ </sender>
+</View::Email>
Modified: ironman/IronMan-Web/trunk/lib/IronMan/Web/Controller/Root.pm
===================================================================
--- ironman/IronMan-Web/trunk/lib/IronMan/Web/Controller/Root.pm 2011-04-16 20:33:46 UTC (rev 9869)
+++ ironman/IronMan-Web/trunk/lib/IronMan/Web/Controller/Root.pm 2011-04-16 20:34:01 UTC (rev 9870)
@@ -178,21 +178,67 @@
}
}
+=head2 retrieve_key
+
+Retrieve a user's unique key by email
+
+=cut
+
+sub retrieve_key : Local Args(0) {
+ my ( $self, $c ) = @_;
+ my $email = $c->req->param('email');
+ if ( $email ) {
+ my $feed =
+ $c->model('FeedDB::Feed')->find( { owner => $email } );
+ if ( defined $feed ) {
+ $c->log->info( 'found key: ' . $feed->id );
+ $c->stash(
+ email => {
+ to => $email,
+ from => 'me at dhoss.net',
+ subject => 'Your IronMan Blog Key',
+ body => qq{
+ Hello } . $feed->owner . qq{,
+ You or someone else has requested your IronMan Blog key.
+ Here it is: } . $feed->id . qq{
+ Regards,
+ The IronMan Blogging Tech Monkies
+ },
+ },
+ );
+
+ $c->forward( $c->view('Email') );
+
+ if ( scalar( @{ $c->error } ) ) {
+
+ $c->stash( error => $c->error );
+
+ } else {
+
+ $c->stash(
+ sent => 1,
+ to => $feed->owner );
+ }
+
+ }
+ }
+}
+
=head2 end
Attempt to render a view, if needed.
=cut
- sub end : ActionClass('RenderView') {
- my ( $self, $c ) = @_;
+sub end : ActionClass('RenderView') {
+ my ( $self, $c ) = @_;
- $c->stash( current_view => 'RSS' )
- if ( ( $c->req->param('feed') && $c->req->param('feed') eq 'rss' )
- || ( $c->req->param('feed') && $c->req->param('feed') eq 'RSS' )
- || ( $c->req->param('feed') && $c->req->param('feed') eq 'atom' ) );
+ $c->stash( current_view => 'RSS' )
+ if ( ( $c->req->param('feed') && $c->req->param('feed') eq 'rss' )
+ || ( $c->req->param('feed') && $c->req->param('feed') eq 'RSS' )
+ || ( $c->req->param('feed') && $c->req->param('feed') eq 'atom' ) );
- }
+}
=head1 AUTHOR
@@ -205,4 +251,4 @@
=cut
- 1;
+1;
Added: ironman/IronMan-Web/trunk/lib/IronMan/Web/View/Email.pm
===================================================================
--- ironman/IronMan-Web/trunk/lib/IronMan/Web/View/Email.pm (rev 0)
+++ ironman/IronMan-Web/trunk/lib/IronMan/Web/View/Email.pm 2011-04-16 20:34:01 UTC (rev 9870)
@@ -0,0 +1,33 @@
+package IronMan::Web::View::Email;
+
+use strict;
+use base 'Catalyst::View::Email';
+
+__PACKAGE__->config(
+ stash_key => 'email'
+);
+
+=head1 NAME
+
+IronMan::Web::View::Email - Email View for IronMan::Web
+
+=head1 DESCRIPTION
+
+View for sending email from IronMan::Web.
+
+=head1 AUTHOR
+
+Devin Austin
+
+=head1 SEE ALSO
+
+L<IronMan::Web>
+
+=head1 LICENSE
+
+This library is free software, you can redistribute it and/or modify
+it under the same terms as Perl itself.
+
+=cut
+
+1;
Added: ironman/IronMan-Web/trunk/root/retrieve_key.tt
===================================================================
--- ironman/IronMan-Web/trunk/root/retrieve_key.tt (rev 0)
+++ ironman/IronMan-Web/trunk/root/retrieve_key.tt 2011-04-16 20:34:01 UTC (rev 9870)
@@ -0,0 +1,12 @@
+[% UNLESS error %]
+[% IF sent %]
+<p>Your key is en route to [% to %]</p>
+[% END %]
+<h2>Retrieve your IronMan Blog key</h2>
+<form method="post" action="">
+<p>Your email: <input type="text" name="email" /></p>
+<p><input type="submit" value="Get it" /></p>
+</form>
+[% ELSE %]
+[% error %]
+[% END %]
Added: ironman/IronMan-Web/trunk/t/view_Email.t
===================================================================
--- ironman/IronMan-Web/trunk/t/view_Email.t (rev 0)
+++ ironman/IronMan-Web/trunk/t/view_Email.t 2011-04-16 20:34:01 UTC (rev 9870)
@@ -0,0 +1,8 @@
+use strict;
+use warnings;
+use Test::More;
+use Test::More;
+
+BEGIN { use_ok 'IronMan::Web::View::Email' }
+
+done_testing();
More information about the Bast-commits
mailing list