]> iEval git - gruntmaster-page.git/blobdiff - lib/Plack/App/Gruntmaster.pm
Fix some bugs
[gruntmaster-page.git] / lib / Plack / App / Gruntmaster.pm
index 1fc3a85742b6a9c8a6f22a513bf819d0892186f6..e009d792041083c4a0b6e7bf00edb4f3c33aca05 100644 (file)
@@ -10,6 +10,7 @@ our $VERSION = '5999.000_001';
 use File::Slurp qw/read_file/;
 use HTTP::Negotiate qw/choose/;
 use Plack::Request;
+use Gruntmaster::Page::Generic;
 
 my %handlers;
 
@@ -35,7 +36,7 @@ sub call {
                        my $content = read_file "a/$article.$lang";
                        my $title = read_file "a/$article.$lang.title";
                        my $html = Gruntmaster::Page::Base::header($lang, $title) . $content . Gruntmaster::Page::Base::footer($lang);
-                       return [200, ['Content-Type' => 'text/html', 'Content-Language' => $lang, 'Vary' => 'Accept-Language'], [$html] ]
+                       return [200, ['Content-Type' => 'text/html', 'Content-Language' => $lang, 'Vary' => 'Accept-Language', 'X-Forever' => 1, 'Cache-Control' => 'max-age=300'], [$html] ]
                }
        }
 
@@ -55,24 +56,30 @@ sub post {
 }
 
 BEGIN{
-       my $word = qr,(\w+),a;
-       my $ct = qr,(?:\/ct/$word)?,a;
+       my $word   = qr,(\w+),a;
+       my $number = qr,(\d+),a;
 
-       get qr,/css/$word, => 'CSS';
-       get qr,/js, => 'JS';
+       sub generic {
+               for my $thing (@_) {
+                       my $pkg = ucfirst $thing;
+                       get  qr,/$thing/,             => $pkg;
+                       get  qr,/$thing/read,         => "${pkg}::Read";
+                       get  qr,/$thing/$word,        => "${pkg}::Entry";
+#                      post qr,/$thing/$word/create, => "${pkg}::Entry::Create";
+                       get  qr,/$thing/$word/read,   => "${pkg}::Entry::Read";
+#                      post qr,/$thing/$word/update, => "${pkg}::Entry::Update";
+#                      post qr,/$thing/$word/delete, => "${pkg}::Entry::Delete";
+               }
+       }
+
+       get qr,/css/$word\.css, => 'CSS';
+       get qr,/js\.js, => 'JS';
 
-       get qr,/ct/, => 'Ct';
-       get qr,/ct/$word, => 'Ct::Entry';
-       get qr,/us/, => 'Us';
-       get qr,/us/$word, => 'Us::Entry';
+       get qr,/log/st, => 'St';
+       generic qw/us ct pb log/;
 
-       get qr,$ct/log/(\d+)?, => 'Log';
-       get qr,$ct/log/st, => 'St';
-       get qr,$ct/log/job/$word, => 'Log::Entry';
-       get qr,$ct/log/src/$word\.$word, => 'Src';
-       get qr,$ct/pb/, => 'Pb';
-       get qr,$ct/pb/$word, => 'Pb::Entry';
-       post qr,$ct/pb/$word/submit, => 'Submit';
+       get qr,/log/src/$number\.$word, => 'Src';
+       post qr,/submit, => 'Submit';
 
        post qr,/action/register, => 'Register';
        post qr,/action/passwd, => 'Passwd';
This page took 0.018957 seconds and 4 git commands to generate.