X-Git-Url: http://git.ieval.ro/?a=blobdiff_plain;f=lib%2FGruntmaster%2FPage%2FBase.pm;h=1741b30c5cdfbd483cd56b7531da63ce51f699bb;hb=dfe9fad19b62489af03cdd2fd29cc5057536b483;hp=5b93f20992e00411b7d981f0af15edfc32a1e7c6;hpb=eafc7f54b9d964aac41b0715e18caf5ed58ef89a;p=plack-app-gruntmaster.git diff --git a/lib/Gruntmaster/Page/Base.pm b/lib/Gruntmaster/Page/Base.pm index 5b93f20..1741b30 100644 --- a/lib/Gruntmaster/Page/Base.pm +++ b/lib/Gruntmaster/Page/Base.pm @@ -4,6 +4,7 @@ use 5.014000; use strict; use warnings; +use Encode qw/encode/; use File::Slurp qw/read_file/; use HTML::Template::Compiled; @@ -24,6 +25,10 @@ sub import { *{"${caller}::strftime"} = \&POSIX::strftime; *{"${caller}::NAME"} = sub () { $name }; *{"${caller}::TITLE"} = sub () { $title }; + *{"${caller}::debug"} = sub { + local $Log::Log4perl::caller_depth = $Log::Log4perl::caller_depth + 1; + $_[0]->({qw/level debug message/ => $_[1]}) + }; } ################################################## @@ -32,18 +37,47 @@ my %orig_header_templates = ( en => <<'HTML', TITLE_GOES_HERE - - - - + + + + + + + +
-
iEval
TITLE_GOES_HERE
- - HTML ); @@ -101,15 +135,19 @@ sub cook_templates { my %templates; sub generate{ - my ($self, $path, $lang) = @_; + my ($self, $lang, @args) = @_; $templates{$self} = { cook_templates $self->TEMPLATES, $self->NAME => $self->TITLE } if !exists $templates{$self} or reload_templates; my $htc = HTML::Template::Compiled->new(scalarref => \$templates{$self}{$lang}, default_escape => 'HTML',); - $self->_generate($htc, $path, $lang); - $htc->output + $self->_generate($htc, $lang, @args); + [200, ['Content-Type' => 'text/html', 'Content-Language' => $_[1], 'Vary' => 'Accept-Language'], [ encode 'UTF-8' => $htc->output ] ] } sub _generate {} +sub variants { + [ map { [ $_, 1, 'text/html', undef, undef, $_, undef ]} keys $_[0]->TEMPLATES ] +} + 1