]> iEval git - plack-app-gruntmaster.git/blob - lib/Gruntmaster/Page/Log.pm
Modernize templates
[plack-app-gruntmaster.git] / lib / Gruntmaster / Page / Log.pm
1 package Gruntmaster::Page::Log;
2
3 use 5.014000;
4 use strict;
5 use warnings;
6 use Gruntmaster::Page::Base log => 'Job log';
7 our @ISA = qw/Gruntmaster::Page::Base/;
8 our $VERSION = '0.001';
9
10 use constant PAGE_SIZE => 10;
11
12 use constant TEMPLATES => {
13 en => <<'HTML',
14 <table border class="table table-bordered table-striped">
15 <thead>
16 <tr><th>ID<th>Problem<th>Date<th>Size<th>User<th>Result
17 <tbody>
18 <tmpl_loop log><tr><td><a href="job/<tmpl_var id>"><tmpl_var id></a>
19 <td><a href="../pb/<tmpl_var problem>"><tmpl_var name></a>
20 <td><tmpl_var date>
21 <td><a href="src/<tmpl_var id>.<tmpl_var extension>"<tmpl_if private> data-private</tmpl_if>><tmpl_var size></a>
22 <td><tmpl_var user><td class="r<tmpl_var result>"><tmpl_var result_text>
23 </tmpl_loop>
24 </table>
25
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>
30 HTML
31 };
32
33 sub _generate{
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;
37
38 my $pages = POSIX::floor (jobcard / PAGE_SIZE);
39 $pages ||= 1;
40 $page ||= $pages;
41
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) : '?'),
46 extension => job_extension,
47 name => problem_name job_problem,
48 problem => job_problem,
49 result => job_result,
50 result_text => job_result_text,
51 size => sprintf ("%.2f KiB", job_filesize() / 1024),
52 user => job_user}, ($page - 1) * PAGE_SIZE + 1 .. ($page == $pages ? jobcard : $page * PAGE_SIZE);
53 $htc->param(log => \@log);
54 $htc->param(next => $page + 1) unless $page == $pages;
55 $htc->param(prev => $page - 1) unless $page == 1;
56 }
57
58 1
This page took 0.045004 seconds and 4 git commands to generate.