]> iEval git - gruntmaster-page.git/blob - lib/Gruntmaster/Page/Log.pm
Remove some languages
[gruntmaster-page.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>
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>.var"><tmpl_var id></a>
19 <td><a href="/pb/<tmpl_var problem>.var"><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 <tmpl_if prev><a href="<tmpl_var prev>.var">Prev page</a></tmpl_if>
27 <tmpl_if next><a href="<tmpl_var next>.var">Next page</a></tmpl_if>
28 HTML
29 };
30
31 sub _generate{
32 my ($self, $htc, $path, $lang) = @_;
33
34 $path =~ m,^(?:ct/([^/]+)/)?log/(\w+)\.html$,;
35 local $Gruntmaster::Data::contest = $1 if $1;
36 my $pages = POSIX::floor (jobcard / PAGE_SIZE);
37 my $page = $2 eq 'index' ? $pages : $2;
38
39 my @log = sort { $b->{id} <=> $a->{id} } map +{
40 id => $_,
41 (job_private() ? (private => job_private) : ()),
42 date => (job_date() ? strftime ('%c' => localtime job_date) : '?'),
43 extension => job_extension,
44 name => problem_name job_problem,
45 problem => job_problem,
46 result => job_result,
47 result_text => job_result_text,
48 size => sprintf ("%.2f KiB", job_filesize() / 1024),
49 user => job_user}, ($page - 1) * PAGE_SIZE + 1 .. ($page == $pages ? jobcard : $page * PAGE_SIZE);
50 $htc->param(log => \@log);
51 $htc->param(next => $page + 1) unless $page == $pages;
52 $htc->param(prev => $page - 1) unless $page == 1;
53 }
54
55 1
This page took 0.050043 seconds and 4 git commands to generate.