X-Git-Url: http://git.ieval.ro/?a=blobdiff_plain;f=lib%2FGruntmaster%2FPage%2FPb.pm;h=ffdde60697862c0b2db66533649082bb0d20ea7d;hb=191f4979def520b8be01554eb954c80ee42df38b;hp=170f03f42d2b020235fe1924c62a2f6f0a9db3d0;hpb=cd9af27e94244e6454c3db787a8ca6811f44fc16;p=plack-app-gruntmaster.git diff --git a/lib/Gruntmaster/Page/Pb.pm b/lib/Gruntmaster/Page/Pb.pm index 170f03f..ffdde60 100644 --- a/lib/Gruntmaster/Page/Pb.pm +++ b/lib/Gruntmaster/Page/Pb.pm @@ -3,68 +3,56 @@ package Gruntmaster::Page::Pb; use 5.014000; use strict; use warnings; -use parent qw/Exporter/; -our @EXPORT_OK = qw/generate/; +use Gruntmaster::Page::Base pb => 'Problems'; +our @ISA = qw/Gruntmaster::Page::Base/; our $VERSION = '0.001'; -use constant TITLE => 'Problems'; - -use Fcntl qw/:flock/; -use HTML::Template::Compiled; -use IO::File; -use POSIX qw/strftime/; -use Gruntmaster::Page::Common qw/header footer/; -use Gruntmaster::Data qw/problem_name problem_level problems/; - -my %templates = ( - en => <<'HTML', +use constant TEMPLATES => { + en => <<'HTML',

Beginner

- +
+ +

Easy

- +
+ +

Medium

- +
+ +

Hard

- +
+ +
- +
+ +
HTML -); +}; -$templates{$_} = header($_, TITLE) . $templates{$_} for keys %templates; -$templates{$_} .= footer $_ for keys %templates; +sub _generate{ + my ($self, $htc, $lang, $env, $ct) = @_; + debug $env => "language is '$lang' and contest is '$ct'"; + local $Gruntmaster::Data::contest = $ct if $ct; -sub generate{ - $_[0] =~ m,^(?:ct/([^/]+)/)?pb/index.html$,; - local $Gruntmaster::Data::contest = $1; - - my $htc = HTML::Template::Compiled->new(scalarref => \$templates{$_[1]}); my @problems = sort { $b->{name} cmp $a->{name} } map +{ id => $_, name => problem_name, level => problem_level}, problems; + for my $d (qw/beginner easy medium advanced hard/) { $htc->param($d => [grep {$_->{level} and $_->{level} eq $d} @problems]); } $htc->param(levels => grep { $_->{level} } @problems); $htc->param(problems => \@problems); - $htc->output } 1