Permalink
Browse files

Merge branch 'release/1.3079_04'

  • Loading branch information...
2 parents e894393 + 2775010 commit ce7b0dee0fd867793e34a3929d889a07227ee40d @xsawyerx xsawyerx committed Oct 2, 2011
Showing with 67 additions and 18 deletions.
  1. +10 −0 CHANGES
  2. +7 −1 lib/Dancer.pm
  3. +3 −0 lib/Dancer/Config.pm
  4. +36 −10 lib/Dancer/Handler/PSGI.pm
  5. +1 −1 lib/Dancer/Plugins.pod
  6. +4 −2 lib/Dancer/Route.pm
  7. +1 −1 t/00_base/14_changelog.t
  8. +5 −3 t/11_logger/05_format.t
View
10 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 ]
View
@@ -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;
@@ -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
View
@@ -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
View
@@ -20,7 +20,6 @@ sub new {
my $self = {};
bless $self, $class;
- return $self;
}
sub start {
@@ -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) );
}
@@ -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 {
@@ -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
View
@@ -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.
View
@@ -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,
View
@@ -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', );
View
@@ -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.