PASCAL => 'pas',
PERL => 'pl',
PYTHON => 'py',
+ SBCL => 'l',
};
use constant NOT_FOUND => [404, ['Content-Type' => 'text/plain'], ['Not found']];
sub (/src/:job) {
return NOT_FOUND if !job;
my $isowner = remote_user && remote_user->id eq job->rawowner;
- forbid !$isowner && (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 $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]]
},
sub (/ed/:contest) {
forbid contest->is_running;
- response ed => 'Editorial of ' . contest->name, db->problem_list(contest => $_{contest}, solution => 1);
+ my $pblist = db->problem_list(contest => $_{contest}, solution => 1);
+ response ed => 'Editorial of ' . contest->name, {%$pblist, editorial => contest->editorial};
},
sub (/login) {
my $source = $prog ? read_file $prog->path : $_{source_code};
unlink $prog->path if $prog;
my $private = (problem->private && !$_{contest}) ? 1 : 0;
+ $private = 1 if contest && contest->is_pending;
my $newjob = db->jobs->create({
maybe contest => $_{contest},
private => $private,