[Bast-commits] r8086 - in ironman: IronMan-Web/lib/IronMan/Web/Controller IronMan-Web/root IronMan-Web/root/archive IronMan-Web/root/inc plagger/lib/IronMan/Schema/ResultSet

fade at dev.catalyst.perl.org fade at dev.catalyst.perl.org
Sat Dec 12 20:13:49 GMT 2009


Author: fade
Date: 2009-12-12 20:13:48 +0000 (Sat, 12 Dec 2009)
New Revision: 8086

Added:
   ironman/plagger/lib/IronMan/Schema/ResultSet/Post.pm
Modified:
   ironman/IronMan-Web/lib/IronMan/Web/Controller/Archive.pm
   ironman/IronMan-Web/root/archive/day.tt
   ironman/IronMan-Web/root/archive/month.tt
   ironman/IronMan-Web/root/inc/post_teaser.tt
   ironman/IronMan-Web/root/index.tt
Log:
outline of months and days archive, fixup post teasers

Modified: ironman/IronMan-Web/lib/IronMan/Web/Controller/Archive.pm
===================================================================
--- ironman/IronMan-Web/lib/IronMan/Web/Controller/Archive.pm	2009-12-12 20:08:49 UTC (rev 8085)
+++ ironman/IronMan-Web/lib/IronMan/Web/Controller/Archive.pm	2009-12-12 20:13:48 UTC (rev 8086)
@@ -26,6 +26,7 @@
 
     $c->response->body('Matched IronMan::Web::Controller::Archive in Archive.');
 }
+
 =head2 year
 
 =head2 year
@@ -35,7 +36,8 @@
 sub year :Path :Args(1) {
     my ( $self, $c, $year ) = @_;
 
-    $c->res->body($c->model('FeedDB::Post')->count);
+    $c->model('FeedDB::Post')->search();
+	$c->stash( 'year' => $year );
 }
 
 =head2 month
@@ -45,6 +47,10 @@
 sub month :Path :Args(2) {
     my ( $self, $c, $year, $month ) = @_;
 	
+	my $posts = $c->model('FeedDB::Post')->posts_for_month($month, $year);
+	$c->stash( 'posts' => $posts );
+	$c->stash( 'year' => $year );
+	$c->stash( 'month' => $month );
 }
 
 
@@ -55,6 +61,11 @@
 sub day :Path :Args(3) {
     my ( $self, $c, $year, $month, $day ) = @_;
 	
+	my $posts = $c->model('FeedDB::Post')->posts_for_day($day, $month, $year);
+	$c->stash( 'posts' => $posts );
+	$c->stash( 'year' => $year );
+	$c->stash( 'month' => $month );
+	$c->stash( 'day' => $day );
 }
 
 =head1 AUTHOR

Modified: ironman/IronMan-Web/root/archive/day.tt
===================================================================
--- ironman/IronMan-Web/root/archive/day.tt	2009-12-12 20:08:49 UTC (rev 8085)
+++ ironman/IronMan-Web/root/archive/day.tt	2009-12-12 20:13:48 UTC (rev 8086)
@@ -1,2 +1,10 @@
 
-Daily archive for [% day %] [% month %] [% year %]
\ No newline at end of file
+Daily archive for [% day %] [% month %] [% year %]
+
+[% FOREACH post IN posts.all %]
+
+[% INCLUDE 'inc/post_teaser.tt'
+    post = post
+%]
+    
+[% END %]

Modified: ironman/IronMan-Web/root/archive/month.tt
===================================================================
--- ironman/IronMan-Web/root/archive/month.tt	2009-12-12 20:08:49 UTC (rev 8085)
+++ ironman/IronMan-Web/root/archive/month.tt	2009-12-12 20:13:48 UTC (rev 8086)
@@ -1,2 +1,10 @@
 
-Monthly archive for [% month %] [% year %]
\ No newline at end of file
+Monthly archive for [% month %] [% year %]
+
+[% FOREACH post IN posts.all %]
+
+[% INCLUDE 'inc/post_teaser.tt'
+    post = post
+%]
+    
+[% END %]

Modified: ironman/IronMan-Web/root/inc/post_teaser.tt
===================================================================
--- ironman/IronMan-Web/root/inc/post_teaser.tt	2009-12-12 20:08:49 UTC (rev 8085)
+++ ironman/IronMan-Web/root/inc/post_teaser.tt	2009-12-12 20:13:48 UTC (rev 8086)
@@ -2,23 +2,47 @@
       <div class="entry">
         <div class="entry-header">
           <div class="entry-title">
+              <a class="entry-source-link" href="[% post.feed.url %]">[% post.feed.title %]</a>:
             
