]> iEval git - gruntmaster-page.git/commitdiff
Split problem list into levels
authorMarius Gavrilescu <marius@ieval.ro>
Sun, 22 Dec 2013 23:05:34 +0000 (01:05 +0200)
committerMarius Gavrilescu <marius@ieval.ro>
Sun, 22 Dec 2013 23:06:39 +0000 (01:06 +0200)
lib/Gruntmaster/Page/Pb.pm

index 617112a539c99a73a3361e8a4e429914f7078754..a2cccff504516d7c90969a00977c2be54a584ec8 100644 (file)
@@ -18,8 +18,29 @@ use Gruntmaster::Page::Common qw/header footer/;
 
 my %templates = (
   en => <<'HTML',
+<h2>Beginner</h2>
 <ul>
-<tmpl_loop problems><li><a href="<tmpl_var id>"><tmpl_var name></a>
+<tmpl_loop beginner><li><a href="<tmpl_var id>"><tmpl_var name></a>
+</tmpl_loop></ul>
+
+<h2>Easy</h2>
+<ul>
+<tmpl_loop easy><li><a href="<tmpl_var id>"><tmpl_var name></a>
+</tmpl_loop></ul>
+
+<h2>Medium</h2>
+<ul>
+<tmpl_loop medium><li><a href="<tmpl_var id>"><tmpl_var name></a>
+</tmpl_loop></ul>
+
+<h2>Advanced</h2>
+<ul>
+<tmpl_loop advanced><li><a href="<tmpl_var id>"><tmpl_var name></a>
+</tmpl_loop></ul>
+
+<h2>Hard</h2>
+<ul>
+<tmpl_loop hard><li><a href="<tmpl_var id>"><tmpl_var name></a>
 </tmpl_loop></ul>
 HTML
 );
@@ -37,8 +58,10 @@ sub generate{
   my @problems = sort { $b->{name} cmp $a->{name} } map {
        my $meta = LoadFile $_;
        my $id = (m,^$path/(.*)/meta.yml$,)[0];
-       +{ id => $id, name => $meta->{name} } } <$path/*/meta.yml>;
-  $htc->param(problems => \@problems);
+       +{ id => $id, name => $meta->{name}, level => $meta->{level} } } <$path/*/meta.yml>;
+  for my $d(qw/beginner easy medium advanced hard/) {
+       $htc->param($d => [grep {$_->{level} eq $d} @problems]);
+  }
   $htc->output
 }
 
This page took 0.026682 seconds and 4 git commands to generate.