Permalink
Browse files

Merge branch 'release/1.3079_03'

  • Loading branch information...
2 parents 3a02025 + f42ee0a commit e89439346f873fdc70f9eea7a647674dfccca488 Alexis Sukrieh committed Sep 10, 2011
View
13 CHANGES
@@ -1,4 +1,15 @@
-{{$NEXT}}
+1.3079_03 10.09.2011
+
+ [ ENHANCEMENTS ]
+ * Support XML::Simple configuration for serializing/deserializing
+ (Alberto Simões)
+ * Hard deprecate lots of stuff (Alberto Simões)
+
+ [ BUG FIXES ]
+ * Don't clobber TT INCLUDE_PATH if the user set it specifically in the
+ config file - Issue 643 (David Precious, reported by meraxes)
+ * Don't require a space after semi-colon delimiting multiple name=value
+ cookie pairs - Issue 642 (David Precious, reported by travisbeck)
1.3079_02 28.08.2011
View
@@ -5,7 +5,7 @@ use warnings;
use Carp;
use Cwd 'realpath';
-our $VERSION = '1.3079_02';
+our $VERSION = '1.3079_03';
our $AUTHORITY = 'SUKRIA';
use Dancer::App;
@@ -129,13 +129,13 @@ sub hook { Dancer::Hook->new(@_) }
sub layout {
Dancer::Deprecation->deprecated(reason => "use 'set layout => \"value\"'",
version => '1.3050',
- fatal => 0);
- set(layout => shift) }
+ fatal => 1);
+}
sub load { require $_ for @_ }
sub load_app { goto &_load_app } # goto doesn't add a call frame. So caller() will work as expected
sub logger {
- Dancer::Deprecation->deprecated(reason => "use 'set logger'",fatal => 0,version=>'1.3050');
- set(logger => @_)
+ Dancer::Deprecation->deprecated(reason => "use 'set logger => \"value\"'",
+ fatal => 1,version=>'1.3050');
}
sub mime { Dancer::MIME->instance() }
sub options { Dancer::App->current->registry->universal_add('options', @_) }
@@ -258,10 +258,11 @@ sub _init_script_dir {
my $LAYOUT_PRE_DANCER_1_2 = 1;
- # in bin/ or public/ we need to go one level upper to find the appdir
+ # in bin/ or public/ or t/ we need to go one level upper to find the appdir
$LAYOUT_PRE_DANCER_1_2 = 0
if ($script_dirs[$#script_dirs - 1] eq 'bin')
- or ($script_dirs[$#script_dirs - 1] eq 'public');
+ or ($script_dirs[$#script_dirs - 1] eq 'public')
+ or ($script_dirs[$#script_dirs - 1] eq 't');
my $appdir = $ENV{DANCER_APPDIR} || (
$LAYOUT_PRE_DANCER_1_2
@@ -1071,10 +1072,6 @@ To load multiple apps repeat load_app:
The old way of loading multiple apps in one go (load_app 'one', 'two';) is
deprecated.
-=head2 mime_type
-
-Deprecated. See L</mime>.
-
=head2 mime
Shortcut to access the instance object of L<Dancer::MIME>. You should
View
@@ -492,7 +492,7 @@ interpolate in the view (note that for convenience, the request, session, params
and vars are automatically accessible in the view, named C<request>, C<session>,
C<params> and C<vars>) - for example:
- before => sub { var time => localtime() };
+ before => sub { var time => scalar(localtime) };
get '/hello/:name' => sub {
my $name = params->{name};
View
@@ -31,7 +31,7 @@ sub parse_cookie_from_env {
return {} unless defined $env_str;
my $cookies = {};
- foreach my $cookie ( split( /[,;]\s/, $env_str ) ) {
+ foreach my $cookie ( split( /[,;]\s?/, $env_str ) ) {
# here, we don't want more than the 2 first elements
# a cookie string can contains something like:
# cookie_name="foo=bar"
View
@@ -21,23 +21,27 @@ sites-available/*site*):
<VirtualHost *:80>
ServerName www.example.com
DocumentRoot /srv/www.example.com/public
- ServerAdmin you@example.com
+ ServerAdmin you@example.com
- <Directory "/srv/www.example.com/public">
+ <Directory "/srv/www.example.com/public">
AllowOverride None
Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
Order allow,deny
Allow from all
AddHandler cgi-script .cgi
- </Directory>
+ </Directory>
- RewriteEngine On
- RewriteCond %{REQUEST_FILENAME} !-f
- RewriteRule ^(.*)$ /dispatch.fcgi$1 [QSA,L]
+ RewriteEngine On
+ RewriteCond %{REQUEST_FILENAME} !-f
+ RewriteRule ^(.*)$ /dispatch.cgi$1 [QSA,L]
ErrorLog /var/log/apache2/www.example.com-error.log
CustomLog /var/log/apache2/www.example.com-access_log common
- </VirtualHost>
+ </VirtualHost>
+
+Note that when using fast-cgi your rewrite rule should be:
+
+ RewriteRule ^(.*)$ /dispatch.fcgi$1 [QSA,L]
Here, the mod_rewrite magic for Pretty-URLs is directly put in Apache's configuration.
But if your web server supports .htaccess files, you can drop those lines in a .htaccess file.
@@ -77,7 +81,7 @@ Of course remember to update your rewrite rules, if you have set any:
=head2 Running stand-alone
At the simplest, your Dancer app can run standalone, operating as its own
-webserver using HTTP::Simple::PSGI.
+webserver using HTTP::Server::Simple::PSGI.
Simply fire up your app:
View
@@ -102,8 +102,7 @@ sub normalize_path {
}x;
$path =~ s{/\./}{/}g;
- $path =~ s{$seqregex}{}g;
- $path =~ s{$seqregex}{};
+ while ( $path =~ s{$seqregex}{} ) {}
return $path;
}
@@ -621,7 +621,7 @@ This is a possible webapp created with Dancer:
};
get '/hello/:name' => sub {
- "Hello ".params->{name}"
+ "Hello ".params->{name};
};
# run the webserver
View
@@ -5,7 +5,6 @@ use warnings;
use base 'Dancer::Object::Singleton';
use Dancer::Config;
-use Dancer::Deprecation;
use Carp;
use MIME::Types;
@@ -65,24 +64,6 @@ sub for_name {
return $self->custom_types->{lc $name} || $self->mime_type->mimeTypeOf(lc $name) || $self->default;
}
-sub add_mime_type {
- Dancer::Deprecation->deprecated(feature => 'add_mime_type',
- fatal => 1,
- reason => 'use the new "add" method');
-}
-
-sub add_mime_alias {
- Dancer::Deprecation->deprecated(feature => 'add_mime_alias',
- fatal => 1,
- reason => 'use the new "add_alias" method');
-}
-
-sub mime_type_for {
- Dancer::Deprecation->deprecated(feature => 'mime_type_for',
- fatal => 1,
- reason => 'use the new "name_or_type" method');
-}
-
42;
@@ -165,20 +146,6 @@ Retrieve the full hash table of added mime types.
Resolves the $thing into a content $type whether it's the name of a
MIME type like "txt" or already a mime type like "text/plain".
-=head1 DEPRECATED API
-
-=head2 add_mime_type
-
-Check the new C<add> method.
-
-=head2 add_mime_alias
-
-Check the new C<add> method.
-
-=head2 mime_type_for
-
-Check the new C<for_name> and C<name_or_type> methods.
-
=head1 AUTHORS
This module has been written and rewritten by different people from
View
@@ -34,14 +34,20 @@ sub register($&) {
my $plugin_name = caller();
$keyword =~ /^[a-zA-Z_]+[a-zA-Z0-9_]*$/
- or croak "You can't use '$keyword', it is an invalid name (it should match ^[a-zA-Z_]+[a-zA-Z0-9_]*$ )";
-
- if (grep { $_ eq $keyword } map { s/^(?:\$|%|&|@|\*)//; $_ } (@Dancer::EXPORT, @Dancer::EXPORT_OK)) {
+ or croak "You can't use '$keyword', it is an invalid name"
+ . " (it should match ^[a-zA-Z_]+[a-zA-Z0-9_]*$ )";
+
+ if (
+ grep { $_ eq $keyword }
+ map { s/^(?:\$|%|&|@|\*)//; $_ }
+ (@Dancer::EXPORT, @Dancer::EXPORT_OK)
+ ) {
croak "You can't use '$keyword', this is a reserved keyword";
}
while (my ($plugin, $keywords) = each %$_keywords) {
if (grep { $_->[0] eq $keyword } @$keywords) {
- croak "You can't use $keyword, this is a keyword reserved by $plugin";
+ croak "You can't use $keyword, "
+ . "this is a keyword reserved by $plugin";
}
}
@@ -151,13 +157,20 @@ A Dancer plugin inherits from Dancer::Plugin and Exporter transparently.
=item B<plugin_setting>
-Configuration for plugin should be structured like this in the config.yaml of the application:
+Configuration for plugin should be structured like this in the config.yml of
+the application:
plugins:
plugin_name:
key: value
-If plugin_setting is called inside a plugin, the appropriate configuration will be returned. The plugin_name should be the name of the package, or, if the plugin name is under the B<Dancer::Plugin::> namespace, the remaining part of the plugin name. Enclose the remaining part in quotes if it contains ::, e.g. for B<Dancer::Plugin::Foo::Bar>, use:
+If C<plugin_setting> is called inside a plugin, the appropriate configuration
+will be returned. The C<plugin_name> should be the name of the package, or,
+if the plugin name is under the B<Dancer::Plugin::> namespace (which is
+recommended), the remaining part of the plugin name.
+
+Enclose the remaining part in quotes if it contains ::, e.g.
+for B<Dancer::Plugin::Foo::Bar>, use:
plugins:
"Foo::Bar":
View
@@ -37,7 +37,7 @@ sub new {
if (@args == 1) {
@args = ('env' => $args[0]);
Dancer::Deprecation->deprecated(
- fatal => 0,
+ fatal => 1,
feature => 'Calling Dancer::Request->new($env)',
version => 1.3059,
reason => 'Please use Dancer::Request->new( env => $env ) instead',
@@ -77,9 +77,9 @@ sub _options_as_hashref {
else {
Dancer::Deprecation->deprecated(
version => '1.3002',
+ fatal => 1,
message => 'options as hash for to_json/from_json is DEPRECATED. please pass a hashref',
);
- return { @_ };
}
}
@@ -4,6 +4,7 @@ use strict;
use warnings;
use Carp;
use Dancer::ModuleLoader;
+use Dancer::Config 'setting';
use base 'Dancer::Serializer::Abstract';
# singleton for the XML::Simple object
@@ -45,13 +46,31 @@ sub init {
sub serialize {
my $self = shift;
my $entity = shift;
- my %options = (RootName => 'data', @_);
+ my %options = (RootName => 'data');
+
+ my $s = setting('engines') || {};
+ if (exists($s->{XMLSerializer}) && exists($s->{XMLSerializer}{serialize})) {
+ %options = (%options, %{$s->{XMLSerializer}{serialize}});
+ }
+
+ %options = (%options, @_);
+
+
$_xs->XMLout($entity, %options);
}
sub deserialize {
my $self = shift;
- $_xs->XMLin(@_);
+ my $xml = shift;
+ my %options = ();
+
+ my $s = setting('engines') || {};
+ if (exists($s->{XMLSerializer}) && exists($s->{XMLSerializer}{deserialize})) {
+ %options = (%options, %{$s->{XMLSerializer}{deserialize}});
+ }
+
+ %options = (%options, @_);
+ $_xs->XMLin($xml, %options);
}
sub content_type {'text/xml'}
@@ -80,3 +99,15 @@ Deserialize a XML structure to a data structure
=head2 content_type
Return 'text/xml'
+
+=head2 CONFIG FILE
+
+You can set XML::Simple options for serialize and deserialize in the
+config file:
+
+ engines:
+ XMLSerializer:
+ serialize:
+ AttrIndent: 1
+ deserialize:
+ ForceArray: 1
@@ -5,7 +5,6 @@ use warnings;
use Carp;
use Dancer::Factory::Hook;
-use Dancer::Deprecation;
use Dancer::FileUtils 'path';
use base 'Dancer::Engine';
@@ -123,17 +122,6 @@ sub _prepare_tokens_options {
return ($tokens, $options);
}
-sub _render_with_layout {
- my ($class, $content, $tokens, $options) = @_;
-
- Dancer::Deprecation::deprecated(
- feature => 'render_with_layout',
- version => '1.3000',
- fatal => 1,
- reason => "use the 'engine' keyword to get the template engine, and use 'apply_layout' on the result",
- );
-}
-
sub template {
my ($class, $view, $tokens, $options) = @_;
my ($content, $full_content);
@@ -38,7 +38,7 @@ sub init {
$tt_config->{START_TAG} = $start_tag if $start_tag ne '[%';
$tt_config->{END_TAG} = $stop_tag if $stop_tag ne '%]';
- $tt_config->{INCLUDE_PATH} = setting('views');
+ $tt_config->{INCLUDE_PATH} ||= setting('views');
$_engine = $class->new(%$tt_config);
}
Oops, something went wrong.

0 comments on commit e894393

Please sign in to comment.