[Bast-commits] r8851 - in ironman/IronMan-Web: lib/IronMan/Web/Controller root/archive

fade at dev.catalyst.perl.org fade at dev.catalyst.perl.org
Tue Mar 2 17:47:44 GMT 2010


Author: fade
Date: 2010-03-02 17:47:43 +0000 (Tue, 02 Mar 2010)
New Revision: 8851

Added:
   ironman/IronMan-Web/root/archive/no_archive.tt
Modified:
   ironman/IronMan-Web/lib/IronMan/Web/Controller/Archive.pm
Log:
better handle days/months with no archive posts

Modified: ironman/IronMan-Web/lib/IronMan/Web/Controller/Archive.pm
===================================================================
--- ironman/IronMan-Web/lib/IronMan/Web/Controller/Archive.pm	2010-03-02 17:16:14 UTC (rev 8850)
+++ ironman/IronMan-Web/lib/IronMan/Web/Controller/Archive.pm	2010-03-02 17:47:43 UTC (rev 8851)
@@ -59,8 +59,15 @@
        'minute' => 0,
        'second' => 0,
 	);
+	$c->stash( 'month' => $dt_month );
 	
 	my @posts = $c->model('FeedDB::Post')->posts_for_month($dt_month)->all;
+
+    if (!scalar(@posts)) {
+        $c->res->status(404);
+        $c->stash('template', 'archive/no_archive.tt');
+        $c->detach();
+    }
 	
 	tie(my %posts_per_day, 'Tie::IxHash');
 
@@ -69,7 +76,6 @@
 	    push( @{$posts_per_day{$day}}, $post);
 	}
 	$c->stash( 'posts_per_day' => \%posts_per_day );
-	$c->stash( 'month' => $dt_month );
 	
 	my $next_post = $posts[-1]->next_post;
 	if (defined($next_post)) {
@@ -101,10 +107,18 @@
        'minute' => 0,
        'second' => 0,
 	);
+	$c->stash( 'day' => $dt_day );
 	
+	
 	my @posts = $c->model('FeedDB::Post')->posts_for_day($dt_day)->all;
+
+	if (!scalar(@posts)) {
+        $c->res->status(404);
+        $c->stash('template', 'archive/no_archive.tt');
+        $c->detach();
+    }
+
 	$c->stash( 'posts' => \@posts );
-	$c->stash( 'day' => $dt_day );
 	
 	my $next_post = $posts[-1]->next_post;
 	if (defined($next_post)) {

Added: ironman/IronMan-Web/root/archive/no_archive.tt
===================================================================
--- ironman/IronMan-Web/root/archive/no_archive.tt	                        (rev 0)
+++ ironman/IronMan-Web/root/archive/no_archive.tt	2010-03-02 17:47:43 UTC (rev 8851)
@@ -0,0 +1 @@
+There are no archives for this date.
\ No newline at end of file




More information about the Bast-commits mailing list