]> iEval git - gruntmaster-page.git/blame - lib/Gruntmaster/Page/Pb/Entry.pm
Add user list and user pages
[gruntmaster-page.git] / lib / Gruntmaster / Page / Pb / Entry.pm
CommitLineData
42546e6c
MG
1package Gruntmaster::Page::Pb::Entry;
2
3use 5.014000;
4use strict;
5use warnings;
6use parent qw/Exporter/;
7our @EXPORT_OK = qw/generate/;
8our $VERSION = '0.001';
9
42546e6c 10use HTML::Template::Compiled;
42546e6c 11use POSIX qw/strftime/;
2b0036ac 12use Gruntmaster::Page::Common qw/cook_templates reload_templates/;
cd9af27e 13use Gruntmaster::Data qw/contest_start contest_end problem_name problem_statement/;
42546e6c
MG
14
15use constant FORMATS => [qw/CPP/];
42546e6c 16
2b0036ac 17my %orig_templates = (
cd9af27e 18 en => <<'HTML',
42546e6c
MG
19<tmpl_var statement>
20
fe78f0c1 21<tmpl_if cansubmit>
42546e6c
MG
22<h1>Submit solution</h1>
23<form action="https://gm.ieval.ro/action/submit" method="POST" enctype="multipart/form-data">
24<input type="hidden" name="problem" value="<tmpl_var id>">
fe78f0c1 25<tmpl_if_defined contest><input type="hidden" name="contest" value="<tmpl_var contest>"></tmpl_if_defined>
42546e6c
MG
26<label>File: <input name="prog" required type="file"></label>
27
28<label>File format: <select name="prog_format" required>
29<tmpl_loop formats><option value="<tmpl_var _>"><tmpl_var _></option>
30</tmpl_loop></select></label>
31
32<input type="submit" value="Submit job">
6d28cb38 33</form>
fe78f0c1 34</tmpl_if>
42546e6c
MG
35HTML
36);
37
2b0036ac 38my %templates = cook_templates %orig_templates, pb_entry => '<tmpl_var name>';
42546e6c
MG
39
40sub generate{
2b0036ac 41 %templates = cook_templates %orig_templates, pb_entry => '<tmpl_var name>' if reload_templates;
3da9c3c2 42 $_[0] =~ m,(?:ct/([^/])+/)?pb/(\w+)\.html$,;
42546e6c 43
cd9af27e
MG
44 my ($contest, $id) = ($1, $2);
45 my $htc = HTML::Template::Compiled->new(scalarref => \$templates{$_[1]});
46
47 $htc->param(cansubmit => 1);
48 if (defined $contest) {
49 $htc->param(cansubmit => time >= contest_start $contest && time <= contest_end $contest);
50 $htc->param(contest => $contest);
51 }
52 $htc->param(formats => FORMATS);
53 $htc->param(id => $id);
3da9c3c2 54 local $Gruntmaster::Data::contest = $contest if $contest;
cd9af27e 55 $htc->param(name => problem_name $id);
3da9c3c2 56 $htc->param(statement => problem_statement $id);
cd9af27e 57 $htc->output
42546e6c
MG
58}
59
601
This page took 0.025536 seconds and 4 git commands to generate.