X-Git-Url: http://git.ieval.ro/?a=blobdiff_plain;f=lib%2FGruntmaster%2FPage%2FBase.pm;h=4ba905bfbab1b227f2c0d518f6dd10966b6bd4ed;hb=e046c73abf1f466bcafca06a01a0af2c9e2120c9;hp=6ced6145a68eff7367d87293f4963258fa861985;hpb=fdbf59e5def9cbb4e1c0749f819ba8d946c37725;p=gruntmaster-page.git diff --git a/lib/Gruntmaster/Page/Base.pm b/lib/Gruntmaster/Page/Base.pm index 6ced614..4ba905b 100644 --- a/lib/Gruntmaster/Page/Base.pm +++ b/lib/Gruntmaster/Page/Base.pm @@ -3,6 +3,7 @@ package Gruntmaster::Page::Base; use 5.014000; use strict; use warnings; +our $VERSION = '5999.000_001'; use File::Slurp qw/read_file/; use HTML::Template::Compiled; @@ -34,6 +35,8 @@ use POSIX (); use Gruntmaster::Data (); use List::Util (); use LWP::UserAgent; +use Plack::Request (); +use feature (); my $ua = LWP::UserAgent->new; my %templates; @@ -43,10 +46,16 @@ use Carp qw/cluck/; sub import_to { my ($self, $caller, $name, $title) = @_; + strict->import; + feature->import(':5.14'); + warnings->import; + File::Slurp->export_to_level(1, $caller, qw/read_file/); Gruntmaster::Data->export_to_level(1, $caller); List::Util->export_to_level(1, $caller, qw/sum/); no strict 'refs'; + *{"${caller}::ISA"} = [__PACKAGE__]; + *{"${caller}::VERSION"} = $VERSION; *{"${caller}::strftime"} = \&POSIX::strftime; *{"${caller}::debug"} = sub { local $Log::Log4perl::caller_depth = $Log::Log4perl::caller_depth + 1; @@ -77,7 +86,7 @@ sub import { sub generate{ my ($self, $lang, @args) = @_; - my $htc = HTML::Template::Compiled->new(scalarref => \$templates{$self}{$lang}, default_escape => 'HTML',); + my $htc = HTML::Template::Compiled->new(scalarref => \$templates{$self}{$lang}, default_escape => 'HTML', use_perl => 1); $self->_generate($htc, $lang, @args); my $out = $htc->output; utf8::downgrade($out); @@ -92,6 +101,7 @@ sub vary { '' } sub max_age { 60 } sub variants { + return [] unless exists $templates{$_[0]}; [ map { [ $_, 1, 'text/html', undef, undef, $_, undef ]} keys $templates{$_[0]} ] }