]> iEval git - plack-app-gruntmaster.git/commitdiff
Add Page::Src
authorMarius Gavrilescu <marius@ieval.ro>
Wed, 5 Feb 2014 12:38:42 +0000 (14:38 +0200)
committerMarius Gavrilescu <marius@ieval.ro>
Wed, 5 Feb 2014 12:38:42 +0000 (14:38 +0200)
lib/Gruntmaster/Page/Src.pm [new file with mode: 0644]
lib/Plack/App/Gruntmaster.pm

diff --git a/lib/Gruntmaster/Page/Src.pm b/lib/Gruntmaster/Page/Src.pm
new file mode 100644 (file)
index 0000000..77a5cd2
--- /dev/null
@@ -0,0 +1,30 @@
+package Gruntmaster::Page::Src;
+
+use 5.014000;
+use strict;
+use warnings;
+use Gruntmaster::Page::Base;
+our @ISA = qw/Gruntmaster::Page::Base/;
+our $VERSION = '0.001';
+
+use constant CONTENT_TYPES => +{
+       c => 'text/x-csrc',
+       cpp => 'text/x-c++src',
+       cs => 'text/x-chsarp', # Used by GNOME. Not in mime.types.
+       java => 'text/x-java',
+       pas => 'text/x-pascal',
+       pl => 'text/x-perl',
+       py => 'text/x-python',
+};
+
+sub generate{
+       my ($self, $format, $logger, $ct, $job, $ext) = @_;
+       debug $logger => "Contest is $ct, job is $job and extension is $ext";
+       local $Gruntmaster::Data::contest = $ct if $ct;
+
+       [200, ['Content-Type' => CONTENT_TYPES->{$ext}, 'Cache-Control' => 'max-age=604800'], [job_inmeta($job)->{files}{prog}{content}] ]
+}
+
+sub variants{ [[file => 1, undef, undef, undef, undef, undef]] }
+
+1
index 5530c73dab29dd2eab00d60d715f73e2dfbf3b40..534326864bfa8c58724bf65f9c88c93fc4a86f59 100644 (file)
@@ -69,6 +69,7 @@ BEGIN{
        get qr,$ct/log/(\d+)?, => 'Log';
        get qr,$ct/log/st, => 'St';
        get qr,$ct/log/job/$word, => 'Log::Entry';
+       get qr,$ct/log/src/$word\.$word, => 'Src';
        get qr,$ct/submit, => 'Submit';
        get qr,$ct/pb/, => 'Pb';
        get qr,$ct/pb/$word, => 'Pb::Entry';
This page took 0.024097 seconds and 4 git commands to generate.