Mojo.
                   The web in a box!
                        Saint Perl 2009
                         English version




6 января 2010 г.
http://mojolicious.org/
6 января 2010 г.
Sebastian Riedel
                      автор Catalyst и Mojo
                       http://labs.kraih.com/




6 января 2010 г.
http://twitter.com/kraih
6 января 2010 г.
Sebastian Riedel
                      автор Catalyst и Mojo
                       http://labs.kraih.com/




6 января 2010 г.
Sebastian Riedel
                    creator 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 г.
Mojo::Base
                   Minimal Base Class For Mojo Projects




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 г.
Mojo::ByteStream
                        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 г.
Mojo::Template
                      Perlish Templates!




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 г.
Mojo::JSON
                    Minimalistic 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 г.
Mojo::Loader
                   Class loader: load, reload, search




6 января 2010 г.
Mojo::Loader
                   Class loader: load, reload, search




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 requirements
                       besides Perl 5.8.1




6 января 2010 г.
Mojo runtime
6 января 2010 г.
Perl 5.005
6 января 2010 г.
Perl 5.006002
6 января 2010 г.
Perl 5.008001
6 января 2010 г.
Mojo Perl 5.010
6 января 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.1
             Connection: keep-alive
             Accept: text/html, application/xhtml, ....
             Accept-Charset: windows-1251, utf-8; ...
             Accept-Encoding: gzip,deflate
             Accept-Language: ru,en-us;q=0.7,en;q=0.3
             Host: localhost:3000
             User-Agent: Mozilla/5.0 (Macintosh; ...
             Content-Length: 0
             Keep-Alive: 300

6 января 2010 г.
GET / HTTP/1.1
             Connection: keep-alive
             Accept: text/html, application/xhtml, ....
             Accept-Charset: windows-1251, utf-8; ...
             Accept-Encoding: gzip,deflate
             Accept-Language: ru,en-us;q=0.7,en;q=0.3
             Host: localhost:3000
             User-Agent: Mozilla/5.0 (Macintosh; ...
             Content-Length: 0
             Keep-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::UserAgent
                                 Pascal 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 cgi
                    script/test_mojo fastcgi
                    script/test_mojo daemon
                    script/test_mojo daemon_prefork --port 80




6 января 2010 г.
script/test_mojo
                   COMMAND [OPTIONS]
                    script/test_mojo cgi
                    script/test_mojo fastcgi
                    script/test_mojo daemon
                    script/test_mojo daemon_prefork --port 80




6 января 2010 г.
PATH_INFO='/' script/
                      test_mojo cgi
                                    Easy check
                    Can profile the mojo app using Devel::NYTProf




6 января 2010 г.
script/test_mojo
                   COMMAND [OPTIONS]
                    script/test_mojo cgi
                    script/test_mojo fastcgi
                    script/test_mojo daemon
                    script/test_mojo daemon_prefork --port 80




6 января 2010 г.
Mojo::Server::FCGI
                   script/test_mojo fcgi
                   script/test_mojo fcgi_prefork




6 января 2010 г.
Mojo::Server::FCGI
                   script/test_mojo fcgi
                   script/test_mojo fcgi_prefork




6 января 2010 г.
Mojo::Server::FCGI
                   script/test_mojo fcgi
                   script/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 cgi
                    script/test_mojo fastcgi
                    script/test_mojo daemon
                    script/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 cgi
                    script/test_mojo fastcgi
                    script/test_mojo daemon
                    script/test_mojo daemon_prefork --port 80




6 января 2010 г.
script/test_mojo
                   COMMAND [OPTIONS]
                    script/test_mojo cgi
                    script/test_mojo fastcgi
                    script/test_mojo daemon
                    script/test_mojo daemon_prefork --port 80
                    script/test_mojo test



6 января 2010 г.
script/test_mojo
                   COMMAND [OPTIONS]
                    script/test_mojo cgi
                    script/test_mojo fastcgi
                    script/test_mojo daemon
                    script/test_mojo daemon_prefork --port 80
                    script/test_mojo test
                    script/test_mojo get


6 января 2010 г.
script/test_mojo
                   COMMAND [OPTIONS]
                    script/test_mojo cgi
                    script/test_mojo fastcgi
                    script/test_mojo daemon
                    script/test_mojo daemon_prefork --port 80
                    script/test_mojo test
                    script/test_mojo get http://goo.gl


6 января 2010 г.
MVC web frameworks



6 января 2010 г.
Mojolicious
                     use 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 г.
Mojolicious::Controller
                         Controller Base Class




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 г.
Mojolicious::Plugin
                        Plugin Base Class




6 января 2010 г.
Mojolicious::Plugins
                   Plugins: load_plugin, add_hook, run_hook




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 cgi
                    script/test_app fastcgi
                    script/test_app daemon
                    script/test_app daemon_prefork --port 80
                    script/test_app test
                    script/test_app get


6 января 2010 г.
script/test_app
                   COMMAND [OPTIONS]
                    script/test_app cgi
                    script/test_app fastcgi
                    script/test_app daemon
                    script/test_app daemon_prefork --port 80
                    script/test_app test
                    script/test_app get
                    scritp/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 generation
                   the 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::Lite
                      use 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 { ... }; # auth
                   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; # 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                      •   MojoX::Routes::AsGraph

                   •   Mojo::Server::FCGI
                                                 •   MojoX::Session
                   •   AnyEvent::Mojo
                                                 •   MojoX::Log::*
                   •   Apache::Mojo,
                       Apache2::Mojo
                                                 •   MojoX::Renderer::*

                   •   Catalyst::Engine::Mojo,
                                                     •   JSON
                       Squatting::On::Mojo
                                                     •   TT
                   •   MojoX::UserAgent
                                                     •   CTTP2, HTP


6 января 2010 г.
Mojo Guide Style
                         Rules




6 января 2010 г.
Mojo Guide Style
        • 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 from
                   The Simpsons or Futurama

6 января 2010 г.
Mojo Guide Style
        • 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 from
                   The Simpsons or Futurama

6 января 2010 г.
Mojo Guide Style
        • 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 from
                   The Simpsons or Futurama

6 января 2010 г.
Mojo Guide Style
        • 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 from
                   The Simpsons or Futurama

6 января 2010 г.
Mojo Guide Style
        • 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 from
                   The Simpsons or Futurama

6 января 2010 г.
Mojo Guide Style
        • 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 from
                   The Simpsons or Futurama

6 января 2010 г.
Mojo Guide Style
        • 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 from
                   The Simpsons or Futurama :)

6 января 2010 г.
The Simpsons or Futurama
6 января 2010 г.
Stable version and
                   backwards compatibility


6 января 2010 г.
Mojo 0.999915
                   The latest version of Mojo always available
                                  on github.com




6 января 2010 г.
http://github.com/kraih/mojo
6 января 2010 г.
No
                            backwards
                          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/perl
               warn $_ while <STDIN>;




6 января 2010 г.
script/test_bug daemon # OK




6 января 2010 г.
script/test_bug daemon # OK
                   script/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 г.
Documentation
                     Less 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 г.
Bootylicious
6 января 2010 г.
Bootylicious
6 января 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::TT
6 января 2010 г.
Mojo + JSON
6 января 2010 г.
Mojolicious::Lite +
6 января 2010 г.
                   MojoX::Renderer::JSON
Mojolicious::Lite +
6 января 2010 г.
                   MojoX::Renderer::JSON + RSS
Mojolicious + Mojo::Template
6 января 2010 г.
Mojolicious + EpRenderer
                            ~7 projects




6 января 2010 г.
«Making hard things possible and
                          everything fun!»
                           The motto of Mojolicious




6 января 2010 г.
use Mojo
                     or die




6 января 2010 г.
use Perl
                     or die




6 января 2010 г.
JFDI



6 января 2010 г.
any ‘/questions’ => sub {
           
 
 shift->render(
           
 
 
 answer => ‘sharifulin’,
           
 
 );
           };
           shagadelic;
6 января 2010 г.
Thanks!
                   Anatoly Sharifulin
                   RostovOnDon.pm




6 января 2010 г.

Mojo. The web in a box!

  • 1.
    Mojo. The web in a box! Saint Perl 2009 English version 6 января 2010 г.
  • 2.
  • 3.
    Sebastian Riedel автор Catalyst и Mojo http://labs.kraih.com/ 6 января 2010 г.
  • 4.
  • 5.
    Sebastian Riedel автор Catalyst и Mojo http://labs.kraih.com/ 6 января 2010 г.
  • 6.
    Sebastian Riedel creator of Catalyst and Mojo http://labs.kraih.com/ 6 января 2010 г.
  • 7.
    Catalyst + Mojo= ? 6 января 2010 г.
  • 8.
    What is Mojo? 6января 2010 г.
  • 9.
    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 г.
  • 10.
    Pure Perl framework 6 января 2010 г.
  • 11.
    • 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 г.
  • 12.
    • 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 г.
  • 13.
    Mojo::Base Minimal Base Class For Mojo Projects 6 января 2010 г.
  • 14.
    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 г.
  • 15.
    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 г.
  • 16.
    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 г.
  • 17.
    • 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 г.
  • 18.
    Mojo::ByteStream ByteStream 6 января 2010 г.
  • 19.
    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 г.
  • 20.
    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 г.
  • 21.
    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 г.
  • 22.
    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 г.
  • 23.
    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 г.
  • 24.
    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 г.
  • 25.
    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 г.
  • 26.
    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 г.
  • 27.
    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 г.
  • 28.
    • 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 г.
  • 29.
    Mojo::Template Perlish Templates! 6 января 2010 г.
  • 30.
    % my $list= $self->stash(‘list’); <ul> % for (@$list) { <li> <%= $_->{title} %> </li> %} </ul> <p><%# comment %></p> 6 января 2010 г.
  • 31.
    % my $list= $self->stash(‘list’); <ul> % for (@$list) { <li> <%= $_->{title} %> </li> %} </ul> <p><%# comment %></p> 6 января 2010 г.
  • 32.
    % my $list= $self->stash(‘list’); <ul> % for (@$list) { <li> <%= $_->{title} %> </li> %} </ul> <p><%# comment %></p> 6 января 2010 г.
  • 33.
    %= my $list= $self->stash(‘list’); <ul> % for (@$list) { <li> <%= $_->{title} %> </li> %} </ul> <p><%# comment %></p> 6 января 2010 г.
  • 34.
    %== my $list= $self->stash(‘list’); <ul> % for (@$list) { <li> <%= $_->{title} %> </li> %} </ul> <p><%# comment %></p> 6 января 2010 г.
  • 35.
    % my $list= $self->stash(‘list’); <ul> % for (@$list) { <li> <%= $_->{title} %> </li> %} </ul> <p><%# comment %></p> 6 января 2010 г.
  • 36.
    % use Foo::Bar; <ul> % for (@$list) { <li> <%= $_->{title} %> </li> %} </ul> <p><%# comment %></p> 6 января 2010 г.
  • 37.
    % my $list= $self->stash(‘list’); <ul> % for (@$list) { <li> <%= $_->{title} %> </li> %} </ul> <p><%# comment %></p> 6 января 2010 г.
  • 38.
    % my $list= $self->stash(‘list’); <ul> % for (@$list) { <li> <%= $_->{title} %> </li> %} </ul> <p><%# comment %></p> 6 января 2010 г.
  • 39.
    % my $list= $self->stash(‘list’); <ul> % for (@$list) { <li> <%= $_->{title} %> </li> %} </ul> <p><%# comment %></p> 6 января 2010 г.
  • 40.
    % my $list= $self->stash(‘list’); <ul> % for (@$list) { <li> <%= $_->{title} %> </li> %} </ul> <p><%# comment %></p> 6 января 2010 г.
  • 41.
    % my $list= $self->stash(‘list’); <ul> % for (@$list) { <li> <%== $_->{title} %> </li> %} </ul> <p><%# comment %></p> 6 января 2010 г.
  • 42.
    % my $list= $self->stash(‘list’); <ul> % for (@$list) { <li> <% my $foo = $_->{id} + 100500; %> </li> %} </ul> <p><%# comment %></p> 6 января 2010 г.
  • 43.
    % my $list= $self->stash(‘list’); <ul> % for (@$list) { <li> <% my $foo = $_->{id} + 100500; %> </li> %} </ul> <p><%# comment %></p> 6 января 2010 г.
  • 44.
    % my $list= $self->stash(‘list’); <ul> % for (@$list) { <li> <%= $_->{title} %> </li> %} </ul> <p><%# comment %></p> 6 января 2010 г.
  • 45.
    % my $list= $self->stash(‘list’); <ul> % for (@$list) { <li> <%= $_->{title} %> </li> %} </ul> <p><%# comment %></p> 6 января 2010 г.
  • 46.
    % my $list= $self->stash(‘list’); <ul> % for (@$list) { <li> <%= $_->{title} %> </li> %} </ul> <p><%# comment %></p> 6 января 2010 г.
  • 47.
    • 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 г.
  • 48.
    Mojo::JSON Minimalistic JSON 6 января 2010 г.
  • 49.
    my $json =Mojo::JSON->new; my $string = $json->encode({foo => ‘bar’}); my $hash = $json->decode(‘{"foo":"bar"}’); 6 января 2010 г.
  • 50.
    my $json =Mojo::JSON->new; my $string = $json->encode({foo => ‘bar’}); my $hash = $json->decode(‘{"foo":"bar"}’); 6 января 2010 г.
  • 51.
    my $json =Mojo::JSON->new; my $string = $json->encode({foo => ‘bar’}); my $hash = $json->decode(‘{"foo":"bar"}’); 6 января 2010 г.
  • 52.
    • 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 г.
  • 53.
    Mojo::Loader Class loader: load, reload, search 6 января 2010 г.
  • 54.
    Mojo::Loader Class loader: load, reload, search 6 января 2010 г.
  • 55.
    • 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 г.
  • 56.
    • 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 г.
  • 57.
    • 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 г.
  • 58.
    • 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 г.
  • 59.
    • 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 г.
  • 60.
    • 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 г.
  • 61.
    • 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 г.
  • 62.
    my $client =Mojo::Client->new; $client->get( ‘http://goo.gl’ => sub { my ($self, $tx) = @_; say $tx->res; } )->process; 6 января 2010 г.
  • 63.
    my $client =Mojo::Client->new; $client->get( ‘http://goo.gl’ => sub { my ($self, $tx) = @_; say $tx->res; } )->process; 6 января 2010 г.
  • 64.
    my $client =Mojo::Client->new; $client->post( ‘http://goo.gl’ => sub { my ($self, $tx) = @_; say $tx->res; } )->process; 6 января 2010 г.
  • 65.
    my $client =Mojo::Client->new; $client->head( ‘http://goo.gl’ => sub { my ($self, $tx) = @_; say $tx->res; } )->process; 6 января 2010 г.
  • 66.
    my $client =Mojo::Client->new; $client->put( ‘http://goo.gl’ => sub { my ($self, $tx) = @_; say $tx->res; } )->process; 6 января 2010 г.
  • 67.
    my $client =Mojo::Client->new; $client->get( ‘http://goo.gl’ => sub { my ($self, $tx) = @_; say $tx->res; } )->process; 6 января 2010 г.
  • 68.
    my $client =Mojo::Client->new; $client->get( ‘http://goo.gl’ => sub { my ($self, $tx) = @_; say $tx->res; } )->process; 6 января 2010 г.
  • 69.
    my $client =Mojo::Client->new; $client->get( ‘http://goo.gl’ => sub { my ($self, $tx) = @_; say $tx->res; } )->process; 6 января 2010 г.
  • 70.
    my $client =Mojo::Client->new; $client->get( ‘http://goo.gl’ => sub { my ($self, $tx) = @_; say $tx->res; } )->process; 6 января 2010 г.
  • 71.
    my $client =Mojo::Client->new; $client->get( ‘http://goo.gl’ => sub { my ($self, $tx) = @_; say $tx->res; } )->process; 6 января 2010 г.
  • 72.
    • 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 г.
  • 73.
    • 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 г.
  • 74.
    • 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 г.
  • 75.
    • 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 г.
  • 76.
    • 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 г.
  • 77.
    Mojo is the web in a box! 6 января 2010 г.
  • 78.
    No requirements besides Perl 5.8.1 6 января 2010 г.
  • 79.
  • 80.
  • 81.
  • 82.
  • 83.
    Mojo Perl 5.010 6января 2010 г.
  • 84.
    Object oriented API 6января 2010 г.
  • 85.
    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 г.
  • 86.
    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 г.
  • 87.
    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 г.
  • 88.
    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 г.
  • 89.
    use overload '""'=> sub { shift->to_string }, fallback => 1; 6 января 2010 г.
  • 90.
    GET / HTTP/1.1 Connection: keep-alive Accept: text/html, application/xhtml, .... Accept-Charset: windows-1251, utf-8; ... Accept-Encoding: gzip,deflate Accept-Language: ru,en-us;q=0.7,en;q=0.3 Host: localhost:3000 User-Agent: Mozilla/5.0 (Macintosh; ... Content-Length: 0 Keep-Alive: 300 6 января 2010 г.
  • 91.
    GET / HTTP/1.1 Connection: keep-alive Accept: text/html, application/xhtml, .... Accept-Charset: windows-1251, utf-8; ... Accept-Encoding: gzip,deflate Accept-Language: ru,en-us;q=0.7,en;q=0.3 Host: localhost:3000 User-Agent: Mozilla/5.0 (Macintosh; ... Content-Length: 0 Keep-Alive: 300 6 января 2010 г.
  • 92.
    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 г.
  • 93.
    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 г.
  • 94.
    A generation of the mojo app 6 января 2010 г.
  • 95.
    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 г.
  • 96.
    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 г.
  • 97.
    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 г.
  • 98.
    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 г.
  • 99.
    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 г.
  • 100.
    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 г.
  • 101.
    #!/usr/bin/env perl use strict; use warnings; use Test::More tests => 1; use_ok('TestMojo'); 6 января 2010 г.
  • 102.
    Full stack HTTP1.1 6 января 2010 г.
  • 103.
  • 104.
    MojoX::UserAgent Pascal Gaudette Thanks to the Google of Summer Code 2009! 6 января 2010 г.
  • 105.
    CGI, FastCGI, PSGI, Daemon, Prefork support 6 января 2010 г.
  • 106.
    script/test_mojo COMMAND [OPTIONS] script/test_mojo cgi script/test_mojo fastcgi script/test_mojo daemon script/test_mojo daemon_prefork --port 80 6 января 2010 г.
  • 107.
    script/test_mojo COMMAND [OPTIONS] script/test_mojo cgi script/test_mojo fastcgi script/test_mojo daemon script/test_mojo daemon_prefork --port 80 6 января 2010 г.
  • 108.
    PATH_INFO='/' script/ test_mojo cgi Easy check Can profile the mojo app using Devel::NYTProf 6 января 2010 г.
  • 109.
    script/test_mojo COMMAND [OPTIONS] script/test_mojo cgi script/test_mojo fastcgi script/test_mojo daemon script/test_mojo daemon_prefork --port 80 6 января 2010 г.
  • 110.
    Mojo::Server::FCGI script/test_mojo fcgi script/test_mojo fcgi_prefork 6 января 2010 г.
  • 111.
    Mojo::Server::FCGI script/test_mojo fcgi script/test_mojo fcgi_prefork 6 января 2010 г.
  • 112.
    Mojo::Server::FCGI script/test_mojo fcgi script/test_mojo fcgi_prefork 6 января 2010 г.
  • 113.
    nginx + fcgi_prefork 6января 2010 г.
  • 114.
    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 г.
  • 115.
    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 г.
  • 116.
    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 г.
  • 117.
    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 г.
  • 118.
    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 г.
  • 119.
    script/test_mojo COMMAND [OPTIONS] script/test_mojo cgi script/test_mojo fastcgi script/test_mojo daemon script/test_mojo daemon_prefork --port 80 6 января 2010 г.
  • 120.
    MOJO_RELOAD=1 script/test_mojo daemon Application code will reload on each request 6 января 2010 г.
  • 121.
    script/test_mojo COMMAND [OPTIONS] script/test_mojo cgi script/test_mojo fastcgi script/test_mojo daemon script/test_mojo daemon_prefork --port 80 6 января 2010 г.
  • 122.
    script/test_mojo COMMAND [OPTIONS] script/test_mojo cgi script/test_mojo fastcgi script/test_mojo daemon script/test_mojo daemon_prefork --port 80 script/test_mojo test 6 января 2010 г.
  • 123.
    script/test_mojo COMMAND [OPTIONS] script/test_mojo cgi script/test_mojo fastcgi script/test_mojo daemon script/test_mojo daemon_prefork --port 80 script/test_mojo test script/test_mojo get 6 января 2010 г.
  • 124.
    script/test_mojo COMMAND [OPTIONS] script/test_mojo cgi script/test_mojo fastcgi script/test_mojo daemon script/test_mojo daemon_prefork --port 80 script/test_mojo test script/test_mojo get http://goo.gl 6 января 2010 г.
  • 125.
    MVC web frameworks 6января 2010 г.
  • 126.
    Mojolicious use base 'Mojo'; 6 января 2010 г.
  • 127.
    • Mojolicous::Controller • Mojolicious::Plugin • Mojolicious::Commands • MojoX::Types • MojoX::Dispatcher, MojoX::Routes 6 января 2010 г.
  • 128.
    • Mojolicous::Controller • Mojolicious::Plugin • Mojolicious::Commands • MojoX::Types • MojoX::Dispatcher, MojoX::Routes 6 января 2010 г.
  • 129.
    Mojolicious::Controller Controller Base Class 6 января 2010 г.
  • 130.
    • render • render_text • render_json • render_inner • render_partial • pause / resume • redirect_to / url_for 6 января 2010 г.
  • 131.
    • render • render_text • render_json • render_inner • render_partial • pause / resume • redirect_to / url_for 6 января 2010 г.
  • 132.
    • render(tempate =>‘foo/bar’) • render_text • render_json • render_inner • render_partial • pause / resume • redirect_to / url_for 6 января 2010 г.
  • 133.
    • render(controller =>‘foo’, action => ‘bar’) • render_text • render_json • render_inner • render_partial • pause / resume • redirect_to / url_for 6 января 2010 г.
  • 134.
    • render(‘foo/bar’, format=> ‘html) • render_text • render_json • render_inner • render_partial • pause / resume • redirect_to / url_for 6 января 2010 г.
  • 135.
    • render • render_text • render_json • render_inner • render_partial • pause / resume • redirect_to / url_for 6 января 2010 г.
  • 136.
    • render • render(text => ‘Saint Perl 2009’) • render_json • render_inner • render_partial • pause / resume • redirect_to / url_for 6 января 2010 г.
  • 137.
    • render • render_text • render_json • render_inner • render_partial • pause / resume • redirect_to / url_for 6 января 2010 г.
  • 138.
    • render • render_text • render(json => {foo => ‘bar’}) • render_inner • render_partial • pause / resume • redirect_to / url_for 6 января 2010 г.
  • 139.
    • render • render_text • render_json • render_inner • render_partial • pause / resume • redirect_to / url_for 6 января 2010 г.
  • 140.
    • render • render_text • render_json • render_inner • render_partial • pause / resume • redirect_to / url_for 6 января 2010 г.
  • 141.
    • render • render_text • render_json • render_inner • render_partial • pause / resume • redirect_to / url_for 6 января 2010 г.
  • 142.
    • render • render_text • render_json • render_inner • render_partial • pause / resume • redirect_to / url_for 6 января 2010 г.
  • 143.
    • Mojolicous::Controller • Mojolicious::Plugin • Mojolicious::Commands • MojoX::Types • MojoX::Dispatcher, MojoX::Routes 6 января 2010 г.
  • 144.
    Mojolicious::Plugin Plugin Base Class 6 января 2010 г.
  • 145.
    Mojolicious::Plugins Plugins: load_plugin, add_hook, run_hook 6 января 2010 г.
  • 146.
    • AgentCondition • Charset • DefaultHelpers • EpRenderer • EplRenderer • RequestTimer 6 января 2010 г.
  • 147.
    • AgentCondition • Charset • DefaultHelpers • EpRenderer • EplRenderer • RequestTimer 6 января 2010 г.
  • 148.
    • AgentCondition • Charset • DefaultHelpers • EpRenderer • EplRenderer • RequestTimer 6 января 2010 г.
  • 149.
    • AgentCondition • Charset • DefaultHelpers • EpRenderer • EplRenderer • RequestTimer 6 января 2010 г.
  • 150.
    • dumper • param • layout • include • content • extends 6 января 2010 г.
  • 151.
    • dumper • param • layout • include • content • extends 6 января 2010 г.
  • 152.
    • Data::Dumper (Maxdepth:2, Indent: 1, Terse: 1) • param • layout • include • content • extends 6 января 2010 г.
  • 153.
    • dumper • param • layout • include • content • extends 6 января 2010 г.
  • 154.
    • dumper • $self->req->param(...) • layout • include • content • extends 6 января 2010 г.
  • 155.
    • dumper • param • layout • include • content • extends 6 января 2010 г.
  • 156.
    • dumper • param • $self->stash(layout => ...) • include • content • extends 6 января 2010 г.
  • 157.
    • dumper • param • layout • include • content • extends 6 января 2010 г.
  • 158.
    • dumper • param • layout • $self->render_partial(...) • content • extends 6 января 2010 г.
  • 159.
    • dumper • param • layout • include • content • extends 6 января 2010 г.
  • 160.
    • dumper • param • layout • include • $self->render_inner(...) • extends 6 января 2010 г.
  • 161.
    • dumper • param • layout • include • content • extends 6 января 2010 г.
  • 162.
    • dumper • param • layout • include • content • $self->stash(extends => ...) 6 января 2010 г.
  • 163.
    • AgentCondition • Charset • DefaultHelpers • EpRenderer • EplRenderer • RequestTimer 6 января 2010 г.
  • 164.
    • extention oftemlplates is .epl • my $self = shift; • $self->stash(foo => ‘bar’) 6 января 2010 г.
  • 165.
    • AgentCondition • Charset • DefaultHelpers • EpRenderer • EplRenderer • RequestTimer 6 января 2010 г.
  • 166.
    • extention oftemlplates is .ep • cashing templates with stash parameters • $self->stash(foo => ‘bar’) – $foo • any helpers • default handler 6 января 2010 г.
  • 167.
    • AgentCondition • Charset • DefaultHelpers • EpRenderer • EplRenderer • RequestTimer 6 января 2010 г.
  • 168.
    • Mojolicous::Controller • Mojolicious::Plugin • Mojolicious::Commands • MojoX::Types • MojoX::Dispatcher, MojoX::Routes 6 января 2010 г.
  • 169.
    script/test_app COMMAND [OPTIONS] script/test_app cgi script/test_app fastcgi script/test_app daemon script/test_app daemon_prefork --port 80 script/test_app test script/test_app get 6 января 2010 г.
  • 170.
    script/test_app COMMAND [OPTIONS] script/test_app cgi script/test_app fastcgi script/test_app daemon script/test_app daemon_prefork --port 80 script/test_app test script/test_app get scritp/test_app routes 6 января 2010 г.
  • 171.
    • Mojolicous::Controller • Mojolicious::Plugin • Mojolicious::Commands • MojoX::Types • MojoX::Dispatcher, MojoX::Routes 6 января 2010 г.
  • 172.
    • Mojolicous::Controller • Mojolicious::Plugin • Mojolicious::Commands • MojoX::Types • MojoX::Dispatcher, MojoX::Routes 6 января 2010 г.
  • 173.
    A generation the mojolicious app 6 января 2010 г.
  • 174.
    mojolicious generate app TestApp 6 января 2010 г.
  • 175.
    [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 г.
  • 176.
    [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 г.
  • 177.
    [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 г.
  • 178.
    [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 г.
  • 179.
    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 г.
  • 180.
    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 г.
  • 181.
    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 г.
  • 182.
    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 г.
  • 183.
    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 г.
  • 184.
    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 г.
  • 185.
    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 г.
  • 186.
    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 г.
  • 187.
    package TestApp::Example; use base 'Mojolicious::Controller'; sub welcome { my $self = shift; warn $self->stash(‘id’); $self->render(message => 'Welcome!'); } 1; 6 января 2010 г.
  • 188.
    [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 г.
  • 189.
    [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 г.
  • 190.
    example/ welcome.html.ep Path to the template 6 января 2010 г.
  • 191.
    example/ welcome.html.ep Path to the template 6 января 2010 г.
  • 192.
    controller/ welcome.html.ep Path to the template 6 января 2010 г.
  • 193.
    example/ welcome.html.ep Path to the template 6 января 2010 г.
  • 194.
    example/ welcome.html.ep Path to the template 6 января 2010 г.
  • 195.
    example/ action.html.ep Path to the template 6 января 2010 г.
  • 196.
    example/ welcome.html.ep Path to the template 6 января 2010 г.
  • 197.
    example/ welcome.html.ep Path to the template 6 января 2010 г.
  • 198.
    example/ welcome.html.handler Path to the template 6 января 2010 г.
  • 199.
    example/ welcome.html.ep Path to the template 6 января 2010 г.
  • 200.
    example/ welcome.html.epl Path to the template 6 января 2010 г.
  • 201.
    example/ welcome.html.tt Path to the template 6 января 2010 г.
  • 202.
    example/ welcome.html.ht Path to the template 6 января 2010 г.
  • 203.
    example/ welcome.html.pro Path to the template 6 января 2010 г.
  • 204.
    example/ welcome.html.ctpp2 Path to the template 6 января 2010 г.
  • 205.
    example/ welcome.html.foo Path to the template 6 января 2010 г.
  • 206.
    example/ welcome.html.ep Path to the template 6 января 2010 г.
  • 207.
    example/ welcome.html.ep Path to the template 6 января 2010 г.
  • 208.
    example/ welcome.format.ep Path to the template 6 января 2010 г.
  • 209.
    example/ welcome.html.ep Path to the template 6 января 2010 г.
  • 210.
    example/ welcome.xml.ep Path to the template 6 января 2010 г.
  • 211.
    example/ welcome.rss.ep Path to the template 6 января 2010 г.
  • 212.
    example/ welcome.json.ep Path to the template 6 января 2010 г.
  • 213.
    example/ welcome.yaml.ep Path to the template 6 января 2010 г.
  • 214.
    example/ welcome.mail.ep Path to the template 6 января 2010 г.
  • 215.
    example/ welcome.bar.ep Path to the template 6 января 2010 г.
  • 216.
    example/ welcome.html.ep Path to the template 6 января 2010 г.
  • 217.
    example/ welcome.html.ep Path to the template 6 января 2010 г.
  • 218.
    controller/ action.format.handler Path to the template 6 января 2010 г.
  • 219.
    % layout 'default'; <h2><%= $message %></h2> <a href="<%== url_for %>">click here</a> 6 января 2010 г.
  • 220.
    [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 г.
  • 221.
    <!doctype html> <html> <head><title>Welcome</title></head> <body> <%== content %> </body> </html> 6 января 2010 г.
  • 222.
    [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 г.
  • 223.
    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 г.
  • 224.
    $ENV{MOJO_MODE} Default value is development 6 января 2010 г.
  • 225.
    [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 г.
  • 226.
    Mojolicious::Lite use base 'Mojolicious'; 6 января 2010 г.
  • 227.
    mojolicious generate lite_app test_lite 6 января 2010 г.
  • 228.
    [write] test_lite [chmod] test_lite 744 6 января 2010 г.
  • 229.
    use Mojolicious::Lite; get '/' => 'index'; any '/:groovy' => sub { my $self = shift; $self->render_text($self->stash('groovy')); }; shagadelic; 6 января 2010 г.
  • 230.
    use Mojolicious::Lite; get '/' => 'index'; any '/:groovy' => sub { my $self = shift; $self->render_text($self->stash('groovy')); }; shagadelic; 6 января 2010 г.
  • 231.
    use Mojolicious::Lite; get '/' => 'index'; any '/:groovy' => sub { my $self = shift; $self->render_text($self->stash('groovy')); }; shagadelic; 6 января 2010 г.
  • 232.
    use Mojolicious::Lite; post '/' => 'index'; any '/:groovy' => sub { my $self = shift; $self->render_text($self->stash('groovy')); }; shagadelic; 6 января 2010 г.
  • 233.
    use Mojolicious::Lite; any '/' => 'index'; any '/:groovy' => sub { my $self = shift; $self->render_text($self->stash('groovy')); }; shagadelic; 6 января 2010 г.
  • 234.
    use Mojolicious::Lite; get '/' => 'index'; any '/:groovy' => sub { my $self = shift; $self->render_text($self->stash('groovy')); }; shagadelic; 6 января 2010 г.
  • 235.
    use Mojolicious::Lite; get '/' => 'index'; any '/:groovy' => [groovy => qr/d+/] => sub { my $self = shift; $self->render_text($self->stash('groovy')); }; shagadelic; 6 января 2010 г.
  • 236.
    use Mojolicious::Lite; get '/' => 'index'; any '/:groovy' => {groovy => 42} => sub { my $self = shift; $self->render_text($self->stash('groovy')); }; shagadelic; 6 января 2010 г.
  • 237.
    use Mojolicious::Lite; get '/' => 'index'; any '/:groovy' => (agent=>qr/Firefox/) => sub { my $self = shift; $self->render_text($self->stash('groovy')); }; shagadelic; 6 января 2010 г.
  • 238.
    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 г.
  • 239.
    use Mojolicious::Lite; ladder sub { ... }; # auth get '/' => 'index'; any '/:groovy' => sub { my $self = shift; $self->render_text($self->stash('groovy')); }; shagadelic; 6 января 2010 г.
  • 240.
    use Mojolicious::Lite; get '/' => 'index'; any '/:groovy' => sub { my $self = shift; $self->render_text($self->stash('groovy')); }; shagadelic; # shagadelic(‘cgi’) 6 января 2010 г.
  • 241.
    __DATA__ @@ index.html.ep % layout 'funky'; Yea baby! @@ layouts/funky.html.ep <!doctype html><html> <body> <%== content %> </body> </html> 6 января 2010 г.
  • 242.
    Mojo modules on CPAN 6 января 2010 г.
  • 243.
    Mojo modules on CPAN • Mojo • MojoX::Routes::AsGraph • Mojo::Server::FCGI • MojoX::Session • AnyEvent::Mojo • MojoX::Log::* • Apache::Mojo, Apache2::Mojo • MojoX::Renderer::* • Catalyst::Engine::Mojo, • JSON Squatting::On::Mojo • TT • MojoX::UserAgent • CTTP2, HTP 6 января 2010 г.
  • 244.
    Mojo Guide Style Rules 6 января 2010 г.
  • 245.
    Mojo Guide Style • 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 from The Simpsons or Futurama 6 января 2010 г.
  • 246.
    Mojo Guide Style • 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 from The Simpsons or Futurama 6 января 2010 г.
  • 247.
    Mojo Guide Style • 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 from The Simpsons or Futurama 6 января 2010 г.
  • 248.
    Mojo Guide Style • 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 from The Simpsons or Futurama 6 января 2010 г.
  • 249.
    Mojo Guide Style • 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 from The Simpsons or Futurama 6 января 2010 г.
  • 250.
    Mojo Guide Style • 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 from The Simpsons or Futurama 6 января 2010 г.
  • 251.
    Mojo Guide Style • 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 from The Simpsons or Futurama :) 6 января 2010 г.
  • 252.
    The Simpsons orFuturama 6 января 2010 г.
  • 253.
    Stable version and backwards compatibility 6 января 2010 г.
  • 254.
    Mojo 0.999915 The latest version of Mojo always available on github.com 6 января 2010 г.
  • 255.
  • 256.
    No backwards compatibility :) Until the first stable version will not be released 6 января 2010 г.
  • 257.
    First critical bug 6января 2010 г.
  • 258.
    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 г.
  • 259.
    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 г.
  • 260.
    test.pl #!/usr/bin/perl warn $_ while <STDIN>; 6 января 2010 г.
  • 261.
    script/test_bug daemon #OK 6 января 2010 г.
  • 262.
    script/test_bug daemon #OK script/test_bug daemon_prefork # DIE 6 января 2010 г.
  • 263.
    Mojo::Server::Daemon::Prefork #323: $SIG{HUP } = $SIG{INT } =  $SIG{CHLD} = $SIG{TERM} = sub { exit 0 }; 6 января 2010 г.
  • 264.
    Mojo::Server::Daemon::Prefork #323: $SIG{HUP } = $SIG{INT } =  $SIG{CHLD} = $SIG{TERM} = sub { exit 0 }; 6 января 2010 г.
  • 265.
    Mojo::Server::Daemon::Prefork #323: $SIG{HUP } = $SIG{INT } =  $SIG{TERM } = sub { exit 0 }; $SIG{CHLD} = ‘IGNORE’; 6 января 2010 г.
  • 266.
    Second critical bug 6января 2010 г.
  • 267.
    MOJO_RELOAD, daemon и attr 6 января 2010 г.
  • 268.
    MOJO_RELOAD=1 script/test_bug2 daemon # OK 6 января 2010 г.
  • 269.
    MOJO_RELOAD=1 script/test_bug2 daemon # sometimes ERROR 6 января 2010 г.
  • 270.
    script/test_bug2 daemon_prefork #OK 6 января 2010 г.
  • 271.
    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 г.
  • 272.
    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 г.
  • 273.
    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 г.
  • 274.
  • 275.
    Documentation Less than necessary :) 6 января 2010 г.
  • 276.
    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 г.
  • 277.
    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 г.
  • 278.
  • 279.
  • 280.
    Links • irc://irc.perl.org/#mojo • http://lists.kraih.com/cgi-bin/mailman/ listinfo/mojo • Twitter: @kraih, @vtivti, @sharifulin • Juick: @vti, @sharifulin 6 января 2010 г.
  • 281.
    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 г.
  • 282.
    My experience in the development using Mojo 6 января 2010 г.
  • 283.
  • 284.
    Mojo + JSON 6января 2010 г.
  • 285.
    Mojolicious::Lite + 6 января2010 г. MojoX::Renderer::JSON
  • 286.
    Mojolicious::Lite + 6 января2010 г. MojoX::Renderer::JSON + RSS
  • 287.
    Mojolicious + Mojo::Template 6января 2010 г.
  • 288.
    Mojolicious + EpRenderer ~7 projects 6 января 2010 г.
  • 289.
    «Making hard thingspossible and everything fun!» The motto of Mojolicious 6 января 2010 г.
  • 290.
    use Mojo or die 6 января 2010 г.
  • 291.
    use Perl or die 6 января 2010 г.
  • 292.
  • 293.
    any ‘/questions’ =>sub { shift->render( answer => ‘sharifulin’, ); }; shagadelic; 6 января 2010 г.
  • 294.
    Thanks! Anatoly Sharifulin RostovOnDon.pm 6 января 2010 г.