]> iEval git - gruntmaster-page.git/blame - lib/Gruntmaster/Page/Log/Entry.pm
Use Redis and reindent code
[gruntmaster-page.git] / lib / Gruntmaster / Page / Log / Entry.pm
CommitLineData
42546e6c
MG
1package Gruntmaster::Page::Log::Entry;
2
3use 5.014000;
4use strict;
5use warnings;
6use parent qw/Exporter/;
7our @EXPORT_OK = qw/generate/;
8our $VERSION = '0.001';
9
10use constant TITLE => 'Job <tmpl_var id>';
11
42546e6c 12use HTML::Template::Compiled;
42546e6c 13use POSIX qw/strftime/;
832cb45e 14use Gruntmaster::Page::Common qw/header footer/;
cd9af27e 15use Gruntmaster::Data qw/job_results/;
42546e6c
MG
16
17my %templates = (
cd9af27e 18 en => <<'HTML',
42546e6c
MG
19<table border>
20<thead>
21<tr><th>Test number<th>Result<th>Time
22<tbody>
23<tmpl_loop tests><tr><td><tmpl_var id><td class="r<tmpl_var result>"><tmpl_var result_text><td><tmpl_var time>
24</tmpl_loop>
25</table>
26HTML
27);
28
29$templates{$_} = header($_, TITLE) . $templates{$_} for keys %templates;
30$templates{$_} .= footer $_ for keys %templates;
31
32sub generate{
cd9af27e
MG
33 $_[0] =~ m,^(?:ct/([^/]+)/)?log/([^/]+)/index\.html$,;
34 local $Gruntmaster::Data::contest = $1;
35 my $id = $2;
36
37 my $htc = HTML::Template::Compiled->new(scalarref => \$templates{$_[1]});
38
39 my @tests = map {
40 $_->{time} = sprintf "%.4fs", $_->{time};
41 $_
42 } @{job_results $id};
43
44 $htc->param(id => $id);
45 $htc->param(tests => \@tests);
46 $htc->output
42546e6c
MG
47}
48
491
This page took 0.027047 seconds and 4 git commands to generate.