X-Git-Url: http://git.ieval.ro/?a=blobdiff_plain;f=lib%2FGruntmaster%2FPage%2FBase.pm;h=cffb656564e21c835ede46c38866335c3e21e52f;hb=5c6aea9392c11422abe85788aac0f62ad3a4dd14;hp=9e2d03034cc5c8550499301beb3a67d6825199e5;hpb=c86e504ed5be25093c1579e736c05dce02901555;p=plack-app-gruntmaster.git diff --git a/lib/Gruntmaster/Page/Base.pm b/lib/Gruntmaster/Page/Base.pm index 9e2d030..cffb656 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 = '0.001'; use File::Slurp qw/read_file/; use HTML::Template::Compiled; @@ -34,18 +35,27 @@ use POSIX (); use Gruntmaster::Data (); use List::Util (); use LWP::UserAgent; +use Plack::Request (); +use feature (); my $ua = LWP::UserAgent->new; my %templates; -sub import { - my $caller = caller; - my ($self, $name, $title) = @_; +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; @@ -65,6 +75,12 @@ sub import { } } +sub import { + return unless $_[0] eq __PACKAGE__; + splice @_, 1, 0, scalar caller; + goto &import_to +} + ################################################## sub generate{ @@ -80,11 +96,12 @@ sub generate{ sub _generate {} -sub vary {} +sub vary { '' } sub max_age { 60 } sub variants { + return [] unless exists $templates{$_[0]}; [ map { [ $_, 1, 'text/html', undef, undef, $_, undef ]} keys $templates{$_[0]} ] }