X-Git-Url: http://git.ieval.ro/?a=blobdiff_plain;f=lib%2FGruntmaster%2FPage%2FLog%2FEntry.pm;h=2c4aa3acb5cfc1bec533ddf6e673a08e5c80e642;hb=7f0f55d8d78f78bdc76d6ac3089c6aa085d95be6;hp=e849876d2a67a32f9abe138457c63d4242e652a8;hpb=832cb45e325364ca1de645a2256efa69284fcf06;p=plack-app-gruntmaster.git diff --git a/lib/Gruntmaster/Page/Log/Entry.pm b/lib/Gruntmaster/Page/Log/Entry.pm index e849876..2c4aa3a 100644 --- a/lib/Gruntmaster/Page/Log/Entry.pm +++ b/lib/Gruntmaster/Page/Log/Entry.pm @@ -3,21 +3,16 @@ package Gruntmaster::Page::Log::Entry; use 5.014000; use strict; use warnings; -use parent qw/Exporter/; -our @EXPORT_OK = qw/generate/; +use Gruntmaster::Page::Base log_entry => 'Job '; +our @ISA = qw/Gruntmaster::Page::Base/; our $VERSION = '0.001'; -use constant TITLE => 'Job '; +use constant TEMPLATES => { + en => <<'HTML', +Compiler output: +
-use Fcntl qw/:flock/; -use HTML::Template::Compiled; -use IO::File; -use POSIX qw/strftime/; -use YAML::Any qw/LoadFile/; -use Gruntmaster::Page::Common qw/header footer/; - -my %templates = ( - en => <<'HTML', +Results:
Test numberResultTime @@ -26,29 +21,27 @@ my %templates = (
HTML -); +}; -$templates{$_} = header($_, TITLE) . $templates{$_} for keys %templates; -$templates{$_} .= footer $_ for keys %templates; +sub _generate{ + my ($self, $htc, $path, $lang) = @_; -sub generate{ - my ($path, $lang) = @_; - my $id = ($path =~ m,log/(.*)/index,)[0]; - $path =~ s,/index\.html,,; - my $template = $templates{$lang}; + $path =~ m,^(?:ct/([^/]+)/)?log/job/([^/]+)\.html$,; + local $Gruntmaster::Data::contest = $1; + my $id = $2; - my $htc = HTML::Template::Compiled->new(scalarref => \$template); - flock my $metafh = IO::File->new("<$path/meta.yml"), LOCK_SH; - my $meta = LoadFile "$path/meta.yml"; + my @tests = (); - my @tests = map { - $_->{time} = sprintf "%.4fs", $_->{time}; - $_ - } @{$meta->{results}}; + eval { + @tests = map { + $_->{time} = sprintf "%.4fs", $_->{time}; + $_ + } @{job_results $id}; + }; - $htc->param(id => $id); - $htc->param(tests => \@tests); - $htc->output + $htc->param(id => $id); + $htc->param(tests => \@tests); + $htc->param(errors => job_errors $id) } 1