From: Marius Gavrilescu Date: Tue, 14 Jan 2014 21:08:48 +0000 (+0200) Subject: More bug fixes X-Git-Url: http://git.ieval.ro/?a=commitdiff_plain;h=e5f2bda6c8984be0c49a3e058a165286791fef51;p=gruntmaster-page.git More bug fixes --- diff --git a/lib/Gruntmaster/Data.pm b/lib/Gruntmaster/Data.pm index 544a6d0..9f4cf95 100644 --- a/lib/Gruntmaster/Data.pm +++ b/lib/Gruntmaster/Data.pm @@ -59,12 +59,13 @@ sub defhash{ dynsub "push_$name", sub { my $nr = INCR cp . $name; HMSET cp . "$name.$nr", @_; + $nr }; } defhash problem => qw/name level statement/; defhash contest => qw/start end name owner/; -defhash job => qw/date file name private problem result result_text user/; +defhash job => qw/date extension filesize private problem result result_text user/; our @EXPORT_OK = do { no strict 'refs'; diff --git a/lib/Gruntmaster/Page.pm b/lib/Gruntmaster/Page.pm index 5a6ed68..bce618c 100644 --- a/lib/Gruntmaster/Page.pm +++ b/lib/Gruntmaster/Page.pm @@ -38,7 +38,7 @@ sub declaregen{ declaregen 'Ct::Entry' => qr,^ct/$component/index$,; declaregen St => qr,^ct/$component/log/st$,; declaregen Log => qr,^${contest}log/(?:\d+|index)$,; - declaregen 'Log::Entry' => qr,^${contest}log/$component/index$,; + declaregen 'Log::Entry' => qr,^${contest}log/job/$component$,; declaregen Submit => qr,^${contest}submit$,; declaregen Pb => qr,^${contest}pb/index$,; declaregen 'Pb::Entry' => qr,^${contest}pb/$component$,; diff --git a/lib/Gruntmaster/Page/Log.pm b/lib/Gruntmaster/Page/Log.pm index 5a2b4c6..0c842c2 100644 --- a/lib/Gruntmaster/Page/Log.pm +++ b/lib/Gruntmaster/Page/Log.pm @@ -17,7 +17,7 @@ use constant FORMAT_EXTENSION => { use HTML::Template::Compiled; use POSIX qw/strftime/; use Gruntmaster::Page::Common qw/header footer/; -use Gruntmaster::Data qw/job_date job_file problem_name job_private job_problem job_result job_result_text job_user/; +use Gruntmaster::Data qw/jobcard job_date job_extension job_filesize problem_name job_private job_problem job_result job_result_text job_user/; my %templates = ( en => <<'HTML', @@ -25,10 +25,10 @@ my %templates = ( IDProblemDateSizeUserResult - + - data-private> + data-private> @@ -41,19 +41,21 @@ $templates{$_} .= footer $_ for keys %templates; sub generate{ $_[0] =~ m,^(?:ct/([^/]+)/)?log/(\w+)\.html$,; local $Gruntmaster::Data::contest = $1; - my $page = $2 eq 'index' ? 0 : $2; + my $pages = jobcard / PAGE_SIZE; + my $page = $2 eq 'index' ? $pages : $2; my $htc = HTML::Template::Compiled->new(scalarref => \$templates{$_[1]}); my @log = sort { $b->{id} <=> $a->{id} } map +{ id => $_, (job_private() ? (private => job_private) : ()), date => (job_date() ? strftime ('%c' => localtime job_date) : '?'), + extension => job_extension, name => problem_name job_problem, problem => job_problem, result => job_result, result_text => job_result_text, - size => sprintf ("%.2f KiB", (length job_file) / 1024), - user => job_user}, ($page - 1) * PAGE_SIZE + 1 .. $page * PAGE_SIZE; + size => sprintf ("%.2f KiB", job_filesize() / 1024), + user => job_user}, ($page - 1) * PAGE_SIZE + 1 .. $page == $pages ? jobcard : $page * PAGE_SIZE; $htc->param(log => \@log); $htc->output } diff --git a/lib/Gruntmaster/Page/Log/Entry.pm b/lib/Gruntmaster/Page/Log/Entry.pm index 309660a..3e9e08f 100644 --- a/lib/Gruntmaster/Page/Log/Entry.pm +++ b/lib/Gruntmaster/Page/Log/Entry.pm @@ -30,7 +30,7 @@ $templates{$_} = header($_, TITLE) . $templates{$_} for keys %templates; $templates{$_} .= footer $_ for keys %templates; sub generate{ - $_[0] =~ m,^(?:ct/([^/]+)/)?log/([^/]+)/index\.html$,; + $_[0] =~ m,^(?:ct/([^/]+)/)?log/job/([^/]+)\.html$,; local $Gruntmaster::Data::contest = $1; my $id = $2;