]> iEval git - gruntmaster-page.git/blobdiff - lib/Gruntmaster/Page/Ct.pm
Add example test suite
[gruntmaster-page.git] / lib / Gruntmaster / Page / Ct.pm
index 8ef38155306fe9b42ec55e92089b04a6a5282086..a21bf77809d352a78ef06c358833c3467945cda9 100644 (file)
@@ -3,69 +3,16 @@ package Gruntmaster::Page::Ct;
 use 5.014000;
 use strict;
 use warnings;
-use parent qw/Exporter/;
-our @EXPORT_OK = qw/generate/;
+use Gruntmaster::Page::Base ct => 'Contests';
+our @ISA = qw/Gruntmaster::Page::Base/;
 our $VERSION = '0.001';
 
-use HTML::Template::Compiled;
-use POSIX qw/strftime/;
-use Gruntmaster::Page::Common qw/cook_templates reload_templates/;
-use Gruntmaster::Data qw/contest_name contest_start contest_end contest_owner/;
-
-my %orig_templates = (
-       en => <<'HTML',
-<tmpl_if running>
-<h1>Running contests</h1>
-<table border>
-<thead>
-<tr><th>Name<th>Start date<th>End date<th>Owner
-<tbody>
-<tmpl_loop running><tr><td><a href="<tmpl_var id>"><tmpl_var name></a>
-<td><tmpl_var start>
-<td><tmpl_var end>
-<td><tmpl_var owner>
-</tmpl_loop>
-</table>
-</tmpl_if>
-
-<tmpl_if pending>
-<h1>Pending contests</h1>
-<table border>
-<thead>
-<tr><th>Name<th>Start date<th>End date<th>Owner
-<tbody>
-<tmpl_loop pending><tr><td><a href="<tmpl_var id>"><tmpl_var name></a>
-<td><tmpl_var start>
-<td><tmpl_var end>
-<td><tmpl_var owner>
-</tmpl_loop>
-</table>
-</tmpl_if>
-
-<tmpl_if finished>
-<h1>Finished contests</h1>
-<table border>
-<thead>
-<tr><th>Name<th>Start date<th>End date<th>Owner
-<tbody>
-<tmpl_loop finished><tr><td><a href="<tmpl_var id>"><tmpl_var name></a>
-<td><tmpl_var start>
-<td><tmpl_var end>
-<td><tmpl_var owner>
-</tmpl_loop>
-</table>
-</tmpl_if>
-HTML
-);
-
-my %templates = cook_templates %orig_templates, ct => 'Contests';
-
-sub generate{
-       %templates = cook_templates %orig_templates, ct => 'Contests' if reload_template;
-       my $htc = HTML::Template::Compiled->new(scalarref => \$templates{$_[1]});
+sub _generate{
+       my ($self, $htc, $lang, $env) = @_;
+       debug $env => "language is '$lang'";
 
        my (@running, @pending, @finished);
-       for (contests) {
+       for (sort {contest_start $a <=> contest_start $b}contests) {
                my $ct = { id => $_,
                                   name => contest_name,
                                   start => strftime ('%c', localtime contest_start),
@@ -78,10 +25,9 @@ sub generate{
                push @finished, $ct if time > contest_end;
        }
 
-       $htc->param(running => \@running);
-       $htc->param(pending => \@pending);
-       $htc->param(finished => \@finished);
-       $htc->output
+       $htc->param(running => \@running) if @running;
+       $htc->param(pending => \@pending) if @pending;
+       $htc->param(finished => \@finished) if @finished;
 }
 
 1
This page took 0.018967 seconds and 4 git commands to generate.