X-Git-Url: http://git.ieval.ro/?a=blobdiff_plain;f=lib%2FGruntmaster%2FPage%2FPb%2FEntry.pm;h=0e6bbc817aed87e3306cfdb13a8a2e8cb3ea6e36;hb=6d28cb383168de84cebad84aa43900844341bf5d;hp=0f91c0128841386ebaed3e4a39a6afbdb9fc5a91;hpb=42546e6c1b709dc4c8d8e7048becc14278b6cdf0;p=plack-app-gruntmaster.git diff --git a/lib/Gruntmaster/Page/Pb/Entry.pm b/lib/Gruntmaster/Page/Pb/Entry.pm index 0f91c01..0e6bbc8 100644 --- a/lib/Gruntmaster/Page/Pb/Entry.pm +++ b/lib/Gruntmaster/Page/Pb/Entry.pm @@ -14,7 +14,7 @@ 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 Gruntmaster::Page::Common qw/header footer/; use constant FORMATS => [qw/CPP/]; use constant TITLE => ''; @@ -23,9 +23,11 @@ my %templates = ( en => <<'HTML', +

Submit solution

+ +
+
HTML ); @@ -41,16 +45,25 @@ $templates{$_} .= footer $_ for keys %templates; sub generate{ my ($path, $lang) = @_; - $path = ($path =~ m,pb/(.*)/index,)[0]; + my $contest; + $contest = $1 if $path =~ m,ct/([^/]*)/,; + my $id = ($path =~ m,pb/([^/]*)/index,)[0]; + $path =~ s,/index\.html$,,; my $template = $templates{$_[1]}; my $htc = HTML::Template::Compiled->new(scalarref => \$template); - flock my $metafh = IO::File->new("new("<$path/meta.yml"), LOCK_SH; + my $meta = LoadFile "$path/meta.yml"; + $htc->param(cansubmit => 1); + if (defined $contest) { + my $meta = LoadFile "ct/$contest/meta.yml"; + $htc->param(cansubmit => time >= $meta->{start} && time <= $meta->{end}); + $htc->param(contest => $contest); + } $htc->param(formats => FORMATS); - $htc->param(id => $path); + $htc->param(id => $id); $htc->param(name => $meta->{name}); - $htc->param(statement => scalar slurp "pb/$path/statement.$lang"); + $htc->param(statement => scalar slurp "$path/statement.$lang"); $htc->output }