]> iEval git - gruntmaster-page.git/blobdiff - lib/Gruntmaster/Page/Submit.pm
Use Redis and reindent code
[gruntmaster-page.git] / lib / Gruntmaster / Page / Submit.pm
index a57b7b177b05d52f27e77eb0aa219f254f77a320..3f289d5c50eebb1f6b0e7680a48f07b92346273c 100644 (file)
@@ -12,12 +12,12 @@ use constant TITLE => 'Submit job';
 
 use Fcntl qw/:flock/;
 use HTML::Template::Compiled;
-use IO::File;
 use YAML::Any qw/LoadFile/;
 use Gruntmaster::Page::Common qw/header footer/;
+use Gruntmaster::Data qw//;
 
 my %templates = (
-  en => <<'HTML',
+       en => <<'HTML',
 <form action="https://gm.ieval.ro/action/submit" method="POST" enctype="multipart/form-data">
 <label>Problem:<br>
 <select name="problem" required>
@@ -40,17 +40,11 @@ $templates{$_}  = header($_, TITLE) . $templates{$_} for keys %templates;
 $templates{$_} .= footer $_ for keys %templates;
 
 sub generate{
-  my $template = $templates{$_[1]};
-  my $htc = HTML::Template::Compiled->new(scalarref => \$template);
-  IO::File->new('>meta.yml')->close unless -f 'meta.yml';
-  flock my $metafh = IO::File->new('<meta.yml'), LOCK_SH;
-  my @problems = map {
-       my $meta = LoadFile $_;
-       my $id = (m,^pb/(.*)/meta.yml$,)[0];
-       +{ id => $id, name => $meta->{name} } } <pb/*/meta.yml>;
-  $htc->param(problems => \@problems);
-  $htc->param(formats => FORMATS);
-  $htc->output
+       my $htc = HTML::Template::Compiled->new(scalarref => \$templates{$_[1]});
+       my @problems = map +{ id => $_, name => problem_name }, problems;
+       $htc->param(problems => \@problems);
+       $htc->param(formats => FORMATS);
+       $htc->output
 }
 
 1
This page took 0.023056 seconds and 4 git commands to generate.