1 package Gruntmaster
::Page
::Submit
;
6 use Gruntmaster
::Page
::Base
;
7 our @ISA = qw
/Gruntmaster::Page::Base/;
8 our $VERSION = '0.001';
10 use Apache2
::Authen
::Passphrase qw
/pwcheck pwset USER_REGEX/;
11 use File
::Slurp qw
/read_file/;
14 use constant FORMAT_EXTENSION
=> {
25 my ($self, $frm, $env) = @_;
26 my $r = Plack
::Request
->new($env);
27 my ($problem, $format, $contest, $private, $prog) = map {scalar $r->param($_)} 'problem', 'prog_format', 'contest', 'private', 'source_code';
28 my $upload = $r->upload('prog');
29 if (defined $upload) {
30 my $temp = read_file
$upload->path;
31 $prog = $temp if $temp
33 die if defined $contest && $contest !~ /^\w+$/ ;
34 die if defined $contest && (time > contest_end
$contest);
35 return reply
'A required parameter was not supplied' if grep { !defined } $problem, $format, $prog;
37 local $Gruntmaster::Data
::contest
= $contest if $contest;
43 defined $private ?
(private
=> $private) : (),
44 defined $contest ?
(contest
=> $contest, private
=> 1) : (),
45 filesize
=> length $prog,
46 extension
=> FORMAT_EXTENSION
->{$format},
49 set_job_inmeta
$job, {
53 name
=> 'prog.' . FORMAT_EXTENSION
->{$format},
60 PUBLISH
'jobs', "$contest.$job";
61 [303, [Location
=> $r->path =~ s
,/pb/\w
+/submit$,/log/,r
], ['']]
64 sub variants
{ [[reply
=> 1, undef, undef, undef, undef, undef]] }