]> iEval git - plack-app-gruntmaster.git/blobdiff - lib/Plack/App/Gruntmaster.pm
Merge branch 'master' into newmc
[plack-app-gruntmaster.git] / lib / Plack / App / Gruntmaster.pm
index 59e5720c96bd28ce571c8021be6dd972156903a2..45cdfd1c5107e7babaad66a51a1f0a4885a5d406 100644 (file)
@@ -113,7 +113,8 @@ sub dispatch_request{
 
                sub (/src/:job) {
                        return NOT_FOUND if !job;
-                       forbid job->private || job->problem->private || job->contest && job->contest->is_running;
+                       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});
                        [200, \@headers, [job->source]]
                },
@@ -152,6 +153,11 @@ sub dispatch_request{
                        }, 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;
 
@@ -195,6 +201,7 @@ sub dispatch_request{
                },
 
                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']] }
        },
 
@@ -232,9 +239,10 @@ sub dispatch_request{
 
                        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},
This page took 0.018478 seconds and 4 git commands to generate.