]> iEval git - gruntmaster-page.git/blame - lib/Gruntmaster/Page/Pb.pm
Initial commit
[gruntmaster-page.git] / lib / Gruntmaster / Page / Pb.pm
CommitLineData
42546e6c
MG
1package Gruntmaster::Page::Pb;
2
3use 5.014000;
4use strict;
5use warnings;
6use parent qw/Exporter/;
7our @EXPORT_OK = qw/generate/;
8our $VERSION = '0.001';
9
10use constant TITLE => 'Problems';
11
12use Fcntl qw/:flock/;
13use HTML::Template::Compiled;
14use IO::File;
15use POSIX qw/strftime/;
16use YAML::Any qw/LoadFile/;
17use Gruntmaster::Page qw/header footer/;
18
19my %templates = (
20 en => <<'HTML',
21<ul>
22<tmpl_loop problems><li><a href="<tmpl_var id>"><tmpl_var name></a>
23</tmpl_loop></ul>
24HTML
25);
26
27$templates{$_} = header($_, TITLE) . $templates{$_} for keys %templates;
28$templates{$_} .= footer $_ for keys %templates;
29
30sub generate{
31 my $template = $templates{$_[1]};
32 my $htc = HTML::Template::Compiled->new(scalarref => \$template);
33 IO::File->new('>pb/meta.yml')->close unless -f 'pb/meta.yml';
34 flock my $metafh = IO::File->new('<pb/meta.yml'), LOCK_SH;
35 my @problems = sort { $b->{name} cmp $a->{name} } map {
36 my $meta = LoadFile $_;
37 my $id = (m,^pb/(.*)/meta.yml$,)[0];
38 +{ id => $id, name => $meta->{name} } } <pb/*/meta.yml>;
39 $htc->param(problems => \@problems);
40 $htc->output
41}
42
431
This page took 0.01937 seconds and 4 git commands to generate.