X-Git-Url: http://git.ieval.ro/?a=blobdiff_plain;ds=sidebyside;f=lib%2FGruntmaster%2FPage%2FPb.pm;h=ffdde60697862c0b2db66533649082bb0d20ea7d;hb=a8b4e6d36eacf5bf07279e99be91f6c228092c39;hp=efe7d26a42d986dbde5dc51b9add82aca7b91c24;hpb=42546e6c1b709dc4c8d8e7048becc14278b6cdf0;p=plack-app-gruntmaster.git
diff --git a/lib/Gruntmaster/Page/Pb.pm b/lib/Gruntmaster/Page/Pb.pm
index efe7d26..ffdde60 100644
--- a/lib/Gruntmaster/Page/Pb.pm
+++ b/lib/Gruntmaster/Page/Pb.pm
@@ -3,41 +3,56 @@ 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 constant TITLE => 'Problems';
+use constant TEMPLATES => {
+ en => <<'HTML',
+
+Beginner
+
-use Fcntl qw/:flock/;
-use HTML::Template::Compiled;
-use IO::File;
-use POSIX qw/strftime/;
-use YAML::Any qw/LoadFile/;
-use Gruntmaster::Page qw/header footer/;
+Easy
+
-my %templates = (
- en => <<'HTML',
-
+Medium
+
+
+Hard
+
+
+
+
+
HTML
-);
-
-$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('>pb/meta.yml')->close unless -f 'pb/meta.yml';
- flock my $metafh = IO::File->new('{name} cmp $a->{name} } map {
- my $meta = LoadFile $_;
- my $id = (m,^pb/(.*)/meta.yml$,)[0];
- +{ id => $id, name => $meta->{name} } } ;
- $htc->param(problems => \@problems);
- $htc->output
+};
+
+sub _generate{
+ my ($self, $htc, $lang, $env, $ct) = @_;
+ debug $env => "language is '$lang' and contest is '$ct'";
+ local $Gruntmaster::Data::contest = $ct if $ct;
+
+ 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);
}
1