]> iEval git - gruntmaster-page.git/blob - lib/Gruntmaster/Page/Pb.pm
Pass PSGI env to generators
[gruntmaster-page.git] / lib / Gruntmaster / Page / Pb.pm
1 package Gruntmaster::Page::Pb;
2
3 use 5.014000;
4 use strict;
5 use warnings;
6 use Gruntmaster::Page::Base pb => 'Problems';
7 our @ISA = qw/Gruntmaster::Page::Base/;
8 our $VERSION = '0.001';
9
10 use constant TEMPLATES => {
11 en => <<'HTML',
12 <tmpl_if levels>
13 <h2>Beginner</h2>
14 <div class="list-group">
15 <tmpl_loop beginner><a class="list-group-item" href="<tmpl_var id>"><tmpl_var name></a>
16 </tmpl_loop></div>
17
18 <h2>Easy</h2>
19 <div class="list-group">
20 <tmpl_loop easy><a class="list-group-item" href="<tmpl_var id>"><tmpl_var name></a>
21 </tmpl_loop></div>
22
23 <h2>Medium</h2>
24 <div class="list-group">
25 <tmpl_loop medium><a class="list-group-item" href="<tmpl_var id>"><tmpl_var name></a>
26 </tmpl_loop></div>
27
28 <h2>Hard</h2>
29 <div class="list-group">
30 <tmpl_loop hard><a class="list-group-item" href="<tmpl_var id>"><tmpl_var name></a>
31 </tmpl_loop></div>
32
33 <tmpl_else>
34 <div class="list-group">
35 <tmpl_loop problems><a class="list-group-item" href="<tmpl_var id>"><tmpl_var name></a>
36 </tmpl_loop></div>
37 </tmpl_if>
38 HTML
39 };
40
41 sub _generate{
42 my ($self, $htc, $lang, $env, $ct) = @_;
43 debug $env => "language is '$lang' and contest is '$ct'";
44 local $Gruntmaster::Data::contest = $ct if $ct;
45
46 my @problems = sort { $b->{name} cmp $a->{name} } map +{
47 id => $_,
48 name => problem_name,
49 level => problem_level}, problems;
50
51 for my $d (qw/beginner easy medium advanced hard/) {
52 $htc->param($d => [grep {$_->{level} and $_->{level} eq $d} @problems]);
53 }
54 $htc->param(levels => grep { $_->{level} } @problems);
55 $htc->param(problems => \@problems);
56 }
57
58 1
This page took 0.053096 seconds and 4 git commands to generate.