[Bast-commits] r9885 - in
ironman/IronMan-Web/tags/IronMan-Web-0.02: .
lib/IronMan/Web/Controller root/inc
idn at dev.catalyst.perl.org
idn at dev.catalyst.perl.org
Tue Jul 5 10:05:36 GMT 2011
Author: idn
Date: 2011-07-05 10:05:36 +0000 (Tue, 05 Jul 2011)
New Revision: 9885
Modified:
ironman/IronMan-Web/tags/IronMan-Web-0.02/
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
Log:
Merge from trunk
Property changes on: ironman/IronMan-Web/tags/IronMan-Web-0.02
___________________________________________________________________
Modified: svn:mergeinfo
- /ironman/IronMan-Web/branches/user_edit:9627-9875
/ironman/IronMan-Web/trunk:9860-9876
+ /ironman/IronMan-Web/branches/user_edit:9627-9875
/ironman/IronMan-Web/trunk:9860-9884
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-07-05 09:54:29 UTC (rev 9884)
+++ ironman/IronMan-Web/tags/IronMan-Web-0.02/lib/IronMan/Web/Controller/Root.pm 2011-07-05 10:05:36 UTC (rev 9885)
@@ -1,4 +1,5 @@
package IronMan::Web::Controller::Root;
+
use strict;
use warnings;
use Data::UUID;
@@ -32,40 +33,31 @@
=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 = ($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_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
@@ -73,75 +65,71 @@
=cut
sub new_feed : Local {
- my ( $self, $c ) = @_;
+ 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 $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');
- $c->stash( params => $c->req->params );
- $c->forward('captcha_get');
+ $c->stash(params => $c->req->params);
+ $c->forward('captcha_get');
- return 1 if ( !%{ $c->req->params } );
+ return 1 if(!%{ $c->req->params });
- 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;
- }
+ 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;
+ }
- $c->log->debug("input ok");
+ $c->log->debug("input ok");
- ## 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 );
+ ## 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
- );
+ 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;
- }
+ if(!$res) {
+ $c->stash(existed => 1);
+ $c->log->debug("$url already exists, id: " . $fdb->id);
+ return 1;
+ }
- $c->stash( inserted => $fdb->id );
+ $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
@@ -150,37 +138,31 @@
=cut
-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') )
- {
+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')
- }
- );
+ my $feed = $c->model('FeedDB::Feed')->find({
+ 'id' => $c->req->param('id'),
+ 'email' => $c->req->param('email')});
- if ( defined $feed ) {
+ if ( defined $feed ) {
+ $feed->update( { url => $c->req->param('url') } ) or die "Error: $!";
+ $c->stash( updated => 1 );
+ }
- $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 => "No such user" );
-
- }
-
- } else {
- $c->stash( error => "All fields required." );
+ else {
+ $c->stash( error => "All fields required." );
+ }
}
- }
}
=head2 retrieve_key
@@ -190,59 +172,57 @@
=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
- },
- },
- );
+ my ( $self, $c ) = @_;
+ my $email = $c->req->param('email');
- $c->forward( $c->view('Email') );
+ if ( $c->req->param ) {
+ if ($email) {
+ my $feed;
- if ( scalar( @{ $c->error } ) ) {
+ ## don't notify whether email address was found,
+ ## brute force could theoretically give a list of valid emails
+ ## contained here.
- $c->stash( error => $c->error );
+ 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') );
- }
- finally {
- if (@_) {
- $c->log->error( "Original error: @_" );
- $c->log->error( 'email ' . $email . ' not found' );
- }
- $c->stash(
- sent => 1,
- to => $email
- );
+ if ( scalar( @{ $c->error } ) ) {
+ $c->stash( error => $c->error );
+ }
+ } # End of try block
- };
+ finally {
+ if (@_) {
+ $c->log->error( "Original error: @_" );
+ $c->log->error( 'email ' . $email . ' not found' );
+ }
- } else {
+ $c->stash( sent => 1,
+ to => $email
+ );
+ }; # End of finally block
+ } # End of if($email)
- $c->stash( error => "No email specified" );
-
+ else {
+ $c->stash( error => "No email specified" );
+ }
}
- }
}
=head2 end
@@ -252,13 +232,13 @@
=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
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-07-05 09:54:29 UTC (rev 9884)
+++ ironman/IronMan-Web/tags/IronMan-Web-0.02/root/inc/ironman_header.tt 2011-07-05 10:05:36 UTC (rev 9885)
@@ -1,9 +1,9 @@
<div class='header'>
<p>
<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> |
- <a href="http://www.enlightenedperl.org/ironman.html">Learn about the program</a> |
- <a href="/update_feed">update your feed URL (current users)</a> |
+ <a href="/new_feed">Join</a> |
+ <a href="http://www.enlightenedperl.org/ironman.html">About</a> |
+ <a href="/update_feed">Update your blog feed</a> |
<a href="mailto:ironman at shadowcat.co.uk">Report a problem</a>
</p>
<p>
More information about the Bast-commits
mailing list