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