X-Git-Url: http://git.ieval.ro/?a=blobdiff_plain;f=lib%2FGruntmaster%2FPage%2FLog%2FEntry.pm;h=2c4aa3acb5cfc1bec533ddf6e673a08e5c80e642;hb=e9e5c8a440a6e3a088a4b9330650e310561ef518;hp=4b7a70df732b645b4622988941d8278d9c53a5e9;hpb=fe78f0c128c35e68e65850b02057997bad6717fe;p=plack-app-gruntmaster.git diff --git a/lib/Gruntmaster/Page/Log/Entry.pm b/lib/Gruntmaster/Page/Log/Entry.pm index 4b7a70d..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 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) = @_; - $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