X-Git-Url: http://git.ieval.ro/?a=blobdiff_plain;f=lib%2FGruntmaster%2FPage%2FCt%2FEntry.pm;h=bba2991c6e8a13d5fbeebbd473cbd440cb2806a4;hb=2b0036ac8e077cc20cf9db6ff8dad4091ab50cb3;hp=50ee0c2b259d1879f77e5233cea04e91df776b38;hpb=832cb45e325364ca1de645a2256efa69284fcf06;p=plack-app-gruntmaster.git diff --git a/lib/Gruntmaster/Page/Ct/Entry.pm b/lib/Gruntmaster/Page/Ct/Entry.pm index 50ee0c2..bba2991 100644 --- a/lib/Gruntmaster/Page/Ct/Entry.pm +++ b/lib/Gruntmaster/Page/Ct/Entry.pm @@ -7,45 +7,37 @@ 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 YAML::Any qw/LoadFile/; -use File::Basename qw/fileparse/; -use File::Slurp qw/slurp/; -use Gruntmaster::Page::Common qw/header footer/; +use Gruntmaster::Page::Common qw/cook_templates reload_templates/; +use Gruntmaster::Data qw/contest_name contest_start contest_end/; -use constant TITLE => ''; - -my %templates = ( - en => <<'HTML', +my %orig_templates = ( + en => <<'HTML', Contest start time:
Contest end time:

Problems
Job log
-Standings
+Standings HTML ); -$templates{$_} = header($_, TITLE) . $templates{$_} for keys %templates; -$templates{$_} .= footer $_ for keys %templates; +my %templates = cook_templates %orig_templates, ct_entry => ''; sub generate{ - my ($path, $lang) = @_; - $path = ($path =~ m,ct/(.*)/index,)[0]; - my $template = $templates{$lang}; - my $htc = HTML::Template::Compiled->new(scalarref => \$template); - flock my $metafh = IO::File->new("param(id => $path); - $htc->param(name => $meta->{name}); - $htc->param(start => strftime '%c', localtime $meta->{start}); - $htc->param(end => strftime '%c', localtime $meta->{end}); - $htc->param(started => time >= $meta->{start}); - $htc->output + %templates = cook_templates %orig_templates, ct_entry => '' if reload_templates; + my ($path, $lang) = @_; + $path = ($path =~ m,ct/(.*)/index,)[0]; + my $template = $templates{$lang}; + my $htc = HTML::Template::Compiled->new(scalarref => \$template); + + $htc->param(id => $path); + $htc->param(name => contest_name $path); + $htc->param(start => strftime '%c', contest_start); + $htc->param(end => strftime '%c', contest_end); + $htc->param(started => time >= contest_start); + $htc->output } 1