r68359 - in /branches/upstream/libdancer-perl/current: ./ examples/dancr/ lib/ lib/Dancer/ lib/Dancer/Handler/ script/ t/00_base/ t/03_route_handler/ t/12_response/
ghedo-guest at users.alioth.debian.org
ghedo-guest at users.alioth.debian.org
Fri Feb 11 13:58:50 UTC 2011
Author: ghedo-guest
Date: Fri Feb 11 13:58:17 2011
New Revision: 68359
URL: http://svn.debian.org/wsvn/pkg-perl/?sc=1&rev=68359
Log:
[svn-upgrade] new version libdancer-perl (1.3010+dfsg)
Modified:
branches/upstream/libdancer-perl/current/CHANGES
branches/upstream/libdancer-perl/current/META.yml
branches/upstream/libdancer-perl/current/examples/dancr/dancr.pl
branches/upstream/libdancer-perl/current/lib/Dancer.pm
branches/upstream/libdancer-perl/current/lib/Dancer/Cookbook.pod
branches/upstream/libdancer-perl/current/lib/Dancer/FileUtils.pm
branches/upstream/libdancer-perl/current/lib/Dancer/Handler/Standalone.pm
branches/upstream/libdancer-perl/current/lib/Dancer/Request.pm
branches/upstream/libdancer-perl/current/lib/Dancer/Tutorial.pod
branches/upstream/libdancer-perl/current/script/dancer
branches/upstream/libdancer-perl/current/t/00_base/11_file_utils.t
branches/upstream/libdancer-perl/current/t/03_route_handler/06_regexp.t
branches/upstream/libdancer-perl/current/t/12_response/04_charset_server.t
Modified: branches/upstream/libdancer-perl/current/CHANGES
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libdancer-perl/current/CHANGES?rev=68359&op=diff
==============================================================================
--- branches/upstream/libdancer-perl/current/CHANGES (original)
+++ branches/upstream/libdancer-perl/current/CHANGES Fri Feb 11 13:58:17 2011
@@ -1,3 +1,27 @@
+1.3010 10.02.2011
+
+ [ BUG FIXES ]
+ * GH#303: Generated Makefile.PL's clean is done correctly now.
+ (Sawyer X)
+ * Minimum version of HTTP::Headers to avoid test fails.
+ (LoonyPandora)
+ * Do not require JSON to get version number (fixes tests).
+ (Sawyer X)
+
+ [ ENHANCEMENTS ]
+ * Allow read_file DWIMishness using wantarray.
+ (LoonyPandora)
+ * Tidy up Dancer.pm
+ (Damien Krotkine)
+ * Document forward should use return.
+ (Sawyer X)
+ * GH#290: Use return with redirect examples in docs.
+ (Damien Krotkine)
+ * Document that base() returns a URI object.
+ (David Precious)
+ * Show version when starting standalone server.
+ (David Precious)
+
1.3003 06.02.2011
[ API CHANGES ]
Modified: branches/upstream/libdancer-perl/current/META.yml
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libdancer-perl/current/META.yml?rev=68359&op=diff
==============================================================================
--- branches/upstream/libdancer-perl/current/META.yml (original)
+++ branches/upstream/libdancer-perl/current/META.yml Fri Feb 11 13:58:17 2011
@@ -1,6 +1,6 @@
--- #YAML:1.0
name: Dancer
-version: 1.3003
+version: 1.3010
abstract: A minimal-effort oriented web application framework
author: []
license: perl
@@ -8,7 +8,7 @@
configure_requires:
ExtUtils::MakeMaker: 0
build_requires:
- ExtUtils::MakeMaker: 0
+ Test::More: 0.88
requires:
Encode: 0
File::Basename: 0
@@ -17,7 +17,6 @@
HTTP::Server::Simple::PSGI: 0.11
LWP: 0
MIME::Types: 0
- Test::More: 0.88
Time::HiRes: 0
URI: 0
resources:
@@ -28,7 +27,7 @@
directory:
- t
- inc
-generated_by: ExtUtils::MakeMaker version 6.55_02
+generated_by: ExtUtils::MakeMaker version 6.56
meta-spec:
url: http://module-build.sourceforge.net/META-spec-v1.4.html
version: 1.4
Modified: branches/upstream/libdancer-perl/current/examples/dancr/dancr.pl
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libdancer-perl/current/examples/dancr/dancr.pl?rev=68359&op=diff
==============================================================================
--- branches/upstream/libdancer-perl/current/examples/dancr/dancr.pl (original)
+++ branches/upstream/libdancer-perl/current/examples/dancr/dancr.pl Fri Feb 11 13:58:17 2011
@@ -94,7 +94,7 @@
else {
session 'logged_in' => true;
set_flash('You are logged in.');
- redirect '/';
+ return redirect '/';
}
}
Modified: branches/upstream/libdancer-perl/current/lib/Dancer.pm
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libdancer-perl/current/lib/Dancer.pm?rev=68359&op=diff
==============================================================================
--- branches/upstream/libdancer-perl/current/lib/Dancer.pm (original)
+++ branches/upstream/libdancer-perl/current/lib/Dancer.pm Fri Feb 11 13:58:17 2011
@@ -7,7 +7,7 @@
use vars qw($VERSION $AUTHORITY @EXPORT);
-$VERSION = '1.3003';
+$VERSION = '1.3010';
$AUTHORITY = 'SUKRIA';
use Dancer::Config;
@@ -99,9 +99,9 @@
# Dancer's syntax
-sub after { Dancer::Route::Registry->hook('after', @_) }
+sub after { Dancer::Route::Registry->hook('after', @_) }
sub any { Dancer::App->current->registry->any_add(@_) }
-sub before { Dancer::Route::Registry->hook('before', @_) }
+sub before { Dancer::Route::Registry->hook('before', @_) }
sub before_template { Dancer::Route::Registry->hook('before_template', @_) }
sub captures { Dancer::SharedData->request->params->{captures} }
sub cookies { Dancer::Cookies->cookies }
@@ -113,54 +113,41 @@
sub engine { Dancer::Engine->engine(@_) }
sub error { goto &Dancer::Logger::error }
sub send_error { Dancer::Helpers->error(@_) }
-sub false {0}
+sub false { 0 }
sub forward { Dancer::Response->forward(shift) }
sub from_dumper { Dancer::Serializer::Dumper::from_dumper(@_) }
sub from_json { Dancer::Serializer::JSON::from_json(@_) }
sub from_yaml { Dancer::Serializer::YAML::from_yaml(@_) }
sub from_xml { Dancer::Serializer::XML::from_xml(@_) }
-
-sub get {
- Dancer::App->current->registry->universal_add('head', @_);
- Dancer::App->current->registry->universal_add('get', @_);
-}
-sub halt { Dancer::Response->halt(@_) }
-sub headers { Dancer::Response->headers(@_); }
-sub header { goto &headers; } # goto ftw!
-sub layout { set(layout => shift) }
-sub load { require $_ for @_ }
-sub logger { set(logger => @_) }
-sub mime_type {
+sub get { map { my $r = $_; Dancer::App->current->registry->universal_add($r, @_) } qw(head get) }
+sub halt { Dancer::Response->halt(@_) }
+sub headers { Dancer::Response->headers(@_) }
+sub header { goto &headers }
+sub layout { set(layout => shift) }
+sub load { require $_ for @_ }
+sub logger { set(logger => @_) }
+sub mime_type {
my $mime = Dancer::MIME->instance();
if (scalar(@_)==2) { $mime->add_mime_type(@_) }
elsif (scalar(@_)==1) { $mime->mime_type_for(@_) }
else { $mime->aliases }
}
-sub params { Dancer::SharedData->request->params(@_) }
-sub pass { Dancer::Response->pass }
-sub path { realpath(Dancer::FileUtils::path(@_)) }
-sub post { Dancer::App->current->registry->universal_add('post', @_) }
-sub prefix { Dancer::App->current->set_prefix(@_) }
-sub del { Dancer::App->current->registry->universal_add('delete', @_) }
-sub options { Dancer::App->current->registry->universal_add('options', @_) }
-sub put { Dancer::App->current->registry->universal_add('put', @_) }
-sub r { croak "'r' is DEPRECATED use qr{} instead"; }
-sub redirect { Dancer::Helpers::redirect(@_) }
-sub render_with_layout { Dancer::Helpers::render_with_layout(@_); }
-sub request { Dancer::SharedData->request }
-sub send_file { Dancer::Helpers::send_file(@_) }
-sub set { goto &setting }
-
-sub setting {
- if (Dancer::App->applications) {
- return Dancer::App->current->setting(@_);
- }
- else {
- return Dancer::Config::setting(@_);
- }
-}
-
-sub set_cookie { Dancer::Helpers::set_cookie(@_) }
+sub params { Dancer::SharedData->request->params(@_) }
+sub pass { Dancer::Response->pass }
+sub path { realpath(Dancer::FileUtils::path(@_)) }
+sub post { Dancer::App->current->registry->universal_add('post', @_) }
+sub prefix { Dancer::App->current->set_prefix(@_) }
+sub del { Dancer::App->current->registry->universal_add('delete', @_) }
+sub options { Dancer::App->current->registry->universal_add('options', @_) }
+sub put { Dancer::App->current->registry->universal_add('put', @_) }
+sub r { croak "'r' is DEPRECATED, use qr{} instead" }
+sub redirect { Dancer::Helpers::redirect(@_) }
+sub render_with_layout { Dancer::Helpers::render_with_layout(@_) }
+sub request { Dancer::SharedData->request }
+sub send_file { Dancer::Helpers::send_file(@_) }
+sub set { goto &setting }
+sub setting { Dancer::App->applications ? Dancer::App->current->setting(@_) : Dancer::Config::setting(@_) }
+sub set_cookie { Dancer::Helpers::set_cookie(@_) }
sub session {
croak "Must specify session engine in settings prior to using 'session' keyword" unless setting('session');
@@ -173,22 +160,19 @@
: Dancer::Session->write(@_);
}
}
-sub splat {
- my $splat = Dancer::SharedData->request->params->{splat};
- return ref $splat ? @$splat : ();
-}
-sub status { Dancer::Response->status(@_) }
-sub template { Dancer::Helpers::template(@_) }
-sub true {1}
-sub to_dumper { Dancer::Serializer::Dumper::to_dumper(@_) }
-sub to_json { Dancer::Serializer::JSON::to_json(@_) }
-sub to_yaml { Dancer::Serializer::YAML::to_yaml(@_) }
-sub to_xml { Dancer::Serializer::XML::to_xml(@_) }
-sub upload { Dancer::SharedData->request->upload(@_) }
-sub uri_for { Dancer::SharedData->request->uri_for(@_) }
-sub var { Dancer::SharedData->var(@_) }
-sub vars { Dancer::SharedData->vars }
-sub warning { goto &Dancer::Logger::warning }
+sub splat { @{ Dancer::SharedData->request->params->{splat} || [] } }
+sub status { Dancer::Response->status(@_) }
+sub template { Dancer::Helpers::template(@_) }
+sub true { 1 }
+sub to_dumper { Dancer::Serializer::Dumper::to_dumper(@_) }
+sub to_json { Dancer::Serializer::JSON::to_json(@_) }
+sub to_yaml { Dancer::Serializer::YAML::to_yaml(@_) }
+sub to_xml { Dancer::Serializer::XML::to_xml(@_) }
+sub upload { Dancer::SharedData->request->upload(@_) }
+sub uri_for { Dancer::SharedData->request->uri_for(@_) }
+sub var { Dancer::SharedData->var(@_) }
+sub vars { Dancer::SharedData->vars }
+sub warning { goto &Dancer::Logger::warning }
# FIXME handle previous usage of load_app with multiple app names
sub load_app {
@@ -519,6 +503,21 @@
reached. If it was a B<GET>, it will remain a B<GET>.
Broader functionality might be added in the future.
+
+It is important to note that issuing a forward by itself does not exit and
+forward immediately, forwarding is deferred until after the current route
+or filter has been processed. To exit and forward immediately, use the return
+function, e.g.
+
+ get '/some/path => sub {
+ if ($condition) {
+ return forward '/articles/$article_id';
+ }
+
+ more_stuff();
+ };
+
+You probably always want to use C<return> with forward.
=head2 from_dumper ($structure)
Modified: branches/upstream/libdancer-perl/current/lib/Dancer/Cookbook.pod
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libdancer-perl/current/lib/Dancer/Cookbook.pod?rev=68359&op=diff
==============================================================================
--- branches/upstream/libdancer-perl/current/lib/Dancer/Cookbook.pod (original)
+++ branches/upstream/libdancer-perl/current/lib/Dancer/Cookbook.pod Fri Feb 11 13:58:17 2011
@@ -543,6 +543,44 @@
template_toolkit:
ENCODING: utf8
+=head3 TT's WRAPPER directive in Dancer (META variables, SETs)
+
+Dancer provides a WRAPPER ability, which we call a "layout". The reason we do
+not use TT's WRAPPER (and that it is incompatible with it) is since not all
+template systems support it. Actually, most don't.
+
+However, you might want to use it, and be able to define META variables and
+regular L<Template::Toolkit> variables.
+
+These few steps will get you there:
+
+=over 4
+
+=item * Disable the layout in Dancer
+
+You can do this by simply commenting (or removing) the C<layout> configuration
+in the F<config.yml> file.
+
+=item * Use Template Toolkit template engine
+
+Change the configuration of the template to Template Toolkit:
+
+ # in config.yml
+ template: "template_toolkit"
+
+=item * Tell the Template Toolkit engine who's your wrapper
+
+ # in config.yml
+ # ...
+ engines:
+ template_toolkit:
+ WRAPPER: layouts/main.tt
+
+=back
+
+Done! Everything will work fine out of the box, including variables and META
+variables.
+
=head2 Configuration and environments
Configuring a Dancer application can be done in many ways. The easiest one (and
Modified: branches/upstream/libdancer-perl/current/lib/Dancer/FileUtils.pm
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libdancer-perl/current/lib/Dancer/FileUtils.pm?rev=68359&op=diff
==============================================================================
--- branches/upstream/libdancer-perl/current/lib/Dancer/FileUtils.pm (original)
+++ branches/upstream/libdancer-perl/current/lib/Dancer/FileUtils.pm Fri Feb 11 13:58:17 2011
@@ -32,7 +32,8 @@
if ($file) {
$fh = open_file('<', $file);
- return read_glob_content($fh);
+
+ return wantarray ? read_glob_content($fh) : scalar read_glob_content($fh);
}
else {
return;
@@ -47,8 +48,8 @@
my @content = <$fh>;
close $fh;
- my $content = join("", @content);
- return $content;
+
+ return wantarray ? @content : join("", @content);
}
'Dancer::FileUtils';
@@ -66,12 +67,13 @@
use Dancer::FileUtils qw/path read_file_content/;
my $content = read_file_content( path( 'folder', 'folder', 'file' ) );
+ my @content = read_file_content( path( 'folder', 'folder', 'file' ) );
=head1 DESCRIPTION
-Dancer::FileUtils encompasses a few utilities that relate to files which Dancer
-uses. Developers may use it instead of writing their own little subroutines or
-use additional modules.
+Dancer::FileUtils includes a few file related utilities related that Dancer
+uses internally. Developers may use it instead of writing their own
+file reading subroutines or using additional modules.
=head1 SUBROUTINES/METHODS
@@ -105,9 +107,13 @@
use Dancer::FileUtils 'read_file_content';
my $content = read_file_content($file);
+ my @content = read_file_content($file);
-Returns either the content of a file (whose filename is the input) or I<undef>
-in case it failed to open the file.
+Returns either the content of a file (whose filename is the input), I<undef>
+if the file could not be opened.
+
+In array context it returns each line (as defined by $/) as a seperate element
+Scalar context returns the entire contents of the file.
=head2 read_glob_content
@@ -115,6 +121,7 @@
open my $fh, '<', $file or die "$!\n";
my $content = read_glob_content($fh);
+ my @content = read_glob_content($fh);
Same as I<read_file_content>, only it accepts a file handle.
Modified: branches/upstream/libdancer-perl/current/lib/Dancer/Handler/Standalone.pm
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libdancer-perl/current/lib/Dancer/Handler/Standalone.pm?rev=68359&op=diff
==============================================================================
--- branches/upstream/libdancer-perl/current/lib/Dancer/Handler/Standalone.pm (original)
+++ branches/upstream/libdancer-perl/current/lib/Dancer/Handler/Standalone.pm Fri Feb 11 13:58:17 2011
@@ -29,13 +29,15 @@
if (setting('daemon')) {
my $pid = $dancer->background();
print STDERR
- ">> Dancer server $pid listening on http://$ipaddr:$port\n"
- if setting('access_log');
+ ">> Dancer $Dancer::VERSION server $pid listening"
+ . "on http://$ipaddr:$port\n"
+ if setting('access_log');
return $pid;
}
else {
- print STDERR ">> Dancer server $$ listening on http://$ipaddr:$port\n"
- if setting('access_log');
+ print STDERR ">> Dancer $Dancer::VERSION server $$ listening"
+ ." on http://$ipaddr:$port\n"
+ if setting('access_log');
$dancer->run();
}
}
Modified: branches/upstream/libdancer-perl/current/lib/Dancer/Request.pm
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libdancer-perl/current/lib/Dancer/Request.pm?rev=68359&op=diff
==============================================================================
--- branches/upstream/libdancer-perl/current/lib/Dancer/Request.pm (original)
+++ branches/upstream/libdancer-perl/current/lib/Dancer/Request.pm Fri Feb 11 13:58:17 2011
@@ -578,14 +578,16 @@
=head2 base()
-Returns an absolute URI for the base of the application
+Returns an absolute URI for the base of the application. Returns a L<URI>
+object (which stringifies to the URL, as you'd expect).
=head2 uri_for(path, params)
Constructs a URI from the base and the passed path. If params (hashref) is
supplied, these are added to the query string of the uri. If the base is
C<http://localhost:5000/foo>, C<< request->uri_for('/bar', { baz => 'baz' }) >>
-would return C<http://localhost:5000/foo/bar?baz=baz>.
+would return C<http://localhost:5000/foo/bar?baz=baz>. Returns a L<URI> object
+(which stringifies to the URL, as you'd expect).
=head2 params($source)
Modified: branches/upstream/libdancer-perl/current/lib/Dancer/Tutorial.pod
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libdancer-perl/current/lib/Dancer/Tutorial.pod?rev=68359&op=diff
==============================================================================
--- branches/upstream/libdancer-perl/current/lib/Dancer/Tutorial.pod (original)
+++ branches/upstream/libdancer-perl/current/lib/Dancer/Tutorial.pod Fri Feb 11 13:58:17 2011
@@ -279,7 +279,7 @@
else {
session 'logged_in' => true;
set_flash('You are logged in.');
- redirect '/';
+ return redirect '/';
}
}
@@ -528,7 +528,7 @@
else {
session 'logged_in' => true;
set_flash('You are logged in.');
- redirect '/';
+ return redirect '/';
}
}
Modified: branches/upstream/libdancer-perl/current/script/dancer
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libdancer-perl/current/script/dancer?rev=68359&op=diff
==============================================================================
--- branches/upstream/libdancer-perl/current/script/dancer (original)
+++ branches/upstream/libdancer-perl/current/script/dancer Fri Feb 11 13:58:17 2011
@@ -234,11 +234,11 @@
my $resp = send_http_request('http://search.cpan.org/api/module/Dancer');
if ($resp) {
- my $data;
- eval { $data = Dancer::from_json($resp) };
- $data or die "Can't understand search.cpan.org's reply.\n";
-
- $latest_version = $data->{'version'};
+ if ( $resp =~ /"version" (?:\s+)? \: (?:\s+)? "(\d\.\d+)"/x ) {
+ $latest_version = $1;
+ } else {
+ die "Can't understand search.cpan.org's reply.\n";
+ }
}
return if $DANCER_VERSION =~ m/_/;
@@ -264,10 +264,12 @@
}
sub templates($) {
- my $appname = shift;
- my $appfile = $appname;
-
- $appfile =~ s{::}{/}g;
+ my $appname = shift;
+ my $appfile = $appname;
+ my $cleanfiles = $appname;
+
+ $appfile =~ s{::}{/}g;
+ $cleanfiles =~ s{::}{-}g;
return {
@@ -291,7 +293,7 @@
'Dancer' => [% dancer_version %],
},
dist => { COMPRESS => 'gzip -9f', SUFFIX => 'gz', },
- clean => { FILES => '$appname-*' },
+ clean => { FILES => '$cleanfiles-*' },
);
",
'index.tt' =>
Modified: branches/upstream/libdancer-perl/current/t/00_base/11_file_utils.t
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libdancer-perl/current/t/00_base/11_file_utils.t?rev=68359&op=diff
==============================================================================
--- branches/upstream/libdancer-perl/current/t/00_base/11_file_utils.t (original)
+++ branches/upstream/libdancer-perl/current/t/00_base/11_file_utils.t Fri Feb 11 13:58:17 2011
@@ -1,10 +1,24 @@
+use Test::More import => ['!pass'];
+use File::Spec;
+use File::Temp;
+
+use Dancer ':syntax';
+use Dancer::FileUtils qw/read_file_content/;
+
+use lib File::Spec->catdir( 't', 'lib' );
+use TestUtils;
+
use strict;
use warnings;
-use Test::More;
-plan tests => 1;
+plan tests => 2;
-use Dancer::FileUtils qw/read_file_content/;
-my $content = read_file_content();
-ok !$content;
+my $tmp = File::Temp->new();
+write_file($tmp, "one$/two");
+
+my $content = read_file_content($tmp);
+ok $content = "one$/two";
+
+my @content = read_file_content($tmp);
+ok $content[0] eq "one$/" && $content[1] eq 'two';
Modified: branches/upstream/libdancer-perl/current/t/03_route_handler/06_regexp.t
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libdancer-perl/current/t/03_route_handler/06_regexp.t?rev=68359&op=diff
==============================================================================
--- branches/upstream/libdancer-perl/current/t/03_route_handler/06_regexp.t (original)
+++ branches/upstream/libdancer-perl/current/t/03_route_handler/06_regexp.t Fri Feb 11 13:58:17 2011
@@ -8,7 +8,7 @@
eval {
get r('/foo') => sub { "foo" };
};
-like $@, qr/'r' is DEPRECATED use qr{} instead/,
+like $@, qr/'r' is DEPRECATED, use qr{} instead/,
"DEPRECATED exception triggered by r()";
ok(get(qr{/hello/([\w]+)} => sub { [splat] }), 'first route set');
Modified: branches/upstream/libdancer-perl/current/t/12_response/04_charset_server.t
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libdancer-perl/current/t/12_response/04_charset_server.t?rev=68359&op=diff
==============================================================================
--- branches/upstream/libdancer-perl/current/t/12_response/04_charset_server.t (original)
+++ branches/upstream/libdancer-perl/current/t/12_response/04_charset_server.t Fri Feb 11 13:58:17 2011
@@ -5,10 +5,15 @@
use Dancer;
use Encode;
+# Ensure a recent version of HTTP::Headers
+my $min_hh = 5.827;
+plan skip_all => "HTTP::Headers $min_hh required (use of content_type_charset)"
+ unless Dancer::ModuleLoader->load( 'HTTP::Headers', $min_hh );
plan skip_all => "HTTP::Request::Common is needed for this test"
unless Dancer::ModuleLoader->load('HTTP::Request::Common');
plan skip_all => "Test::TCP is needed for this test"
unless Dancer::ModuleLoader->load("Test::TCP");
+
use LWP::UserAgent;
More information about the Pkg-perl-cvs-commits
mailing list