use Fcntl qw/:flock/;
use HTML::Template::Compiled;
-use IO::File;
use YAML::Any qw/LoadFile/;
-use Gruntmaster::Page qw/header footer/;
+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>
$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