Skip to content

Commit

Permalink
Merge branch 'release/1.3079_04'
Browse files Browse the repository at this point in the history
  • Loading branch information
xsawyerx committed Oct 2, 2011
2 parents e894393 + 2775010 commit ce7b0de
Show file tree
Hide file tree
Showing 8 changed files with 67 additions and 18 deletions.
10 changes: 10 additions & 0 deletions CHANGES
@@ -1,3 +1,13 @@
1.3079_04 02.10.2011

[ ENHANCEMENTS ]
* PSGI handler code cleaned up (chromatic).
* Improved warning localizations (chromatic).

[ DOCUMENTATION ]
* Dancer::Plugins typos (Olof Johansson).
* PSGI handler documented (chromatic).

1.3079_03 10.09.2011

[ ENHANCEMENTS ]
Expand Down
8 changes: 7 additions & 1 deletion lib/Dancer.pm
Expand Up @@ -5,7 +5,7 @@ use warnings;
use Carp;
use Cwd 'realpath';

our $VERSION = '1.3079_03';
our $VERSION = '1.3079_04';
our $AUTHORITY = 'SUKRIA';

use Dancer::App;
Expand Down Expand Up @@ -1582,6 +1582,12 @@ For example, to disable the layout for a specific request:
template 'index.tt', {}, { layout => undef };
};
Or to request a specific layout, of course:
get '/user' => sub {
template 'user.tt', {}, { layout => 'user' };
};
Some tokens are automatically added to your template (C<perl_version>,
C<dancer_version>, C<settings>, C<request>, C<params>, C<vars> and, if
you have sessions enabled, C<session>). Check
Expand Down
3 changes: 3 additions & 0 deletions lib/Dancer/Config.pm
Expand Up @@ -417,6 +417,9 @@ use Template Toolkit, add the following to C<config.yml>:
The name of the layout to use when rendering view. Dancer will look for
a matching template in the directory $views/layout.
Your can override the default layout using the third argument of the
C<template> keyword. Check C<Dancer> manpage for details.
=head2 Logging, debugging and error handling
Expand Down
46 changes: 36 additions & 10 deletions lib/Dancer/Handler/PSGI.pm
Expand Up @@ -20,7 +20,6 @@ sub new {

my $self = {};
bless $self, $class;
return $self;
}

sub start {
Expand Down Expand Up @@ -51,7 +50,7 @@ sub apply_plack_middlewares_map {

while ( my ( $path, $mw ) = each %$mw_map ) {
my $builder = Plack::Builder->new();
map { $builder->add_middleware(@$_) } @$mw;
$builder->add_middleware(@$_) for @$mw;
$urlmap->map( $path => $builder->to_app($app) );
}

Expand All @@ -67,19 +66,17 @@ sub apply_plack_middlewares {
croak "Plack::Builder is needed for middlewares support"
unless Dancer::ModuleLoader->load('Plack::Builder');

my $builder = Plack::Builder->new();

ref $middlewares eq "ARRAY"
or croak "'plack_middlewares' setting must be an ArrayRef";

map {
Dancer::Logger::core "add middleware " . $_->[0];
$builder->add_middleware(@$_)
} @$middlewares;
my $builder = Plack::Builder->new();

$app = $builder->to_app($app);
for my $mw (@$middlewares) {
Dancer::Logger::core "add middleware " . $mw->[0];
$builder->add_middleware(@$mw)
}

return $app;
return $builder->to_app($app);
}

sub init_request_headers {
Expand All @@ -89,3 +86,32 @@ sub init_request_headers {
}

1;
__END__
=pod
=head1 NAME
Dancer::Handler::PSGI - a PSGI handler for Dancer applications
=head1 DESCRIPTION
This handler allows Dancer applications to run as part of PSGI stacks. Dancer
will automatically determine when running in a PSGI environment and enable this
handler, such that calling C<dance> will return a valid PSGI application.
You may enable Plack middleware in your configuration file under the
C<plack_middlewares> key. See L<Dancer::Cookbook> for more information.
Note that you must have L<Plack> installed for this handler to work.
=head1 USAGE
# in bin/app.pl
set apphandler => 'Debug';
# then, run the app the following way
perl -d bin/app.pl GET '/some/path/to/test' 'with=parameters&other=42'
=head1 AUTHORS
Dancer contributors
2 changes: 1 addition & 1 deletion lib/Dancer/Plugins.pod
Expand Up @@ -87,7 +87,7 @@ Provides dead-simple profiling of your app using L<Devel::NYTProf> - enables
profiling for each request individually, serves up a list of profiling runs, and
generates & sends the HTML reports produced by C<nytprofhtml>.

=item L<Dancer::Plugin::Bcypt>
=item L<Dancer::Plugin::Bcrypt>

Provides simple effective password hashing and validation using Bcrypt.

Expand Down
6 changes: 4 additions & 2 deletions lib/Dancer/Route.pm
Expand Up @@ -236,8 +236,10 @@ sub execute {

if (Dancer::Config::setting('warnings')) {
my $warning;
local $SIG{__WARN__} = sub { $warning = $_[0] };
my $content = $self->code->();
my $content = do {
local $SIG{__WARN__} = sub { $warning = $_[0] };
$self->code->();
};
if ($warning) {
return Dancer::Error->new(
code => 500,
Expand Down
2 changes: 1 addition & 1 deletion t/00_base/14_changelog.t
Expand Up @@ -13,7 +13,7 @@ unless ( $ENV{RELEASE_TESTING} ) {
my $changelog_filename = 'CHANGES';

# don't check for versions older or equal to this
my $stop_checking_version = '1.3071';
my $stop_checking_version = '1.3079_03';

# ordered list of possible sections
my @possible_sections = ('SECURITY', 'API CHANGES', 'BUG FIXES', 'ENHANCEMENTS', 'DOCUMENTATION', );
Expand Down
8 changes: 5 additions & 3 deletions t/11_logger/05_format.t
Expand Up @@ -63,7 +63,9 @@ $str = $l->format_message('debug', 'this is debug');
like $str, qr/\[text\/html\] this is debug/;

my $warn;
local $SIG{__WARN__} = sub { $warn = $_[0] };
setting logger_format => '%y';
$str = $l->format_message('debug', 'this is sparta');
do {
local $SIG{__WARN__} = sub { $warn = $_[0] };
setting logger_format => '%y';
$str = $l->format_message('debug', 'this is sparta');
};
like $warn, qr/%y not supported/;

0 comments on commit ce7b0de

Please sign in to comment.