]>
iEval git - gruntmaster-page.git/blob - lib/Gruntmaster/Page/Base.pm
1 package Gruntmaster
::Page
::Base
;
7 use File
::Slurp qw
/read_file/;
8 use HTML
::Template
::Compiled
;
10 ##################################################
16 map { m/\.(.+)$/; $1 => scalar read_file
$_ } <tmpl
/$name.*>;
19 my %header_templates = read_templates
'header';
20 my %footer_templates = read_templates
'footer';
23 my ($language, $title) = @_;
24 $header_templates{$language} =~ s/TITLE_GOES_HERE/$title/ger;
28 $footer_templates{$_[0]};
31 ##################################################
34 use Gruntmaster
::Data
();
38 my $ua = LWP
::UserAgent
->new;
43 my ($self, $name, $title) = @_;
45 Gruntmaster
::Data
->export_to_level(1, $caller);
46 List
::Util
->export_to_level(1, $caller, qw
/sum/);
49 *{"${caller}::strftime"} = \
&POSIX
::strftime
;
50 *{"${caller}::debug"} = sub {
51 local $Log::Log4perl
::caller_depth
= $Log::Log4perl
::caller_depth
+ 1;
52 $_[0]->{'psgix.logger'}->({qw
/level debug message/ => $_[1]})
54 *{"${caller}::reply"} = sub { [200, ['Content-Type' => 'text/plain', 'Cache-Control' => 'no-cache'], [ @_ ] ] };
55 *{"${caller}::purge"} = sub {
56 return unless $ENV{PURGE_HOST
};
57 my $req = HTTP
::Request
->new(PURGE
=> "http://$ENV{PURGE_HOST}$_[0]");
62 $templates{$caller} = { read_templates
$name };
63 $templates{$caller}{$_} = header
($_, $title) . $templates{$caller}{$_} for keys $templates{$caller};
64 $templates{$caller}{$_} .= footer
$_ for keys $templates{$caller};
68 ##################################################
71 my ($self, $lang, @args) = @_;
73 my $htc = HTML
::Template
::Compiled
->new(scalarref
=> \
$templates{$self}{$lang}, default_escape
=> 'HTML',);
74 $self->_generate($htc, $lang, @args);
75 my $out = $htc->output;
76 utf8
::downgrade
($out);
77 [200, ['Content-Type' => 'text/html', 'Content-Language' => $_[1], 'Vary' => 'Accept-Language', 'X-Forever' => 1, 'Cache-Control' => 'max-age=' . $self->max_age], [ $out ] ]
85 [ map { [ $_, 1, 'text/html', undef, undef, $_, undef ]} keys $templates{$_[0]} ]
This page took 0.054944 seconds and 5 git commands to generate.