]>
Commit | Line | Data |
---|---|---|
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 | ||
10 | use HTML::Template::Compiled; | |
11 | use POSIX qw/strftime/; | |
12 | use Gruntmaster::Page::Common qw/cook_templates reload_templates/; | |
13 | use Gruntmaster::Data qw/job_results/; | |
14 | ||
15 | my %orig_templates = ( | |
16 | en => <<'HTML', | |
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 | ||
27 | my %templates = cook_templates %orig_templates, log_entry => 'Job <tmpl_var id>'; | |
28 | ||
29 | sub generate{ | |
30 | %templates = cook_templates %orig_templates, log_entry => 'Job <tmpl_var id>' if reload_templates; | |
31 | $_[0] =~ m,^(?:ct/([^/]+)/)?log/job/([^/]+)\.html$,; | |
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 | |
45 | } | |
46 | ||
47 | 1 |