X-Git-Url: http://git.ieval.ro/?a=blobdiff_plain;f=lib%2FGruntmaster%2FPage%2FPb%2FEntry.pm;h=dbfbe18ca42b86c6c2f0b7fd3a6b21de6518b503;hb=4aa8ba862bf3a79362df73c3d1e8707e8135af23;hp=ebcf56eca506752b8cee8631a0c615d9defdc196;hpb=cd9af27e94244e6454c3db787a8ca6811f44fc16;p=plack-app-gruntmaster.git diff --git a/lib/Gruntmaster/Page/Pb/Entry.pm b/lib/Gruntmaster/Page/Pb/Entry.pm index ebcf56e..dbfbe18 100644 --- a/lib/Gruntmaster/Page/Pb/Entry.pm +++ b/lib/Gruntmaster/Page/Pb/Entry.pm @@ -7,18 +7,14 @@ use parent qw/Exporter/; our @EXPORT_OK = qw/generate/; our $VERSION = '0.001'; -use Fcntl qw/:flock/; use HTML::Template::Compiled; -use IO::File; use POSIX qw/strftime/; -use File::Basename qw/fileparse/; -use Gruntmaster::Page::Common qw/header footer/; +use Gruntmaster::Page::Common qw/cook_templates reload_templates/; use Gruntmaster::Data qw/contest_start contest_end problem_name problem_statement/; use constant FORMATS => [qw/CPP/]; -use constant TITLE => ''; -my %templates = ( +my %orig_templates = ( en => <<'HTML', @@ -39,11 +35,11 @@ my %templates = ( HTML ); -$templates{$_} = header($_, TITLE) . $templates{$_} for keys %templates; -$templates{$_} .= footer $_ for keys %templates; +my %templates = cook_templates %orig_templates, pb_entry => ''; sub generate{ - $_[0] =~ m,(?:ct/([^/])+/)?log/(\w+)\.html$,; + %templates = cook_templates %orig_templates, pb_entry => '' if reload_templates; + $_[0] =~ m,(?:ct/([^/])+/)?pb/(\w+)\.html$,; my ($contest, $id) = ($1, $2); my $htc = HTML::Template::Compiled->new(scalarref => \$templates{$_[1]}); @@ -55,9 +51,9 @@ sub generate{ } $htc->param(formats => FORMATS); $htc->param(id => $id); - local $Gruntmaster::Data::contest = ($_[0] =~ m,(?:ct/([^/])+/)?,)[0]; + local $Gruntmaster::Data::contest = $contest if $contest; $htc->param(name => problem_name $id); - $htc->param(statement => problem_statement $id, $_[2]); + $htc->param(statement => problem_statement $id); $htc->output }