[Bast-commits] r9877 - in ironman/IronMan-Web/tags/IronMan-Web-0.02: . lib/IronMan/Web/Controller lib/IronMan/Web/View root root/inc t

idn at dev.catalyst.perl.org idn at dev.catalyst.perl.org
Tue Apr 26 07:49:09 GMT 2011


Author: idn
Date: 2011-04-26 07:49:09 +0000 (Tue, 26 Apr 2011)
New Revision: 9877

Added:
   ironman/IronMan-Web/tags/IronMan-Web-0.02/lib/IronMan/Web/View/Email.pm
   ironman/IronMan-Web/tags/IronMan-Web-0.02/root/retrieve_key.tt
   ironman/IronMan-Web/tags/IronMan-Web-0.02/t/view_Email.t
Modified:
   ironman/IronMan-Web/tags/IronMan-Web-0.02/
   ironman/IronMan-Web/tags/IronMan-Web-0.02/Makefile.PL
   ironman/IronMan-Web/tags/IronMan-Web-0.02/development-cycle.pod
   ironman/IronMan-Web/tags/IronMan-Web-0.02/ironman_web.conf
   ironman/IronMan-Web/tags/IronMan-Web-0.02/lib/IronMan/Web/Controller/Root.pm
   ironman/IronMan-Web/tags/IronMan-Web-0.02/root/inc/ironman_header.tt
   ironman/IronMan-Web/tags/IronMan-Web-0.02/root/update_feed.tt
Log:
Merge from trunk ready for release


Property changes on: ironman/IronMan-Web/tags/IronMan-Web-0.02
___________________________________________________________________
Modified: svn:mergeinfo
   - /ironman/IronMan-Web/branches/user_edit:9627-9858
   + /ironman/IronMan-Web/branches/user_edit:9627-9875
/ironman/IronMan-Web/trunk:9860-9876

Modified: ironman/IronMan-Web/tags/IronMan-Web-0.02/Makefile.PL
===================================================================
--- ironman/IronMan-Web/tags/IronMan-Web-0.02/Makefile.PL	2011-04-26 07:46:49 UTC (rev 9876)
+++ ironman/IronMan-Web/tags/IronMan-Web-0.02/Makefile.PL	2011-04-26 07:49:09 UTC (rev 9877)
@@ -24,7 +24,7 @@
 requires 'YAML::XS';
 requires 'IronMan::Schema';
 requires 'Term::Prompt';
-
+requires 'Try::Tiny';
 # We need DateTime::Format::SQLite for script/import_csv.pl if using SQLite
 recommends 'DateTime::Format::SQLite';
 

Modified: ironman/IronMan-Web/tags/IronMan-Web-0.02/development-cycle.pod
===================================================================
--- ironman/IronMan-Web/tags/IronMan-Web-0.02/development-cycle.pod	2011-04-26 07:46:49 UTC (rev 9876)
+++ ironman/IronMan-Web/tags/IronMan-Web-0.02/development-cycle.pod	2011-04-26 07:49:09 UTC (rev 9877)
@@ -8,14 +8,34 @@
  
 The latest version of this document can be found at:
 
-    http://dev.catalyst.perl.org/repos/bast/ironman/IronMan-Web/branches/dev/development-cycle.pod
+    http://dev.catalyst.perl.org/repos/bast/ironman/IronMan-Web/trunk/development-cycle.pod
 
-=head2 Development branch preparation.
+The repository is layed out as follows:
 
-The development branch has the following known intentional differences:
+    branches    - current development branches
+    tags        - current releases including live and dev sites
+    trunk       - current cutting edge waiting for release tagging
 
-=head3 The '-Debug' option
+=head1 Trunk and branches.
 
+Trunk contains the latest cutting edge code.  It's recommended that you don't
+work directly in trunk, but create yourself a branch.
+
+=head2 Branches.
+
+Create your own branch for 'very cool new feature' as follows:
+
+    svn cp http://dev.catalyst.perl.org/repos/bast/ironman/IronMan-Web/trunk/ \
+           http://dev.catalyst.perl.org/repos/bast/ironman/IronMan-Web/branches/very_cool_new_feature \
+        -m "Creating branch to work on my very cool new feature"
+
+Work on files in your branch, then once you're done you can either poke someone
+on the irc channel or you can merge it back into trunk yourself (see below).
+
+=head2 The '-Debug' option
+
+You may wish to enable the Catalyst debugging module within your branch.
+
     diff -Naur branches/ironboy/lib/IronMan/Web.pm branches/dev/lib/IronMan/Web.pm
     --- branches/ironboy/lib/IronMan/Web.pm 2010-07-10 10:37:30.825413356 +0100
     +++ branches/dev/lib/IronMan/Web.pm     2010-07-10 10:37:31.174421647 +0100
