sub (/src/:job) {
return NOT_FOUND if !job;
- forbid job->private || job->problem->private || job->contest && job->contest->is_running;
- my @headers = ('X-Forever' => 1, 'Cache-Control' => 'public, max-age=604800', 'Content-Type' => CONTENT_TYPES->{job->format});
+ my $isowner = remote_user && remote_user->id eq job->rawowner;
+ my $private = job->private || job->problem->private || job->contest && job->contest->is_running;
+ forbid !$isowner && $private;
+ my $privacy = $private ? 'private' : 'public';
+ my @headers = ('X-Forever' => 1, 'Cache-Control' => "$privacy, max-age=604800", 'Content-Type' => CONTENT_TYPES->{job->format});
+ push @headers, (Vary => 'Authorization') if $private;
[200, \@headers, [job->source]]
},
my ($r) = @_;
return $r if ref $r ne 'Plack::App::Gruntmaster::Response';
my @hdrs = ('X-Forever' => 1, 'Cache-Control' => "$privacy, max-age=$r->{maxage}");
+ push @hdrs, Vary => 'Authorization' if $privacy eq 'private';
return [200, ['Content-Type' => 'application/json', @hdrs], [encode_json $r->{params}]] if $format eq 'json';
my $ret = render $r->{template}, 'en', title => $r->{title}, %{$r->{params}};
[200, ['Content-Type' => 'text/html', @hdrs], [encode 'UTF-8', $ret]]
}, 10
},
+ sub (/ed/:contest) {
+ forbid contest->is_running;
+ response ed => 'Editorial of ' . contest->name, db->problem_list(contest => $_{contest}, solution => 1);
+ },
+
sub (/login) {
forbid !remote_user;
},
sub (/) { redispatch_to '/index' },
+ sub (/favicon.ico) { redirect '/static/favicon.ico' },
sub (/:article) { [200, ['Content-Type' => 'text/html', 'Cache-Control' => 'public, max-age=60', 'X-Forever' => 1], [render_article $_{article}, 'en']] }
},
my $source = $prog ? read_file $prog->path : $_{source_code};
unlink $prog->path if $prog;
+ my $private = (problem->private && !$_{contest}) ? 1 : 0;
my $newjob = db->jobs->create({
maybe contest => $_{contest},
- maybe private => problem->private && !$_{contest},
+ private => $private,
date => time,
extension => FORMAT_EXTENSION->{$_{prog_format}},
format => $_{prog_format},