X-Git-Url: http://git.ieval.ro/?a=blobdiff_plain;ds=sidebyside;f=lib%2FGruntmaster%2FPage%2FCt.pm;h=a21bf77809d352a78ef06c358833c3467945cda9;hb=e55994952606e391a57c974b6ce4c9f94c73f7a7;hp=1c108fddf5162f534ede875c41128c6e89c3d69d;hpb=4aa8ba862bf3a79362df73c3d1e8707e8135af23;p=plack-app-gruntmaster.git
diff --git a/lib/Gruntmaster/Page/Ct.pm b/lib/Gruntmaster/Page/Ct.pm
index 1c108fd..a21bf77 100644
--- a/lib/Gruntmaster/Page/Ct.pm
+++ b/lib/Gruntmaster/Page/Ct.pm
@@ -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/contests contest_name contest_start contest_end contest_owner/;
-
-my %orig_templates = (
- en => <<'HTML',
-
-Running contests
-
-
-Name | Start date | End date | Owner
- |
-
- |
-
-
-
- | | |
-
-
-
-Pending contests
-
-
-Name | Start date | End date | Owner
- |
-
- |
-
-
-
- | | |
-
-
-
-Finished contests
-
-
-Name | Start date | End date | Owner
- |
-
- |
-
-
-
- | | |
-
-HTML
-);
-
-my %templates = cook_templates %orig_templates, ct => 'Contests';
-
-sub generate{
- %templates = cook_templates %orig_templates, ct => 'Contests' if reload_templates;
- 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