From: Marius Gavrilescu Date: Wed, 29 Jan 2014 10:15:17 +0000 (+0200) Subject: Update gruntmaster database-editing tools X-Git-Url: http://git.ieval.ro/?a=commitdiff_plain;h=e0f96c91c9a2336893b36a11142e0a55fd3c9851;p=gruntmaster-page.git Update gruntmaster database-editing tools --- diff --git a/gruntmaster-contest b/gruntmaster-contest index e61a6c2..c2608c9 100755 --- a/gruntmaster-contest +++ b/gruntmaster-contest @@ -1,11 +1,9 @@ #!/usr/bin/perl -w use v5.14; -use Gruntmaster::Data qw/contests insert_contest remove_contest contest_name contest_owner contest_start contest_end/; +use Gruntmaster::Data; use IO::Prompter [ -style => 'bold', '-stdio', '-verbatim' ]; -use File::Slurp qw/read_file/; -use Term::ANSIColor qw/RED RESET/; use POSIX qw/strftime/; use Date::Parse qw/str2time/; @@ -36,10 +34,13 @@ sub cmd_add{ my $end = str2time prompt 'End time' or die 'Cannot parse time'; insert_contest $id => name => $name, owner => $owner, start => $start, end => $end; + PUBLISH genpage => "ct/$id/index.html"; + PUBLISH genpage => "ct/index.html"; } sub cmd_rm{ remove_contest shift; + PUBLISH genpage => "ct/index.html"; } ################################################## diff --git a/gruntmaster-job b/gruntmaster-job index b454ad4..20395ce 100755 --- a/gruntmaster-job +++ b/gruntmaster-job @@ -1,22 +1,24 @@ #!/usr/bin/perl -w use v5.14; -use Gruntmaster::Data qw/jobcard job_date job_user job_problem job_filesize job_private job_result_text job_daemon clean_job problem_name PUBLISH HDEL/; +use Gruntmaster::Data; use IO::Prompter [ -style => 'bold', '-stdio', '-verbatim' ]; use File::Slurp qw/read_file/; +use Getopt::Long; use Term::ANSIColor qw/RED RESET/; use POSIX qw/strftime/; ################################################## +my $contest; + sub cmd_help{ exec perldoc => $0 } sub cmd_card{ - my $contest = shift; - print jobcard; + say jobcard; } sub cmd_show{ @@ -24,10 +26,12 @@ sub cmd_show{ say "Date: " , strftime ('%c', localtime job_date); say "User: ", job_user; say "Problem: ", problem_name job_problem; + say "Extension: ", job_extension; say "Size: ", sprintf "%.2fKB", job_filesize() / 1024; say "Private: ", (job_private() ? 'yes' : 'no'); say "Result text: ", job_result_text; say "Daemon: ", job_daemon; + say "Compile errors: ", job_errors; } sub cmd_rerun{ @@ -38,9 +42,11 @@ sub cmd_rerun{ ################################################## -no strict 'refs'; +GetOptions ( 'contest=s' => \$contest ); +local $Gruntmaster::Data::contest = $contest; my $cmd = 'cmd_' . shift; cmd_help unless exists $main::{$cmd}; +no strict 'refs'; $cmd->(@ARGV) if exists $main::{$cmd}; 1; diff --git a/gruntmaster-problem b/gruntmaster-problem index 611235f..80aa68d 100755 --- a/gruntmaster-problem +++ b/gruntmaster-problem @@ -1,14 +1,18 @@ #!/usr/bin/perl -w use v5.14; -use Gruntmaster::Data qw/insert_problem remove_problem set_problem_meta problems/; +use Gruntmaster::Data; +use Gruntmaster::Page::Submit; use IO::Prompter [ -style => 'bold', '-stdio', '-verbatim' ]; use File::Slurp qw/read_file/; use Term::ANSIColor qw/RED RESET/; +use Getopt::Long qw/GetOptions/; ################################################## +my $contest; + sub cmd_help{ exec perldoc => $0 } @@ -17,16 +21,15 @@ sub prompt_file{ my ($meta, $name, $prefix) = @_; my $filename = prompt '$prefix filename', -complete => 'filenames'; $meta->{files}{$name}{content} = read_file $filename; - $meta->{files}{$name}{format} = prompt '$prefix format', -menu => [keys Gruntmaster::Page::Log::FORMAT_EXTENSION()]; + $meta->{files}{$name}{format} = prompt '$prefix format', -menu => Gruntmaster::Page::Submit::FORMATS; $meta->{files}{$name}{name} = prompt "$prefix filename [$filename]", -default => $filename; - } sub cmd_add{ my $id = shift; - my $contest = prompt 'Contest'; - local $Gruntmaster::Data::contest = $contest if $contest; my $name = prompt 'Problem name'; + my $author = prompt 'Problem author (full name)'; + my $owner = prompt 'Problem owner (username)'; my $level = prompt 'Problem level', -menu => "beginner\neasy\nmedium\nhard"; my $statement = read_file prompt 'File with problem statement', -complete => 'filenames'; my %meta; @@ -61,18 +64,30 @@ sub cmd_add{ prompt_file int => '[Runner::Interactive] Interactive verifier'; } - insert_problem $id => name => $name, level => $level, statement => $statement; + insert_problem $id => name => $name, level => $level, statement => $statement, author => $author, owner => $owner; set_problem_meta $id => \%meta; + PUBLISH genpage => $contest ? "ct/$contest/pb/index.html" : 'pb/index.html'; + PUBLISH genpage => $contest ? "ct/$contest/pb/$id.html" : "pb/$id.html"; +} + +sub cmd_set{ + my $file; + GetOptions ( 'file!' => \$file ); + my ($id, %values) = @ARGV; + %values = map { $_ => scalar read_file $values{$_} } keys %values if $file; + edit_problem $id => %values; + PUBLISH genpage => 'pb/index.html'; + PUBLISH genpage => "pb/$id.html"; } sub cmd_list{ - my $contest = shift; - local $Gruntmaster::Data::contest = $contest if $contest; - print problems; + local $, = "\n"; + say problems; } sub cmd_rm{ - remove_problem shift + remove_problem shift; + PUBLISH genpage => $contest ? "ct/$contest/pb/index.html" : 'pb/index.html'; } sub cmd_show{ @@ -81,9 +96,11 @@ sub cmd_show{ ################################################## -no strict 'refs'; +GetOptions ( 'contest=s' => \$contest ); +local $Gruntmaster::Data::contest = $contest; my $cmd = 'cmd_' . shift; cmd_help unless exists $main::{$cmd}; +no strict 'refs'; $cmd->(@ARGV) if exists $main::{$cmd}; 1;