X-Git-Url: http://git.ieval.ro/?a=blobdiff_plain;f=lib%2FPlack%2FApp%2FGruntmaster.pm;h=99ce4987c9e24b387f95487464f8752b70d385a6;hb=d3200993969efcd4d9c0ce6a5666a012815ad2d5;hp=2334235f1670bf64f997eafccde6e5d239c44812;hpb=191f4979def520b8be01554eb954c80ee42df38b;p=plack-app-gruntmaster.git diff --git a/lib/Plack/App/Gruntmaster.pm b/lib/Plack/App/Gruntmaster.pm index 2334235..99ce498 100644 --- a/lib/Plack/App/Gruntmaster.pm +++ b/lib/Plack/App/Gruntmaster.pm @@ -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] ] } } @@ -58,21 +59,36 @@ BEGIN{ my $word = qr,(\w+),a; my $ct = qr,(?:\/ct/$word)?,a; - get qr,/css/$word, => 'CSS'; - get qr,/js, => 'JS'; + sub generic { + my ($thing, $ct, $fs) = @_; + $ct //= '', $fs //= ''; + my $pkg = ucfirst $thing; + get qr,$ct/$thing/, => $pkg; + get qr,$ct/$thing/read, => "${pkg}::Read"; + get qr,$ct/$thing/$word$fs, => "${pkg}::Entry"; +# post qr,$ct/$thing/$word/create, => "${pkg}::Entry::Create"; + get qr,$ct/$thing/$word/read, => "${pkg}::Entry::Read"; +# post qr,$ct/$thing/$word/update, => "${pkg}::Entry::Update"; +# post qr,$ct/$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'; + generic 'us'; + generic ct => '', '/'; + generic pb => $ct; + #generic log => $ct; get qr,$ct/log/(\d+)?, => 'Log'; get qr,$ct/log/st, => 'St'; get qr,$ct/log/job/$word, => 'Log::Entry'; + get qr,$ct/log/job/$word/read, => 'Log::Entry::Read'; get qr,$ct/log/src/$word\.$word, => 'Src'; - get qr,$ct/submit, => 'Submit'; - get qr,$ct/pb/, => 'Pb'; - get qr,$ct/pb/$word, => 'Pb::Entry'; + post qr,$ct/pb/$word/submit, => 'Submit'; + + post qr,/action/register, => 'Register'; + post qr,/action/passwd, => 'Passwd'; } 1;