@@ -28,22 +48,65 @@
      
      our $VERSION = '0.01';
 
-=head2 Comparing branches
 
-Use the following to compare the two branches:
+=head1 Merging bug fixes and branches back into trunk.
 
-    diff -Naur branches/ironboy/ branches/dev/ --exclude .svn | more
+In order to maintain a nice history and clean revisions for rollback and
+additions, we'll create ourselves a new tagged version and then copy that
+to ironboy for testing.  Once testing is completed, we'll delete the
+ironboy tag and copy ironman to it.
 
-Carefully review the changes presented to ensure there is nothing unexpected.
+=head2 Merging into trunk
 
-=head2 Development to IronBoy
+Merging a branch back into trunk:
 
-Merge the changes from dev to ironboy, I suggest doing this per file (eg :
+    svn co http://dev.catalyst.perl.org/repos/bast/ironman/IronMan-Web/trunk/
+    cd trunk
+    svn merge --reintegrate http://dev.catalyst.perl.org/repos/bast/ironman/IronMan-Web/branches/very_cool_new_feature
+    svn commit -m "Merging very cool new feature branch back into trunk"
 
+=head2 Comparing branches for cherry picking
 
 
-    svn merge 
+Need to add docs here...
 
-    
 
+=head1 Release process
+
+=head2 Trunk to release
+
+Increment the version number within lib/IronMan/Web.pm:
+
+    our $VERSION = '0.02';
+
+Commit the change:
+
+    svn commit lib/IronMan/Web.pm -m "Incrementing version"
+
+Copy trunk to the release:
+
+    svn cp http://dev.catalyst.perl.org/repos/bast/ironman/IronMan-Web/tags/IronMan-Web-0.02 \
+           http://dev.catalyst.perl.org/repos/bast/ironman/IronMan-Web/tags/ironboy \
+        -m "Releasing IronMan-Web-0.02 to ironboy"
+
+=head2 Release to ironboy
+
+Delete the currently tagges ironman
+
+    svn del http://dev.catalyst.perl.org/repos/bast/ironman/IronMan-Web/tags/ironboy \
+         -m "Removing ironboy for release of IronMan-Web-0.02"
+    svn cp http://dev.catalyst.perl.org/repos/bast/ironman/IronMan-Web/tags/IronMan-Web-0.02 \
+           http://dev.catalyst.perl.org/repos/bast/ironman/IronMan-Web/tags/ironboy \
+        -m "Releasing IronMan-Web-0.02 to ironboy"
+
+=head2 Ironboy to ironman
+
+Delete the currently tagges ironman
+
+    svn del http://dev.catalyst.perl.org/repos/bast/ironman/IronMan-Web/tags/ironman \
+         -m "Removing ironman for release of ironboy"
+    svn cp http://dev.catalyst.perl.org/repos/bast/ironman/IronMan-Web/tags/ironboy
+           http://dev.catalyst.perl.org/repos/bast/ironman/IronMan-Web/tags/ironman \
+        -m "Releasing ironboy to ironman"
+
 =cut

Modified: ironman/IronMan-Web/tags/IronMan-Web-0.02/ironman_web.conf
===================================================================
--- ironman/IronMan-Web/tags/IronMan-Web-0.02/ironman_web.conf	2011-04-26 07:46:49 UTC (rev 9876)
+++ ironman/IronMan-Web/tags/IronMan-Web-0.02/ironman_web.conf	2011-04-26 07:49:09 UTC (rev 9877)
@@ -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/tags/IronMan-Web-0.02/lib/IronMan/Web/Controller/Root.pm
===================================================================
--- ironman/IronMan-Web/tags/IronMan-Web-0.02/lib/IronMan/Web/Controller/Root.pm	2011-04-26 07:46:49 UTC (rev 9876)
+++ ironman/IronMan-Web/tags/IronMan-Web-0.02/lib/IronMan/Web/Controller/Root.pm	2011-04-26 07:49:09 UTC (rev 9877)
@@ -1,5 +1,4 @@
 package IronMan::Web::Controller::Root;
-
 use strict;
 use warnings;
 use Data::UUID;
@@ -7,6 +6,7 @@
 use Email::Valid;
 use DateTime;
 use XML::OPML;
+use Try::Tiny;
 use base 'Catalyst::Controller::reCAPTCHA';
 
 #
@@ -30,33 +30,42 @@
 =head2 auto
 
 =cut
+
 sub auto : Private {
-    my ( $self, $c ) = @_;
+  my ( $self, $c ) = @_;
 
-    $c->stash->{'feeds'} = $c->model('FeedDB::Feed')->search({ 'link' => \'IS NOT NULL'});
-    $c->stash->{'branding'} = $c->config()->{'branding'};
+  $c->stash->{'feeds'} =
+    $c->model('FeedDB::Feed')->search( { 'link' => \'IS NOT NULL' } );
+  $c->stash->{'branding'} = $c->config()->{'branding'};
 }
 
-
 =head2 index
 
 =cut
 
-sub index :Path :Args(0) {
-    my ( $self, $c ) = @_;
+sub index : Path : Args(0) {
+  my ( $self, $c ) = @_;
 
-    my $posts = $c->model('FeedDB::Post')->search({},{
-        'order_by' => \'posted_on DESC',
-        'rows' => $c->config->{'frontpage_entries'} + 1,
-    });
+  my $posts = $c->model('FeedDB::Post')->search(
+    {},
+    {
+      'order_by' => \'posted_on DESC',
+      'rows'     => $c->config->{'frontpage_entries'} + 1,
+    }
+  );
 
-    $c->stash( 'posts' => $posts );
+  $c->stash( 'posts' => $posts );
 
-    my $next_post = ($posts->all)[-1];
-    
-    my $next_post_date = $next_post->posted_on;
-    my $next_post_url = $c->uri_for_action('archive/day', $next_post_date->year, $next_post_date->month, $next_post_date->day ). '#' . $next_post->post_id;
-    $c->stash( 'older_url' => $next_post_url );
+  my $next_post = ( $posts->all )[-1];
+
+  my $next_post_date = $next_post->posted_on;
+  my $next_post_url  = $c->uri_for_action(
+    'archive/day',          $next_post_date->year,
+    $next_post_date->month, $next_post_date->day
+    )
+    . '#'
+    . $next_post->post_id;
+  $c->stash( 'older_url' => $next_post_url );
 }
 
 =head2 new_feed
@@ -64,98 +73,178 @@
 =cut
 
 sub new_feed : Local {
-    my ($self, $c) = @_;
-    
-    my $url = $c->req->param('url');
-    my $email = $c->req->param('email');
-    my $email_conf = $c->req->param('email_2');
-    my $title = $c->req->param('title');
+  my ( $self, $c ) = @_;
 
-    $c->stash( params => $c->req->params);
-    $c->forward('captcha_get');
+  my $url        = $c->req->param('url');
+  my $email      = $c->req->param('email');
+  my $email_conf = $c->req->param('email_2');
+  my $title      = $c->req->param('title');
 
-    return 1 if(!%{ $c->req->params });
+  $c->stash( params => $c->req->params );
+  $c->forward('captcha_get');
 
-    my $errors = [];
-    my $feed = IronMan::Feeds::verify_feed_data($title, $url, $email, $email_conf, $errors);
-    if(!$feed || @$errors) {
-        $c->log->_dump($errors);
-        $c->stash( errors => $errors);
-        return 1;
-    }
-    if(!$c->forward('captcha_check')) {
-        $c->log->_dump($c->stash->{recaptcha_error});
-        $c->stash( errors => ['reCAPTCHA failed']);
-        return 1;
-    }
+  return 1 if ( !%{ $c->req->params } );
 
-    $c->log->debug("input ok");
+  my $errors = [];
+  my $feed =
+    IronMan::Feeds::verify_feed_data( $title, $url, $email, $email_conf,
+    $errors );
+  if ( !$feed || @$errors ) {
+    $c->log->_dump($errors);
+    $c->stash( errors => $errors );
+    return 1;
+  }
+  if ( !$c->forward('captcha_check') ) {
+    $c->log->_dump( $c->stash->{recaptcha_error} );
+    $c->stash( errors => ['reCAPTCHA failed'] );
+    return 1;
+  }
 
-    ## verify_feed_data attempts to find the first feed in the given page, if it is not a feed
-    $url = $feed->{feed};
-    $c->stash(feed_url => $url);
-    
-    my ($res, $fdb) = $c->model('FeedDB::Feed')->add_new_blog(title => $title, 
-                                                              url => $url, 
-                                                              email => $email);
+  $c->log->debug("input ok");
 
-    if(!$res) {
-        $c->stash(existed => 1);
-        $c->log->debug("$url already exists, id: " . $fdb->id);
-        return 1;
-    }
-    
-    $c->stash(inserted => $fdb->id);
+  ## verify_feed_data attempts to find the first feed in the given page, if it is not a feed
+  $url = $feed->{feed};
+  $c->stash( feed_url => $url );
+
+  my ( $res, $fdb ) = $c->model('FeedDB::Feed')->add_new_blog(
+    title => $title,
+    url   => $url,
+    email => $email
+  );
+
+  if ( !$res ) {
+    $c->stash( existed => 1 );
+    $c->log->debug( "$url already exists, id: " . $fdb->id );
+    return 1;
+  }
+
+  $c->stash( inserted => $fdb->id );
 }
 
 #Display OPML showing the feeds.
 sub opml : Local Args(0) {
-    my ( $self, $c ) = @_;
+  my ( $self, $c ) = @_;
 
-    my $opml = new XML::OPML(version => "1.1");
+  my $opml = new XML::OPML( version => "1.1" );
 
-    $opml->head(
-        title => 'all.things.per.ly',
-        dateCreated => DateTime->now(),
-    ); 
+  $opml->head(
+    title       => 'all.things.per.ly',
+    dateCreated => DateTime->now(),
+  );
 
-    $c->res->content_type('application/xml');
+  $c->res->content_type('application/xml');
 
-    foreach my $feed ($c->model('FeedDB::Feed')->all) {
-        $opml->add_outline( 
-            'title'     => $feed->title,
-            'xmlUrl'    => $feed->url,
-        );
-    }
+  foreach my $feed ( $c->model('FeedDB::Feed')->all ) {
+    $opml->add_outline(
+      'title'  => $feed->title,
+      'xmlUrl' => $feed->url,
+    );
+  }
 
-    $c->res->body($opml->as_string);
+  $c->res->body( $opml->as_string );
 }
 
-
 =head2 update_feed
 
 Update a feed give a user's unique key
 
 =cut
 
-sub update_feed : Local Args(1) {
-  my ($self, $c, $id) = @_;
-  my $feed = $c->model('FeedDB::Feed')->find({ id => $id });
-  if ( defined $feed ) {
-    $c->stash( 
-      owner => $feed->owner,
-      feed  => $feed->url,
-    );
-    if ( $c->req->param('url') ) {
-      $feed->update({ url => $c->req->param('url') })
-        or die "Error: $!";
-      $c->stash( updated => 1 );
+sub update_feed : Local Args(0) {
+  my ( $self, $c ) = @_;
+  if ( $c->req->param ) {
+    if ( $c->req->param('url')
+      && $c->req->param('email')
+      && $c->req->param('id') )
+    {
+
+      my $feed = $c->model('FeedDB::Feed')->find(
+        {
+          id    => $c->req->param('id'),
+          email => $c->req->param('email')
+        }
+      );
+
+      if ( defined $feed ) {
+
+        $feed->update( { url => $c->req->param('url') } )
+          or die "Error: $!";
+        $c->stash( updated => 1 );
+
+      } else {
+
+        $c->stash( error => "No such user" );
+
+      }
+
+    } else {
+      $c->stash( error => "All fields required." );
     }
-  } else {
-    $c->stash( error => "No such user" );
   }
 }
 
+=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 ( $c->req->param ) {
+    if ($email) {
+      my $feed;
+      ## don't notify whether email address was found,
+      ## brute force could theoretically give a list of valid emails
+      ## contained here.
+      try {
+        $feed = $c->model('FeedDB::Feed')->find( { owner => $email } );
+        $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 );
+
+        }
+
+      }
+      finally {
+        if (@_) {
+          $c->log->error( "Original error: @_" );
+          $c->log->error( 'email ' . $email . ' not found' );
+        }
+        $c->stash(
+          sent => 1,
+          to   => $email
+        );
+
+      };
+
+    } else {
+
+      $c->stash( error => "No email specified" );
+
+    }
+  }
+}
+
 =head2 end
 
 Attempt to render a view, if needed.
@@ -163,19 +252,15 @@
 =cut 
 
 sub end : ActionClass('RenderView') {
-    my ( $self, $c ) = @_;
+  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
 
 Catalyst developer

Copied: ironman/IronMan-Web/tags/IronMan-Web-0.02/lib/IronMan/Web/View/Email.pm (from rev 9876, ironman/IronMan-Web/trunk/lib/IronMan/Web/View/Email.pm)
===================================================================
--- ironman/IronMan-Web/tags/IronMan-Web-0.02/lib/IronMan/Web/View/Email.pm	                        (rev 0)
+++ ironman/IronMan-Web/tags/IronMan-Web-0.02/lib/IronMan/Web/View/Email.pm	2011-04-26 07:49:09 UTC (rev 9877)
@@ -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;

Modified: ironman/IronMan-Web/tags/IronMan-Web-0.02/root/inc/ironman_header.tt
===================================================================
--- ironman/IronMan-Web/tags/IronMan-Web-0.02/root/inc/ironman_header.tt	2011-04-26 07:46:49 UTC (rev 9876)
+++ ironman/IronMan-Web/tags/IronMan-Web-0.02/root/inc/ironman_header.tt	2011-04-26 07:49:09 UTC (rev 9877)
@@ -3,7 +3,7 @@
         <a href="/new_feed"><img src="http://enlightenedperl.org/images/ironsignup.png" alt="signup banner" /></a><br />
         <a href="/new_feed">Join the program</a>&nbsp;|&nbsp;
         <a href="http://www.enlightenedperl.org/ironman.html">Learn about the program</a>&nbsp;|&nbsp;
-
+        <a href="/update_feed">update your feed URL (current users)</a>&nbsp;|&nbsp;
         <a href="mailto:ironman at shadowcat.co.uk">Report a problem</a>
       </p>
       <p>

Copied: ironman/IronMan-Web/tags/IronMan-Web-0.02/root/retrieve_key.tt (from rev 9876, ironman/IronMan-Web/trunk/root/retrieve_key.tt)
===================================================================
--- ironman/IronMan-Web/tags/IronMan-Web-0.02/root/retrieve_key.tt	                        (rev 0)
+++ ironman/IronMan-Web/tags/IronMan-Web-0.02/root/retrieve_key.tt	2011-04-26 07:49:09 UTC (rev 9877)
@@ -0,0 +1,11 @@
+[% IF error %]
+[% error %]
+[% END %]
+[% 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>

Modified: ironman/IronMan-Web/tags/IronMan-Web-0.02/root/update_feed.tt
===================================================================
--- ironman/IronMan-Web/tags/IronMan-Web-0.02/root/update_feed.tt	2011-04-26 07:46:49 UTC (rev 9876)
+++ ironman/IronMan-Web/tags/IronMan-Web-0.02/root/update_feed.tt	2011-04-26 07:49:09 UTC (rev 9877)
@@ -1,12 +1,12 @@
-[% UNLESS error %]
+[% IF error %]
+[% error %]
+[% END %]
 [% IF updated %]
 <p>Feed url successfully updated</p>
 [% END %]
-<p>Welcome, [% owner %]</p>
 <form method="post" action="">
+<p>Your email: <input type="text" name="email" /></p>
+<p>Your user key: (<a href="/retrieve_key">forgot it?</a>): <input type="text" name="id" /></p>
 <p>New url for feed (current is: [% feed %]): <input type="text" name="url" /></p>
 <p><input type="submit" value="Update feed url" /></p>
 </form>
-[% ELSE %]
-[% error %]
-[% END %]

Copied: ironman/IronMan-Web/tags/IronMan-Web-0.02/t/view_Email.t (from rev 9876, ironman/IronMan-Web/trunk/t/view_Email.t)
===================================================================
--- ironman/IronMan-Web/tags/IronMan-Web-0.02/t/view_Email.t	                        (rev 0)
+++ ironman/IronMan-Web/tags/IronMan-Web-0.02/t/view_Email.t	2011-04-26 07:49:09 UTC (rev 9877)
@@ -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