[Catalyst-commits] r14243 - in trunk/examples/CatalystAdvent: . lib lib/CatalystAdvent/Controller root

caelum at dev.catalyst.perl.org caelum at dev.catalyst.perl.org
Wed Jan 4 23:53:54 GMT 2012


Author: caelum
Date: 2012-01-04 23:53:54 +0000 (Wed, 04 Jan 2012)
New Revision: 14243

Added:
   trunk/examples/CatalystAdvent/catalystadvent.conf
Modified:
   trunk/examples/CatalystAdvent/lib/CatalystAdvent.pm
   trunk/examples/CatalystAdvent/lib/CatalystAdvent/Controller/Calendar.pm
   trunk/examples/CatalystAdvent/root/wrapper.tt
Log:
fix calendar

Added: trunk/examples/CatalystAdvent/catalystadvent.conf
===================================================================
--- trunk/examples/CatalystAdvent/catalystadvent.conf	                        (rev 0)
+++ trunk/examples/CatalystAdvent/catalystadvent.conf	2012-01-04 23:53:54 UTC (rev 14243)
@@ -0,0 +1 @@
+retired 1

Modified: trunk/examples/CatalystAdvent/lib/CatalystAdvent/Controller/Calendar.pm
===================================================================
--- trunk/examples/CatalystAdvent/lib/CatalystAdvent/Controller/Calendar.pm	2011-12-28 09:54:46 UTC (rev 14242)
+++ trunk/examples/CatalystAdvent/lib/CatalystAdvent/Controller/Calendar.pm	2012-01-04 23:53:54 UTC (rev 14243)
@@ -43,23 +43,30 @@
 
 sub index : Chained('base') PathPart('') Args(0) {
     my ( $self, $c ) = @_;
+
     my $now = $c->stash->{now};
-    my $start_date = $now->clone->set( month => 12, day => 1 );
-    my $until = $start_date - $now;
-    $c->stash(
-      days_until => $until->delta_days
-    );
+    my $start_date = $now->clone->set(month => 12, day => 1);
+
     opendir DIR, $c->path_to('root') or die "Error opening root: $!";
     my @years = sort grep { /\d{4}/ } readdir DIR;
     closedir DIR;
 
-    my $year = pop @years || $c->stash->{now}->year;
-    $c->stash( previous_years =>\@years );
-    $c->go( $self->action_for('year'), [$year], []);
+    my $days_until = $start_date->delta_days($now)->delta_days;
+
+    if (not $c->config->{retired}) {
+        if (not ($now->month == 12 || ($now->month == 1 || $now->month == 2))) {
+            $c->stash(days_until => $days_until);
+            pop @years if @years && $years[-1] == $now->year;
+        }
+    }
+
+    $c->stash(previous_years => \@years) if @years;
+
+    $c->go($self->action_for('year'), [$years[-1]], []) if @years;
+
 #    $c->stash->{year}     = $year;
 #    $c->stash->{calendar} = calendar( 12, $year );
 #    $c->stash->{template} = 'year.tt';
-
 }
 
 =head2 get_year

Modified: trunk/examples/CatalystAdvent/lib/CatalystAdvent.pm
===================================================================
--- trunk/examples/CatalystAdvent/lib/CatalystAdvent.pm	2011-12-28 09:54:46 UTC (rev 14242)
+++ trunk/examples/CatalystAdvent/lib/CatalystAdvent.pm	2012-01-04 23:53:54 UTC (rev 14243)
@@ -4,6 +4,7 @@
 use warnings;
 
 use Catalyst qw( Static::Simple
+                 ConfigLoader
                  Cache
                  Unicode::Encoding
               );

Modified: trunk/examples/CatalystAdvent/root/wrapper.tt
===================================================================
--- trunk/examples/CatalystAdvent/root/wrapper.tt	2011-12-28 09:54:46 UTC (rev 14242)
+++ trunk/examples/CatalystAdvent/root/wrapper.tt	2012-01-04 23:53:54 UTC (rev 14243)
@@ -17,9 +17,20 @@
 [% END %]
 
         <div id="content">
-[%- IF days_until AND days_until > 0 %]
-<h1>[% days_until %] [% IF days_until == 1 %]day[% ELSE %]days[% END %] until the calendar starts!</h2>
+[%- IF c.config.retired OR (days_until AND days_until > 0) %]
+    [%- IF !c.config.retired %]
+<h2>[% days_until %] [% IF days_until == 1 %]day[% ELSE %]days[% END %] until the calendar starts!</h2>
+        [%- IF previous_years %]
 <p class="center">In the mean time, you might want to check our archives.</p>
+        [% END %]
+    [%- ELSE %]
+<h2>The calendar has been retired, stay tuned for the Catalyst monthly
+    blog!</h2>
+        [%- IF previous_years %]
+<p class="center">Please check out the archive of awesome articles from previous
+years.</p>
+        [% END %]
+    [%- END %]
 <p class="center">
 [% FOREACH previous_year IN previous_years %]
     <a href="[% c.uri_for('/', previous_year) %]">[% previous_year %]</a>[% UNLESS loop.last %] - [% END %]




More information about the Catalyst-commits mailing list