]>
iEval git - plack-app-gruntmaster.git/blob - Gruntmaster/Page/Pb.pm
1 package Gruntmaster
::Page
::Pb
;
6 use parent qw
/Exporter/;
7 our @EXPORT_OK = qw
/generate/;
8 our $VERSION = '0.001';
10 use constant TITLE
=> 'Problems';
13 use HTML
::Template
::Compiled
;
15 use POSIX qw
/strftime/;
16 use YAML
::Any qw
/LoadFile/;
17 use Gruntmaster
::Page
::Common qw
/header footer/;
24 <tmpl_loop beginner><li><a href="<tmpl_var id>"><tmpl_var name></a>
29 <tmpl_loop easy><li><a href="<tmpl_var id>"><tmpl_var name></a>
34 <tmpl_loop medium><li><a href="<tmpl_var id>"><tmpl_var name></a>
39 <tmpl_loop hard><li><a href="<tmpl_var id>"><tmpl_var name></a>
44 <tmpl_loop problems><li><a href="<tmpl_var id>"><tmpl_var name></a>
50 $templates{$_} = header
($_, TITLE
) . $templates{$_} for keys %templates;
51 $templates{$_} .= footer
$_ for keys %templates;
54 my ($path, $lang) = @_;
55 $path =~ s
,/index\
.html
$,,;
56 my $template = $templates{$lang};
57 my $htc = HTML
::Template
::Compiled
->new(scalarref
=> \
$template);
58 IO
::File
->new(">$path/meta.yml")->close unless -f
"$path/meta.yml";
59 flock my $metafh = IO
::File
->new("<$path/meta.yml"), LOCK_SH
;
60 my @problems = sort { $b->{name
} cmp $a->{name
} } map {
61 my $meta = LoadFile
$_;
62 my $id = (m
,^$path/(.*)/meta
.yml
$,)[0];
63 +{ id
=> $id, name
=> $meta->{name
}, level
=> $meta->{level
} } } <$path/*/meta
.yml
>;
64 for my $d(qw
/beginner easy medium advanced hard/) {
65 $htc->param($d => [grep {$_->{level
} and $_->{level
} eq $d} @problems]);
67 $htc->param(levels
=> grep { $_->{level
} } @problems);
68 $htc->param(problems
=> \
@problems);
This page took 0.051767 seconds and 4 git commands to generate.