Mojo. The web in a box!
-
Upload
anatoly-sharifulin -
Category
Education
-
view
3.040 -
download
1
description
Transcript of Mojo. The web in a box!
Mojo.The web in a box!
Saint Perl 2009English version
6 января 2010 г.
Sebastian Riedelавтор Catalyst и Mojohttp://labs.kraih.com/
6 января 2010 г.
Sebastian Riedelавтор Catalyst и Mojohttp://labs.kraih.com/
6 января 2010 г.
Sebastian Riedelcreator of Catalyst and Mojo
http://labs.kraih.com/
6 января 2010 г.
Catalyst + Mojo = ?6 января 2010 г.
What is Mojo?
6 января 2010 г.
What is Mojo?• Pure Perl framework, without
any hidden magick
• No requirements besides Perl 5.8.1
• Very clean and object oriented API
• Full stack HTTP 1.1 (client / server)
• CGI, FastCGI, PSGI, Daemon и Prefork
• Two MVC web frameworks: Mojolicious and Mojolicious::Lite
6 января 2010 г.
Pure Perl framework
6 января 2010 г.
• Mojo::Base
• Mojo::ByteStream
• Mojo::Template, Mojo::JSON
• Mojo::Loader, Mojo::Log, Mojo::Path
• Mojo::URL, Mojo::Parameters, Mojo::Content
• Mojo::Message::Request, Mojo::Message::Response,Mojo::Headers, Mojo::Cookie, Mojo::Date
6 января 2010 г.
• Mojo::Base
• Mojo::ByteStream
• Mojo::Template, Mojo::JSON
• Mojo::Loader, Mojo::Log, Mojo::Path
• Mojo::URL, Mojo::Parameters, Mojo::Content
• Mojo::Message::Request, Mojo::Message::Response,Mojo::Headers, Mojo::Cookie, Mojo::Date
6 января 2010 г.
Minimal Base Class For Mojo Projects
Mojo::Base
6 января 2010 г.
package App;use base ‘Mojo::Base’;
__PACKAGE__->attr(conf => sub { return do ‘conf/app.conf’;});__PACKAGE__->attr(db => sub { my $self = shift; return Util->db($self->conf->{'db'});});
sub dispatch { ... }6 января 2010 г.
package App;use base ‘Mojo::Base’;
__PACKAGE__->attr(conf => sub { return do ‘conf/app.conf’;});__PACKAGE__->attr(db => sub { my $self = shift; return Util->db($self->conf->{'db'});});
sub dispatch { ... }6 января 2010 г.
package App;use base ‘Mojo::Base’;
__PACKAGE__->attr(conf => sub { return do ‘conf/app.conf’;});__PACKAGE__->attr(db => sub { my $self = shift; return Util->db($self->conf->{'db'});});
sub dispatch { ... }6 января 2010 г.
• Mojo::Base
• Mojo::ByteStream
• Mojo::Template, Mojo::JSON
• Mojo::Loader, Mojo::Log, Mojo::Path
• Mojo::URL, Mojo::Parameters, Mojo::Content
• Mojo::Message::Request, Mojo::Message::Response,Mojo::Headers, Mojo::Cookie, Mojo::Date
6 января 2010 г.
ByteStream
Mojo::ByteStream
6 января 2010 г.
use Mojo::ByteStream;my $s = Mojo::ByteStream->new('foo_bar');
$s->camelize; $s->decamelize;$s->b64_encode; $s->b64_decode;$s->encode('utf8'); $s->decode('utf8');$s->html_escape; $s->html_unescape;$s->qp_encode; $s->qp_decode;$s->quote; $stream->unquote;$s->url_escape; $s->url_unescape;$s->xml_escape;
6 января 2010 г.
use Mojo::ByteStream;my $s = Mojo::ByteStream->new('foo_bar');
$s->camelize; $s->decamelize;$s->b64_encode; $s->b64_decode;$s->encode('utf8'); $s->decode('utf8');$s->html_escape; $s->html_unescape;$s->qp_encode; $s->qp_decode;$s->quote; $stream->unquote;$s->url_escape; $s->url_unescape;$s->xml_escape;
6 января 2010 г.
use Mojo::ByteStream;my $s = Mojo::ByteStream->new('foo_bar');
$s->camelize; $s->decamelize;$s->b64_encode; $s->b64_decode;$s->encode('utf8'); $s->decode('utf8');$s->html_escape; $s->html_unescape;$s->qp_encode; $s->qp_decode;$s->quote; $stream->unquote;$s->url_escape; $s->url_unescape;$s->xml_escape;
6 января 2010 г.
use Mojo::ByteStream;my $s = Mojo::ByteStream->new('foo_bar');
$s->camelize; $s->decamelize;$s->b64_encode; $s->b64_decode;$s->encode('utf8'); $s->decode('utf8');$s->html_escape; $s->html_unescape;$s->qp_encode; $s->qp_decode;$s->quote; $stream->unquote;$s->url_escape; $s->url_unescape;$s->xml_escape;
6 января 2010 г.
use Mojo::ByteStream;my $s = Mojo::ByteStream->new('foo_bar');
$s->camelize; $s->decamelize;$s->b64_encode; $s->b64_decode;$s->encode('utf8'); $s->decode('utf8');$s->html_escape; $s->html_unescape;$s->qp_encode; $s->qp_decode;$s->quote; $stream->unquote;$s->url_escape; $s->url_unescape;$s->xml_escape;
6 января 2010 г.
use Mojo::ByteStream;my $s = Mojo::ByteStream->new('foo_bar');
$s->camelize; $s->decamelize;$s->b64_encode; $s->b64_decode;$s->encode('utf8'); $s->decode('utf8');$s->html_escape; $s->html_unescape;$s->qp_encode; $s->qp_decode;$s->quote; $stream->unquote;$s->url_escape; $s->url_unescape;$s->xml_escape;
6 января 2010 г.
use Mojo::ByteStream;my $s = Mojo::ByteStream->new('foo_bar');
$s->camelize; $s->decamelize;$s->b64_encode; $s->b64_decode;$s->encode('utf8'); $s->decode('utf8');$s->html_escape; $s->html_unescape;$s->qp_encode; $s->qp_decode;$s->quote; $stream->unquote;$s->url_escape; $s->url_unescape;$s->xml_escape;
6 января 2010 г.
use Mojo::ByteStream;my $s = Mojo::ByteStream->new('foo_bar');
$s->camelize; $s->decamelize;$s->b64_encode; $s->b64_decode;$s->encode('utf8'); $s->decode('utf8');$s->html_escape; $s->html_unescape;$s->qp_encode; $s->qp_decode;$s->quote; $stream->unquote;$s->url_escape; $s->url_unescape;$s->xml_escape;
6 января 2010 г.
use Mojo::ByteStream;my $s = Mojo::ByteStream->new('foo_bar');
$s->camelize; $s->decamelize;$s->b64_encode; $s->b64_decode;$s->encode('utf8'); $s->decode('utf8');$s->html_escape; $s->html_unescape;$s->qp_encode; $s->qp_decode;$s->quote; $stream->unquote;$s->url_escape; $s->url_unescape;$s->xml_escape;
6 января 2010 г.
• Mojo::Base
• Mojo::ByteStream
• Mojo::Template, Mojo::JSON
• Mojo::Loader, Mojo::Log, Mojo::Path
• Mojo::URL, Mojo::Parameters, Mojo::Content
• Mojo::Message::Request, Mojo::Message::Response,Mojo::Headers, Mojo::Cookie, Mojo::Date
6 января 2010 г.
Perlish Templates!
Mojo::Template
6 января 2010 г.
% my $list = $self->stash(‘list’);
<ul>% for (@$list) { <li> <%= $_->{title} %> </li>% }</ul>
<p><%# comment %></p>
6 января 2010 г.
% my $list = $self->stash(‘list’);
<ul>% for (@$list) { <li> <%= $_->{title} %> </li>% }</ul>
<p><%# comment %></p>
6 января 2010 г.
% my $list = $self->stash(‘list’);
<ul>% for (@$list) { <li> <%= $_->{title} %> </li>% }</ul>
<p><%# comment %></p>
6 января 2010 г.
%= my $list = $self->stash(‘list’);
<ul>% for (@$list) { <li> <%= $_->{title} %> </li>% }</ul>
<p><%# comment %></p>
6 января 2010 г.
%== my $list = $self->stash(‘list’);
<ul>% for (@$list) { <li> <%= $_->{title} %> </li>% }</ul>
<p><%# comment %></p>
6 января 2010 г.
% my $list = $self->stash(‘list’);
<ul>% for (@$list) { <li> <%= $_->{title} %> </li>% }</ul>
<p><%# comment %></p>
6 января 2010 г.
% use Foo::Bar;
<ul>% for (@$list) { <li> <%= $_->{title} %> </li>% }</ul>
<p><%# comment %></p>
6 января 2010 г.
% my $list = $self->stash(‘list’);
<ul>% for (@$list) { <li> <%= $_->{title} %> </li>% }</ul>
<p><%# comment %></p>
6 января 2010 г.
% my $list = $self->stash(‘list’);
<ul>% for (@$list) { <li> <%= $_->{title} %> </li>% }</ul>
<p><%# comment %></p>
6 января 2010 г.
% my $list = $self->stash(‘list’);
<ul>% for (@$list) { <li> <%= $_->{title} %> </li>% }</ul>
<p><%# comment %></p>
6 января 2010 г.
% my $list = $self->stash(‘list’);
<ul>% for (@$list) { <li> <%= $_->{title} %> </li>% }</ul>
<p><%# comment %></p>
6 января 2010 г.
% my $list = $self->stash(‘list’);
<ul>% for (@$list) { <li> <%== $_->{title} %> </li>% }</ul>
<p><%# comment %></p>
6 января 2010 г.
% my $list = $self->stash(‘list’);
<ul>% for (@$list) { <li> <% my $foo = $_->{id} + 100500; %> </li>% }</ul>
<p><%# comment %></p>
6 января 2010 г.
% my $list = $self->stash(‘list’);
<ul>% for (@$list) { <li> <% my $foo = $_->{id} + 100500; %> </li>% }</ul>
<p><%# comment %></p>
6 января 2010 г.
% my $list = $self->stash(‘list’);
<ul>% for (@$list) { <li> <%= $_->{title} %> </li>% }</ul>
<p><%# comment %></p>
6 января 2010 г.
% my $list = $self->stash(‘list’);
<ul>% for (@$list) { <li> <%= $_->{title} %> </li>% }</ul>
<p><%# comment %></p>
6 января 2010 г.
% my $list = $self->stash(‘list’);
<ul>% for (@$list) { <li> <%= $_->{title} %> </li>% }</ul>
<p><%# comment %></p>
6 января 2010 г.
• Mojo::Base
• Mojo::ByteStream
• Mojo::Template, Mojo::JSON
• Mojo::Loader, Mojo::Log, Mojo::Path
• Mojo::URL, Mojo::Parameters, Mojo::Content
• Mojo::Message::Request, Mojo::Message::Response,Mojo::Headers, Mojo::Cookie, Mojo::Date
6 января 2010 г.
Minimalistic JSON
Mojo::JSON
6 января 2010 г.
my $json = Mojo::JSON->new;
my $string = $json->encode({foo => ‘bar’});
my $hash = $json->decode(‘{"foo":"bar"}’);
6 января 2010 г.
my $json = Mojo::JSON->new;
my $string = $json->encode({foo => ‘bar’});
my $hash = $json->decode(‘{"foo":"bar"}’);
6 января 2010 г.
my $json = Mojo::JSON->new;
my $string = $json->encode({foo => ‘bar’});
my $hash = $json->decode(‘{"foo":"bar"}’);
6 января 2010 г.
• Mojo::Base
• Mojo::ByteStream
• Mojo::Template, Mojo::JSON
• Mojo::Loader, Mojo::Log, Mojo::Path
• Mojo::URL, Mojo::Parameters, Mojo::Content
• Mojo::Message::Request, Mojo::Message::Response,Mojo::Headers, Mojo::Cookie, Mojo::Date
6 января 2010 г.
Class loader: load, reload, search
Mojo::Loader
6 января 2010 г.
Class loader: load, reload, search
Mojo::Loader
6 января 2010 г.
• Mojo::Base
• Mojo::ByteStream
• Mojo::Template, Mojo::JSON
• Mojo::Loader, Mojo::Log, Mojo::Path
• Mojo::URL, Mojo::Parameters, Mojo::Content
• Mojo::Message::Request, Mojo::Message::Response,Mojo::Headers, Mojo::Cookie, Mojo::Date
6 января 2010 г.
• Mojo::Base
• Mojo::ByteStream
• Mojo::Template, Mojo::JSON
• Mojo::Loader, Mojo::Log, Mojo::Path
• Mojo::URL, Mojo::Parameters, Mojo::Content
• Mojo::Message::Request, Mojo::Message::Response,Mojo::Headers, Mojo::Cookie, Mojo::Date
6 января 2010 г.
• Mojo::Base
• Mojo::ByteStream
• Mojo::Template, Mojo::JSON
• Mojo::Loader, Mojo::Log, Mojo::Path
• Mojo::URL, Mojo::Parameters, Mojo::Content
• Mojo::Message::Request, Mojo::Message::Response,Mojo::Headers, Mojo::Cookie, Mojo::Date
6 января 2010 г.
• Mojo::Trasaction, Mojo::Stateful
• Mojo::IOLoop
• Mojo::Client, Mojo::Server
• Mojo::Server::CGI, Mojo::Server::FastCGI
• Mojo::Server::PSGI
• Mojo::Server::Daemon и ::Prefork
• Mojo::Command
• Mojo::Command::Generate и ~ Server
6 января 2010 г.
• Mojo::Trasaction, Mojo::Stateful
• Mojo::IOLoop
• Mojo::Client, Mojo::Server
• Mojo::Server::CGI, Mojo::Server::FastCGI
• Mojo::Server::PSGI
• Mojo::Server::Daemon и ::Prefork
• Mojo::Command
• Mojo::Command::Generate и ~ Server
6 января 2010 г.
• Mojo::Trasaction, Mojo::Stateful
• Mojo::IOLoop
• Mojo::Client, Mojo::Server
• Mojo::Server::CGI, Mojo::Server::FastCGI
• Mojo::Server::PSGI
• Mojo::Server::Daemon и ::Prefork
• Mojo::Command
• Mojo::Command::Generate и ~ Server
6 января 2010 г.
• Mojo::Trasaction, Mojo::Stateful
• Mojo::IOLoop
• Mojo::Client, Mojo::Server
• Mojo::Server::CGI, Mojo::Server::FastCGI
• Mojo::Server::PSGI
• Mojo::Server::Daemon и ::Prefork
• Mojo::Command
• Mojo::Command::Generate и ~ Server
6 января 2010 г.
my $client = Mojo::Client->new;
$client->get( ‘http://goo.gl’ => sub { my ($self, $tx) = @_; say $tx->res; })->process;
6 января 2010 г.
my $client = Mojo::Client->new;
$client->get( ‘http://goo.gl’ => sub { my ($self, $tx) = @_; say $tx->res; })->process;
6 января 2010 г.
my $client = Mojo::Client->new;
$client->post( ‘http://goo.gl’ => sub { my ($self, $tx) = @_; say $tx->res; })->process;
6 января 2010 г.
my $client = Mojo::Client->new;
$client->head( ‘http://goo.gl’ => sub { my ($self, $tx) = @_; say $tx->res; })->process;
6 января 2010 г.
my $client = Mojo::Client->new;
$client->put( ‘http://goo.gl’ => sub { my ($self, $tx) = @_; say $tx->res; })->process;
6 января 2010 г.
my $client = Mojo::Client->new;
$client->get( ‘http://goo.gl’ => sub { my ($self, $tx) = @_; say $tx->res; })->process;
6 января 2010 г.
my $client = Mojo::Client->new;
$client->get( ‘http://goo.gl’ => sub { my ($self, $tx) = @_; say $tx->res; })->process;
6 января 2010 г.
my $client = Mojo::Client->new;
$client->get( ‘http://goo.gl’ => sub { my ($self, $tx) = @_; say $tx->res; })->process;
6 января 2010 г.
my $client = Mojo::Client->new;
$client->get( ‘http://goo.gl’ => sub { my ($self, $tx) = @_; say $tx->res; })->process;
6 января 2010 г.
my $client = Mojo::Client->new;
$client->get( ‘http://goo.gl’ => sub { my ($self, $tx) = @_; say $tx->res; })->process;
6 января 2010 г.
• Mojo::Trasaction, Mojo::Stateful
• Mojo::IOLoop
• Mojo::Client, Mojo::Server
• Mojo::Server::CGI, Mojo::Server::FastCGI
• Mojo::Server::PSGI
• Mojo::Server::Daemon и ::Prefork
• Mojo::Command
• Mojo::Command::Generate и ~ Server
6 января 2010 г.
• Mojo::Trasaction, Mojo::Stateful
• Mojo::IOLoop
• Mojo::Client, Mojo::Server
• Mojo::Server::CGI, Mojo::Server::FastCGI
• Mojo::Server::PSGI
• Mojo::Server::Daemon и ::Prefork
• Mojo::Command
• Mojo::Command::Generate и ~ Server
6 января 2010 г.
• Mojo::Trasaction, Mojo::Stateful
• Mojo::IOLoop
• Mojo::Client, Mojo::Server
• Mojo::Server::CGI, Mojo::Server::FastCGI
• Mojo::Server::PSGI
• Mojo::Server::Daemon и ::Prefork
• Mojo::Command
• Mojo::Command::Generate и ~ Server
6 января 2010 г.
• Mojo::Trasaction, Mojo::Stateful
• Mojo::IOLoop
• Mojo::Client, Mojo::Server
• Mojo::Server::CGI, Mojo::Server::FastCGI
• Mojo::Server::PSGI
• Mojo::Server::Daemon и ::Prefork
• Mojo::Command
• Mojo::Command::Generate и ~ Server
6 января 2010 г.
• Mojo::Trasaction, Mojo::Stateful
• Mojo::IOLoop
• Mojo::Client, Mojo::Server
• Mojo::Server::CGI, Mojo::Server::FastCGI
• Mojo::Server::PSGI
• Mojo::Server::Daemon и ::Prefork
• Mojo::Command
• Mojo::Command::Generate и ~ Server
6 января 2010 г.
Mojo is the web in a box!
6 января 2010 г.
No requirementsbesides Perl 5.8.1
6 января 2010 г.
Mojo runtime6 января 2010 г.
Perl 5.0056 января 2010 г.
Perl 5.0060026 января 2010 г.
Perl 5.0080016 января 2010 г.
Mojo Perl 5.0106 января 2010 г.
Object oriented API
6 января 2010 г.
package TestMojo;use base 'Mojo';
sub handler { my ($self, $tx) = @_; warn $tx->req; warn $tx->req->url; $tx->res->headers ->content_type('text/plain'); $tx->res->body('Hello Mojo!');}
6 января 2010 г.
package TestMojo;use base 'Mojo';
sub handler { my ($self, $tx) = @_; warn $tx->req; warn $tx->req->url; $tx->res->headers ->content_type('text/plain'); $tx->res->body('Hello Mojo!');}
6 января 2010 г.
package TestMojo;use base 'Mojo';
sub handler { my ($self, $tx) = @_; warn $tx->req; warn $tx->req->url; $tx->res->headers ->content_type('text/plain'); $tx->res->body('Hello Mojo!');}
6 января 2010 г.
package TestMojo;use base 'Mojo';
sub handler { my ($self, $tx) = @_; warn $tx->req; warn $tx->req->url; $tx->res->headers ->content_type('text/plain'); $tx->res->body('Hello Mojo!');}
6 января 2010 г.
use overload '""' => sub { shift->to_string },
fallback => 1;
6 января 2010 г.
GET / HTTP/1.1Connection: keep-aliveAccept: text/html, application/xhtml, ....Accept-Charset: windows-1251, utf-8; ...Accept-Encoding: gzip,deflateAccept-Language: ru,en-us;q=0.7,en;q=0.3Host: localhost:3000User-Agent: Mozilla/5.0 (Macintosh; ...Content-Length: 0Keep-Alive: 300
6 января 2010 г.
GET / HTTP/1.1Connection: keep-aliveAccept: text/html, application/xhtml, ....Accept-Charset: windows-1251, utf-8; ...Accept-Encoding: gzip,deflateAccept-Language: ru,en-us;q=0.7,en;q=0.3Host: localhost:3000User-Agent: Mozilla/5.0 (Macintosh; ...Content-Length: 0Keep-Alive: 300
6 января 2010 г.
package TestMojo;use base 'Mojo';
sub handler { my ($self, $tx) = @_; warn $tx->req; warn $tx->req->url; $tx->res->headers ->content_type('text/plain'); $tx->res->body('Hello Mojo!');}
6 января 2010 г.
package TestMojo;use base 'Mojo';
sub handler { my ($self, $tx) = @_; warn $tx->req; warn $tx->req->url; $tx->res->headers ->content_type('text/plain'); $tx->res->body('Hello Mojo!');}
6 января 2010 г.
A generation of the mojo app
6 января 2010 г.
mojo generate app TestMojo
[mkdir] test_mojo/script[write] test_mojo/script/test_mojo[chmod] test_mojo/script/test_mojo 744[mkdir] test_mojo/lib[write] test_mojo/lib/TestMojo.pm[mkdir] test_mojo/t[write] test_mojo/t/basic.t
6 января 2010 г.
mojo generate app TestMojo
[mkdir] test_mojo/script[write] test_mojo/script/test_mojo[chmod] test_mojo/script/test_mojo 744[mkdir] test_mojo/lib[write] test_mojo/lib/TestMojo.pm[mkdir] test_mojo/t[write] test_mojo/t/basic.t
6 января 2010 г.
use FindBin;
use lib "$FindBin::Bin/../lib";use lib "$FindBin::Bin/../../lib";
# Application$ENV{MOJO_APP} ||= 'TestMojo';
use Mojo::Commands;Mojo::Commands->start; # ->start(‘cgi’)
6 января 2010 г.
mojo generate app TestMojo
[mkdir] test_mojo/script[write] test_mojo/script/test_mojo[chmod] test_mojo/script/test_mojo 744[mkdir] test_mojo/lib[write] test_mojo/lib/TestMojo.pm[mkdir] test_mojo/t[write] test_mojo/t/basic.t
6 января 2010 г.
package TestMojo;use base 'Mojo';
sub handler { my ($self, $tx) = @_; warn $tx->req; warn $tx->req->url; $tx->res->headers ->content_type('text/plain'); $tx->res->body('Hello Mojo!');}
6 января 2010 г.
mojo generate app TestMojo
[mkdir] test_mojo/script[write] test_mojo/script/test_mojo[chmod] test_mojo/script/test_mojo 744[mkdir] test_mojo/lib[write] test_mojo/lib/TestMojo.pm[mkdir] test_mojo/t[write] test_mojo/t/basic.t
6 января 2010 г.
#!/usr/bin/env perl
use strict;use warnings;
use Test::More tests => 1;
use_ok('TestMojo');
6 января 2010 г.
Full stack HTTP 1.1
6 января 2010 г.
6 января 2010 г.
MojoX::UserAgentPascal Gaudette
Thanks to the Google of Summer Code 2009!
6 января 2010 г.
CGI, FastCGI, PSGI, Daemon, Prefork
support
6 января 2010 г.
script/test_mojo COMMAND [OPTIONS]
script/test_mojo cgiscript/test_mojo fastcgiscript/test_mojo daemonscript/test_mojo daemon_prefork --port 80
6 января 2010 г.
script/test_mojo COMMAND [OPTIONS]
script/test_mojo cgiscript/test_mojo fastcgiscript/test_mojo daemonscript/test_mojo daemon_prefork --port 80
6 января 2010 г.
PATH_INFO='/' script/test_mojo cgi
Easy checkCan profile the mojo app using Devel::NYTProf
6 января 2010 г.
script/test_mojo COMMAND [OPTIONS]
script/test_mojo cgiscript/test_mojo fastcgiscript/test_mojo daemonscript/test_mojo daemon_prefork --port 80
6 января 2010 г.
Mojo::Server::FCGIscript/test_mojo fcgiscript/test_mojo fcgi_prefork
6 января 2010 г.
Mojo::Server::FCGIscript/test_mojo fcgiscript/test_mojo fcgi_prefork
6 января 2010 г.
Mojo::Server::FCGIscript/test_mojo fcgiscript/test_mojo fcgi_prefork
6 января 2010 г.
nginx + fcgi_prefork
6 января 2010 г.
location / { fastcgi_pass 127.0.0.1:3000; fastcgi_param MOJO_APP App; fastcgi_param SCRIPT_NAME http://127.0.0.1:3000; fastcgi_param PATH_INFO $fastcgi_script_name; fastcgi_param QUERY_STRING $query_string; fastcgi_param REQUEST_METHOD $request_method; fastcgi_param CONTENT_TYPE $content_type; fastcgi_param CONTENT_LENGTH $content_length;}
6 января 2010 г.
location / { fastcgi_pass 127.0.0.1:3000; fastcgi_param MOJO_APP App; fastcgi_param SCRIPT_NAME http://127.0.0.1:3000; fastcgi_param PATH_INFO $fastcgi_script_name; fastcgi_param QUERY_STRING $query_string; fastcgi_param REQUEST_METHOD $request_method; fastcgi_param CONTENT_TYPE $content_type; fastcgi_param CONTENT_LENGTH $content_length;}
6 января 2010 г.
location / { fastcgi_pass 127.0.0.1:3000; fastcgi_param MOJO_APP App; fastcgi_param SCRIPT_NAME http://127.0.0.1:3000; fastcgi_param PATH_INFO $fastcgi_script_name; fastcgi_param QUERY_STRING $query_string; fastcgi_param REQUEST_METHOD $request_method; fastcgi_param CONTENT_TYPE $content_type; fastcgi_param CONTENT_LENGTH $content_length;}
6 января 2010 г.
location / { fastcgi_pass 127.0.0.1:3000; fastcgi_param MOJO_APP App; fastcgi_param SCRIPT_NAME http://127.0.0.1:3000; fastcgi_param PATH_INFO $fastcgi_script_name; fastcgi_param QUERY_STRING $query_string; fastcgi_param REQUEST_METHOD $request_method; fastcgi_param CONTENT_TYPE $content_type; fastcgi_param CONTENT_LENGTH $content_length;}
6 января 2010 г.
location / { fastcgi_pass 127.0.0.1:3000; fastcgi_param MOJO_APP App; fastcgi_param SCRIPT_NAME http://127.0.0.1:3000; fastcgi_param PATH_INFO $fastcgi_script_name; fastcgi_param QUERY_STRING $query_string; fastcgi_param REQUEST_METHOD $request_method; fastcgi_param CONTENT_TYPE $content_type; fastcgi_param CONTENT_LENGTH $content_length;}
6 января 2010 г.
script/test_mojo COMMAND [OPTIONS]
script/test_mojo cgiscript/test_mojo fastcgiscript/test_mojo daemonscript/test_mojo daemon_prefork --port 80
6 января 2010 г.
MOJO_RELOAD=1 script/test_mojo daemon
Application code will reload on each request
6 января 2010 г.
script/test_mojo COMMAND [OPTIONS]
script/test_mojo cgiscript/test_mojo fastcgiscript/test_mojo daemonscript/test_mojo daemon_prefork --port 80
6 января 2010 г.
script/test_mojo COMMAND [OPTIONS]
script/test_mojo cgiscript/test_mojo fastcgiscript/test_mojo daemonscript/test_mojo daemon_prefork --port 80script/test_mojo test
6 января 2010 г.
script/test_mojo COMMAND [OPTIONS]
script/test_mojo cgiscript/test_mojo fastcgiscript/test_mojo daemonscript/test_mojo daemon_prefork --port 80script/test_mojo testscript/test_mojo get
6 января 2010 г.
script/test_mojo COMMAND [OPTIONS]
script/test_mojo cgiscript/test_mojo fastcgiscript/test_mojo daemonscript/test_mojo daemon_prefork --port 80script/test_mojo testscript/test_mojo get http://goo.gl
6 января 2010 г.
MVC web frameworks
6 января 2010 г.
Mojolicioususe base 'Mojo';
6 января 2010 г.
• Mojolicous::Controller
• Mojolicious::Plugin
• Mojolicious::Commands
• MojoX::Types
• MojoX::Dispatcher, MojoX::Routes
6 января 2010 г.
• Mojolicous::Controller
• Mojolicious::Plugin
• Mojolicious::Commands
• MojoX::Types
• MojoX::Dispatcher, MojoX::Routes
6 января 2010 г.
Controller Base Class
Mojolicious::Controller
6 января 2010 г.
• render
• render_text
• render_json
• render_inner
• render_partial
• pause / resume
• redirect_to / url_for
6 января 2010 г.
• render
• render_text
• render_json
• render_inner
• render_partial
• pause / resume
• redirect_to / url_for
6 января 2010 г.
• render(tempate => ‘foo/bar’)
• render_text
• render_json
• render_inner
• render_partial
• pause / resume
• redirect_to / url_for
6 января 2010 г.
• render(controller => ‘foo’, action => ‘bar’)
• render_text
• render_json
• render_inner
• render_partial
• pause / resume
• redirect_to / url_for
6 января 2010 г.
• render(‘foo/bar’, format => ‘html)
• render_text
• render_json
• render_inner
• render_partial
• pause / resume
• redirect_to / url_for
6 января 2010 г.
• render
• render_text
• render_json
• render_inner
• render_partial
• pause / resume
• redirect_to / url_for
6 января 2010 г.
• render
• render(text => ‘Saint Perl 2009’)
• render_json
• render_inner
• render_partial
• pause / resume
• redirect_to / url_for
6 января 2010 г.
• render
• render_text
• render_json
• render_inner
• render_partial
• pause / resume
• redirect_to / url_for
6 января 2010 г.
• render
• render_text
• render(json => {foo => ‘bar’})
• render_inner
• render_partial
• pause / resume
• redirect_to / url_for
6 января 2010 г.
• render
• render_text
• render_json
• render_inner
• render_partial
• pause / resume
• redirect_to / url_for
6 января 2010 г.
• render
• render_text
• render_json
• render_inner
• render_partial
• pause / resume
• redirect_to / url_for
6 января 2010 г.
• render
• render_text
• render_json
• render_inner
• render_partial
• pause / resume
• redirect_to / url_for
6 января 2010 г.
• render
• render_text
• render_json
• render_inner
• render_partial
• pause / resume
• redirect_to / url_for
6 января 2010 г.
• Mojolicous::Controller
• Mojolicious::Plugin
• Mojolicious::Commands
• MojoX::Types
• MojoX::Dispatcher, MojoX::Routes
6 января 2010 г.
Plugin Base Class
Mojolicious::Plugin
6 января 2010 г.
Plugins: load_plugin, add_hook, run_hook
Mojolicious::Plugins
6 января 2010 г.
• AgentCondition
• Charset
• DefaultHelpers
• EpRenderer
• EplRenderer
• RequestTimer
6 января 2010 г.
• AgentCondition
• Charset
• DefaultHelpers
• EpRenderer
• EplRenderer
• RequestTimer
6 января 2010 г.
• AgentCondition
• Charset
• DefaultHelpers
• EpRenderer
• EplRenderer
• RequestTimer
6 января 2010 г.
• AgentCondition
• Charset
• DefaultHelpers
• EpRenderer
• EplRenderer
• RequestTimer
6 января 2010 г.
• dumper
• param
• layout
• include
• content
• extends
6 января 2010 г.
• dumper
• param
• layout
• include
• content
• extends
6 января 2010 г.
• Data::Dumper (Maxdepth: 2, Indent: 1, Terse: 1)
• param
• layout
• include
• content
• extends
6 января 2010 г.
• dumper
• param
• layout
• include
• content
• extends
6 января 2010 г.
• dumper
• $self->req->param(...)
• layout
• include
• content
• extends
6 января 2010 г.
• dumper
• param
• layout
• include
• content
• extends
6 января 2010 г.
• dumper
• param
• $self->stash(layout => ...)
• include
• content
• extends
6 января 2010 г.
• dumper
• param
• layout
• include
• content
• extends
6 января 2010 г.
• dumper
• param
• layout
• $self->render_partial(...)
• content
• extends
6 января 2010 г.
• dumper
• param
• layout
• include
• content
• extends
6 января 2010 г.
• dumper
• param
• layout
• include
• $self->render_inner(...)
• extends
6 января 2010 г.
• dumper
• param
• layout
• include
• content
• extends
6 января 2010 г.
• dumper
• param
• layout
• include
• content
• $self->stash(extends => ...)
6 января 2010 г.
• AgentCondition
• Charset
• DefaultHelpers
• EpRenderer
• EplRenderer
• RequestTimer
6 января 2010 г.
• extention of temlplates is .epl
• my $self = shift;
• $self->stash(foo => ‘bar’)
6 января 2010 г.
• AgentCondition
• Charset
• DefaultHelpers
• EpRenderer
• EplRenderer
• RequestTimer
6 января 2010 г.
• extention of temlplates is .ep
• cashing templates with stash parameters
• $self->stash(foo => ‘bar’) – $foo
• any helpers
• default handler
6 января 2010 г.
• AgentCondition
• Charset
• DefaultHelpers
• EpRenderer
• EplRenderer
• RequestTimer
6 января 2010 г.
• Mojolicous::Controller
• Mojolicious::Plugin
• Mojolicious::Commands
• MojoX::Types
• MojoX::Dispatcher, MojoX::Routes
6 января 2010 г.
script/test_app COMMAND [OPTIONS]
script/test_app cgiscript/test_app fastcgiscript/test_app daemonscript/test_app daemon_prefork --port 80script/test_app testscript/test_app get
6 января 2010 г.
script/test_app COMMAND [OPTIONS]
script/test_app cgiscript/test_app fastcgiscript/test_app daemonscript/test_app daemon_prefork --port 80script/test_app testscript/test_app getscritp/test_app routes
6 января 2010 г.
• Mojolicous::Controller
• Mojolicious::Plugin
• Mojolicious::Commands
• MojoX::Types
• MojoX::Dispatcher, MojoX::Routes
6 января 2010 г.
• Mojolicous::Controller
• Mojolicious::Plugin
• Mojolicious::Commands
• MojoX::Types
• MojoX::Dispatcher, MojoX::Routes
6 января 2010 г.
A generationthe mojolicious app
6 января 2010 г.
mojolicious generate app TestApp
6 января 2010 г.
[mkdir] test_app/script[write] test_app/script/test_app[chmod] test_app/script/test_app 744[mkdir] test_app/lib[write] test_app/lib/TestApp.pm[mkdir] test_app/lib/TestApp[write] test_app/lib/TestApp/Example.pm[mkdir] test_app/t[write] test_app/t/basic.t[mkdir] test_app/log[mkdir] test_app/public[write] test_app/public/404.html[exist] test_app/public[write] test_app/public/500.html
6 января 2010 г.
[mkdir] test_app/script[write] test_app/script/test_app[chmod] test_app/script/test_app 744[mkdir] test_app/lib[write] test_app/lib/TestApp.pm[mkdir] test_app/lib/TestApp[write] test_app/lib/TestApp/Example.pm[mkdir] test_app/t[write] test_app/t/basic.t[mkdir] test_app/log[mkdir] test_app/public[write] test_app/public/404.html[exist] test_app/public[write] test_app/public/500.html
6 января 2010 г.
[mkdir] test_app/script[write] test_app/script/test_app[chmod] test_app/script/test_app 744[mkdir] test_app/lib[write] test_app/lib/TestApp.pm[mkdir] test_app/lib/TestApp[write] test_app/lib/TestApp/Example.pm[mkdir] test_app/t[write] test_app/t/basic.t[mkdir] test_app/log[mkdir] test_app/public[write] test_app/public/404.html[exist] test_app/public[write] test_app/public/500.html
6 января 2010 г.
[mkdir] test_app/script[write] test_app/script/test_app[chmod] test_app/script/test_app 744[mkdir] test_app/lib[write] test_app/lib/TestApp.pm[mkdir] test_app/lib/TestApp[write] test_app/lib/TestApp/Example.pm[mkdir] test_app/t[write] test_app/t/basic.t[mkdir] test_app/log[mkdir] test_app/public[write] test_app/public/404.html[exist] test_app/public[write] test_app/public/500.html
6 января 2010 г.
package TestApp;
use base 'Mojolicious';sub startup { my $self = shift; my $r = $self->routes; $r->route('/:controller/:action/:id') ->to(controller => 'example', action => 'welcome', id => 1);}
6 января 2010 г.
package TestApp;
use base 'Mojolicious';sub startup { my $self = shift; my $r = $self->routes; $r->route('/:controller/:action/:id') ->to(controller => 'example', action => 'welcome', id => 1);}
6 января 2010 г.
package TestApp;
use base 'Mojolicious';sub startup { my $self = shift;
my $r = $self->routes; $r->route('/:controller/:action/:id') ->to(controller => 'example', action => 'welcome', id => 1);}
6 января 2010 г.
package TestApp;
use base 'Mojolicious';sub startup { my $self = shift;
my $r = $self->routes; $r->route('/:controller/:action/:id') ->to(controller => 'example', action => 'welcome', id => 1);}
6 января 2010 г.
package TestApp;
use base 'Mojolicious';sub startup { my $self = shift;
my $r = $self->routes; $r->route('/:controller/:action/:id') ->to(controller => 'example', action => 'welcome', id => 1);}
6 января 2010 г.
package TestApp;
use base 'Mojolicious';sub startup { my $self = shift;
my $r = $self->routes; $r->route('/:controller/:action/:id') ->to(controller => 'example', action => 'welcome', id => 1);}
6 января 2010 г.
package TestApp;
use base 'Mojolicious';sub startup { my $self = shift;
my $r = $self->routes; $r->bridge->route('/:controller/:action/:id') ->to(controller => 'example', action => 'welcome', id => 1);}
6 января 2010 г.
package TestApp;
use base 'Mojolicious';sub startup { my $self = shift;
my $r = $self->routes; $r->route('/:controller/:action/:id') ->to(controller => 'example', action => 'welcome', id => 1);}
6 января 2010 г.
package TestApp::Example;
use base 'Mojolicious::Controller';sub welcome { my $self = shift; warn $self->stash(‘id’); $self->render(message => 'Welcome!');}
1;
6 января 2010 г.
[exist] test_app/public[write] test_app/public/index.html[mkdir] test_app/templates[write] test_app/templates/exception.html.ep[write] test_app/templates/not_found.html.ep[mkdir] test_app/templates/layouts[write] test_app/templates/layouts/default.html.ep[mkdir] test_app/templates/example[write] test_app/templates/example/welcome.html.ep
6 января 2010 г.
[exist] test_app/public[write] test_app/public/index.html[mkdir] test_app/templates[write] test_app/templates/exception.html.ep[write] test_app/templates/not_found.html.ep[mkdir] test_app/templates/layouts[write] test_app/templates/layouts/default.html.ep[mkdir] test_app/templates/example[write] test_app/templates/example/welcome.html.ep
6 января 2010 г.
example/welcome.html.ep
Path to the template
6 января 2010 г.
example/welcome.html.ep
Path to the template
6 января 2010 г.
controller/welcome.html.ep
Path to the template
6 января 2010 г.
example/welcome.html.ep
Path to the template
6 января 2010 г.
example/welcome.html.ep
Path to the template
6 января 2010 г.
example/action.html.ep
Path to the template
6 января 2010 г.
example/welcome.html.ep
Path to the template
6 января 2010 г.
example/welcome.html.ep
Path to the template
6 января 2010 г.
example/welcome.html.handler
Path to the template
6 января 2010 г.
example/welcome.html.ep
Path to the template
6 января 2010 г.
example/welcome.html.epl
Path to the template
6 января 2010 г.
example/welcome.html.tt
Path to the template
6 января 2010 г.
example/welcome.html.ht
Path to the template
6 января 2010 г.
example/welcome.html.pro
Path to the template
6 января 2010 г.
example/welcome.html.ctpp2
Path to the template
6 января 2010 г.
example/welcome.html.foo
Path to the template
6 января 2010 г.
example/welcome.html.ep
Path to the template
6 января 2010 г.
example/welcome.html.ep
Path to the template
6 января 2010 г.
example/welcome.format.ep
Path to the template
6 января 2010 г.
example/welcome.html.ep
Path to the template
6 января 2010 г.
example/welcome.xml.ep
Path to the template
6 января 2010 г.
example/welcome.rss.ep
Path to the template
6 января 2010 г.
example/welcome.json.ep
Path to the template
6 января 2010 г.
example/welcome.yaml.ep
Path to the template
6 января 2010 г.
example/welcome.mail.ep
Path to the template
6 января 2010 г.
example/welcome.bar.ep
Path to the template
6 января 2010 г.
example/welcome.html.ep
Path to the template
6 января 2010 г.
example/welcome.html.ep
Path to the template
6 января 2010 г.
controller/action.format.handler
Path to the template
6 января 2010 г.
% layout 'default';
<h2><%= $message %></h2>
<a href="<%== url_for %>">click here</a>
6 января 2010 г.
[exist] test_app/public[write] test_app/public/index.html[mkdir] test_app/templates[write] test_app/templates/exception.html.ep[write] test_app/templates/not_found.html.ep[mkdir] test_app/templates/layouts[write] test_app/templates/layouts/default.html.ep[mkdir] test_app/templates/example[write] test_app/templates/example/welcome.html.ep
6 января 2010 г.
<!doctype html><html> <head><title>Welcome</title></head> <body> <%== content %> </body></html>
6 января 2010 г.
[exist] test_app/public[write] test_app/public/index.html[mkdir] test_app/templates[write] test_app/templates/exception.html.ep[write] test_app/templates/not_found.html.ep[mkdir] test_app/templates/layouts[write] test_app/templates/layouts/default.html.ep[mkdir] test_app/templates/example[write] test_app/templates/example/welcome.html.ep
6 января 2010 г.
Global symbol "$message2" requires explicit package name at (eval 280) line 2.
1: % layout 'default';2: <h2><%= $message2 %></h2>3: ...
{ 'status' => 500, 'message' => ‘Saint Perl 2009’, ... }
6 января 2010 г.
$ENV{MOJO_MODE}Default value is development
6 января 2010 г.
[exist] test_app/public[write] test_app/public/index.html[mkdir] test_app/templates[write] test_app/templates/exception.html.ep[write] test_app/templates/not_found.html.ep[mkdir] test_app/templates/layouts[write] test_app/templates/layouts/default.html.ep[mkdir] test_app/templates/example[write] test_app/templates/example/welcome.html.ep
6 января 2010 г.
Mojolicious::Liteuse base 'Mojolicious';
6 января 2010 г.
mojolicious generate lite_app test_lite
6 января 2010 г.
[write] test_lite[chmod] test_lite 744
6 января 2010 г.
use Mojolicious::Lite;
get '/' => 'index';
any '/:groovy' => sub { my $self = shift; $self->render_text($self->stash('groovy'));};
shagadelic;
6 января 2010 г.
use Mojolicious::Lite;
get '/' => 'index';
any '/:groovy' => sub { my $self = shift; $self->render_text($self->stash('groovy'));};
shagadelic;
6 января 2010 г.
use Mojolicious::Lite;
get '/' => 'index';
any '/:groovy' => sub { my $self = shift; $self->render_text($self->stash('groovy'));};
shagadelic;
6 января 2010 г.
use Mojolicious::Lite;
post '/' => 'index';
any '/:groovy' => sub { my $self = shift; $self->render_text($self->stash('groovy'));};
shagadelic;
6 января 2010 г.
use Mojolicious::Lite;
any '/' => 'index';
any '/:groovy' => sub { my $self = shift; $self->render_text($self->stash('groovy'));};
shagadelic;
6 января 2010 г.
use Mojolicious::Lite;
get '/' => 'index';
any '/:groovy' => sub { my $self = shift; $self->render_text($self->stash('groovy'));};
shagadelic;
6 января 2010 г.
use Mojolicious::Lite;
get '/' => 'index';
any '/:groovy' => [groovy => qr/\d+/] => sub { my $self = shift; $self->render_text($self->stash('groovy'));};
shagadelic;
6 января 2010 г.
use Mojolicious::Lite;
get '/' => 'index';
any '/:groovy' => {groovy => 42} => sub { my $self = shift; $self->render_text($self->stash('groovy'));};
shagadelic;
6 января 2010 г.
use Mojolicious::Lite;
get '/' => 'index';
any '/:groovy' => (agent=>qr/Firefox/) => sub { my $self = shift; $self->render_text($self->stash('groovy'));};
shagadelic;
6 января 2010 г.
use Mojolicious::Lite;
get '/' => 'index';
any '/:groovy' => sub { my $self = shift; $self->render_text($self->stash('groovy'));};app->renderer->default_handler(‘epl’);shagadelic;
6 января 2010 г.
use Mojolicious::Lite;ladder sub { ... }; # authget '/' => 'index';
any '/:groovy' => sub { my $self = shift; $self->render_text($self->stash('groovy'));};
shagadelic;
6 января 2010 г.
use Mojolicious::Lite;
get '/' => 'index';
any '/:groovy' => sub { my $self = shift; $self->render_text($self->stash('groovy'));};
shagadelic; # shagadelic(‘cgi’)
6 января 2010 г.
__DATA__
@@ index.html.ep% layout 'funky';Yea baby!
@@ layouts/funky.html.ep<!doctype html><html> <body> <%== content %> </body></html>
6 января 2010 г.
Mojo modules on CPAN
6 января 2010 г.
Mojo modules on CPAN
• Mojo
• Mojo::Server::FCGI
• AnyEvent::Mojo
• Apache::Mojo, Apache2::Mojo
• Catalyst::Engine::Mojo,Squatting::On::Mojo
• MojoX::UserAgent
• MojoX::Routes::AsGraph
• MojoX::Session
• MojoX::Log::*
• MojoX::Renderer::*
• JSON
• TT
• CTTP2, HTP
6 января 2010 г.
Mojo Guide StyleRules
6 января 2010 г.
• Keep it simple, no magick unless absolutely nessary
• Code should be written with a Perl6 port in mind
• It’s not a feature without a test
• Only add prereqs if absolutely necessary
• No inline POD
• No spaghetti code
• Every files should contain at least one quote fromThe Simpsons or Futurama
Mojo Guide Style
6 января 2010 г.
• Keep it simple, no magick unless absolutely nessary
• Code should be written with a Perl6 port in mind
• It’s not a feature without a test
• Only add prereqs if absolutely necessary
• No inline POD
• No spaghetti code
• Every files should contain at least one quote fromThe Simpsons or Futurama
Mojo Guide Style
6 января 2010 г.
• Keep it simple, no magick unless absolutely nessary
• Code should be written with a Perl6 port in mind
• It’s not a feature without a test
• Only add prereqs if absolutely necessary
• No inline POD
• No spaghetti code
• Every files should contain at least one quote fromThe Simpsons or Futurama
Mojo Guide Style
6 января 2010 г.
• Keep it simple, no magick unless absolutely nessary
• Code should be written with a Perl6 port in mind
• It’s not a feature without a test
• Only add prereqs if absolutely necessary
• No inline POD
• No spaghetti code
• Every files should contain at least one quote fromThe Simpsons or Futurama
Mojo Guide Style
6 января 2010 г.
• Keep it simple, no magick unless absolutely nessary
• Code should be written with a Perl6 port in mind
• It’s not a feature without a test
• Only add prereqs if absolutely necessary
• No inline POD
• No spaghetti code
• Every files should contain at least one quote fromThe Simpsons or Futurama
Mojo Guide Style
6 января 2010 г.
• Keep it simple, no magick unless absolutely nessary
• Code should be written with a Perl6 port in mind
• It’s not a feature without a test
• Only add prereqs if absolutely necessary
• No inline POD
• No spaghetti code
• Every files should contain at least one quote fromThe Simpsons or Futurama
Mojo Guide Style
6 января 2010 г.
• Keep it simple, no magick unless absolutely nessary
• Code should be written with a Perl6 port in mind
• It’s not a feature without a test
• Only add prereqs if absolutely necessary
• No inline POD
• No spaghetti code
• Every files should contain at least one quote fromThe Simpsons or Futurama :)
Mojo Guide Style
6 января 2010 г.
The Simpsons or Futurama6 января 2010 г.
Stable version and backwards compatibility
6 января 2010 г.
Mojo 0.999915The latest version of Mojo always available
on github.com
6 января 2010 г.
http://github.com/kraih/mojo6 января 2010 г.
Nobackwards
compatibility :)Until the first stable version will not be released
6 января 2010 г.
First critical bug
6 января 2010 г.
get ‘/bug/’ => sub { my $self = shift;
# open my $fh, ‘|-’, ‘/usr/sbin/sendmail -t’; open my $fh, ‘|-’, ‘perl test.pl’; print $fh join "\n", 'To: sharifulin at gmail.com', 'Subject: Test', '', 'Test!'; $self->render_text(‘Test’);;};
6 января 2010 г.
get ‘/bug/’ => sub { my $self = shift;
# open my $fh, ‘|-’, ‘/usr/sbin/sendmail -t’; open my $fh, ‘|-’, ‘perl test.pl’; print $fh join "\n", 'To: sharifulin at gmail.com', 'Subject: Test', '', 'Test!'; $self->render_text(‘Test’);;};
6 января 2010 г.
test.pl
#!/usr/bin/perlwarn $_ while <STDIN>;
6 января 2010 г.
script/test_bug daemon # OK
6 января 2010 г.
script/test_bug daemon # OKscript/test_bug daemon_prefork # DIE
6 января 2010 г.
Mojo::Server::Daemon::Prefork #323:
$SIG{HUP } = $SIG{INT } = $SIG{CHLD} = $SIG{TERM} = sub { exit 0 };
6 января 2010 г.
Mojo::Server::Daemon::Prefork #323:
$SIG{HUP } = $SIG{INT } = $SIG{CHLD} = $SIG{TERM} = sub { exit 0 };
6 января 2010 г.
Mojo::Server::Daemon::Prefork #323:
$SIG{HUP } = $SIG{INT } = $SIG{TERM } = sub { exit 0 };
$SIG{CHLD} = ‘IGNORE’;
6 января 2010 г.
Second critical bug
6 января 2010 г.
MOJO_RELOAD, daemon и attr
6 января 2010 г.
MOJO_RELOAD=1 script/test_bug2 daemon# OK
6 января 2010 г.
MOJO_RELOAD=1 script/test_bug2 daemon# sometimes ERROR
6 января 2010 г.
script/test_bug2 daemon_prefork # OK
6 января 2010 г.
package App;use base ‘Mojo::Base’;
__PACKAGE__->attr(conf => sub { return do ‘conf/app.conf’;});__PACKAGE__->attr(db => sub { my $self = shift; return Util->db($self->conf->{'db'});});
sub dispatch { ... }6 января 2010 г.
package App;use base ‘Mojo::Base’;
__PACKAGE__->attr(conf => sub { return do ‘conf/app.conf’;});__PACKAGE__->attr(db => sub { my $self = shift; return Util->db($self->conf->{'db'});});
sub dispatch { ... }6 января 2010 г.
package App;use base ‘Mojo::Base’;
__PACKAGE__->attr(conf => sub { return do ‘conf/app.conf’;});__PACKAGE__->attr(db => sub { my $self = shift; return $::DB ||= Util->db(...->{'db'});});
sub dispatch { ... }6 января 2010 г.
Documentation
6 января 2010 г.
DocumentationLess than necessary :)
6 января 2010 г.
Links
• http://mojolicious.org
• http://labs.kraih.com/blog/
• http://search.cpan.org/dist/Mojo/
• http://github.com/kraih/mojo
• http://sharifulin.livejournal.com/tag/mojo
• http://getbootylicious.org/
6 января 2010 г.
Links
• http://mojolicious.org
• http://labs.kraih.com/blog/
• http://search.cpan.org/dist/Mojo/
• http://github.com/kraih/mojo
• http://sharifulin.livejournal.com/tag/mojo
• http://getbootylicious.org/
6 января 2010 г.
Bootylicious6 января 2010 г.
Bootylicious6 января 2010 г.
Links
• irc://irc.perl.org/#mojo
• http://lists.kraih.com/cgi-bin/mailman/listinfo/mojo
• Twitter: @kraih, @vtivti, @sharifulin
• Juick: @vti, @sharifulin
6 января 2010 г.
The latest news
• PSGI and Plack is the future of HTTP::Engine that has support for servers like CGI, FastCGI, Apache, AnyEvent and Mojo.
• New #mod_perlite release looks great, #Mojolicious with CGI backend should "just work™" on it.
• Slowly starting with documentation work, crazy how much #Mojolicious has grown recently, looks like it needs a few extra chapters now. :)
• Added native #PSGI support to #Mojolicious
6 января 2010 г.
My experience in the development
using Mojo
6 января 2010 г.
Mojolicious + MojoX::Renderer::TT6 января 2010 г.
Mojo + JSON6 января 2010 г.
Mojolicious::Lite + MojoX::Renderer::JSON
6 января 2010 г.
Mojolicious::Lite + MojoX::Renderer::JSON + RSS
6 января 2010 г.
Mojolicious + Mojo::Template6 января 2010 г.
Mojolicious + EpRenderer~7 projects
6 января 2010 г.
«Making hard things possible and everything fun!»The motto of Mojolicious
6 января 2010 г.
use Mojoor die
6 января 2010 г.
use Perlor die
6 января 2010 г.
JFDI
6 января 2010 г.
any ‘/questions’ => sub { shift->render( answer => ‘sharifulin’, );};shagadelic;
6 января 2010 г.
Thanks!Anatoly SharifulinRostovOnDon.pm
6 января 2010 г.