| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
# ABSTRACT: Plack middleware to insert Firebug Lite code into HTML. |
|
2
|
|
|
|
|
|
|
package Plack::Middleware::Firebug::Lite; |
|
3
|
|
|
|
|
|
|
BEGIN { |
|
4
|
1
|
|
|
1
|
|
21949
|
$Plack::Middleware::Firebug::Lite::VERSION = '0.2.3'; |
|
5
|
|
|
|
|
|
|
} |
|
6
|
1
|
|
|
1
|
|
9
|
use strict; |
|
|
1
|
|
|
|
|
3
|
|
|
|
1
|
|
|
|
|
32
|
|
|
7
|
1
|
|
|
1
|
|
5
|
use warnings; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
33
|
|
|
8
|
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
=head1 NAME |
|
10
|
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
Plack::Middleware::Firebug::Lite - Plack middleware to insert Firebug Lite code into HTML. |
|
12
|
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
=head1 VERSION |
|
14
|
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
version 0.2.3 |
|
16
|
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
=head1 DESCRIPTION |
|
18
|
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
This module will insert Firebug Lite code into HTML. |
|
20
|
|
|
|
|
|
|
Currently it will check if Content-Type is C. |
|
21
|
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
=head1 SYNOPSIS |
|
23
|
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
use Plack::Builder; |
|
25
|
|
|
|
|
|
|
builder { |
|
26
|
|
|
|
|
|
|
# Use stable channel from official site. |
|
27
|
|
|
|
|
|
|
enable 'Firebug::Lite'; |
|
28
|
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
# or, use local copy |
|
30
|
|
|
|
|
|
|
enable 'Firebug::Lite', url => '/local/path/to/firebug-lite.js'; |
|
31
|
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
$app; |
|
33
|
|
|
|
|
|
|
} |
|
34
|
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
=cut |
|
36
|
|
|
|
|
|
|
|
|
37
|
1
|
|
|
1
|
|
819
|
use parent 'Plack::Middleware'; |
|
|
1
|
|
|
|
|
293
|
|
|
|
1
|
|
|
|
|
5
|
|
|
38
|
|
|
|
|
|
|
|
|
39
|
1
|
|
|
1
|
|
19425
|
use HTML::Entities; |
|
|
1
|
|
|
|
|
31436
|
|
|
|
1
|
|
|
|
|
174
|
|
|
40
|
1
|
|
|
1
|
|
18
|
use Plack::Util::Accessor qw/url/; |
|
|
1
|
|
|
|
|
3
|
|
|
|
1
|
|
|
|
|
16
|
|
|
41
|
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
sub call { |
|
43
|
0
|
|
|
0
|
1
|
|
my ($self, $env) = @_; |
|
44
|
|
|
|
|
|
|
|
|
45
|
0
|
|
|
|
|
|
my $res = $self->app->($env); |
|
46
|
|
|
|
|
|
|
Plack::Util::response_cb($res, sub { |
|
47
|
0
|
|
|
0
|
|
|
my $res = shift; |
|
48
|
|
|
|
|
|
|
|
|
49
|
0
|
|
|
|
|
|
my $h = Plack::Util::headers($res->[1]); |
|
50
|
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
# Only process text/html. |
|
52
|
0
|
|
|
|
|
|
my $ct = $h->get('Content-Type'); |
|
53
|
0
|
0
|
0
|
|
|
|
return unless defined $ct and $ct =~ qr{text/html}; |
|
54
|
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
# Don't touch compressed content. |
|
56
|
0
|
0
|
|
|
|
|
return if defined $h->get('Content-Encoding'); |
|
57
|
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
# Concat all content, and if response body is undefined then ignore it. |
|
59
|
0
|
|
|
|
|
|
my $body = []; |
|
60
|
0
|
|
|
|
|
|
Plack::Util::foreach($res->[2], sub { push @$body, $_[0]; }); |
|
|
0
|
|
|
|
|
|
|
|
61
|
0
|
|
|
|
|
|
$body = join '', @$body; |
|
62
|
|
|
|
|
|
|
|
|
63
|
0
|
|
|
|
|
|
my $url = encode_entities($self->url, '<>&"'); |
|
64
|
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
# Insert Firebug Lite code and replace it. |
|
66
|
0
|
|
|
|
|
|
$body =~ s{^(.*)\ |