]> iEval git - gruntmaster-page.git/blame - lib/Gruntmaster/Page/Submit.pm
Centralize template cooking and introduce reloadable templates
[gruntmaster-page.git] / lib / Gruntmaster / Page / Submit.pm
CommitLineData
42546e6c
MG
1package Gruntmaster::Page::Submit;
2
3use 5.014000;
4use strict;
5use warnings;
6use parent qw/Exporter/;
7our @EXPORT_OK = qw/generate/;
8our $VERSION = '0.001';
9
10use constant FORMATS => [qw/CPP/];
42546e6c 11
42546e6c 12use HTML::Template::Compiled;
2b0036ac
MG
13use Gruntmaster::Page::Common qw/cook_templates reload_templates/;
14use Gruntmaster::Data qw/problem_name problems/;
42546e6c 15
2b0036ac 16my %orig_templates = (
cd9af27e 17 en => <<'HTML',
42546e6c
MG
18<form action="https://gm.ieval.ro/action/submit" method="POST" enctype="multipart/form-data">
19<label>Problem:<br>
20<select name="problem" required>
21<tmpl_loop problems><option value="<tmpl_var id>"><tmpl_var name></option>
22</tmpl_loop></select></label><p>
23
24<label>File:<br>
25<input name="prog" required type="file"></label><p>
26
27<label>File format:<br>
28<select name="prog_format" required>
29<tmpl_loop formats><option value="<tmpl_var _>"><tmpl_var _></option>
30</tmpl_loop></select></label><p>
31
32<input type="submit" value="Submit job">
33HTML
34);
35
2b0036ac 36my %templates = cook_templates %orig_templates, submit => 'Submit job';
42546e6c
MG
37
38sub generate{
2b0036ac
MG
39 %templates = cook_templates %orig_templates, submit => 'Submit job' if reload_templates;
40
cd9af27e
MG
41 my $htc = HTML::Template::Compiled->new(scalarref => \$templates{$_[1]});
42 my @problems = map +{ id => $_, name => problem_name }, problems;
43 $htc->param(problems => \@problems);
44 $htc->param(formats => FORMATS);
45 $htc->output
42546e6c
MG
46}
47
481
This page took 0.019924 seconds and 4 git commands to generate.