X-Git-Url: http://git.ieval.ro/?a=blobdiff_plain;f=lib%2FGruntmaster%2FPage%2FBase.pm;h=a7188d7cd4e660b3c6371be00f316bf55f54cb6e;hb=7dc3247307f2e86af154dc449224f22ba8923c79;hp=7fa14970be31f20d32d6c0445e21edbfca22aa60;hpb=bb95f538bf263c0294d87cfb90d58c66117b9aab;p=plack-app-gruntmaster.git diff --git a/lib/Gruntmaster/Page/Base.pm b/lib/Gruntmaster/Page/Base.pm index 7fa1497..a7188d7 100644 --- a/lib/Gruntmaster/Page/Base.pm +++ b/lib/Gruntmaster/Page/Base.pm @@ -24,6 +24,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,17 +36,20 @@ my %orig_header_templates = ( en => <<'HTML', TITLE_GOES_HERE - - - - + + + +
iEval
TITLE_GOES_HERE
- + HTML ); @@ -59,10 +66,10 @@ HTML ); sub patch_templates { - my $root = $ENV{GRUNTMASTER_TEMPLATE_ROOT} or return; + my $root = $ENV{GRUNTMASTER_TEMPLATE_ROOT} or return %{$_[0]}; my ($templates, $name) = @_; my %out = %$templates; - for (<$root/$name*>) { + for (<$root/$name.*>) { m/\.(.+)$/; $out{$1} = read_file $_ } @@ -101,15 +108,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]], [ $htc->output ] ] } sub _generate {} +sub variants { + [ map { [ $_, 1, 'text/html', undef, undef, $_, undef ]} keys $_[0]->TEMPLATES ] +} + 1