]>
Commit | Line | Data |
---|---|---|
42546e6c MG |
1 | package Gruntmaster::Page::Log::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 | ||
42546e6c | 10 | use HTML::Template::Compiled; |
42546e6c | 11 | use POSIX qw/strftime/; |
2b0036ac | 12 | use Gruntmaster::Page::Common qw/cook_templates reload_templates/; |
cd9af27e | 13 | use Gruntmaster::Data qw/job_results/; |
42546e6c | 14 | |
2b0036ac | 15 | my %orig_templates = ( |
cd9af27e | 16 | en => <<'HTML', |
42546e6c MG |
17 | <table border> |
18 | <thead> | |
19 | <tr><th>Test number<th>Result<th>Time | |
20 | <tbody> | |
21 | <tmpl_loop tests><tr><td><tmpl_var id><td class="r<tmpl_var result>"><tmpl_var result_text><td><tmpl_var time> | |
22 | </tmpl_loop> | |
23 | </table> | |
24 | HTML | |
25 | ); | |
26 | ||
2b0036ac | 27 | my %templates = cook_templates %orig_templates, log_entry => 'Job <tmpl_var id>'; |
42546e6c MG |
28 | |
29 | sub generate{ | |
2b0036ac | 30 | %templates = cook_templates %orig_templates, log_entry => 'Job <tmpl_var id>' if reload_templates; |
e5f2bda6 | 31 | $_[0] =~ m,^(?:ct/([^/]+)/)?log/job/([^/]+)\.html$,; |
cd9af27e MG |
32 | local $Gruntmaster::Data::contest = $1; |
33 | my $id = $2; | |
34 | ||
35 | my $htc = HTML::Template::Compiled->new(scalarref => \$templates{$_[1]}); | |
36 | ||
37 | my @tests = map { | |
38 | $_->{time} = sprintf "%.4fs", $_->{time}; | |
39 | $_ | |
40 | } @{job_results $id}; | |
41 | ||
42 | $htc->param(id => $id); | |
43 | $htc->param(tests => \@tests); | |
44 | $htc->output | |
42546e6c MG |
45 | } |
46 | ||
47 | 1 |