This file is indexed.

/usr/share/perl5/Plack/Middleware/Debug/Base.pm is in libplack-middleware-debug-perl 0.16+dfsg-1.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
package Plack::Middleware::Debug::Base;
use 5.008;
use strict;
use warnings;
use parent qw(Plack::Middleware);
use Plack::Util::Accessor qw(renderer);
use Text::MicroTemplate;
use Data::Dump;
use Scalar::Util;

our $VERSION = '0.16';

sub call {
    my($self, $env) = @_;

    my $panel = $self->default_panel;
    my $after = $self->run($env, $panel);

    $self->response_cb($self->app->($env), sub {
        my $res = shift;
        $after->($res) if $after && ref $after eq 'CODE';
        push @{$env->{'plack.debug.panels'}}, $panel;
    });
}

sub run { }

sub panel_id {
    my $self = shift;
    (my $name = ref $self) =~ s/.*:://;
    $name . Scalar::Util::refaddr($self);
}

sub panel_name {
    my $self = shift;
    (my $name = ref $self) =~ s/.*:://;
    $name =~ s/(?<=[a-z])(?=[A-Z])/ /g;
    $name;
}

sub default_panel {
    my($self, $env) = @_;

    my $id   = $self->panel_id;
    my $name = $self->panel_name;

    my $panel = Plack::Middleware::Debug::Panel->new;
    $panel->dom_id("plDebug${id}Panel");
    $panel->url('#');
    $panel->title($name);
    $panel->nav_title($name);
    $panel->nav_subtitle('');
    $panel->content('');

    $panel;
}

sub vardump {
    my $scalar = shift;
    return '(undef)' unless defined $scalar;
    return "$scalar" unless ref $scalar;
    scalar Data::Dump::dump($scalar);
}

sub build_template {
    my $class = shift;
    Text::MicroTemplate->new(
        template => $_[0],
        tag_start => '<%',
        tag_end => '%>',
        line_start => '%',
    )->build;
}

sub render {
    my ($self, $template, $vars) = @_;
    $template->($vars);
}

my $list_section_template = __PACKAGE__->build_template(<<'EOTMPL');
% foreach my $s (@{$_[0]->{sections}}) {
<h3><%= ucfirst $s %></h3>
%   if (scalar @{$_[0]->{list}->{$s}}) {
<table>
    <thead>
        <tr>
            <th>Key</th>
            <th>Value</th>
        </tr>
    </thead>
    <tbody>
% my $i;
% while (@{$_[0]->{list}->{$s}}) {
% my($key, $value) = splice(@{$_[0]->{list}->{$s}}, 0, 2);
            <tr class="<%= ++$i % 2 ? 'plDebugOdd' : 'plDebugEven' %>">
                <td><%= $key %></td>
                <td><%= vardump($value) %></td>
            </tr>
% }
    </tbody>
</table>
%   }
% }
EOTMPL

my $list_template = __PACKAGE__->build_template(<<'EOTMPL');
<table>
    <thead>
        <tr>
            <th>Key</th>
            <th>Value</th>
        </tr>
    </thead>
    <tbody>
% my $i;
% while (@{$_[0]->{list}}) {
% my($key, $value) = splice(@{$_[0]->{list}}, 0, 2);
            <tr class="<%= ++$i % 2 ? 'plDebugOdd' : 'plDebugEven' %>">
                <td><%= $key %></td>
                <td><%= vardump($value) %></td>
            </tr>
% }
    </tbody>
</table>
EOTMPL

my $line_template = __PACKAGE__->build_template(<<'EOTMPL');
<table>
    <tbody>
% my $i;
% if (defined $_[0]->{lines}) {
%   my @lines = ref $_[0]->{lines} eq 'ARRAY' ? @{$_[0]->{lines}} : split /\r?\n/, $_[0]->{lines};
%   for my $line (@lines) {
            <tr class="<%= ++$i % 2 ? 'plDebugEven' : 'plDebugOdd' %>">
                <td><%= $line %></td>
            </tr>
%   }
% }
    </tbody>
</table>
EOTMPL

sub render_lines {
    my ($self, $lines) = @_;
    $self->render($line_template, { lines => $lines });
}

sub render_list_pairs {
    my ($self, $list, $sections) = @_;
    if ($sections) {
        $self->render($list_section_template, { list => $list, sections => $sections });
    }else{
        $self->render($list_template, { list => $list });
    }
}

sub render_hash {
    my ( $self, $hash, $sections ) = @_;
    if ($sections) {
        my %hash;
        foreach my $section ( keys %$hash ) {
            push @{ $hash{$section} },
                map { $_ => $hash->{$section}->{$_} }
                sort keys %{ $hash->{$section} };
        }
        $self->render( $list_section_template,
            { sections => $sections, list => \%hash } );
    }
    else {
        my @hash = map { $_ => $hash->{$_} } sort keys %$hash;
        $self->render( $list_template, { list => \@hash } );
    }
}

1;
__END__

=head1 NAME

Plack::Middleware::Debug::Base - Base class for Debug panels

=head1 SYNOPSIS

  package Plack::Middleware::Debug::YourPanel;
  use parent qw(Plack::Middleware::Debug::Base);

  sub run {
      my($self, $env, $panel) = @_;

      # Do something before the application runs

      return sub {
          my $res = shift;

          # Do something after the application returns

      };
  }

=head1 DESCRIPTION

This is the base class for panels.

=head1 METHODS

=over 4

=item C<run>

This method is called when a request has arrived, before the main
application runs. The parameters are C<$env>, the PSGI environment
hash reference and C<$panel>, a Plack::Middleware::Debug::Panel
object.

If your panel needs to do some response munging, you should return a
callback that takes C<$res> the response object. Because you can
return a closure, the response filter can also use C<$env> and
C<$panel> easily.

=back

=head1 BUGS AND LIMITATIONS

No bugs have been reported.

Please report any bugs or feature requests through the web interface at
L<http://rt.cpan.org>.

=head1 INSTALLATION

See perlmodinstall for information and options on installing Perl modules.

=head1 AVAILABILITY

The latest version of this module is available from the Comprehensive Perl
Archive Network (CPAN). Visit L<http://www.perl.com/CPAN/> to find a CPAN
site near you. Or see L<http://search.cpan.org/dist/Plack-Middleware-Debug/>.

The development version lives at L<http://github.com/miyagawa/plack-middleware-debug/>.
Instead of sending patches, please fork this project using the standard git
and github infrastructure.

=head1 AUTHORS

Marcel GrE<uuml>nauer, C<< <marcel@cpan.org> >>

Tatsuhiko Miyagawa, C<< <miyagawa@bulknews.net> >>

=head1 COPYRIGHT AND LICENSE

Copyright 2009 by Marcel GrE<uuml>nauer

This library is free software; you can redistribute it and/or modify
it under the same terms as Perl itself.

=cut