]>
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 | |
3da9c3c2 | 12 | use constant FORMAT_EXTENSION => { |
c2a23f84 MG |
13 | C => 'c', |
14 | CPP => 'cpp', | |
15 | MONO => 'cs', | |
16 | JAVA => 'java', | |
17 | PASCAL => 'pas', | |
18 | PERL => 'pl', | |
19 | PYTHON => 'py', | |
20 | RUBY => 'rb', | |
3da9c3c2 MG |
21 | }; |
22 | ||
bb95f538 | 23 | use constant TEMPLATES => { |
cd9af27e | 24 | en => <<'HTML', |
42546e6c MG |
25 | <table border> |
26 | <thead> | |
27 | <tr><th>ID<th>Problem<th>Date<th>Size<th>User<th>Result | |
28 | <tbody> | |
e5f2bda6 | 29 | <tmpl_loop log><tr><td><a href="job/<tmpl_var id>.var"><tmpl_var id></a> |
3da9c3c2 | 30 | <td><a href="../pb/<tmpl_var problem>"><tmpl_var name></a> |
42546e6c | 31 | <td><tmpl_var date> |
e5f2bda6 | 32 | <td><a href="src/<tmpl_var id>.<tmpl_var extension>"<tmpl_if private> data-private</tmpl_if>><tmpl_var size></a></a> |
42546e6c MG |
33 | <td><tmpl_var user><td class="r<tmpl_var result>"><tmpl_var result_text> |
34 | </tmpl_loop> | |
35 | </table> | |
36 | HTML | |
bb95f538 | 37 | }; |
42546e6c | 38 | |
bb95f538 MG |
39 | sub _generate{ |
40 | my ($self, $htc, $path, $lang) = @_; | |
42546e6c | 41 | |
bb95f538 | 42 | $path =~ m,^(?:ct/([^/]+)/)?log/(\w+)\.html$,; |
493d07a5 MG |
43 | local $Gruntmaster::Data::contest = $1 if $1; |
44 | my $pages = POSIX::ceil (jobcard / PAGE_SIZE); | |
e5f2bda6 | 45 | my $page = $2 eq 'index' ? $pages : $2; |
cd9af27e | 46 | |
cd9af27e MG |
47 | my @log = sort { $b->{id} <=> $a->{id} } map +{ |
48 | id => $_, | |
49 | (job_private() ? (private => job_private) : ()), | |
50 | date => (job_date() ? strftime ('%c' => localtime job_date) : '?'), | |
e5f2bda6 | 51 | extension => job_extension, |
3da9c3c2 | 52 | name => problem_name job_problem, |
cd9af27e MG |
53 | problem => job_problem, |
54 | result => job_result, | |
55 | result_text => job_result_text, | |
e5f2bda6 | 56 | size => sprintf ("%.2f KiB", job_filesize() / 1024), |
493d07a5 | 57 | user => job_user}, ($page - 1) * PAGE_SIZE + 1 .. ($page == $pages ? jobcard : $page * PAGE_SIZE); |
cd9af27e | 58 | $htc->param(log => \@log); |
42546e6c MG |
59 | } |
60 | ||
61 | 1 |