]>
Commit | Line | Data |
---|---|---|
fe78f0c1 MG |
1 | package Gruntmaster::Page::Ct::Entry; |
2 | ||
3 | use 5.014000; | |
4 | use strict; | |
5 | use warnings; | |
6 | use parent qw/Exporter/; | |
7 | our @EXPORT_OK = qw/generate/; | |
8 | our $VERSION = '0.001'; | |
9 | ||
fe78f0c1 | 10 | use HTML::Template::Compiled; |
fe78f0c1 | 11 | use POSIX qw/strftime/; |
2b0036ac | 12 | use Gruntmaster::Page::Common qw/cook_templates reload_templates/; |
cd9af27e | 13 | use Gruntmaster::Data qw/contest_name contest_start contest_end/; |
fe78f0c1 | 14 | |
2b0036ac | 15 | my %orig_templates = ( |
cd9af27e | 16 | en => <<'HTML', |
fe78f0c1 MG |
17 | Contest start time: <tmpl_var start><br> |
18 | Contest end time: <tmpl_var end><p> | |
19 | ||
20 | <tmpl_if started><a href="pb/">Problems</a><br> | |
21 | <a href="log/">Job log</a><br> | |
5bbf0128 | 22 | <a href="log/st.var">Standings</a></tmpl_if> |
fe78f0c1 MG |
23 | HTML |
24 | ); | |
25 | ||
2b0036ac | 26 | my %templates = cook_templates %orig_templates, ct_entry => '<tmpl_var name>'; |
fe78f0c1 MG |
27 | |
28 | sub generate{ | |
2b0036ac | 29 | %templates = cook_templates %orig_templates, ct_entry => '<tmpl_var name>' if reload_templates; |
cd9af27e MG |
30 | my ($path, $lang) = @_; |
31 | $path = ($path =~ m,ct/(.*)/index,)[0]; | |
32 | my $template = $templates{$lang}; | |
33 | my $htc = HTML::Template::Compiled->new(scalarref => \$template); | |
34 | ||
35 | $htc->param(id => $path); | |
36 | $htc->param(name => contest_name $path); | |
37 | $htc->param(start => strftime '%c', contest_start); | |
38 | $htc->param(end => strftime '%c', contest_end); | |
39 | $htc->param(started => time >= contest_start); | |
40 | $htc->output | |
fe78f0c1 MG |
41 | } |
42 | ||
43 | 1 |