From: Marius Gavrilescu Date: Wed, 5 Feb 2014 09:54:46 +0000 (+0200) Subject: Add article support X-Git-Url: http://git.ieval.ro/?p=plack-app-gruntmaster.git;a=commitdiff_plain;h=f34254b8ee796c7b3416d6b6b31886c10fcf62c1 Add article support --- diff --git a/a/account.en b/a/account.en new file mode 100644 index 0000000..7c55ecf --- /dev/null +++ b/a/account.en @@ -0,0 +1,21 @@ +

Register

+
+
+
+
+
+
+
+
+
+
+ +
+ +

Change password

+
+
+
+
+ +
diff --git a/a/account.en.title b/a/account.en.title new file mode 100644 index 0000000..171e128 --- /dev/null +++ b/a/account.en.title @@ -0,0 +1 @@ +Account diff --git a/a/index.en b/a/index.en new file mode 100644 index 0000000..e69de29 diff --git a/a/index.en.title b/a/index.en.title new file mode 100644 index 0000000..e7e81c9 --- /dev/null +++ b/a/index.en.title @@ -0,0 +1 @@ +Gruntmaster 6000 \ No newline at end of file diff --git a/css/custom.css b/css/custom.css index 3511469..429e489 100644 --- a/css/custom.css +++ b/css/custom.css @@ -58,6 +58,6 @@ div.container-fluid { padding: 0 15px; } -.list-group-item { +.list-group-item, .form-control { max-width: 30em; } diff --git a/lib/Plack/App/Gruntmaster.pm b/lib/Plack/App/Gruntmaster.pm index 60ab49f..5530c73 100644 --- a/lib/Plack/App/Gruntmaster.pm +++ b/lib/Plack/App/Gruntmaster.pm @@ -7,6 +7,7 @@ use parent qw/Plack::Component/; no if $] >= 5.017011, warnings => 'experimental::smartmatch'; our $VERSION = '5999.000_001'; +use File::Slurp qw/read_file/; use HTTP::Negotiate qw/choose/; use Plack::Request; @@ -24,6 +25,20 @@ sub call { return $obj->generate($format, $env->{'psgix.logger'}, map { $_ // '' } @args); } + if ($r->method eq 'GET' || $r->method eq 'HEAD') { + my $article = $r->path eq '/' ? '/index' : $r->path; + $article = substr $article, 1; + $article =~ tr,/,_,; + my @variants = grep { !/\.title$/ } ; + if (@variants) { + my $lang = choose [ map { [$_, 1, 'text/html', undef, undef, $_, undef] } map { /\.(.+)$/ } @variants ], $r->headers; + 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] ] + } + } + [404, ['Content-Type' => 'text/plain'], ['Not found']] }