]>
Commit | Line | Data |
---|---|---|
42546e6c MG |
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/]; | |
42546e6c | 11 | |
42546e6c | 12 | use HTML::Template::Compiled; |
2b0036ac MG |
13 | use Gruntmaster::Page::Common qw/cook_templates reload_templates/; |
14 | use Gruntmaster::Data qw/problem_name problems/; | |
42546e6c | 15 | |
2b0036ac | 16 | my %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"> | |
33 | HTML | |
34 | ); | |
35 | ||
2b0036ac | 36 | my %templates = cook_templates %orig_templates, submit => 'Submit job'; |
42546e6c MG |
37 | |
38 | sub 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 | ||
48 | 1 |