line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Plack::Middleware::Bootstrap; |
2
|
2
|
|
|
2
|
|
1188
|
use 5.008001; |
|
2
|
|
|
|
|
5
|
|
3
|
2
|
|
|
2
|
|
7
|
use strict; |
|
2
|
|
|
|
|
1
|
|
|
2
|
|
|
|
|
28
|
|
4
|
2
|
|
|
2
|
|
6
|
use warnings; |
|
2
|
|
|
|
|
7
|
|
|
2
|
|
|
|
|
61
|
|
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
our $VERSION = "0.08"; |
7
|
|
|
|
|
|
|
|
8
|
2
|
|
|
2
|
|
359
|
use parent qw(Plack::Middleware); |
|
2
|
|
|
|
|
202
|
|
|
2
|
|
|
|
|
10
|
|
9
|
2
|
|
|
2
|
|
8642
|
use Plack::Util (); |
|
2
|
|
|
|
|
2
|
|
|
2
|
|
|
|
|
22
|
|
10
|
2
|
|
|
2
|
|
700
|
use Plack::Response; |
|
2
|
|
|
|
|
12544
|
|
|
2
|
|
|
|
|
43
|
|
11
|
|
|
|
|
|
|
|
12
|
2
|
|
|
2
|
|
737
|
use Text::MicroTemplate::DataSection qw(); |
|
2
|
|
|
|
|
23264
|
|
|
2
|
|
|
|
|
30
|
|
13
|
2
|
|
|
2
|
|
833
|
use HTML::TreeBuilder::XPath; |
|
2
|
|
|
|
|
84405
|
|
|
2
|
|
|
|
|
14
|
|
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
sub call { |
16
|
6
|
|
|
6
|
1
|
23857
|
my ($self, $env) = @_; |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
Plack::Util::response_cb( |
19
|
|
|
|
|
|
|
$self->app->($env), |
20
|
|
|
|
|
|
|
sub { |
21
|
6
|
|
|
6
|
|
128
|
my $res = shift; |
22
|
|
|
|
|
|
|
|
23
|
6
|
|
|
|
|
22
|
my $plack_res = Plack::Response->new(@$res); |
24
|
6
|
100
|
|
|
|
294
|
return unless $plack_res->content_type =~ /\Atext\/html/; |
25
|
5
|
100
|
|
|
|
104
|
return if $plack_res->content_encoding; |
26
|
|
|
|
|
|
|
|
27
|
4
|
|
|
|
|
35
|
my $content; |
28
|
4
|
|
50
|
|
|
20
|
Plack::Util::foreach($res->[2] || [], sub { $content .= $_[0] }); |
|
4
|
|
|
|
|
25
|
|
29
|
|
|
|
|
|
|
|
30
|
4
|
|
|
|
|
29
|
my $tree = HTML::TreeBuilder::XPath->new(); |
31
|
4
|
|
|
|
|
573
|
$tree->ignore_unknown(0); |
32
|
4
|
|
|
|
|
26
|
$tree->store_comments(1); |
33
|
4
|
|
|
|
|
23
|
$tree->parse_content($content); |
34
|
|
|
|
|
|
|
|
35
|
4
|
50
|
|
|
|
1822
|
my $head = join "\n", map { ref($_) ? $_->as_HTML(q{&<>'"}, '', {}) : $_ } $tree->findnodes('//head')->[0]->content_list; |
|
1
|
|
|
|
|
362
|
|
36
|
4
|
100
|
|
|
|
1920
|
my $body = join "\n", map { ref($_) ? $_->as_HTML(q{&<>'"}, '', {}) : $_ } $tree->findnodes('//body')->[0]->content_list; |
|
6
|
|
|
|
|
1744
|
|
37
|
|
|
|
|
|
|
|
38
|
4
|
|
|
|
|
247
|
my $renderer = Text::MicroTemplate::DataSection->new( |
39
|
|
|
|
|
|
|
escape_func => undef |
40
|
|
|
|
|
|
|
); |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
# render_mt returns Text::MicroTemplate::EncodedString. |
43
|
4
|
|
|
|
|
176
|
$res->[2] = [ $renderer->render_mt('template.mt', $head, $body).q() ]; |
44
|
|
|
|
|
|
|
|
45
|
4
|
|
|
|
|
4967
|
Plack::Util::header_remove($res->[1], 'Content-Length'); |
46
|
6
|
|
|
|
|
18
|
}); |
47
|
|
|
|
|
|
|
} |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
1; |
50
|
|
|
|
|
|
|
__DATA__ |