use Gruntmaster::Page;
use Gruntmaster::Page::Log;
-use Gruntmaster::Data qw/contests jobcard problems/;
+use Gruntmaster::Data qw/contests jobcard problems users/;
sub generate{
my $what = shift;
generate "index.html";
generate "learn.html";
+
generate "ct/index.html";
generate "ct/$_/index.thml" for contests;
generate "ct/$_/log/st.html" for contests;
+generate "us/index.html";
+generate "us/$_.html" for users;
+
for my $ct (undef, contests) {
local $Gruntmaster::Data::contests = $ct;
my $ctp = defined $ct ? "ct/$ct/" : '';
sub problems () { SMEMBERS cp . 'problem' }
sub contests () { SMEMBERS cp . 'contest' }
+sub users () { SMEMBERS cp . 'user' }
sub jobcard () { GET cp . 'job' }
sub job_results (_) { decode_json HGET cp . "job.$_[0]", 'results' }
defhash problem => qw/name level statement/;
defhash contest => qw/start end name owner/;
defhash job => qw/date extension filesize private problem result result_text user/;
-defhash user => qw/name email town university/;
+defhash user => qw/name email town university level/;
sub clean_job (_){
HDEL cp . "job.$_[0]", qw/result result_text results daemon/
declaregen Index => qr,^index$,;
declaregen Learn => qr,^learn$,;
declaregen Account => qr,^account$,;
+ declaregen Us => qr,^us/index$,;
+ declaregen 'Us::Entry' => qr,^us/$component$,;
declaregen Ct => qr,^ct/index$,;
declaregen 'Ct::Entry' => qr,^ct/$component/index$,;
declaregen St => qr,^ct/$component/log/st$,;
use HTML::Template::Compiled;
use POSIX qw/strftime/;
use Gruntmaster::Page::Common qw/cook_templates reload_templates/;
-use Gruntmaster::Data qw/contest_name contest_start contest_end contest_owner/;
+use Gruntmaster::Data qw/contests contest_name contest_start contest_end contest_owner/;
my %orig_templates = (
en => <<'HTML',
my %templates = cook_templates %orig_templates, ct => 'Contests';
sub generate{
- %templates = cook_templates %orig_templates, ct => 'Contests' if reload_template;
+ %templates = cook_templates %orig_templates, ct => 'Contests' if reload_templates;
my $htc = HTML::Template::Compiled->new(scalarref => \$templates{$_[1]});
my (@running, @pending, @finished);
--- /dev/null
+package Gruntmaster::Page::Us;
+
+use 5.014000;
+use strict;
+use warnings;
+use parent qw/Exporter/;
+our @EXPORT_OK = qw/generate/;
+our $VERSION = '0.001';
+
+use HTML::Template::Compiled;
+use Gruntmaster::Data qw/users user_name/;
+use Gruntmaster::Page::Common qw/cook_templates reload_templates/;
+
+my %orig_templates = (
+ en => <<'HTML',
+<ul><tmpl_loop users><li><a href="<tmpl_var id>.var"><tmpl_var name></a>
+</tmpl_loop></ul>
+HTML
+);
+
+my %templates = cook_templates %orig_templates, us => 'Users';
+
+sub generate{
+ %templates = cook_templates %orig_templates, us => 'Users' if reload_templates;
+ my $htc = HTML::Template::Compiled->new(scalarref => \$templates{$_[1]});
+
+ $htc->param(users => [ map { {id => $_, name => user_name} } users ]);
+ $htc->output;
+}
+
+1
--- /dev/null
+package Gruntmaster::Page::Us::Entry;
+
+use 5.014000;
+use strict;
+use warnings;
+use parent qw/Exporter/;
+our @EXPORT_OK = qw/generate/;
+our $VERSION = '0.001';
+
+use HTML::Template::Compiled;
+use Gruntmaster::Data qw/users user_name user_town user_university user_level/;
+use Gruntmaster::Page::Common qw/cook_templates reload_templates/;
+
+my %orig_templates = (
+ en => <<'HTML',
+<h1><tmpl_var name></h1>
+Town: <tmpl_var town><br>
+University: <tmpl_var university><br>
+Level: <tmpl_var level>
+HTML
+);
+
+my %templates = cook_templates %orig_templates, us_entry => '<tmpl_var name>';
+
+sub generate{
+ %templates = cook_templates %orig_templates, us_entry => '<tmpl_var name>' if reload_templates;
+ $_[0] =~ m,^us/([^/]+)\.html$,;
+ local $_ = $1;
+ my $htc = HTML::Template::Compiled->new(scalarref => \$templates{$_[1]});
+
+ $htc->param(name => user_name);
+ $htc->param(town => user_town);
+ $htc->param(university => user_university);
+ $htc->param(level => user_level);
+ $htc->output;
+}
+
+1