X-Git-Url: http://git.ieval.ro/?a=blobdiff_plain;f=lib%2FGruntmaster%2FPage%2FLog%2FEntry.pm;h=309660a3065155f55f701790a18431c6b78e7c80;hb=cd9af27e94244e6454c3db787a8ca6811f44fc16;hp=08230bfaf8fa475895960943e58a5aa5dd98e340;hpb=42546e6c1b709dc4c8d8e7048becc14278b6cdf0;p=plack-app-gruntmaster.git diff --git a/lib/Gruntmaster/Page/Log/Entry.pm b/lib/Gruntmaster/Page/Log/Entry.pm index 08230bf..309660a 100644 --- a/lib/Gruntmaster/Page/Log/Entry.pm +++ b/lib/Gruntmaster/Page/Log/Entry.pm @@ -9,15 +9,13 @@ our $VERSION = '0.001'; use constant TITLE => 'Job '; -use Fcntl qw/:flock/; use HTML::Template::Compiled; -use IO::File; use POSIX qw/strftime/; -use YAML::Any qw/LoadFile/; -use Gruntmaster::Page qw/header footer/; +use Gruntmaster::Page::Common qw/header footer/; +use Gruntmaster::Data qw/job_results/; my %templates = ( - en => <<'HTML', + en => <<'HTML',
Test numberResultTime @@ -32,22 +30,20 @@ $templates{$_} = header($_, TITLE) . $templates{$_} for keys %templates; $templates{$_} .= footer $_ for keys %templates; sub generate{ - my ($path, $lang) = @_; - $path = ($path =~ m,log/(.*)/index,)[0]; - my $template = $templates{$lang}; - - my $htc = HTML::Template::Compiled->new(scalarref => \$template); - flock my $metafh = IO::File->new("{time} = sprintf "%.4fs", $_->{time}; - $_ - } @{$meta->{results}}; - - $htc->param(id => $path); - $htc->param(tests => \@tests); - $htc->output + $_[0] =~ m,^(?:ct/([^/]+)/)?log/([^/]+)/index\.html$,; + local $Gruntmaster::Data::contest = $1; + my $id = $2; + + my $htc = HTML::Template::Compiled->new(scalarref => \$templates{$_[1]}); + + my @tests = map { + $_->{time} = sprintf "%.4fs", $_->{time}; + $_ + } @{job_results $id}; + + $htc->param(id => $id); + $htc->param(tests => \@tests); + $htc->output } 1