-              <a class="entry-source-link" href="http://lastofthecarelessmen.blogspot.com/">SF</a>:
-            
-            <a class="entry-link" href="http://lastofthecarelessmen.blogspot.com/2009/12/intro-to-abc.html">Intro to ABC</a>
+            <a class="entry-link" href="[% post.url %]">[% post.title %]</a>
           </div>
           
             <span class="entry-by-line">
-              by <span class="entry-author">SF</span>
+              by <span class="entry-author">Post Author</span>
 
             </span>
           
-          
+            [% IF post.tags.size > 0 %]
             <span class="entry-tags">
               on
-              <span class="entry-tag">
-                ABC</span>, <span class="entry-tag">Perl 6
-              </span>
+              [% FOREACH tag in post.tags -%]
+                [%- IF loop.count != 1 %], [% END %]<span class="entry-tag">[% tag %]</span>
+              [%- END %]
             </span>
+            [% END %]
+            
+        </div>
+        
+          <div class="entry-body">
+            [% post.body %]
+          </div>
+
+        
+        <div class="entry-footer">
           
+            <span class="entry-posted">
+              Posted on
+              <span class="entry-post-date">Sat, 12 Dec 2009 01:26:00 -0000</span>
+            </span>
+          
+          <a class="entry-permalink" href="[% post.url %]">permalink</a>
+          <!-- AddThis Button BEGIN -->
+<script type="text/javascript">var addthis_pub="ironman";</script>
+
+<a href="http://www.addthis.com/bookmark.php?v=20" onmouseover="return addthis_open(this, '', '[% post.url %]', '[% post.title %]')" onmouseout="addthis_close()" onclick="return addthis_sendto()"><img src="http://s7.addthis.com/static/btn/lg-share-en.gif" width="125" height="16" alt="Bookmark and Share" style="border:0"/></a><script type="text/javascript" src="http://s7.addthis.com/js/200/addthis_widget.js"></script>
+          <!-- AddThis Button END -->
+
+          
         </div>
+      </div>
+        
\ No newline at end of file

Modified: ironman/IronMan-Web/root/index.tt
===================================================================
--- ironman/IronMan-Web/root/index.tt	2009-12-12 20:08:49 UTC (rev 8085)
+++ ironman/IronMan-Web/root/index.tt	2009-12-12 20:13:48 UTC (rev 8086)
@@ -1,5 +1,5 @@
 
-[% FOREACH post IN posts %]
+[% FOREACH post IN posts.all %]
 
 [% INCLUDE 'inc/post_teaser.tt'
     post = post

Added: ironman/plagger/lib/IronMan/Schema/ResultSet/Post.pm
===================================================================
--- ironman/plagger/lib/IronMan/Schema/ResultSet/Post.pm	                        (rev 0)
+++ ironman/plagger/lib/IronMan/Schema/ResultSet/Post.pm	2009-12-12 20:13:48 UTC (rev 8086)
@@ -0,0 +1,72 @@
+package IronMan::Schema::ResultSet::Post;
+
+use strict;
+use warnings;
+
+use base 'DBIx::Class::ResultSet';
+
+use DateTime;
+
+=head2 posts_for_day
+
+posts_for_day($day, $month, $year)
+
+Returns a resultset containing all posts for a particular date.
+
+=cut
+
+sub posts_for_day {
+   my ($self, $day, $month, $year) = @_;
+      
+	my $dt_parser = $self->result_source->storage->datetime_parser;
+	
+	my $day_start = DateTime->new(
+	   'year'   => $year,
+       'month'  => $month,
+       'day'   => $day,
+       'hour'   => 0,
+       'minute' => 0,
+       'second' => 0,
+	);
+	
+	my $day_end = $day_start->clone()->add( 'days' => 1 )->subtract( 'seconds' => 1 );
+	
+	return $self->search({
+	   'posted_on' => { '-between' => [ map $dt_parser->format_datetime($_), $day_start, $day_end ] },
+	},{
+	    'order_by' => \'posted_on DESC',
+    });
+}
+
+=head2 posts_for_month
+
+posts_for_month($month, $year)
+
+Returns a resultset containing all posts for a particular month.
+
+=cut
+
+sub posts_for_month {
+   my ($self, $month, $year) = @_;
+      
+	my $dt_parser = $self->result_source->storage->datetime_parser;
+	
+	my $month_start = DateTime->new(
+	   'year'   => $year,
+       'month'  => $month,
+       'day'   => 1,
+       'hour'   => 0,
+       'minute' => 0,
+       'second' => 0,
+	);
+	
+	my $month_end = $month_start->clone()->add( 'months' => 1 )->subtract( 'seconds' => 1 );
+	
+	return $self->search({
+	   'posted_on' => { '-between' => [ map $dt_parser->format_datetime($_), $month_start, $month_end ] },
+	},{
+	    'order_by' => \'posted_on DESC',
+    });
+}
+
+1;




More information about the Bast-commits mailing list