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

caelum at dev.catalyst.perl.org caelum at dev.catalyst.perl.org
Thu Jan 5 18:37:18 GMT 2012


Author: caelum
Date: 2012-01-05 18:37:18 +0000 (Thu, 05 Jan 2012)
New Revision: 14244

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

Modified: trunk/examples/CatalystAdvent/Makefile.PL
===================================================================
--- trunk/examples/CatalystAdvent/Makefile.PL	2012-01-04 23:53:54 UTC (rev 14243)
+++ trunk/examples/CatalystAdvent/Makefile.PL	2012-01-05 18:37:18 UTC (rev 14244)
@@ -9,8 +9,11 @@
 include('ExtUtils::AutoInstall');
 
 requires Catalyst => '5.90';
+requires 'Moose';
+requires 'namespace::autoclean';
 requires 'Catalyst::Plugin::Unicode::Encoding';
 requires 'Catalyst::Plugin::Cache' => '0.08';
+requires 'Catalyst::Plugin::ConfigLoader';
 requires 'Cache::FileCache';
 requires 'Catalyst::Plugin::Static::Simple';
 requires 'Catalyst::View::TT';

Modified: trunk/examples/CatalystAdvent/catalystadvent.conf
===================================================================
--- trunk/examples/CatalystAdvent/catalystadvent.conf	2012-01-04 23:53:54 UTC (rev 14243)
+++ trunk/examples/CatalystAdvent/catalystadvent.conf	2012-01-05 18:37:18 UTC (rev 14244)
@@ -1 +1,3 @@
-retired 1
+<Controller::Calendar>
+#    retired "The calendar has been retired, stay tuned for the Catalyst monthly blog!"
+</Controller::Calendar>

Modified: trunk/examples/CatalystAdvent/lib/CatalystAdvent/Controller/Calendar.pm
===================================================================
--- trunk/examples/CatalystAdvent/lib/CatalystAdvent/Controller/Calendar.pm	2012-01-04 23:53:54 UTC (rev 14243)
+++ trunk/examples/CatalystAdvent/lib/CatalystAdvent/Controller/Calendar.pm	2012-01-05 18:37:18 UTC (rev 14244)
@@ -1,10 +1,9 @@
 package CatalystAdvent::Controller::Calendar;
 
-use strict;
-use warnings;
+use base 'Catalyst::Controller';
+use Moose;
+use namespace::autoclean;
 
-use base qw( Catalyst::Controller );
-
 use DateTime;
 use Calendar::Simple;
 use File::stat;
@@ -39,6 +38,8 @@
 
 =cut
 
+has retired => (is => 'ro');
+
 sub base : Chained('/base') PathPart('') CaptureArgs(0) {}
 
 sub index : Chained('base') PathPart('') Args(0) {
@@ -53,12 +54,15 @@
 
     my $days_until = $start_date->delta_days($now)->delta_days;
 
-    if (not $c->config->{retired}) {
+    if (not $self->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;
         }
     }
+    else {
+        $c->stash(retired => $self->retired);
+    }
 
     $c->stash(previous_years => \@years) if @years;
 
@@ -289,5 +293,7 @@
 
 =cut
 
+__PACKAGE__->meta->make_immutable;
+
 1;
 

Modified: trunk/examples/CatalystAdvent/root/wrapper.tt
===================================================================
--- trunk/examples/CatalystAdvent/root/wrapper.tt	2012-01-04 23:53:54 UTC (rev 14243)
+++ trunk/examples/CatalystAdvent/root/wrapper.tt	2012-01-05 18:37:18 UTC (rev 14244)
@@ -17,19 +17,18 @@
 [% END %]
 
         <div id="content">
-[%- IF c.config.retired OR (days_until AND days_until > 0) %]
-    [%- IF !c.config.retired %]
+[%- IF retired OR (days_until AND days_until > 0) %]
+    [%- IF !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 %]
+        [%- END %]
     [%- ELSE %]
-<h2>The calendar has been retired, stay tuned for the Catalyst monthly
-    blog!</h2>
+<h2>[% retired %]</h2>
         [%- IF previous_years %]
 <p class="center">Please check out the archive of awesome articles from previous
 years.</p>
-        [% END %]
+        [%- END %]
     [%- END %]
 <p class="center">
 [% FOREACH previous_year IN previous_years %]




More information about the Catalyst-commits mailing list