]>
iEval git - gruntmaster-page.git/blob - lib/Gruntmaster/Page/Log.pm
c92bf4d82ab962cfbab64f9df3a31b1ddd6db562
1 package Gruntmaster
::Page
::Log
;
6 use parent qw
/Exporter/;
7 our @EXPORT_OK = qw
/generate/;
8 our $VERSION = '0.001';
10 use constant TITLE
=> 'Job log';
13 use HTML
::Template
::Compiled
;
15 use POSIX qw
/strftime/;
16 use YAML
::Any qw
/LoadFile/;
17 use Gruntmaster
::Page
::Common qw
/header footer/;
23 <tr><th>ID<th>Problem<th>Date<th>Size<th>User<th>Result
25 <tmpl_loop log><tr><td><a href="<tmpl_var id>"><tmpl_var id></a>
26 <td><a href="/pb/<tmpl_var problem>"><tmpl_var name></a>
28 <td><a href="<tmpl_var id>/in/<tmpl_var filename>"<tmpl_if private> data-private</tmpl_if>><tmpl_var size></a>
29 <td><tmpl_var user><td class="r<tmpl_var result>"><tmpl_var result_text>
35 $templates{$_} = header
($_, TITLE
) . $templates{$_} for keys %templates;
36 $templates{$_} .= footer
$_ for keys %templates;
39 my ($path, $lang) = @_;
40 $path =~ s
,/index\
.html
$,,;
41 my $template = $templates{$lang};
42 my $htc = HTML
::Template
::Compiled
->new(scalarref
=> \
$template);
43 IO
::File
->new(">$path/meta.yml")->close unless -f
"$path/meta.yml";
44 flock my $metafh = IO
::File
->new("<$path/meta.yml"), LOCK_SH
;
45 my $meta = LoadFile
"$path/meta.yml";
46 my @log = sort { $b->{id
} <=> $a->{id
} } map {
47 my $meta = LoadFile
"$path/$_/meta.yml";
49 date
=> (exists $meta->{date
} ? strftime
('%c' => localtime $meta->{date
}) : '?'),
50 user
=> $meta->{user
},
51 result
=> $meta->{result
},
52 name
=> $meta->{name
},
53 problem
=> $meta->{problem
},
54 filename
=> $meta->{files
}{prog
}{name
},
55 (defined $meta->{private
} ?
(private
=> $meta->{private
}) : ()),
56 size
=> sprintf ("%.2f KiB", (-s
"$path/$_/in/" . $meta->{files
}{prog
}{name
}) / 1024),
57 result_text
=> $meta->{result_text
}} } 1 .. $meta->{last};
58 $htc->param(log => \
@log);
This page took 0.049543 seconds and 4 git commands to generate.