]>
Commit | Line | Data |
---|---|---|
42546e6c MG |
1 | package Gruntmaster::Page::Log; |
2 | ||
3 | use 5.014000; | |
4 | use strict; | |
5 | use warnings; | |
bb95f538 MG |
6 | use Gruntmaster::Page::Base log => 'Job log'; |
7 | our @ISA = qw/Gruntmaster::Page::Base/; | |
42546e6c MG |
8 | our $VERSION = '0.001'; |
9 | ||
cd9af27e | 10 | use constant PAGE_SIZE => 10; |
42546e6c | 11 | |
bb95f538 | 12 | use constant TEMPLATES => { |
cd9af27e | 13 | en => <<'HTML', |
42546e6c MG |
14 | <table border> |
15 | <thead> | |
16 | <tr><th>ID<th>Problem<th>Date<th>Size<th>User<th>Result | |
17 | <tbody> | |
e5f2bda6 | 18 | <tmpl_loop log><tr><td><a href="job/<tmpl_var id>.var"><tmpl_var id></a> |
b83e43dc | 19 | <td><a href="/pb/<tmpl_var problem>.var"><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 MG |
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> | |
42546e6c | 28 | HTML |
bb95f538 | 29 | }; |
42546e6c | 30 | |
bb95f538 MG |
31 | sub _generate{ |
32 | my ($self, $htc, $path, $lang) = @_; | |
42546e6c | 33 | |
bb95f538 | 34 | $path =~ m,^(?:ct/([^/]+)/)?log/(\w+)\.html$,; |
493d07a5 | 35 | local $Gruntmaster::Data::contest = $1 if $1; |
b83e43dc | 36 | my $pages = POSIX::floor (jobcard / PAGE_SIZE); |
e5f2bda6 | 37 | my $page = $2 eq 'index' ? $pages : $2; |
cd9af27e | 38 | |
cd9af27e MG |
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) : '?'), | |
e5f2bda6 | 43 | extension => job_extension, |
3da9c3c2 | 44 | name => problem_name job_problem, |
cd9af27e MG |
45 | problem => job_problem, |
46 | result => job_result, | |
47 | result_text => job_result_text, | |
e5f2bda6 | 48 | size => sprintf ("%.2f KiB", job_filesize() / 1024), |
493d07a5 | 49 | user => job_user}, ($page - 1) * PAGE_SIZE + 1 .. ($page == $pages ? jobcard : $page * PAGE_SIZE); |
cd9af27e | 50 | $htc->param(log => \@log); |
b83e43dc MG |
51 | $htc->param(next => $page + 1) unless $page == $pages; |
52 | $htc->param(prev => $page - 1) unless $page == 1; | |
42546e6c MG |
53 | } |
54 | ||
55 | 1 |