]> iEval git - plack-app-gruntmaster.git/blame_incremental - lib/Gruntmaster/Page/Ct.pm
Return 404 when the requested theme is not found
[plack-app-gruntmaster.git] / lib / Gruntmaster / Page / Ct.pm
... / ...
CommitLineData
1package Gruntmaster::Page::Ct;
2
3use 5.014000;
4use strict;
5use warnings;
6use Gruntmaster::Page::Base ct => 'Contests';
7our @ISA = qw/Gruntmaster::Page::Base/;
8our $VERSION = '0.001';
9
10use constant TEMPLATES => {
11 en => <<'HTML',
12<tmpl_if running>
13<h1>Running contests</h1>
14<table border class="table table-bordered table-striped">
15<thead>
16<tr><th>Name<th>Start date<th>End date<th>Owner
17<tbody>
18<tmpl_loop running><tr><td><a href="<tmpl_var id>"><tmpl_var name></a>
19<td><tmpl_var start>
20<td><tmpl_var end>
21<td><tmpl_var owner>
22</tmpl_loop>
23</table>
24</tmpl_if>
25
26<tmpl_if pending>
27<h1>Pending contests</h1>
28<table border class="table table-bordered table-striped">
29<thead>
30<tr><th>Name<th>Start date<th>End date<th>Owner
31<tbody>
32<tmpl_loop pending><tr><td><a href="<tmpl_var id>"><tmpl_var name></a>
33<td><tmpl_var start>
34<td><tmpl_var end>
35<td><tmpl_var owner>
36</tmpl_loop>
37</table>
38</tmpl_if>
39
40<tmpl_if finished>
41<h1>Finished contests</h1>
42<table border class="table table-bordered table-striped">
43<thead>
44<tr><th>Name<th>Start date<th>End date<th>Owner
45<tbody>
46<tmpl_loop finished><tr><td><a href="<tmpl_var id>"><tmpl_var name></a>
47<td><tmpl_var start>
48<td><tmpl_var end>
49<td><tmpl_var owner>
50</tmpl_loop>
51</table>
52</tmpl_if>
53HTML
54};
55
56sub _generate{
57 my ($self, $htc, $lang, $logger) = @_;
58 debug $logger => "language is '$lang'";
59
60 my (@running, @pending, @finished);
61 for (contests) {
62 my $ct = { id => $_,
63 name => contest_name,
64 start => strftime ('%c', localtime contest_start),
65 end => strftime ('%c', localtime contest_end),
66 owner => contest_owner };
67
68 my $time = time;
69 push @pending, $ct if time < contest_start;
70 push @running, $ct if time >= contest_start && time < contest_end;
71 push @finished, $ct if time > contest_end;
72 }
73
74 $htc->param(running => \@running) if @running;
75 $htc->param(pending => \@pending) if @pending;
76 $htc->param(finished => \@finished) if @finished;
77}
78
791
This page took 0.01607 seconds and 4 git commands to generate.