]> iEval git - gruntmaster-page.git/blobdiff - lib/Gruntmaster/Page/Pb.pm
Make all generators inherit from a common base
[gruntmaster-page.git] / lib / Gruntmaster / Page / Pb.pm
index 18b47bf894710cb8449ba68910592c7a1a266004..8e4a40886e26d329c6a113d84e97ed209ecd6f19 100644 (file)
@@ -3,19 +3,12 @@ package Gruntmaster::Page::Pb;
 use 5.014000;
 use strict;
 use warnings;
-use parent qw/Exporter/;
-our @EXPORT_OK = qw/generate/;
+use Gruntmaster::Page::Base pb => 'Problems';
+our @ISA = qw/Gruntmaster::Page::Base/;
 our $VERSION = '0.001';
 
-use Fcntl qw/:flock/;
-use HTML::Template::Compiled;
-use IO::File;
-use POSIX qw/strftime/;
-use Gruntmaster::Page::Common qw/cook_templates reload_templates/;
-use Gruntmaster::Data qw/problem_name problem_level problems/;
-
-my %orig_templates = (
-  en => <<'HTML',
+use constant TEMPLATES => {
+       en => <<'HTML',
 <tmpl_if levels>
 <h2>Beginner</h2>
 <ul>
@@ -43,26 +36,24 @@ my %orig_templates = (
 </tmpl_loop></ul>
 </tmpl_if>
 HTML
-);
+};
 
-my %templates = cook_templates %orig_templates, pb => 'Problems';
+sub _generate{
+       my ($self, $htc, $path, $lang) = @_;
 
-sub generate{
-       %templates = cook_templates %orig_templates, pb => 'Problems' if reload_templates;
-       $_[0] =~ m,^(?:ct/([^/]+)/)?pb/index.html$,;
+       $path =~ m,^(?:ct/([^/]+)/)?pb/index.html$,;
        local $Gruntmaster::Data::contest = $1;
 
-       my $htc = HTML::Template::Compiled->new(scalarref => \$templates{$_[1]});
        my @problems = sort { $b->{name} cmp $a->{name} } map +{
                id    => $_,
                name  => problem_name,
                level => problem_level}, problems;
+
        for my $d (qw/beginner easy medium advanced hard/) {
                $htc->param($d => [grep {$_->{level} and $_->{level} eq $d} @problems]);
        }
        $htc->param(levels => grep { $_->{level} } @problems);
        $htc->param(problems => \@problems);
-       $htc->output
 }
 
 1
This page took 0.025664 seconds and 4 git commands to generate.