]> iEval git - gruntmaster-page.git/blobdiff - lib/Gruntmaster/Page/Log/Entry.pm
Make all generators inherit from a common base
[gruntmaster-page.git] / lib / Gruntmaster / Page / Log / Entry.pm
index 08230bfaf8fa475895960943e58a5aa5dd98e340..e20c891307960a6fc5c1fd71679ef370c04134fc 100644 (file)
@@ -3,21 +3,12 @@ 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 <tmpl_var id>';
+our @ISA = qw/Gruntmaster::Page::Base/;
 our $VERSION = '0.001';
 
-use constant TITLE => 'Job <tmpl_var id>';
-
-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',
+use constant TEMPLATES => {
+       en => <<'HTML',
 <table border>
 <thead>
 <tr><th>Test number<th>Result<th>Time
@@ -26,28 +17,22 @@ my %templates = (
 </tmpl_loop>
 </table>
 HTML
-);
-
-$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};
+sub _generate{
+       my ($self, $htc, $path, $lang) = @_;
 
-  my $htc = HTML::Template::Compiled->new(scalarref => \$template);
-  flock my $metafh = IO::File->new("<log/$path/meta.yml"), LOCK_SH;
-  my $meta = LoadFile "log/$path/meta.yml";
+       $path =~ m,^(?:ct/([^/]+)/)?log/job/([^/]+)\.html$,;
+       local $Gruntmaster::Data::contest = $1;
+       my $id = $2;
 
-  my @tests = map {
-       $_->{time} = sprintf "%.4fs", $_->{time};
-       $_
-  } @{$meta->{results}};
+       my @tests = map {
+               $_->{time} = sprintf "%.4fs", $_->{time};
+               $_
+       } @{job_results $id};
 
-  $htc->param(id => $path);
-  $htc->param(tests => \@tests);
-  $htc->output
+       $htc->param(id => $id);
+       $htc->param(tests => \@tests);
 }
 
 1
This page took 0.021824 seconds and 4 git commands to generate.