line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Catalyst::Plugin::Firebug; |
2
|
3
|
|
|
3
|
|
6942
|
use strict; |
|
3
|
|
|
|
|
7
|
|
|
3
|
|
|
|
|
118
|
|
3
|
3
|
|
|
3
|
|
15
|
use warnings; |
|
3
|
|
|
|
|
6
|
|
|
3
|
|
|
|
|
109
|
|
4
|
|
|
|
|
|
|
|
5
|
3
|
|
|
3
|
|
1981
|
use NEXT; |
|
3
|
|
|
|
|
8225
|
|
|
3
|
|
|
|
|
1019
|
|
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
our $VERSION = '0.02'; |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
=head1 NAME |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
Catalyst::Plugin::Firebug - Catalyst plugin for Firebug Lite |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
=head1 SYNOPSIS |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
use Catalyst qw/Firebug/; |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
=head1 DESCRIPTION |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
Catalyst plugin for Firebug Lite. |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
If you load this plugin, and your app running on debug mode or $ENV{FIREBUG_DEBUG} is set, |
22
|
|
|
|
|
|
|
this plugin insert firebug lite tags to its output automaticaly. |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
=head1 CONFIGURATION |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
You can specify firebug.js path by following config: |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
$c->config->{firebug}{path} = '/path/to/firebug.js'; |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
Default path is '/js/firebug/firebug.js'. |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
=head1 SEE ALSO |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
Firebug, http://getfirebug.com/ |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
Firebug Lite, http://getfirebug.com/lite.html |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
=head1 EXTENDED METHODS |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
=head2 finalize |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
=cut |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
sub finalize { |
45
|
1
|
|
|
1
|
1
|
101833
|
my $c = shift; |
46
|
1
|
50
|
33
|
|
|
6
|
return $c->NEXT::finalize unless $c->debug || $ENV{FIREBUG_DEBUG}; |
47
|
|
|
|
|
|
|
|
48
|
1
|
50
|
|
|
|
52
|
if ($c->res->content_type =~ /html/) { |
49
|
1
|
|
|
|
|
247
|
$c->log->debug('enable firebug lite'); |
50
|
|
|
|
|
|
|
|
51
|
1
|
|
50
|
|
|
546
|
my $firebug = $c->uri_for( $c->config->{firebug}{path} || '/js/firebug/firebug.js' ); |
52
|
|
|
|
|
|
|
|
53
|
1
|
|
|
|
|
220
|
my $body = $c->res->body; |
54
|
|
|
|
|
|
|
|
55
|
1
|
50
|
|
|
|
84
|
if ($body =~ m!<head.*?>.*?</head>!is) { |
56
|
1
|
|
|
|
|
26
|
$body =~ s!(<head.*?>(?:.*?))(</head>)!$1<script type="text/javascript" src="$firebug"></script>$2!is; |
57
|
|
|
|
|
|
|
} |
58
|
|
|
|
|
|
|
else { |
59
|
0
|
|
|
|
|
0
|
$body .= qq{<script type="text/javascript" src="$firebug"></script>}; |
60
|
|
|
|
|
|
|
} |
61
|
|
|
|
|
|
|
|
62
|
1
|
50
|
|
|
|
37
|
if ($body =~ m!<html.*?>.*?</html>!is) { |
63
|
1
|
|
|
|
|
19
|
$body =~ s!(<html.*?)>!$1 debug="true">!is; |
64
|
|
|
|
|
|
|
} |
65
|
|
|
|
|
|
|
else { |
66
|
0
|
|
|
|
|
0
|
$body = qq{<html debug="true">$body</html>}; |
67
|
|
|
|
|
|
|
} |
68
|
|
|
|
|
|
|
|
69
|
1
|
|
|
|
|
6
|
$c->res->body( $body ); |
70
|
|
|
|
|
|
|
} |
71
|
|
|
|
|
|
|
|
72
|
1
|
|
|
|
|
85
|
$c->NEXT::finalize; |
73
|
|
|
|
|
|
|
} |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
=head1 AUTHOR |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
Daisuke Murase <typester@cpan.org> |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
=head1 COPYRIGHT |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
This program is free software; you can redistribute |
82
|
|
|
|
|
|
|
it and/or modify it under the same terms as Perl itself. |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
The full text of the license can be found in the |
85
|
|
|
|
|
|
|
LICENSE file included with this module. |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
=cut |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
1; |