[Bast-commits] r8848 - in ironman/IronMan-Web:
lib/IronMan/Web/Controller root/archive root/inc
fade at dev.catalyst.perl.org
fade at dev.catalyst.perl.org
Tue Mar 2 13:48:24 GMT 2010
Author: fade
Date: 2010-03-02 13:48:24 +0000 (Tue, 02 Mar 2010)
New Revision: 8848
Added:
ironman/IronMan-Web/root/inc/next_prev.tt
Modified:
ironman/IronMan-Web/lib/IronMan/Web/Controller/Archive.pm
ironman/IronMan-Web/root/archive/day.tt
ironman/IronMan-Web/root/archive/month.tt
Log:
add monthly archive
Modified: ironman/IronMan-Web/lib/IronMan/Web/Controller/Archive.pm
===================================================================
--- ironman/IronMan-Web/lib/IronMan/Web/Controller/Archive.pm 2010-03-02 11:48:31 UTC (rev 8847)
+++ ironman/IronMan-Web/lib/IronMan/Web/Controller/Archive.pm 2010-03-02 13:48:24 UTC (rev 8848)
@@ -5,6 +5,7 @@
BEGIN {extends 'Catalyst::Controller'; }
use DateTime;
+use Tie::IxHash;
=head1 NAME
@@ -60,8 +61,28 @@
);
my $posts = $c->model('FeedDB::Post')->posts_for_month($dt_month);
- $c->stash( 'posts' => $posts );
+
+ tie(my %posts_per_day, 'Tie::IxHash');
+
+ foreach my $post ($posts->all) {
+ my $day = $post->posted_on->day;
+ push( @{$posts_per_day{$day}}, $post);
+ }
+ $c->stash( 'posts_per_day' => \%posts_per_day );
$c->stash( 'month' => $dt_month );
+
+ my $next_month = $dt_month->clone->subtract( 'months' => 1 );
+ if ($c->model('FeedDB::Post')->posts_for_month($next_month)->count) {
+ my $older_url = $c->uri_for($c->action, $next_month->year, $next_month->month );
+ $c->stash( 'older_url' => $older_url );
+ }
+
+ my $prev_month = $dt_month->clone->add( 'months' => 1 );
+ if ($c->model('FeedDB::Post')->posts_for_month($prev_month)->count) {
+ my $younger_url = $c->uri_for($c->action, $prev_month->year, $prev_month->month );
+ $c->stash( 'younger_url' => $younger_url );
+ }
+
}
Modified: ironman/IronMan-Web/root/archive/day.tt
===================================================================
--- ironman/IronMan-Web/root/archive/day.tt 2010-03-02 11:48:31 UTC (rev 8847)
+++ ironman/IronMan-Web/root/archive/day.tt 2010-03-02 13:48:24 UTC (rev 8848)
@@ -9,4 +9,4 @@
[% END %]
-<p>[% IF younger_url %]<a href="[% younger_url %]">< Younger posts</a> | [% END %]<a href="[% older_url %]">Older posts ></a></p>
+[% INCLUDE 'inc/next_prev.tt' %]
Modified: ironman/IronMan-Web/root/archive/month.tt
===================================================================
--- ironman/IronMan-Web/root/archive/month.tt 2010-03-02 11:48:31 UTC (rev 8847)
+++ ironman/IronMan-Web/root/archive/month.tt 2010-03-02 13:48:24 UTC (rev 8848)
@@ -1,10 +1,16 @@
Monthly archive for [% month.strftime('%B %Y') %]
-[% FOREACH post IN posts.all %]
+[% FOREACH day IN posts_per_day.values %]
+<h3><a href="[% c.uri_for_action('archive/day', day.0.posted_on.year, day.0.posted_on.month, day.0.posted_on.day ) %]">[% day.0.posted_on.strftime('%A, %B %e') %]</a></h3>
+<ul>
+ [% FOREACH post IN day %]
+ <li>
+ <a class="entry-source-link" href="[% post.feed.link %]">[% post.feed.title %]</a>:
+ <a class="entry-link" href="[% post.url %]">[% post.title %]</a>
+ </li>
+ [% END %]
+ </ul>
+[% END %]
-[% INCLUDE 'inc/post_teaser.tt'
- post = post
-%]
-
-[% END %]
+[% INCLUDE 'inc/next_prev.tt' %]
Added: ironman/IronMan-Web/root/inc/next_prev.tt
===================================================================
--- ironman/IronMan-Web/root/inc/next_prev.tt (rev 0)
+++ ironman/IronMan-Web/root/inc/next_prev.tt 2010-03-02 13:48:24 UTC (rev 8848)
@@ -0,0 +1,5 @@
+<p>
+[% IF younger_url %]<a href="[% younger_url %]">< Younger posts</a>[% END %]
+[% IF younger_url AND older_url %] | [% END %]
+[% IF older_url %] <a href="[% older_url %]">Older posts ></a>[% END %]
+</p>
More information about the Bast-commits
mailing list