line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Moxy::Plugin::ControlPanel; |
2
|
11
|
|
|
11
|
|
72368
|
use strict; |
|
11
|
|
|
|
|
392
|
|
|
11
|
|
|
|
|
359
|
|
3
|
11
|
|
|
11
|
|
88
|
use warnings; |
|
11
|
|
|
|
|
29
|
|
|
11
|
|
|
|
|
307
|
|
4
|
11
|
|
|
11
|
|
172
|
use base qw/Moxy::Plugin/; |
|
11
|
|
|
|
|
30
|
|
|
11
|
|
|
|
|
475
|
|
5
|
11
|
|
|
11
|
|
612
|
use Moxy::Util; |
|
11
|
|
|
|
|
32
|
|
|
11
|
|
|
|
|
116
|
|
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
sub response_filter: Hook { |
8
|
0
|
|
|
0
|
0
|
|
my ($self, $context, $args) = @_; |
9
|
|
|
|
|
|
|
|
10
|
0
|
0
|
0
|
|
|
|
return unless (($args->{response}->header('Content-Type')||'') =~ /html/); |
11
|
|
|
|
|
|
|
|
12
|
0
|
|
|
|
|
|
$context->log("debug" => "generate ControlPanel"); |
13
|
|
|
|
|
|
|
|
14
|
0
|
|
|
|
|
|
my @parts = do { |
15
|
0
|
|
|
|
|
|
my @r; |
16
|
0
|
|
|
|
|
|
for my $hook (@{$context->class_component_hooks->{'control_panel'}}) { |
|
0
|
|
|
|
|
|
|
17
|
0
|
|
|
|
|
|
my ($plugin, $method) = ($hook->{plugin}, $hook->{method}); |
18
|
0
|
|
|
0
|
|
|
push @r, { title => sub { (my $x = ref $plugin) =~ s/.+:://; $x }->(), body => $plugin->$method($context, $args) }; |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
} |
20
|
0
|
|
|
|
|
|
@r; |
21
|
|
|
|
|
|
|
}; |
22
|
|
|
|
|
|
|
|
23
|
0
|
|
|
|
|
|
my $output = $self->render_template( |
24
|
|
|
|
|
|
|
$context, |
25
|
|
|
|
|
|
|
'panelcontainer.tt' => { |
26
|
|
|
|
|
|
|
parts => \@parts, |
27
|
|
|
|
|
|
|
} |
28
|
|
|
|
|
|
|
); |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
# convert html charset to response charset. |
31
|
0
|
|
|
|
|
|
my $charset = $args->{response}->charset; |
32
|
0
|
|
|
|
|
|
my $enc = Encode::find_encoding($charset); |
33
|
0
|
0
|
|
|
|
|
$output = Encode::encode(($enc ? $enc->name : 'utf-8'), $output); |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
# insert control panel to html response. |
36
|
0
|
|
|
|
|
|
my $content = $args->{response}->content; |
37
|
0
|
|
|
|
|
|
$content =~ s!( |