]>
iEval git - gruntmaster-page.git/blob - lib/Gruntmaster/Page/Pb.pm
a2cccff504516d7c90969a00977c2be54a584ec8
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/;
23 <tmpl_loop beginner><li><a href="<tmpl_var id>"><tmpl_var name></a>
28 <tmpl_loop easy><li><a href="<tmpl_var id>"><tmpl_var name></a>
33 <tmpl_loop medium><li><a href="<tmpl_var id>"><tmpl_var name></a>
38 <tmpl_loop advanced><li><a href="<tmpl_var id>"><tmpl_var name></a>
43 <tmpl_loop hard><li><a href="<tmpl_var id>"><tmpl_var name></a>
48 $templates{$_} = header
($_, TITLE
) . $templates{$_} for keys %templates;
49 $templates{$_} .= footer
$_ for keys %templates;
52 my ($path, $lang) = @_;
53 $path =~ s
,/index\
.html
$,,;
54 my $template = $templates{$lang};
55 my $htc = HTML
::Template
::Compiled
->new(scalarref
=> \
$template);
56 IO
::File
->new(">$path/meta.yml")->close unless -f
"$path/meta.yml";
57 flock my $metafh = IO
::File
->new("<$path/meta.yml"), LOCK_SH
;
58 my @problems = sort { $b->{name
} cmp $a->{name
} } map {
59 my $meta = LoadFile
$_;
60 my $id = (m
,^$path/(.*)/meta
.yml
$,)[0];
61 +{ id
=> $id, name
=> $meta->{name
}, level
=> $meta->{level
} } } <$path/*/meta
.yml
>;
62 for my $d(qw
/beginner easy medium advanced hard/) {
63 $htc->param($d => [grep {$_->{level
} eq $d} @problems]);
This page took 0.046789 seconds and 4 git commands to generate.