- sub (/us/) { response us => 'Users', {us => db->user_list} },
- sub (/ct/ + ?:owner~) { response ct => 'Contests', db->contest_list(%_) },
- sub (/log/ + ?:contest~&:owner~&:page~&:problem~) { response log => 'Job list', {%{db->job_list(%_)}, maybe contest => $_{contest}} },
- sub (/pb/ + ?:owner~&:contest~) { response pb => 'Problems', {%{db->problem_list(%_)}, maybe contest => $_{contest}} },
-
- sub (/us/:user) { response us_entry => user->name, db->user_entry($_{user}) },
- sub (/ct/:contest) { response ct_entry => contest->name, db->contest_entry($_{contest}) },
- sub (/log/:job) { response log_entry => "Job $_{job}", db->job_entry($_{job}) },
- sub (/pb/:problem + ?:contest~) {
- return NOT_FOUND if !contest && !problem->is_in_archive || contest && !db->contest_problems->find($_{contest}, $_{problem});
- forbid problem->is_private;
- response pb_entry => problem->name, db->problem_entry($_{problem}, $_{contest}, remote_user && remote_user->id);
+ sub (/us/) { response us => 'Users', {us => user_list} },
+ sub (/ct/ + ?:owner~) { response ct => 'Contests', {ct => contest_list(%_)}, 300 },
+ sub (/log/ + ?:contest~&:owner~&:page~&:problem~&:private~&:result~) {
+ forbid $_{private};
+ my ($jobs, $pageinfo) = job_list(%_);
+ response log => 'Job log', {log => $jobs, %$pageinfo}, 5
+ },
+ sub (/pb/ + ?:owner~&:contest~&:private~) {
+ forbid $_{private};
+ my $pending = $_{contest} && !contest_entry($_{contest})->{started};
+ forbid $pending;
+ response pb => 'Problems', {pb => problem_list %_}
+ },
+
+ sub (/us/:user) {
+ my $user = user_entry $_{user};
+ response us_entry => $user->{name}, $user
+ },
+ sub (/ct/:contest) {
+ my $contest = contest_entry $_{contest};
+ response ct_entry => $contest->{name}, $contest, 60
+ },
+ sub (/log/:job) {
+ my $job = job_entry $_{job};
+ forbid $job->{private};
+ response log_entry => "Job $_{job}", $job, 10
+ },
+ sub (/pb/:problem + ?contest~) {
+ my (undef, undef, $contest) = @_;
+ $_{contest} = $contest;
+ $contest = $contest && contest_entry $_{contest};
+ return NOT_FOUND if $contest && !contest_has_problem $_{contest}, $_{problem};
+ my $problem = problem_entry $_{problem}, $_{contest};
+ forbid $problem->{private} && !$contest;
+ if ($contest) {
+ return redirect "/pb/$_{problem}" if !$contest->{started} || $contest->{finished};
+ forbid !remote_user;
+ $privacy = 'private';
+ }
+ response pb_entry => $problem->{name}, $problem, $_{contest} ? 10 : ();
+ },
+ sub (/sol/:problem) {
+ my $problem = problem_entry $_{problem};
+ forbid $problem->{private};
+ response sol => 'Solution of ' . $problem->{name}, {solution => $problem->{solution}};