our @EXPORT_OK = qw/generate/;
our $VERSION = '0.001';
-use constant TITLE => 'Problems';
-
use Fcntl qw/:flock/;
use HTML::Template::Compiled;
use IO::File;
use POSIX qw/strftime/;
-use Gruntmaster::Page::Common qw/header footer/;
+use Gruntmaster::Page::Common qw/cook_templates reload_templates/;
use Gruntmaster::Data qw/problem_name problem_level problems/;
-my %templates = (
+my %orig_templates = (
en => <<'HTML',
<tmpl_if levels>
<h2>Beginner</h2>
<ul>
-<tmpl_loop beginner><li><a href="<tmpl_var id>"><tmpl_var name></a>
+<tmpl_loop beginner><li><a href="<tmpl_var id>.var"><tmpl_var name></a>
</tmpl_loop></ul>
<h2>Easy</h2>
<ul>
-<tmpl_loop easy><li><a href="<tmpl_var id>"><tmpl_var name></a>
+<tmpl_loop easy><li><a href="<tmpl_var id>.var"><tmpl_var name></a>
</tmpl_loop></ul>
<h2>Medium</h2>
<ul>
-<tmpl_loop medium><li><a href="<tmpl_var id>"><tmpl_var name></a>
+<tmpl_loop medium><li><a href="<tmpl_var id>.var"><tmpl_var name></a>
</tmpl_loop></ul>
<h2>Hard</h2>
<ul>
-<tmpl_loop hard><li><a href="<tmpl_var id>"><tmpl_var name></a>
+<tmpl_loop hard><li><a href="<tmpl_var id>.var"><tmpl_var name></a>
</tmpl_loop></ul>
<tmpl_else>
<ul>
-<tmpl_loop problems><li><a href="<tmpl_var id>"><tmpl_var name></a>
+<tmpl_loop problems><li><a href="<tmpl_var id>.var"><tmpl_var name></a>
</tmpl_loop></ul>
</tmpl_if>
HTML
);
-$templates{$_} = header($_, TITLE) . $templates{$_} for keys %templates;
-$templates{$_} .= footer $_ for keys %templates;
+my %templates = cook_templates %orig_templates, pb => 'Problems';
sub generate{
+ %templates = cook_templates %orig_templates, pb => 'Problems' if reload_templates;
$_[0] =~ m,^(?:ct/([^/]+)/)?pb/index.html$,;
local $Gruntmaster::Data::contest = $1;