]> iEval git - gruntmaster-page.git/blobdiff - lib/Gruntmaster/Page/Submit.pm
Centralize template cooking and introduce reloadable templates
[gruntmaster-page.git] / lib / Gruntmaster / Page / Submit.pm
index 3f289d5c50eebb1f6b0e7680a48f07b92346273c..7e4d1634d27ca6ef328cc530b4e095db02c4a976 100644 (file)
@@ -8,15 +8,12 @@ our @EXPORT_OK = qw/generate/;
 our $VERSION = '0.001';
 
 use constant FORMATS => [qw/CPP/];
-use constant TITLE => 'Submit job';
 
-use Fcntl qw/:flock/;
 use HTML::Template::Compiled;
-use YAML::Any qw/LoadFile/;
-use Gruntmaster::Page::Common qw/header footer/;
-use Gruntmaster::Data qw//;
+use Gruntmaster::Page::Common qw/cook_templates reload_templates/;
+use Gruntmaster::Data qw/problem_name problems/;
 
-my %templates = (
+my %orig_templates = (
        en => <<'HTML',
 <form action="https://gm.ieval.ro/action/submit" method="POST" enctype="multipart/form-data">
 <label>Problem:<br>
@@ -36,10 +33,11 @@ my %templates = (
 HTML
 );
 
-$templates{$_}  = header($_, TITLE) . $templates{$_} for keys %templates;
-$templates{$_} .= footer $_ for keys %templates;
+my %templates = cook_templates %orig_templates, submit => 'Submit job';
 
 sub generate{
+       %templates = cook_templates %orig_templates, submit => 'Submit job' if reload_templates;
+
        my $htc = HTML::Template::Compiled->new(scalarref => \$templates{$_[1]});
        my @problems = map +{ id => $_, name => problem_name }, problems;
        $htc->param(problems => \@problems);
This page took 0.025861 seconds and 4 git commands to generate.