]>
iEval git - gruntmaster-handlers.git/blob - lib/Gruntmaster/Handlers.pm
1 package Gruntmaster
::Handlers
;
6 our $VERSION = '0.001';
9 use Apache2
::AuthzCaps qw
/hascaps/;
10 use Apache2
::RequestRec
;
11 use Apache2
::RequestIO
;
13 use Apache2
::Const qw
/OK DECLINED/;
18 use File
::Basename qw
/fileparse/;
19 use File
::Temp qw
/tempdir/;
20 use File
::Copy qw
/move/;
21 use Gruntmaster
::Data qw
/contest_start contest_end push_job set_job_inmeta PUBLISH/;
22 use Gruntmaster
::Page
::Log
;
26 chdir $r->dir_config('root');
27 my $req = Apache2
::Request
->new($r);
28 my ($problem, $format, $contest, $private) = map {scalar $req->param($_)} 'problem', 'prog_format', 'contest', 'private';
30 $req->upload('prog')->slurp($prog);
31 die if defined $contest && $contest !~ /^\w+$/ ;
32 die if defined $contest && (time < contest_start
$contest || time > contest_end
$contest);
38 defined $private ?
(private
=> $private) : (),
39 defined $contest ?
(contest
=> $contest, private
=> 1) : (),
40 filesize
=> length $prog,
41 extension
=> Gruntmaster
::Page
::Log
::FORMAT_EXTENSION
->{$format},
44 set_job_inmeta
$job, {
48 name
=> 'prog.' . Gruntmaster
::Page
::Log
::FORMAT_EXTENSION
->{$format},
55 $r->print("Job submitted");
63 my $dir = (fileparse $r->uri)[1];
65 chdir $r->dir_config('root') . $dir;
67 for my $requirement (map { $_->{requirement} } @{$r->requires}) {
68 my ($command, @args) = split ' ', $requirement;
71 when('admin-if-private'){
72 my $meta = LoadFile 'meta.yml';
73 return OK if !$meta->{private} || ($r->user && hascaps $r->user, 'gmadm')
88 # Below is stub documentation for your module. You'd better edit it!
92 Gruntmaster::Handlers - Perl extension for blah blah blah
96 use Gruntmaster::Handlers;
101 Stub documentation for Gruntmaster::Handlers, created by h2xs. It looks like the
102 author of the extension was negligent enough to leave the stub
110 Mention other useful documentation such as the documentation of
111 related modules or operating system documentation (such as man pages
112 in UNIX), or any relevant external documentation such as RFCs or
115 If you have a mailing list set up for your module, mention it here.
117 If you have a web site set up for your module, mention it here.
121 Marius Gavrilescu, E<lt>marius@E<gt>
123 =head1 COPYRIGHT AND LICENSE
125 Copyright (C) 2013 by Marius Gavrilescu
127 This library is free software; you can redistribute it and/or modify
128 it under the same terms as Perl itself, either Perl version 5.18.1 or,
129 at your option, any later version of Perl 5 you may have available.
This page took 0.051804 seconds and 4 git commands to generate.