]>
Commit | Line | Data |
---|---|---|
1 | package Gruntmaster::Page::Submit; | |
2 | ||
3 | use 5.014000; | |
4 | use strict; | |
5 | use warnings; | |
6 | use parent qw/Exporter/; | |
7 | our @EXPORT_OK = qw/generate/; | |
8 | our $VERSION = '0.001'; | |
9 | ||
10 | use constant FORMATS => [qw/CPP/]; | |
11 | ||
12 | use HTML::Template::Compiled; | |
13 | use Gruntmaster::Page::Common qw/cook_templates reload_templates/; | |
14 | use Gruntmaster::Data qw/problem_name problems/; | |
15 | ||
16 | my %orig_templates = ( | |
17 | en => <<'HTML', | |
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"> | |
33 | HTML | |
34 | ); | |
35 | ||
36 | my %templates = cook_templates %orig_templates, submit => 'Submit job'; | |
37 | ||
38 | sub generate{ | |
39 | %templates = cook_templates %orig_templates, submit => 'Submit job' if reload_templates; | |
40 | ||
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 | |
46 | } | |
47 | ||
48 | 1 |