]> iEval git - plack-app-gruntmaster.git/blobdiff - lib/Gruntmaster/Page/Base.pm
From Redis to Postgres - Part 1 (Getting started)
[plack-app-gruntmaster.git] / lib / Gruntmaster / Page / Base.pm
index 475be80d6952521e4d0fc96c6c82881913b64764..0cae932d05cf197e8674ef8e4c9cfee1ae761dcd 100644 (file)
@@ -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;
@@ -31,9 +32,10 @@ sub footer{
 ##################################################
 
 use POSIX ();
-use Gruntmaster::Data ();
 use List::Util ();
 use LWP::UserAgent;
+use Plack::Request ();
+use feature ();
 
 my $ua = LWP::UserAgent->new;
 my %templates;
@@ -43,15 +45,21 @@ use Carp qw/cluck/;
 sub import_to {
        my ($self, $caller, $name, $title) = @_;
 
-       Gruntmaster::Data->export_to_level(1, $caller);
+       strict->import;
+       feature->import(':5.14');
+       warnings->import;
+       File::Slurp->export_to_level(1, $caller, qw/read_file/);
        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;
                $_[0]->{'psgix.logger'}->({qw/level debug message/ => $_[1]})
        };
+       *{"${caller}::db"} = sub { $_[0]->{'gruntmaster.dbic'} };
        *{"${caller}::reply"} = sub { [200, ['Content-Type' => 'text/plain', 'Cache-Control' => 'no-cache'], [ @_ ] ] };
        *{"${caller}::purge"} = sub {
                return unless $ENV{PURGE_HOST};
@@ -77,7 +85,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);
This page took 0.021921 seconds and 4 git commands to generate.