X-Git-Url: http://git.ieval.ro/?a=blobdiff_plain;f=lib%2FGruntmaster%2FPage%2FCt%2FEntry.pm;fp=lib%2FGruntmaster%2FPage%2FCt%2FEntry.pm;h=625020d8372e1ee0f01f8cb1e468c1c898c28b43;hb=fe78f0c128c35e68e65850b02057997bad6717fe;hp=0000000000000000000000000000000000000000;hpb=42546e6c1b709dc4c8d8e7048becc14278b6cdf0;p=plack-app-gruntmaster.git diff --git a/lib/Gruntmaster/Page/Ct/Entry.pm b/lib/Gruntmaster/Page/Ct/Entry.pm new file mode 100644 index 0000000..625020d --- /dev/null +++ b/lib/Gruntmaster/Page/Ct/Entry.pm @@ -0,0 +1,51 @@ +package Gruntmaster::Page::Ct::Entry; + +use 5.014000; +use strict; +use warnings; +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 qw/header footer/; + +use constant TITLE => ''; + +my %templates = ( + en => <<'HTML', +Contest start time:
+Contest end time:

+ +Problems
+Job log
+Standings
+HTML +); + +$templates{$_} = header($_, TITLE) . $templates{$_} for keys %templates; +$templates{$_} .= footer $_ for keys %templates; + +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 +} + +1