]> iEval git - plack-app-gruntmaster.git/blame - lib/Gruntmaster/Page/Log.pm
Modernize templates
[plack-app-gruntmaster.git] / lib / Gruntmaster / Page / Log.pm
CommitLineData
42546e6c
MG
1package Gruntmaster::Page::Log;
2
3use 5.014000;
4use strict;
5use warnings;
bb95f538
MG
6use Gruntmaster::Page::Base log => 'Job log';
7our @ISA = qw/Gruntmaster::Page::Base/;
42546e6c
MG
8our $VERSION = '0.001';
9
cd9af27e 10use constant PAGE_SIZE => 10;
42546e6c 11
bb95f538 12use constant TEMPLATES => {
cd9af27e 13 en => <<'HTML',
a94f8453 14<table border class="table table-bordered table-striped">
42546e6c
MG
15<thead>
16<tr><th>ID<th>Problem<th>Date<th>Size<th>User<th>Result
17<tbody>
7dc32473 18<tmpl_loop log><tr><td><a href="job/<tmpl_var id>"><tmpl_var id></a>
a94f8453 19<td><a href="../pb/<tmpl_var problem>"><tmpl_var name></a>
42546e6c 20<td><tmpl_var date>
b83e43dc 21<td><a href="src/<tmpl_var id>.<tmpl_var extension>"<tmpl_if private> data-private</tmpl_if>><tmpl_var size></a>
42546e6c
MG
22<td><tmpl_var user><td class="r<tmpl_var result>"><tmpl_var result_text>
23</tmpl_loop>
24</table>
b83e43dc 25
a94f8453
MG
26<ul class="pager">
27<tmpl_if prev><li class="previous"><a href="<tmpl_var prev>">Previous</a></tmpl_if>
28<tmpl_if next><li class="next"><a href="<tmpl_var next>">Next</a></tmpl_if>
29</ul>
42546e6c 30HTML
bb95f538 31};
42546e6c 32
bb95f538 33sub _generate{
7dc32473
MG
34 my ($self, $htc, $lang, $logger, $ct, $page) = @_;
35 debug $logger => "language is '$lang', contest is '$ct' and page is '$page'";
36 local $Gruntmaster::Data::contest = $ct if $ct;
42546e6c 37
b83e43dc 38 my $pages = POSIX::floor (jobcard / PAGE_SIZE);
b9d003fd 39 $pages ||= 1;
a94f8453 40 $page ||= $pages;
cd9af27e 41
cd9af27e
MG
42 my @log = sort { $b->{id} <=> $a->{id} } map +{
43 id => $_,
44 (job_private() ? (private => job_private) : ()),
45 date => (job_date() ? strftime ('%c' => localtime job_date) : '?'),
e5f2bda6 46 extension => job_extension,
3da9c3c2 47 name => problem_name job_problem,
cd9af27e
MG
48 problem => job_problem,
49 result => job_result,
50 result_text => job_result_text,
e5f2bda6 51 size => sprintf ("%.2f KiB", job_filesize() / 1024),
493d07a5 52 user => job_user}, ($page - 1) * PAGE_SIZE + 1 .. ($page == $pages ? jobcard : $page * PAGE_SIZE);
cd9af27e 53 $htc->param(log => \@log);
b83e43dc
MG
54 $htc->param(next => $page + 1) unless $page == $pages;
55 $htc->param(prev => $page - 1) unless $page == 1;
42546e6c
MG
56}
57
581
This page took 0.032004 seconds and 4 git commands to generate.