]>
Commit | Line | Data |
---|---|---|
fe78f0c1 MG |
1 | package Gruntmaster::Page::Ct; |
2 | ||
3 | use 5.014000; | |
4 | use strict; | |
5 | use warnings; | |
bb95f538 MG |
6 | use Gruntmaster::Page::Base ct => 'Contests'; |
7 | our @ISA = qw/Gruntmaster::Page::Base/; | |
fe78f0c1 MG |
8 | our $VERSION = '0.001'; |
9 | ||
bb95f538 | 10 | use constant TEMPLATES => { |
cd9af27e MG |
11 | en => <<'HTML', |
12 | <tmpl_if running> | |
fe78f0c1 MG |
13 | <h1>Running contests</h1> |
14 | <table border> | |
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 | ||
cd9af27e | 26 | <tmpl_if pending> |
fe78f0c1 MG |
27 | <h1>Pending contests</h1> |
28 | <table border> | |
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 | ||
cd9af27e | 40 | <tmpl_if finished> |
fe78f0c1 MG |
41 | <h1>Finished contests</h1> |
42 | <table border> | |
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> | |
53 | HTML | |
bb95f538 | 54 | }; |
fe78f0c1 | 55 | |
bb95f538 MG |
56 | sub _generate{ |
57 | my ($self, $htc, $path, $lang) = @_; | |
fe78f0c1 | 58 | |
cd9af27e MG |
59 | my (@running, @pending, @finished); |
60 | for (contests) { | |
61 | my $ct = { id => $_, | |
62 | name => contest_name, | |
63 | start => strftime ('%c', localtime contest_start), | |
64 | end => strftime ('%c', localtime contest_end), | |
65 | owner => contest_owner }; | |
fe78f0c1 | 66 | |
cd9af27e MG |
67 | my $time = time; |
68 | push @pending, $ct if time < contest_start; | |
69 | push @running, $ct if time >= contest_start && time < contest_end; | |
70 | push @finished, $ct if time > contest_end; | |
71 | } | |
fe78f0c1 | 72 | |
62a11450 MG |
73 | $htc->param(running => \@running) if @running; |
74 | $htc->param(pending => \@pending) if @pending; | |
75 | $htc->param(finished => \@finished) if @finished; | |
fe78f0c1 MG |
76 | } |
77 | ||
78 | 1 |