Hello community,
here is the log from the commit of package perl-Mojolicious for openSUSE:Factory checked in at 2015-03-16 07:01:02
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Comparing /work/SRC/openSUSE:Factory/perl-Mojolicious (Old)
and /work/SRC/openSUSE:Factory/.perl-Mojolicious.new (New)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "perl-Mojolicious"
Changes:
--------
--- /work/SRC/openSUSE:Factory/perl-Mojolicious/perl-Mojolicious.changes 2015-03-03 11:15:14.000000000 +0100
+++ /work/SRC/openSUSE:Factory/.perl-Mojolicious.new/perl-Mojolicious.changes 2015-03-16 07:01:13.000000000 +0100
@@ -1,0 +2,13 @@
+Thu Mar 12 13:55:35 UTC 2015 - coolo@suse.com
+
+- updated to 6.02
+ - Added daemon attribute to Mojo::Server::Morbo.
+ - Improved portability of Mojo::Server::Morbo.
+ - Fixed empty template handling in Mojo::Template.
+
+ 6.01 2015-03-03
+ - Added content_with helper to Mojolicious::Plugin::DefaultHelpers.
+ - Relaxed request-line handling in Mojo::Message::Request.
+ - Fixed code name in version command and built-in templates.
+
+-------------------------------------------------------------------
Old:
----
Mojolicious-6.0.tar.gz
New:
----
Mojolicious-6.02.tar.gz
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Other differences:
------------------
++++++ perl-Mojolicious.spec ++++++
--- /var/tmp/diff_new_pack.IbbnLg/_old 2015-03-16 07:01:14.000000000 +0100
+++ /var/tmp/diff_new_pack.IbbnLg/_new 2015-03-16 07:01:14.000000000 +0100
@@ -17,7 +17,7 @@
Name: perl-Mojolicious
-Version: 6.0
+Version: 6.02
Release: 0
%define cpan_name Mojolicious
Summary: Real-time web framework
++++++ Mojolicious-6.0.tar.gz -> Mojolicious-6.02.tar.gz ++++++
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Mojolicious-6.0/Changes new/Mojolicious-6.02/Changes
--- old/Mojolicious-6.0/Changes 2015-02-26 06:57:34.000000000 +0100
+++ new/Mojolicious-6.02/Changes 2015-03-10 01:26:27.000000000 +0100
@@ -1,4 +1,14 @@
+6.02 2015-03-09
+ - Added daemon attribute to Mojo::Server::Morbo.
+ - Improved portability of Mojo::Server::Morbo.
+ - Fixed empty template handling in Mojo::Template.
+
+6.01 2015-03-03
+ - Added content_with helper to Mojolicious::Plugin::DefaultHelpers.
+ - Relaxed request-line handling in Mojo::Message::Request.
+ - Fixed code name in version command and built-in templates.
+
6.0 2015-02-26
- Code name "Clinking Beer Mugs", this is a major release.
- Removed name listing support from param method in Mojolicious::Controller.
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Mojolicious-6.0/META.json new/Mojolicious-6.02/META.json
--- old/Mojolicious-6.0/META.json 2015-02-26 23:16:00.000000000 +0100
+++ new/Mojolicious-6.02/META.json 2015-03-10 03:52:12.000000000 +0100
@@ -4,7 +4,7 @@
"Sebastian Riedel "
],
"dynamic_config" : 1,
- "generated_by" : "ExtUtils::MakeMaker version 7.04, CPAN::Meta::Converter version 2.143240",
+ "generated_by" : "ExtUtils::MakeMaker version 7.04, CPAN::Meta::Converter version 2.150001",
"license" : [
"artistic_2"
],
@@ -54,5 +54,5 @@
},
"x_IRC" : "irc://irc.perl.org/#mojo"
},
- "version" : "6.0"
+ "version" : "6.02"
}
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Mojolicious-6.0/META.yml new/Mojolicious-6.02/META.yml
--- old/Mojolicious-6.0/META.yml 2015-02-26 23:16:00.000000000 +0100
+++ new/Mojolicious-6.02/META.yml 2015-03-10 03:52:12.000000000 +0100
@@ -7,7 +7,7 @@
configure_requires:
ExtUtils::MakeMaker: '0'
dynamic_config: 1
-generated_by: 'ExtUtils::MakeMaker version 7.04, CPAN::Meta::Converter version 2.143240'
+generated_by: 'ExtUtils::MakeMaker version 7.04, CPAN::Meta::Converter version 2.150001'
license: artistic_2
meta-spec:
url: http://module-build.sourceforge.net/META-spec-v1.4.html
@@ -29,4 +29,4 @@
homepage: http://mojolicio.us
license: http://www.opensource.org/licenses/artistic-license-2.0
repository: https://github.com/kraih/mojo.git
-version: '6.0'
+version: '6.02'
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Mojolicious-6.0/lib/Mojo/Message/Request.pm new/Mojolicious-6.02/lib/Mojo/Message/Request.pm
--- old/Mojolicious-6.0/lib/Mojo/Message/Request.pm 2015-02-24 23:56:28.000000000 +0100
+++ new/Mojolicious-6.02/lib/Mojo/Message/Request.pm 2015-03-02 22:28:04.000000000 +0100
@@ -10,12 +10,6 @@
has url => sub { Mojo::URL->new };
has 'reverse_proxy';
-my $START_LINE_RE = qr/
- ^([a-zA-Z]+) # Method
- \s+([0-9a-zA-Z!#\$\%&'()*+,\-.\/:;=?\@[\\\]^_`\{|\}~]+) # URL
- \s+HTTP\/(\d\.\d)$ # Version
-/x;
-
sub clone {
my $self = shift;
@@ -61,7 +55,7 @@
# We have a (hopefully) full request-line
return !$self->error({message => 'Bad request start-line'})
- unless $1 =~ $START_LINE_RE;
+ unless $1 =~ /^(\S+)\s+(\S+)\s+HTTP\/(\d\.\d)$/;
my $url = $self->method($1)->version($3)->url;
return !!($1 eq 'CONNECT' ? $url->authority($2) : $url->parse($2));
}
@@ -323,9 +317,9 @@
HTTP request URL, defaults to a LMojo::URL object.
# Get request information
- say $req->url->to_abs->userinfo;
- say $req->url->to_abs->host;
- say $req->url->to_abs->path;
+ my $info = $req->url->to_abs->userinfo;
+ my $host = $req->url->to_abs->host;
+ my $path = $req->url->to_abs->path;
=head2 reverse_proxy
@@ -353,6 +347,9 @@
Access request cookies, usually LMojo::Cookie::Request objects.
+ # Names of all cookies
+ say $_->name for @{$req->cookies};
+
=head2 every_param
my $values = $req->every_param('foo');
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Mojolicious-6.0/lib/Mojo/Message/Response.pm new/Mojolicious-6.02/lib/Mojo/Message/Response.pm
--- old/Mojolicious-6.0/lib/Mojo/Message/Response.pm 2015-02-24 23:56:35.000000000 +0100
+++ new/Mojolicious-6.02/lib/Mojo/Message/Response.pm 2015-02-27 06:31:47.000000000 +0100
@@ -211,6 +211,9 @@
Access response cookies, usually LMojo::Cookie::Response objects.
+ # Names of all cookies
+ say $_->name for @{$res->cookies};
+
=head2 default_message
my $msg = $res->default_message;
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Mojolicious-6.0/lib/Mojo/Message.pm new/Mojolicious-6.02/lib/Mojo/Message.pm
--- old/Mojolicious-6.0/lib/Mojo/Message.pm 2015-02-26 02:38:19.000000000 +0100
+++ new/Mojolicious-6.02/lib/Mojo/Message.pm 2015-02-27 06:33:12.000000000 +0100
@@ -651,6 +651,9 @@
All C file uploads, usually LMojo::Upload objects.
+ # Names of all uploads
+ say $_->name for @{$msg->uploads};
+
=head1 SEE ALSO
L<Mojolicious>, LMojolicious::Guides, Lhttp://mojolicio.us.
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Mojolicious-6.0/lib/Mojo/Parameters.pm new/Mojolicious-6.02/lib/Mojo/Parameters.pm
--- old/Mojolicious-6.0/lib/Mojo/Parameters.pm 2015-02-25 00:11:13.000000000 +0100
+++ new/Mojolicious-6.02/lib/Mojo/Parameters.pm 2015-02-27 04:25:20.000000000 +0100
@@ -308,7 +308,6 @@
=head2 param
- my @names = $params->param;
my $value = $params->param('foo');
$params = $params->param(foo => 'ba&r');
$params = $params->param(foo => qw(ba&r baz));
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Mojolicious-6.0/lib/Mojo/Server/Morbo.pm new/Mojolicious-6.02/lib/Mojo/Server/Morbo.pm
--- old/Mojolicious-6.0/lib/Mojo/Server/Morbo.pm 2015-02-24 23:58:13.000000000 +0100
+++ new/Mojolicious-6.02/lib/Mojo/Server/Morbo.pm 2015-03-10 01:28:13.000000000 +0100
@@ -8,7 +8,8 @@
use Mojo::Server::Daemon;
use POSIX 'WNOHANG';
-has watch => sub { [qw(lib templates)] };
+has daemon => sub { Mojo::Server::Daemon->new };
+has watch => sub { [qw(lib templates)] };
sub check {
my $self = shift;
@@ -31,8 +32,7 @@
my ($self, $app) = @_;
# Clean manager environment
- local $SIG{CHLD} = sub { $self->_reap if $self->{worker} };
- local $SIG{INT} = local $SIG{TERM} = local $SIG{QUIT} = sub {
+ local $SIG{INT} = local $SIG{TERM} = sub {
$self->{finished} = 1;
kill 'TERM', $self->{worker} if $self->{worker};
};
@@ -40,9 +40,9 @@
$self->{modified} = 1;
# Prepare and cache listen sockets for smooth restarting
- $self->{daemon} = Mojo::Server::Daemon->new->start->stop;
+ $self->daemon->start->stop;
- $self->_manage while !$self->{finished} || $self->{worker};
+ $self->_manage until $self->{finished} && !$self->{worker};
exit 0;
}
@@ -67,16 +67,14 @@
$self->{modified} = 1;
}
- # Windows workaround
- delete $self->{worker} if $self->{worker} && !kill 0, $self->{worker};
+ if (my $pid = $self->{worker}) {
+ delete $self->{worker} if waitpid($pid, WNOHANG) == $pid;
+ }
- $self->_reap;
$self->_spawn if !$self->{worker} && delete $self->{modified};
sleep 1;
}
-sub _reap { delete $_[0]{worker} while (waitpid -1, WNOHANG) > 0 }
-
sub _spawn {
my $self = shift;
@@ -86,14 +84,10 @@
return if $pid;
# Worker
- $SIG{CHLD} = 'DEFAULT';
- $SIG{INT} = $SIG{TERM} = $SIG{QUIT} = sub { $self->{finished} = 1 };
- my $daemon = $self->{daemon};
+ my $daemon = $self->daemon;
$daemon->load_app($self->watch->[0]);
- my $loop = $daemon->start->ioloop;
- $loop->recurring(
- 1 => sub { shift->stop if !kill(0, $manager) || $self->{finished} });
- $loop->start;
+ $daemon->ioloop->recurring(1 => sub { shift->stop unless kill 0, $manager });
+ $daemon->run;
exit 0;
}
@@ -139,7 +133,7 @@
The LMojo::Server::Morbo process can be controlled at runtime with the
following signals.
-=head2 INT, QUIT, TERM
+=head2 INT, TERM
Shut down server immediately.
@@ -147,6 +141,13 @@
LMojo::Server::Morbo implements the following attributes.
+=head2 daemon
+
+ my $daemon = $morbo->daemon;
+ $morbo = $morbo->daemon(Mojo::Server::Daemon->new);
+
+LMojo::Server::Daemon object this server manages.
+
=head2 watch
my $watch = $morbo->watch;
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Mojolicious-6.0/lib/Mojo/Template.pm new/Mojolicious-6.02/lib/Mojo/Template.pm
--- old/Mojolicious-6.0/lib/Mojo/Template.pm 2015-02-25 19:41:52.000000000 +0100
+++ new/Mojolicious-6.02/lib/Mojo/Template.pm 2015-03-09 19:48:07.000000000 +0100
@@ -87,7 +87,7 @@
my $self = shift;
# Compile with line directive
- return undef unless my $code = $self->code;
+ return undef unless defined(my $code = $self->code);
my $compiled = eval $self->_wrap($code);
$self->compiled($compiled) and return undef unless $@;
@@ -378,7 +378,9 @@
lines
You can capture whole template blocks for reuse later with the C<begin> and
-C<end> keywords.
+C<end> keywords. Just be aware that both keywords are part of the surrounding
+tag and not actual Perl code, so there can only be whitespace after C<begin>
+and before C<end>.
<% my $block = begin %>
<% my $name = shift; =%>
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Mojolicious-6.0/lib/Mojo/Transaction/WebSocket.pm new/Mojolicious-6.02/lib/Mojo/Transaction/WebSocket.pm
--- old/Mojolicious-6.0/lib/Mojo/Transaction/WebSocket.pm 2015-02-25 00:00:06.000000000 +0100
+++ new/Mojolicious-6.02/lib/Mojo/Transaction/WebSocket.pm 2015-02-28 19:52:17.000000000 +0100
@@ -564,9 +564,9 @@
=head2 connection
- my $connection = $ws->connection;
+ my $id = $ws->connection;
-Connection identifier or socket.
+Connection identifier.
=head2 finish
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Mojolicious-6.0/lib/Mojo/UserAgent/Transactor.pm new/Mojolicious-6.02/lib/Mojo/UserAgent/Transactor.pm
--- old/Mojolicious-6.0/lib/Mojo/UserAgent/Transactor.pm 2015-02-26 06:55:45.000000000 +0100
+++ new/Mojolicious-6.02/lib/Mojo/UserAgent/Transactor.pm 2015-03-09 18:12:10.000000000 +0100
@@ -265,12 +265,9 @@
use Mojo::UserAgent::Transactor;
- # Simple GET request
+ # GET request with Accept header
my $t = Mojo::UserAgent::Transactor->new;
- say $t->tx(GET => 'http://example.com')->req->to_string;
-
- # PATCH request with "Do Not Track" header and content
- say $t->tx(PATCH => 'example.com' => {DNT => 1} => 'Hi!')->req->to_string;
+ say $t->tx(GET => 'http://example.com' => {Accept => '*/*'})->req->to_string;
# POST request with form-data
say $t->tx(POST => 'example.com' => form => {a => 'b'})->req->to_string;
@@ -367,9 +364,9 @@
my $tx = $t->tx(PUT => 'http://example.com' => json => {a => 'b'});
my $tx = $t->tx(POST => 'http://example.com' => {Accept => '*/*'} => 'Hi!');
my $tx = $t->tx(
- PUT => 'http://example.com' => {Accept => '*/*'} => form => {a => 'b'});
+ PUT => 'http://example.com' => {Accept => '*/*'} => form => {a => 'b'});
my $tx = $t->tx(
- PUT => 'http://example.com' => {Accept => '*/*'} => json => {a => 'b'});
+ PUT => 'http://example.com' => {Accept => '*/*'} => json => {a => 'b'});
Versatile general purpose LMojo::Transaction::HTTP transaction builder for
requests, with support for L"GENERATORS">.
@@ -440,7 +437,7 @@
POST => 'http://example.com' => form => {mytext => {file => $asset}});
A C<filename> value will be generated automatically, but can also be set
-manually if necessary. All remainging values in the hash reference get merged
+manually if necessary. All remaining values in the hash reference get merged
into the C content as headers.
# POST request with form values and customized upload (filename and header)
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Mojolicious-6.0/lib/Mojo/UserAgent.pm new/Mojolicious-6.02/lib/Mojo/UserAgent.pm
--- old/Mojolicious-6.0/lib/Mojo/UserAgent.pm 2015-02-26 07:04:17.000000000 +0100
+++ new/Mojolicious-6.02/lib/Mojo/UserAgent.pm 2015-03-10 02:02:34.000000000 +0100
@@ -259,13 +259,13 @@
if (my $new = $self->transactor->upgrade($old)) {
weaken $self;
$new->on(resume => sub { $self->_write($id) });
- $c->{cb}->($self, $c->{tx} = $new);
+ $c->{cb}($self, $c->{tx} = $new);
return $new->client_read($old->res->content->leftovers);
}
# Finish normal connection and handle redirects
$self->_remove($id, $close);
- $c->{cb}->($self, $old) unless $self->_redirect($c, $old);
+ $c->{cb}($self, $old) unless $self->_redirect($c, $old);
}
sub _loop { $_[1] ? Mojo::IOLoop->singleton : $_[0]->ioloop }
@@ -361,11 +361,11 @@
use Mojo::UserAgent;
- # Say hello to the Unicode snowman with "Do Not Track" header
+ # Say hello to the Unicode snowman and include an Accept header
my $ua = Mojo::UserAgent->new;
- say $ua->get('www.☃.net?hello=there' => {DNT => 1})->res->body;
+ say $ua->get('www.☃.net?hello=there' => {Accept => '*/*'})->res->body;
- # Form POST with exception handling
+ # Form POST (application/x-www-form-urlencoded) with exception handling
my $tx = $ua->post('https://metacpan.org/search' => form => {q => 'mojo'});
if (my $res = $tx->success) { say $res->body }
else {
@@ -374,34 +374,32 @@
die "Connection error: $err->{message}";
}
- # Quick JSON API request with Basic authentication
- say $ua->get('https://sri:s3cret@example.com/search.json?q=perl')
- ->res->json('/results/0/title');
-
- # Extract data from HTML and XML resources
+ # Extract data from HTML and XML resources with CSS selectors
say $ua->get('www.perl.org')->res->dom->at('title')->text;
- # Scrape the latest headlines from a news site with CSS selectors
+ # Scrape the latest headlines from a news site
say $ua->get('blogs.perl.org')
->res->dom->find('h2 > a')->map('text')->join("\n");
+ # IPv6 PUT request with Content-Type header and content
+ my $tx = $ua->put('[::1]:3000' => {'Content-Type' => 'text/plain'} => 'Hi!');
+
+ # Quick JSON API request with Basic authentication
+ my $value = $ua->get('https://sri:s3cret@example.com/test.json')->res->json;
+
+ # JSON POST (application/json) with TLS certificate authentication
+ my $tx = $ua->cert('tls.crt')->key('tls.key')
+ ->post('https://example.com' => json => {top => 'secret'});
+
# Search DuckDuckGo anonymously through Tor
$ua->proxy->http('socks://127.0.0.1:9050');
say $ua->get('api.3g2upl4pq6kufc4m.onion/?q=mojolicious&format=json')
->res->json('/Abstract');
- # IPv6 PUT request with content
- my $tx
- = $ua->put('[::1]:3000' => {'Content-Type' => 'text/plain'} => 'Hello!');
-
- # Follow redirects to grab the latest Mojolicious release :)
+ # Follow redirects to download Mojolicious from GitHub
$ua->max_redirects(5)
->get('https://www.github.com/kraih/mojo/tarball/master')
- ->res->content->asset->move_to('/Users/sri/mojo.tar.gz');
-
- # TLS certificate authentication and JSON POST
- my $tx = $ua->cert('tls.crt')->key('tls.key')
- ->post('https://example.com' => json => {top => 'secret'});
+ ->res->content->asset->move_to('/home/sri/mojo.tar.gz');
# Non-blocking concurrent requests
Mojo::IOLoop->delay(
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Mojolicious-6.0/lib/Mojo/Util.pm new/Mojolicious-6.02/lib/Mojo/Util.pm
--- old/Mojolicious-6.0/lib/Mojo/Util.pm 2015-02-25 00:17:08.000000000 +0100
+++ new/Mojolicious-6.02/lib/Mojo/Util.pm 2015-03-04 15:38:13.000000000 +0100
@@ -276,7 +276,7 @@
my @spec;
for my $row (@$rows) {
for my $i (0 .. $#$row) {
- $row->[$i] =~ s/[\r\n]//g;
+ ($row->[$i] //= '') =~ s/[\r\n]//g;
my $len = length $row->[$i];
$spec[$i] = $len if $len >= ($spec[$i] // 0);
}
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Mojolicious-6.0/lib/Mojolicious/Controller.pm new/Mojolicious-6.02/lib/Mojolicious/Controller.pm
--- old/Mojolicious-6.0/lib/Mojolicious/Controller.pm 2015-02-25 05:38:44.000000000 +0100
+++ new/Mojolicious-6.02/lib/Mojolicious/Controller.pm 2015-02-27 18:24:14.000000000 +0100
@@ -590,7 +590,7 @@
For more control you can also access request information directly.
# Only GET parameters
- my $foo = $c->req->url->query->param('foo');
+ my $foo = $c->req->query_params->param('foo');
# Only POST parameters
my $foo = $c->req->body_params->param('foo');
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Mojolicious-6.0/lib/Mojolicious/Guides/Rendering.pod new/Mojolicious-6.02/lib/Mojolicious/Guides/Rendering.pod
--- old/Mojolicious-6.0/lib/Mojolicious/Guides/Rendering.pod 2015-02-25 19:44:56.000000000 +0100
+++ new/Mojolicious-6.02/lib/Mojolicious/Guides/Rendering.pod 2015-03-06 04:36:47.000000000 +0100
@@ -350,15 +350,12 @@
# Controller
my $serialized = $c->dumper([1, 2, 3]);
-The helper LMojolicious::Plugin::DefaultHelpers/"dumper" for example will use
-LData::Dumper to serialize whatever data structure you pass it, this can be
-very useful for debugging. We differentiate between default helpers which are
-more general purpose like C<dumper> and tag helpers, which are template
-specific and mostly used to generate HTML tags.
+We differentiate between default helpers, which are more general purpose like
+LMojolicious::Plugin::DefaultHelpers/"dumper", and tag helpers like
+LMojolicious::Plugin::TagHelpers/"link_to", which are template specific and
+mostly used to generate HTML tags.
- %= link_to 'http://mojolicio.us' => begin
- Mojolicious
- % end
+ %= link_to Mojolicious => 'http://mojolicio.us'
In controllers you can also use the method LMojolicious::Controller/"helpers"
to fully qualify helper calls and ensure that they don't conflict with existing
@@ -637,7 +634,9 @@
It's never fun to repeat yourself, that's why you can build reusable template
blocks in C<ep> that work very similar to normal Perl functions, with the
-C<begin> and C<end> keywords.
+C<begin> and C<end> keywords. Just be aware that both keywords are part of the
+surrounding tag and not actual Perl code, so there can only be whitespace after
+C<begin> and before C<end>.
use Mojolicious::Lite;
@@ -675,8 +674,9 @@
=head2 Adding helpers
You should always try to keep your actions small and reuse as much code as
-possible. Helpers make this very easy, you can use them to do pretty much
-anything an action could do.
+possible. Helpers make this very easy, they get passed the current controller
+object as first argument and you can use them to do pretty much anything an
+action could do.
use Mojolicious::Lite;
@@ -782,7 +782,7 @@
@@ layouts/mylayout.html.ep
<!DOCTYPE html>
<html>
- <head><%= content_for 'header' %></head>
+ <head><%= content 'header' %></head>
<body><%= content %></body>
</html>
@@ -1017,7 +1017,12 @@
use Mojolicious::Lite;
- get '/some_static_file' => sub {
+ get '/' => sub {
+ my $c = shift;
+ $c->reply->static('index.html');
+ };
+
+ get '/some_download' => sub {
my $c = shift;
$c->res->headers->content_disposition('attachment; filename=bar.png;');
$c->reply->static('foo/bar.png');
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Mojolicious-6.0/lib/Mojolicious/Plugin/DefaultHelpers.pm new/Mojolicious-6.02/lib/Mojolicious/Plugin/DefaultHelpers.pm
--- old/Mojolicious-6.0/lib/Mojolicious/Plugin/DefaultHelpers.pm 2015-02-26 22:22:42.000000000 +0100
+++ new/Mojolicious-6.02/lib/Mojolicious/Plugin/DefaultHelpers.pm 2015-03-03 22:34:32.000000000 +0100
@@ -25,9 +25,13 @@
$app->helper(c => sub { shift; Mojo::Collection->new(@_) });
$app->helper(config => sub { shift->app->config(@_) });
+ $app->helper(content => sub { _content(0, 0, @_) });
+ $app->helper(content_for => sub { _content(1, 0, @_) });
+ $app->helper(content_with => sub { _content(0, 1, @_) });
+
$app->helper($_ => $self->can("_$_"))
- for qw(content content_for csrf_token current_route delay),
- qw(inactivity_timeout is_fresh url_with);
+ for
+ qw(csrf_token current_route delay inactivity_timeout is_fresh url_with);
$app->helper(dumper => sub { shift; dumper @_ });
$app->helper(include => sub { shift->render_to_string(@_) });
@@ -36,7 +40,8 @@
$app->helper('reply.exception' => sub { _development('exception', @_) });
$app->helper('reply.not_found' => sub { _development('not_found', @_) });
- $app->helper(ua => sub { shift->app->ua });
+
+ $app->helper(ua => sub { shift->app->ua });
}
sub _asset {
@@ -45,26 +50,22 @@
$c->rendered;
}
+sub _block { ref $_[0] eq 'CODE' ? $_[0]() : $_[0] }
+
sub _content {
- my ($c, $name, $content) = @_;
+ my ($append, $replace, $c, $name, $content) = @_;
$name ||= 'content';
- # Set (first come)
my $hash = $c->stash->{'mojo.content'} ||= {};
- $hash->{$name} //= ref $content eq 'CODE' ? $content->() : $content
- if defined $content;
+ if (defined $content) {
+ if ($append) { $hash->{$name} .= _block($content) }
+ if ($replace) { $hash->{$name} = _block($content) }
+ else { $hash->{$name} //= _block($content) }
+ }
- # Get
return Mojo::ByteStream->new($hash->{$name} // '');
}
-sub _content_for {
- my ($c, $name, $content) = @_;
- return _content($c, $name) unless defined $content;
- my $hash = $c->stash->{'mojo.content'} ||= {};
- return $hash->{$name} .= ref $content eq 'CODE' ? $content->() : $content;
-}
-
sub _csrf_token {
my $c = shift;
$c->session->{csrf_token}
@@ -238,10 +239,10 @@
%= content 'bar'
%= content
-Store partial rendered content in named buffer and retrieve it, defaults to
-retrieving the named buffer C<content>, which is commonly used for the
-renderers C<layout> and C<extends> features. Note that new content will be
-ignored if the named buffer is already in use.
+Store partial rendered content in a named buffer and retrieve it later,
+defaults to retrieving the named buffer C<content>, which is commonly used for
+the renderers C<layout> and C<extends> features. New content will be ignored if
+the named buffer is already in use.
=head2 content_for
@@ -250,8 +251,8 @@
% end
%= content_for 'foo'
-Append partial rendered content to named buffer and retrieve it. Note that
-named buffers are shared with the L"content"> helper.
+Same as L"content">, but appends content to named buffers if they are already
+in use.
% content_for message => begin
Hello
@@ -259,7 +260,25 @@
% content_for message => begin
world!
% end
- %= content_for 'message'
+ %= content 'message'
+
+=head2 content_with
+
+ % content_with foo => begin
+ test
+ % end
+ %= content_with 'foo'
+
+Same as L"content">, but replaces content of named buffers if they are
+already in use.
+
+ % content message => begin
+ world!
+ % end
+ % content_with message => begin
+ Hello <%= content 'message' %>
+ % end
+ %= content 'message'
=head2 csrf_token
@@ -309,7 +328,8 @@
%= dumper {some => 'data'}
-Dump a Perl data structure with LMojo::Util/"dumper".
+Dump a Perl data structure with LMojo::Util/"dumper", very useful for
+debugging.
=head2 extends
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Mojolicious-6.0/lib/Mojolicious/Plugin/EPRenderer.pm new/Mojolicious-6.02/lib/Mojolicious/Plugin/EPRenderer.pm
--- old/Mojolicious-6.0/lib/Mojolicious/Plugin/EPRenderer.pm 2015-02-21 07:08:18.000000000 +0100
+++ new/Mojolicious-6.02/lib/Mojolicious/Plugin/EPRenderer.pm 2015-03-09 20:03:32.000000000 +0100
@@ -36,7 +36,7 @@
# Stash values (every time)
my $prepend = 'my $self = my $c = shift; my $_S = $c->stash; {';
$prepend .= join '', map {" my \$$_ = \$_S->{'$_'};"} @keys;
- $mt->prepend($prepend . $mt->prepend)->append('}' . $mt->append);
+ $mt->prepend($prepend . $mt->prepend)->append(';}' . $mt->append);
$cache->set($key => $mt);
}
@@ -47,7 +47,7 @@
local *{"${ns}::_C"} = sub {$c};
# Render with "epl" handler
- return $renderer->handlers->{epl}->($renderer, $c, $output, $options);
+ return $renderer->handlers->{epl}($renderer, $c, $output, $options);
}
);
}
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Mojolicious-6.0/lib/Mojolicious/Renderer.pm new/Mojolicious-6.02/lib/Mojolicious/Renderer.pm
--- old/Mojolicious-6.0/lib/Mojolicious/Renderer.pm 2015-02-24 23:48:25.000000000 +0100
+++ new/Mojolicious-6.02/lib/Mojolicious/Renderer.pm 2015-03-03 01:13:10.000000000 +0100
@@ -112,20 +112,20 @@
# Data
my $output;
if (defined(my $data = delete $stash->{data})) {
- $self->handlers->{data}->($self, $c, \$output, {data => $data});
+ $self->handlers->{data}($self, $c, \$output, {data => $data});
return $output, $options->{format};
}
# JSON
elsif (exists $stash->{json}) {
my $json = delete $stash->{json};
- $self->handlers->{json}->($self, $c, \$output, {json => $json});
+ $self->handlers->{json}($self, $c, \$output, {json => $json});
return $output, 'json';
}
# Text
elsif (defined(my $text = delete $stash->{text})) {
- $self->handlers->{text}->($self, $c, \$output, {text => $text});
+ $self->handlers->{text}($self, $c, \$output, {text => $text});
}
# Template or templateless handler
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Mojolicious-6.0/lib/Mojolicious/templates/perldoc.html.ep new/Mojolicious-6.02/lib/Mojolicious/templates/perldoc.html.ep
--- old/Mojolicious-6.0/lib/Mojolicious/templates/perldoc.html.ep 2015-02-21 07:08:18.000000000 +0100
+++ new/Mojolicious-6.02/lib/Mojolicious/templates/perldoc.html.ep 2015-03-03 22:20:45.000000000 +0100
@@ -109,7 +109,7 @@
</li>
% }
</ul>
- %= content_for 'perldoc'
+ %= content 'perldoc'
</div>
</div>
<div id="footer">
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Mojolicious-6.0/lib/Mojolicious.pm new/Mojolicious-6.02/lib/Mojolicious.pm
--- old/Mojolicious-6.0/lib/Mojolicious.pm 2015-02-24 23:31:49.000000000 +0100
+++ new/Mojolicious-6.02/lib/Mojolicious.pm 2015-03-03 17:11:31.000000000 +0100
@@ -42,8 +42,8 @@
has types => sub { Mojolicious::Types->new };
has validator => sub { Mojolicious::Validator->new };
-our $CODENAME = 'Tiger Face';
-our $VERSION = '6.0';
+our $CODENAME = 'Clinking Beer Mugs';
+our $VERSION = '6.02';
sub AUTOLOAD {
my $self = shift;
@@ -117,7 +117,7 @@
# Dispatcher has to be last in the chain
++$self->{dispatch}
- and $self->hook(around_action => sub { $_[2]->($_[1]) })
+ and $self->hook(around_action => sub { $_[2]($_[1]) })
and $self->hook(around_dispatch => sub { $_[1]->app->dispatch($_[1]) })
unless $self->{dispatch};
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Mojolicious-6.0/lib/Test/Mojo.pm new/Mojolicious-6.02/lib/Test/Mojo.pm
--- old/Mojolicious-6.0/lib/Test/Mojo.pm 2015-02-26 05:59:01.000000000 +0100
+++ new/Mojolicious-6.02/lib/Test/Mojo.pm 2015-03-09 21:37:55.000000000 +0100
@@ -626,6 +626,14 @@
Checks for existence of the CSS selectors first matching HTML/XML element with
LMojo::DOM/"at".
+ # Check attribute values
+ $t->get_ok('/login')
+ ->element_exists('label[for=email]')
+ ->element_exists('input[name=email][type=text][value*="example.com"]')
+ ->element_exists('label[for=pass]')
+ ->element_exists('input[name=pass][type=password]')
+ ->element_exists('input[type=submit][value]');
+
=head2 element_exists_not
$t = $t->element_exists_not('div.foo[x=y]');
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Mojolicious-6.0/lib/ojo.pm new/Mojolicious-6.02/lib/ojo.pm
--- old/Mojolicious-6.0/lib/ojo.pm 2015-02-24 23:26:42.000000000 +0100
+++ new/Mojolicious-6.02/lib/ojo.pm 2015-03-03 22:07:08.000000000 +0100
@@ -17,7 +17,7 @@
my $caller = caller;
eval "package $caller; use Mojolicious::Lite; 1" or die $@;
my $ua = $caller->app->ua;
- $ua->server->app->hook(around_action => sub { local $_ = $_[1]; $_[0]->() });
+ $ua->server->app->hook(around_action => sub { local $_ = $_[1]; $_[0]() });
$ua->max_redirects(10) unless defined $ENV{MOJO_MAX_REDIRECTS};
$ua->proxy->detect unless defined $ENV{MOJO_PROXY};
@@ -116,6 +116,8 @@
my $res = d('example.com');
my $res = d('http://example.com' => {Accept => '*/*'} => 'Hi!');
+ my $res = d('http://example.com' => {Accept => '*/*'} => form => {a => 'b'});
+ my $res = d('http://example.com' => {Accept => '*/*'} => json => {a => 'b'});
Perform C<DELETE> request with LMojo::UserAgent/"delete" and return resulting
LMojo::Message::Response object.
@@ -124,6 +126,8 @@
my $res = g('example.com');
my $res = g('http://example.com' => {Accept => '*/*'} => 'Hi!');
+ my $res = g('http://example.com' => {Accept => '*/*'} => form => {a => 'b'});
+ my $res = g('http://example.com' => {Accept => '*/*'} => json => {a => 'b'});
Perform C<GET> request with LMojo::UserAgent/"get" and return resulting
LMojo::Message::Response object.
@@ -134,6 +138,8 @@
my $res = h('example.com');
my $res = h('http://example.com' => {Accept => '*/*'} => 'Hi!');
+ my $res = h('http://example.com' => {Accept => '*/*'} => form => {a => 'b'});
+ my $res = h('http://example.com' => {Accept => '*/*'} => json => {a => 'b'});
Perform C<HEAD> request with LMojo::UserAgent/"head" and return resulting
LMojo::Message::Response object.
@@ -162,6 +168,8 @@
my $res = o('example.com');
my $res = o('http://example.com' => {Accept => '*/*'} => 'Hi!');
+ my $res = o('http://example.com' => {Accept => '*/*'} => form => {a => 'b'});
+ my $res = o('http://example.com' => {Accept => '*/*'} => json => {a => 'b'});
Perform C<OPTIONS> request with LMojo::UserAgent/"options" and return
resulting LMojo::Message::Response object.
@@ -170,6 +178,8 @@
my $res = p('example.com');
my $res = p('http://example.com' => {Accept => '*/*'} => 'Hi!');
+ my $res = p('http://example.com' => {Accept => '*/*'} => form => {a => 'b'});
+ my $res = p('http://example.com' => {Accept => '*/*'} => json => {a => 'b'});
Perform C<POST> request with LMojo::UserAgent/"post" and return resulting
LMojo::Message::Response object.
@@ -186,6 +196,8 @@
my $res = t('example.com');
my $res = t('http://example.com' => {Accept => '*/*'} => 'Hi!');
+ my $res = t('http://example.com' => {Accept => '*/*'} => form => {a => 'b'});
+ my $res = t('http://example.com' => {Accept => '*/*'} => json => {a => 'b'});
Perform C<PATCH> request with LMojo::UserAgent/"patch" and return resulting
LMojo::Message::Response object.
@@ -194,6 +206,8 @@
my $res = u('example.com');
my $res = u('http://example.com' => {Accept => '*/*'} => 'Hi!');
+ my $res = u('http://example.com' => {Accept => '*/*'} => form => {a => 'b'});
+ my $res = u('http://example.com' => {Accept => '*/*'} => json => {a => 'b'});
Perform C<PUT> request with LMojo::UserAgent/"put" and return resulting
LMojo::Message::Response object.
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Mojolicious-6.0/script/morbo new/Mojolicious-6.02/script/morbo
--- old/Mojolicious-6.0/script/morbo 2015-02-24 21:03:06.000000000 +0100
+++ new/Mojolicious-6.02/script/morbo 2015-03-10 01:27:29.000000000 +0100
@@ -18,9 +18,9 @@
die Mojolicious::Command->new->extract_usage;
}
-$ENV{MOJO_LISTEN} = join ',', @listen if @listen;
require Mojo::Server::Morbo;
my $morbo = Mojo::Server::Morbo->new;
+$morbo->daemon->listen(\@listen) if @listen;
$morbo->watch(\@watch) if @watch;
$morbo->run($app);
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Mojolicious-6.0/t/mojo/hypnotoad.t new/Mojolicious-6.02/t/mojo/hypnotoad.t
--- old/Mojolicious-6.0/t/mojo/hypnotoad.t 2015-02-22 08:07:48.000000000 +0100
+++ new/Mojolicious-6.02/t/mojo/hypnotoad.t 2015-03-10 01:59:12.000000000 +0100
@@ -94,9 +94,8 @@
sleep 1 while !_port($port2);
my $old = _pid();
-my $ua = Mojo::UserAgent->new;
-
# Application is alive
+my $ua = Mojo::UserAgent->new;
my $tx = $ua->get("http://127.0.0.1:$port1/hello");
ok $tx->is_finished, 'transaction is finished';
ok $tx->keep_alive, 'connection will be kept alive';
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Mojolicious-6.0/t/mojo/morbo.t new/Mojolicious-6.02/t/mojo/morbo.t
--- old/Mojolicious-6.0/t/mojo/morbo.t 2015-02-22 06:29:15.000000000 +0100
+++ new/Mojolicious-6.02/t/mojo/morbo.t 2015-03-10 01:58:41.000000000 +0100
@@ -40,9 +40,8 @@
"http://127.0.0.1:$port", $script;
sleep 1 while !_port($port);
-my $ua = Mojo::UserAgent->new;
-
# Application is alive
+my $ua = Mojo::UserAgent->new;
my $tx = $ua->get("http://127.0.0.1:$port/hello");
ok $tx->is_finished, 'transaction is finished';
is $tx->res->code, 200, 'right status';
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Mojolicious-6.0/t/mojo/request.t new/Mojolicious-6.02/t/mojo/request.t
--- old/Mojolicious-6.0/t/mojo/request.t 2015-02-23 21:19:54.000000000 +0100
+++ new/Mojolicious-6.02/t/mojo/request.t 2015-03-02 22:36:12.000000000 +0100
@@ -2070,12 +2070,12 @@
# Parse lots of special characters in URL
$req = Mojo::Message::Request->new;
-$req->parse('GET /#09azAZ!$%&\'()*+,-./:;=?@[\\]^_`{|}~ ');
+$req->parse("GET /#09azAZ!\$%&'()*+,-./:;=?@[\\]^_`{|}~\xC3\x9F ");
$req->parse("HTTP/1.1\x0d\x0a\x0d\x0a");
ok $req->is_finished, 'request is finished';
is $req->method, 'GET', 'right method';
is $req->version, '1.1', 'right version';
-is $req->url, '/#09azAZ!$%&\'()*+,-./:;=?@%5B%5C%5D%5E_%60%7B%7C%7D~',
+is $req->url, "/#09azAZ!\$%&\'()*+,-./:;=?@%5B%5C%5D%5E_%60%7B%7C%7D~%C3%9F",
'right URL';
# Abstract methods
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Mojolicious-6.0/t/mojo/template.t new/Mojolicious-6.02/t/mojo/template.t
--- old/Mojolicious-6.0/t/mojo/template.t 2015-02-25 19:30:14.000000000 +0100
+++ new/Mojolicious-6.02/t/mojo/template.t 2015-03-10 03:08:48.000000000 +0100
@@ -1,3 +1,11 @@
+use Mojo::Base -strict;
+
+use Test::More;
+use Cwd 'abs_path';
+use File::Basename 'dirname';
+use File::Spec::Functions 'catfile';
+use Mojo::Template;
+
package MyTemplateExporter;
use Mojo::Base -strict;
@@ -13,21 +21,15 @@
sub exception { die 'ohoh' }
package main;
-use Mojo::Base -strict;
-use Test::More;
-use Cwd 'abs_path';
-use File::Basename 'dirname';
-use File::Spec::Functions 'catfile';
-use Mojo::Template;
-
-# Capture helper
-my $capture = 'no warnings "redefine"; sub capture { shift->(@_) }';
+# Empty template
+my $mt = Mojo::Template->new;
+my $output = $mt->render('');
+is $output, '', 'empty string';
# Consistent scalar context
-my $mt = Mojo::Template->new;
$mt->prepend('my @foo = (3, 4);')->parse('<%= @foo %>:<%== @foo %>');
-my $output = $mt->build->compile || $mt->interpret;
+$output = $mt->build->compile || $mt->interpret;
is $output, "2:2\n", 'same context';
# Parentheses
@@ -42,8 +44,8 @@
# Trim expression
$mt = Mojo::Template->new;
-$output = $mt->render("<%= '123' %><%= 'test' =%>\n");
-is $output, '123test', 'expression trimmed';
+$output = $mt->render("<%= '123' %><%= 'begin#test' =%>\n");
+is $output, '123begin#test', 'expression trimmed';
# Trim expression (multiple lines)
$mt = Mojo::Template->new;
@@ -66,6 +68,7 @@
is $output, " \ntest \n", 'expression trimmed';
# Trim expression tags
+my $capture = 'no warnings "redefine"; sub capture { shift->(@_) }';
$mt = Mojo::Template->new(prepend => $capture);
$output = $mt->render(' <%= capture begin =%><html><% end =%> ');
is $output, '<html>', 'expression tags trimmed';
@@ -641,21 +644,21 @@
EOF
isa_ok $output, 'Mojo::Exception', 'right exception';
like $output->message, qr/ohoh/, 'right message';
-is $output->lines_before->[0][0], 8, 'right number';
+is $output->lines_before->[0][0], 16, 'right number';
is $output->lines_before->[0][1], '}', 'right line';
-is $output->lines_before->[1][0], 9, 'right number';
+is $output->lines_before->[1][0], 17, 'right number';
is $output->lines_before->[1][1], '', 'right line';
-is $output->lines_before->[2][0], 10, 'right number';
+is $output->lines_before->[2][0], 18, 'right number';
is $output->lines_before->[2][1], 'package MyTemplateException;', 'right line';
-is $output->lines_before->[3][0], 11, 'right number';
+is $output->lines_before->[3][0], 19, 'right number';
is $output->lines_before->[3][1], 'use Mojo::Base -strict;', 'right line';
-is $output->lines_before->[4][0], 12, 'right number';
+is $output->lines_before->[4][0], 20, 'right number';
is $output->lines_before->[4][1], '', 'right line';
-is $output->line->[0], 13, 'right number';
+is $output->line->[0], 21, 'right number';
is $output->line->[1], "sub exception { die 'ohoh' }", 'right line';
-is $output->lines_after->[0][0], 14, 'right number';
+is $output->lines_after->[0][0], 22, 'right number';
is $output->lines_after->[0][1], '', 'right line';
-is $output->lines_after->[1][0], 15, 'right number';
+is $output->lines_after->[1][0], 23, 'right number';
is $output->lines_after->[1][1], 'package main;', 'right line';
like "$output", qr/ohoh/, 'right result';
@@ -842,14 +845,14 @@
$mt->auto_escape(1);
$output = $mt->render(<<'EOF');
<html><%= '<html>' %>
-%= '<'
-%== '<'
+%= 'begin#<'
+%== 'begin#<'
</html>
EOF
is $output, < {inline => '<%= "inline!" %>'};
get '/inline/again' => {inline => 0};
@@ -235,6 +237,9 @@
$t->get_ok('/content_for')->status_is(200)
->header_is(Server => 'Mojolicious (Perl)')
->content_is("DefaultThis\n\nseems\nto\nHello world!\n\nwork!\n\n");
+$t->get_ok('/content_with')->status_is(200)
+ ->header_is(Server => 'Mojolicious (Perl)')
+ ->content_is("Default\n\nSomething <b>else</b>!\n\n\n<br>Hello world!\n\n");
# Inline template
$t->get_ok('/inline')->status_is(200)
@@ -399,6 +404,17 @@
<%= content_for 'message' %>
work!
+@@ content_with.html.ep
+<% content first => begin %>Something<% end %>
+<% content_for first => begin %> <b>else<% end %>
+% content_for first => '</b>!';
+%= content_with 'first'
+% content_with first => '';
+%= content_with 'first'
+<% content second => begin %>world<% end %>
+<%= content_with second => begin %><br>Hello <%= content 'second' %>!<% end %>
+% content_with 'second'
+
@@ layouts/variants.txt.ep
Variant: <%= content %>\
--
To unsubscribe, e-mail: opensuse-commit+unsubscribe@opensuse.org
For additional commands, e-mail: opensuse-commit+help@opensuse.org