X-Git-Url: http://git.ieval.ro/?a=blobdiff_plain;f=lib%2FGruntmaster%2FPage%2FBase.pm;h=cf29eacc3c56962148f012739c16bc36b0260aee;hb=1053baeebc541fc3508aabb6121759bb4a884e23;hp=bc8e9cec1b176e81c63a37cb903cbf880fdd6206;hpb=31d700150e564fd3bf0eb167ef416c87aed771eb;p=plack-app-gruntmaster.git diff --git a/lib/Gruntmaster/Page/Base.pm b/lib/Gruntmaster/Page/Base.pm index bc8e9ce..cf29eac 100644 --- a/lib/Gruntmaster/Page/Base.pm +++ b/lib/Gruntmaster/Page/Base.pm @@ -4,7 +4,6 @@ use 5.014000; use strict; use warnings; -use Encode qw/encode/; use File::Slurp qw/read_file/; use HTML::Template::Compiled; @@ -13,6 +12,9 @@ use HTML::Template::Compiled; use POSIX (); use Gruntmaster::Data (); use List::Util (); +use LWP::UserAgent; + +my $ua = LWP::UserAgent->new; sub import { my $caller = caller; @@ -29,8 +31,12 @@ sub import { local $Log::Log4perl::caller_depth = $Log::Log4perl::caller_depth + 1; $_[0]->{'psgix.logger'}->({qw/level debug message/ => $_[1]}) }; - *{"${caller}::reply"} = sub { [200, ['Content-Type' => 'text/plain'], [ @_ ] ] } - + *{"${caller}::reply"} = sub { [200, ['Content-Type' => 'text/plain'], [ @_ ] ] }; + *{"${caller}::purge"} = sub { + return unless $ENV{PURGE_HOST}; + my $req = HTTP::Request->new(PURGE => "http://$ENV{PURGE_HOST}$_[0]"); + $ua->request($req) + }; } ################################################## @@ -77,7 +83,7 @@ my %orig_header_templates = (
-
TITLE_GOES_HERE
+

TITLE_GOES_HERE

HTML ); @@ -139,7 +145,9 @@ sub generate{ my $htc = HTML::Template::Compiled->new(scalarref => \$templates{$self}{$lang}, default_escape => 'HTML',); $self->_generate($htc, $lang, @args); - [200, ['Content-Type' => 'text/html', 'Content-Language' => $_[1], 'Vary' => 'Accept-Language'], [ encode 'UTF-8' => $htc->output ] ] + my $out = $htc->output; + utf8::downgrade($out); + [200, ['Content-Type' => 'text/html', 'Content-Language' => $_[1], 'Vary' => 'Accept-Language', 'X-Forever' => 1], [ $out ] ] } sub _generate {}