1 package Gruntmaster
::Handlers
;
6 our $VERSION = '0.001';
8 use constant FORMAT_EXTENSION
=> {
13 use Apache2
::AuthzCaps qw
/hascaps/;
14 use Apache2
::RequestRec
;
15 use Apache2
::RequestIO
;
17 use Apache2
::Const qw
/OK DECLINED/;
22 use File
::Basename qw
/fileparse/;
23 use File
::Temp qw
/tempdir/;
24 use File
::Copy qw
/move/;
25 use YAML
::Any qw
/LoadFile DumpFile/;
29 chdir $r->dir_config('root');
30 my $req = Apache2
::Request
->new($r);
31 my ($problem, $format) = ($req->param('problem'), $req->param('prog_format'));
32 my $ext = FORMAT_EXTENSION
->{$format};
33 my $prog = $req->upload('prog');
36 $prog->link("$dir/prog.$ext");
37 DumpFile
"$dir/meta.yml", {
48 my $jobname = int rand 1_000_000_000
;
49 $jobname = int rand 1_000_000_000
while -d
"jobs/$jobname";
50 move
$dir, "jobs/$jobname" or die $!;
52 $r->print("Job submitted");
58 my $dir = (fileparse
$r->uri)[1];
60 chdir $r->dir_config('root') . $dir;
62 for my $requirement (map { $_->{requirement
} } @
{$r->requires}) {
63 my ($command, @args) = split ' ', $requirement;
66 when('admin-if-private'){
67 my $meta = LoadFile
'meta.yml';
68 return OK
if !$meta->{private
} || ($r->user && hascaps
$r->user, 'gmadm')
79 # Below is stub documentation for your module. You'd better edit it!
83 Gruntmaster::Handlers - Perl extension for blah blah blah
87 use Gruntmaster::Handlers;
92 Stub documentation for Gruntmaster::Handlers, created by h2xs. It looks like the
93 author of the extension was negligent enough to leave the stub
101 Mention other useful documentation such as the documentation of
102 related modules or operating system documentation (such as man pages
103 in UNIX), or any relevant external documentation such as RFCs or
106 If you have a mailing list set up for your module, mention it here.
108 If you have a web site set up for your module, mention it here.
112 Marius Gavrilescu, E<lt>marius@E<gt>
114 =head1 COPYRIGHT AND LICENSE
116 Copyright (C) 2013 by Marius Gavrilescu
118 This library is free software; you can redistribute it and/or modify
119 it under the same terms as Perl itself, either Perl version 5.18.1 or,
120 at your option, any later version of Perl 5 you may have available.