Permalink
Browse files

Merge branch 'franckcuny/master'

  • Loading branch information...
miyagawa committed May 4, 2010
2 parents b668ca2 + fc533b8 commit 3c76150093910d6adc0b4abf56b72067fa5a9a69
@@ -332,7 +332,7 @@ 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/hanekomu/plack-middleware-debug/>. Instead of sending
+L<http://github.com/miyagawa/plack-middleware-debug/>. Instead of sending
patches, please fork this project using the standard git and github
infrastructure.
@@ -77,6 +77,32 @@ sub render {
$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>
@@ -118,14 +144,30 @@ sub render_lines {
}
sub render_list_pairs {
- my ($self, $list) = @_;
- $self->render($list_template, { list => $list });
+ 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) = @_;
- my @hash = map { $_ => $hash->{$_} } sort keys %$hash;
- $self->render($list_template, { list => \@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;
@@ -192,7 +234,7 @@ 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/hanekomu/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.
@@ -65,7 +65,7 @@ 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/hanekomu/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.
@@ -47,7 +47,7 @@ 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/hanekomu/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.
@@ -49,7 +49,7 @@ 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/hanekomu/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.
@@ -0,0 +1,70 @@
+package Plack::Middleware::Debug::Parameters;
+use strict;
+use warnings;
+use Plack::Util::Accessor qw(elements);
+use parent qw/Plack::Middleware::Debug::Base/;
+use Plack::Request;
+
+sub prepare_app {
+ my $self = shift;
+ $self->elements( [qw/headers cookies get post session/] )
+ unless $self->elements;
+}
+
+sub run {
+ my ( $self, $env, $panel ) = @_;
+ return sub {
+ my $parameters;
+ my $request = Plack::Request->new($env);
+
+ $parameters = {
+ get => $request->query_parameters,
+ cookies => $request->cookies,
+ post => $request->body_parameters,
+ session => $env->{'psgix.session'},
+ headers => $request->headers,
+ };
+ $panel->title('Request Variables');
+ $panel->nav_title('Request Variables');
+ $panel->content( sub { $self->render_hash( $parameters, $self->elements ) } );
+ }
+}
+
+1;
+__END__
+
+=head1 NAME
+
+Plack::Middleware::Debug::Parameters - Parameters Panel
+
+=head1 SYNOPSIS
+
+ builder {
+ enable 'Debug'; # load defaults
+ enable 'Debug::DBITrace', elements => [qw/headers cookies/];
+ $app;
+ };
+
+=head1 DESCRIPTION
+
+return info about:
+
+=over 4
+
+=item request headers
+
+=item query parameters
+
+=item body parameters
+
+=item cookies
+
+=item session
+
+=back
+
+=head1 SEE ALSO
+
+L<Plack::Middleware::Debug>
+
+=cut
@@ -47,7 +47,7 @@ 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/hanekomu/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.
@@ -58,7 +58,7 @@ 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/hanekomu/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.
@@ -72,7 +72,7 @@ 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/hanekomu/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.

0 comments on commit 3c76150

Please sign in to comment.