Mojo. Веб в коробке!

Preview:

DESCRIPTION

BY Perl Too 2009

Citation preview

Mojo.Веб в коробке!

BY Perl Too 2009

17 октября 2009 г.

http://mojolicious.org/17 октября 2009 г.

Sebastian Riedelсоздатель Catalyst и Mojo

http://labs.kraih.com/

17 октября 2009 г.

http://twitter.com/kraih17 октября 2009 г.

Catalyst + Mojo = ?17 октября 2009 г.

Что такое Mojo?

17 октября 2009 г.

Что такое Mojo?

• Pure Perl веб-фреймворк

• Без зависимостей (начиная с Perl 5.10)

• Объектно-ориентированное API

• Поддержка HTTP 1.1 (клиент-сервер)

• CGI, FastCGI, Daemon и Daemon Prefork

• MVC веб-фреймворки: Mojolicious и Mojolicious::Lite

17 октября 2009 г.

Что такое Mojo?

• Pure Perl веб-фреймворк

• Без зависимостей (с версии Perl 5.8.1)

• Объектно-ориентированное API

• Поддержка HTTP 1.1 (клиент-сервер)

• CGI, FastCGI, Daemon и Daemon Prefork

• MVC веб-фреймворки: Mojolicious и Mojolicious::Lite

17 октября 2009 г.

Что такое Mojo?

• Pure Perl веб-фреймворк

• Без зависимостей (с версии Perl 5.8.1)

• Объектно-ориентированное API

• Поддержка HTTP 1.1 (клиент-сервер)

• CGI, FastCGI, Daemon и Daemon Prefork

• MVC веб-фреймворки: Mojolicious и Mojolicious::Lite

17 октября 2009 г.

Что такое Mojo?

• Pure Perl веб-фреймворк

• Без зависимостей (с версии Perl 5.8.1)

• Объектно-ориентированное API

• Поддержка HTTP 1.1 (клиент-сервер)

• CGI, FastCGI, Daemon и Daemon Prefork

• MVC веб-фреймворки: Mojolicious и Mojolicious::Lite

17 октября 2009 г.

Что такое Mojo?

• Pure Perl веб-фреймворк

• Без зависимостей (с версии Perl 5.8.1)

• Объектно-ориентированное API

• Поддержка HTTP 1.1 (клиент-сервер)

• CGI, FastCGI, Daemon и Daemon Prefork

• MVC веб-фреймворки: Mojolicious и Mojolicious::Lite

17 октября 2009 г.

Что такое Mojo?

• Pure Perl веб-фреймворк

• Без зависимостей (с версии Perl 5.8.1)

• Объектно-ориентированное API

• Поддержка HTTP 1.1 (клиент-сервер)

• CGI, FastCGI, Daemon и Daemon Prefork

• MVC веб-фреймворки: Mojolicious и Mojolicious::Lite

17 октября 2009 г.

Что такое Mojo?

• Pure Perl веб-фреймворк

• Без зависимостей (с версии Perl 5.8.1)

• Объектно-ориентированное API

• Поддержка HTTP 1.1 (клиент-сервер)

• CGI, FastCGI, Daemon и Daemon Prefork

• MVC веб-фреймворки: Mojolicious и Mojolicious::Lite

17 октября 2009 г.

Pure Perl веб-фреймворк

17 октября 2009 г.

• 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

17 октября 2009 г.

• 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

17 октября 2009 г.

Minimal Base Class For Mojo Projects

Mojo::Base

17 октября 2009 г.

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 { ... }17 октября 2009 г.

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 { ... }17 октября 2009 г.

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 { ... }17 октября 2009 г.

• 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

17 октября 2009 г.

ByteStream

Mojo::ByteStream

17 октября 2009 г.

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;

17 октября 2009 г.

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;

17 октября 2009 г.

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;

17 октября 2009 г.

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;

17 октября 2009 г.

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;

17 октября 2009 г.

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;

17 октября 2009 г.

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;

17 октября 2009 г.

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;

17 октября 2009 г.

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;

17 октября 2009 г.

• 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

17 октября 2009 г.

Perlish Templates!

Mojo::Template

17 октября 2009 г.

% my $self = shift;% my $list = $self->stash(‘list’);

<ul>% for (@$list) { <li><%= $_->{title} %></li>% }</ul>

17 октября 2009 г.

• 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

17 октября 2009 г.

• 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

17 октября 2009 г.

• 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

17 октября 2009 г.

• 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

17 октября 2009 г.

• 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

17 октября 2009 г.

• Mojo::Trasaction, Mojo::Stateful

• Mojo::Client

• Mojo::Server

• Mojo::Server::CGI, Mojo::Server::FastCGI

• Mojo::Server::Daemon

• Mojo::Server::Daemon::Prefork

• Mojo::Command

• Mojo::Command::Generate и ~ Server

17 октября 2009 г.

• Mojo::Trasaction, Mojo::Stateful

• Mojo::Client

• Mojo::Server

• Mojo::Server::CGI, Mojo::Server::FastCGI

• Mojo::Server::Daemon

• Mojo::Server::Daemon::Prefork

• Mojo::Command

• Mojo::Command::Generate и ~ Server

17 октября 2009 г.

• Mojo::Trasaction, Mojo::Stateful

• Mojo::Client

• Mojo::Server

• Mojo::Server::CGI, Mojo::Server::FastCGI

• Mojo::Server::Daemon

• Mojo::Server::Daemon::Prefork

• Mojo::Command

• Mojo::Command::Generate и ~ Server

17 октября 2009 г.

• Mojo::Trasaction, Mojo::Stateful

• Mojo::Client

• Mojo::Server

• Mojo::Server::CGI, Mojo::Server::FastCGI

• Mojo::Server::Daemon

• Mojo::Server::Daemon::Prefork

• Mojo::Command

• Mojo::Command::Generate и ~ Server

17 октября 2009 г.

• Mojo::Trasaction, Mojo::Stateful

• Mojo::Client

• Mojo::Server

• Mojo::Server::CGI, Mojo::Server::FastCGI

• Mojo::Server::Daemon

• Mojo::Server::Daemon::Prefork

• Mojo::Command

• Mojo::Command::Generate и ~ Server

17 октября 2009 г.

• Mojo::Trasaction, Mojo::Stateful

• Mojo::Client

• Mojo::Server

• Mojo::Server::CGI, Mojo::Server::FastCGI

• Mojo::Server::Daemon

• Mojo::Server::Daemon::Prefork

• Mojo::Command

• Mojo::Command::Generate и ~ Server

17 октября 2009 г.

• Mojo::Trasaction, Mojo::Stateful

• Mojo::Client

• Mojo::Server

• Mojo::Server::CGI, Mojo::Server::FastCGI

• Mojo::Server::Daemon

• Mojo::Server::Daemon::Prefork

• Mojo::Command

• Mojo::Command::Generate и ~ Server

17 октября 2009 г.

Mojo – веб в коробке!

Всё, что нужно есть

17 октября 2009 г.

Mojo – веб в коробке!

Почти всё, что нужно есть :)

17 октября 2009 г.

Без зависимостейс версии Perl 5.8.1

17 октября 2009 г.

Почтибез зависимостей :)

17 октября 2009 г.

Mojo runtime17 октября 2009 г.

Perl 5.00517 октября 2009 г.

Perl 5.00600217 октября 2009 г.

Perl 5.00800117 октября 2009 г.

Mojo Perl 5.01017 октября 2009 г.

Объектно-ориентированное API

17 октября 2009 г.

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!');}

17 октября 2009 г.

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!');}

17 октября 2009 г.

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!');}

17 октября 2009 г.

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!');}

17 октября 2009 г.

use overload '""' => sub { shift->to_string },

fallback => 1;

17 октября 2009 г.

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!');}

17 октября 2009 г.

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!');}

17 октября 2009 г.

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!');}

17 октября 2009 г.

Генерацияmojo-приложения

17 октября 2009 г.

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

17 октября 2009 г.

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

17 октября 2009 г.

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’)

17 октября 2009 г.

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

17 октября 2009 г.

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

17 октября 2009 г.

#!/usr/bin/env perl

use strict;use warnings;

use Test::More tests => 1;

use_ok('TestMojo');

17 октября 2009 г.

Поддержка HTTP 1.1

17 октября 2009 г.

17 октября 2009 г.

MojoX::UserAgentPascal Gaudette

Спасибо Google of Summer Code 2009!

17 октября 2009 г.

Поддержка CGI, FastCGI, Daemon, Daemon Prefork

17 октября 2009 г.

script/test_mojo COMMAND [OPTIONS]

script/test_mojo cgiscript/test_mojo fastcgiscript/test_mojo daemonscript/test_mojo daemon_prefork --port 80

17 октября 2009 г.

script/test_mojo COMMAND [OPTIONS]

script/test_mojo cgiscript/test_mojo fastcgiscript/test_mojo daemonscript/test_mojo daemon_prefork --port 80

17 октября 2009 г.

PATH_INFO='/' script/test_mojo cgi

Легко тестироватьМожно профилировать код, используя Devel::NYProf

17 октября 2009 г.

script/test_mojo COMMAND [OPTIONS]

script/test_mojo cgiscript/test_mojo fastcgiscript/test_mojo daemonscript/test_mojo daemon_prefork --port 80

17 октября 2009 г.

Mojo::Server::FCGIscript/test_mojo fcgiscript/test_mojo fcgi_prefork

17 октября 2009 г.

Mojo::Server::FCGIscript/test_mojo fcgiscript/test_mojo fcgi_prefork

17 октября 2009 г.

Mojo::Server::FCGIscript/test_mojo fcgiscript/test_mojo fcgi_prefork

17 октября 2009 г.

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;}

17 октября 2009 г.

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;}

17 октября 2009 г.

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;}

17 октября 2009 г.

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;}

17 октября 2009 г.

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;}

17 октября 2009 г.

script/test_mojo COMMAND [OPTIONS]

script/test_mojo cgiscript/test_mojo fastcgiscript/test_mojo daemonscript/test_mojo daemon_prefork --port 80

17 октября 2009 г.

MOJO_RELOAD=1 script/test_mojo daemon

Код перезагружается при каждом запросе

17 октября 2009 г.

script/test_mojo COMMAND [OPTIONS]

script/test_mojo cgiscript/test_mojo fastcgiscript/test_mojo daemonscript/test_mojo daemon_prefork --port 80

17 октября 2009 г.

script/test_mojo COMMAND [OPTIONS]

script/test_mojo cgiscript/test_mojo fastcgiscript/test_mojo daemonscript/test_mojo daemon_prefork --port 80

script/test_mojo test

17 октября 2009 г.

MVC веб-фреймворки

17 октября 2009 г.

Mojolicioususe base 'Mojo';

17 октября 2009 г.

• Mojolicious::Renderer

• Mojolicous::Controller

• Mojolicious::Commands

• MojoX::Types

• MojoX::Dispatcher, MojoX::Routes

17 октября 2009 г.

• Mojolicious::Renderer

• Mojolicous::Controller

• Mojolicious::Commands

• MojoX::Types

• MojoX::Dispatcher, MojoX::Routes

17 октября 2009 г.

• Mojolicious::Renderer

• Mojolicous::Controller

• Mojolicious::Commands

• MojoX::Types

• MojoX::Dispatcher, MojoX::Routes

17 октября 2009 г.

• Mojolicious::Renderer

• Mojolicous::Controller

• Mojolicious::Commands

• MojoX::Types

• MojoX::Dispatcher, MojoX::Routes

17 октября 2009 г.

• Mojolicious::Renderer

• Mojolicous::Controller

• Mojolicious::Commands

• MojoX::Types

• MojoX::Dispatcher, MojoX::Routes

17 октября 2009 г.

• Mojolicious::Renderer

• Mojolicous::Controller

• Mojolicious::Commands

• MojoX::Types

• MojoX::Dispatcher, MojoX::Routes

17 октября 2009 г.

Генерацияmojolicious-приложения

17 октября 2009 г.

mojolicious generate app TestApp

17 октября 2009 г.

[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

17 октября 2009 г.

[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

17 октября 2009 г.

[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

17 октября 2009 г.

[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

17 октября 2009 г.

package TestApp;

use base 'Mojolicious';sub startup { my $self = shift; $self->renderer->default_handler('ep');

my $r = $self->routes; $r->route('/:controller/:action/:id') ->to(controller => 'example', action => 'welcome', id => 1);}

17 октября 2009 г.

package TestApp;

use base 'Mojolicious';sub startup { my $self = shift; $self->renderer->default_handler('ep');

my $r = $self->routes; $r->route('/:controller/:action/:id') ->to(controller => 'example', action => 'welcome', id => 1);}

17 октября 2009 г.

package TestApp;

use base 'Mojolicious';sub startup { my $self = shift; $self->renderer->default_handler('ep');

my $r = $self->routes; $r->route('/:controller/:action/:id') ->to(controller => 'example', action => 'welcome', id => 1);}

17 октября 2009 г.

package TestApp;

use base 'Mojolicious';sub startup { my $self = shift; $self->renderer->default_handler('ep');

my $r = $self->routes; $r->route('/:controller/:action/:id') ->to(controller => 'example', action => 'welcome', id => 1);}

17 октября 2009 г.

package TestApp;

use base 'Mojolicious';sub startup { my $self = shift; $self->renderer->default_handler('ep');

my $r = $self->routes; $r->route('/:controller/:action/:id') ->to(controller => 'example', action => 'welcome', id => 1);}

17 октября 2009 г.

package TestApp;

use base 'Mojolicious';sub startup { my $self = shift; $self->renderer->default_handler('ep');

my $r = $self->routes; $r->route('/:controller/:action/:id') ->to(controller => 'example', action => 'welcome', id => 1);}

17 октября 2009 г.

package TestApp;

use base 'Mojolicious';sub startup { my $self = shift; $self->renderer->default_handler('ep');

my $r = $self->routes; $r->route('/:controller/:action/:id') ->to(controller => 'example', action => 'welcome', id => 1);}

17 октября 2009 г.

package TestApp::Example;

use base 'Mojolicious::Controller';sub welcome { my $self = shift; warn $self->stash(‘id’); $self->render(message => 'Welcome!');}

1;

17 октября 2009 г.

[exist] test_app/public[write] test_app/public/index.html[mkdir] test_app/templates[write] test_app/templates/exception.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

17 октября 2009 г.

[exist] test_app/public[write] test_app/public/index.html[mkdir] test_app/templates[write] test_app/templates/exception.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

17 октября 2009 г.

% layout 'default';

<h2><%= $message %></h2>

<a href="<%== url_for %>">click here</a>

17 октября 2009 г.

[exist] test_app/public[write] test_app/public/index.html[mkdir] test_app/templates[write] test_app/templates/exception.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

17 октября 2009 г.

<!doctype html><html> <head><title>Welcome</title></head> <body> <%== content %> </body></html>

17 октября 2009 г.

[exist] test_app/public[write] test_app/public/index.html[mkdir] test_app/templates[write] test_app/templates/exception.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

17 октября 2009 г.

Mojolicious::Liteuse base 'Mojolicious';

17 октября 2009 г.

mojolicious generate lite_app test_lite

17 октября 2009 г.

[write] test_lite[chmod] test_lite 744

17 октября 2009 г.

use Mojolicious::Lite;

app->renderer->default_handler('ep');

get '/' => 'index';

any '/:groovy' => sub { my $self = shift; $self->render_text($self->stash('groovy'));};

shagadelic;17 октября 2009 г.

use Mojolicious::Lite;

app->renderer->default_handler('ep');

get '/' => 'index';

any '/:groovy' => sub { my $self = shift; $self->render_text($self->stash('groovy'));};

shagadelic;17 октября 2009 г.

use Mojolicious::Lite;

app->renderer->default_handler('ep');

get '/' => 'index';

any '/:groovy' => sub { my $self = shift; $self->render_text($self->stash('groovy'));};

shagadelic;17 октября 2009 г.

use Mojolicious::Lite;

app->renderer->default_handler('ep');

get '/' => 'index';

any '/:groovy' => sub { my $self = shift; $self->render_text($self->stash('groovy'));};

shagadelic; # shagadelic(‘cgi’)17 октября 2009 г.

__DATA__

@@ index.html.ep% layout 'funky';Yea baby!

@@ layouts/funky.html.ep<!doctype html><html> <body> <%== content %> </body></html>

17 октября 2009 г.

Mojo-модули на CPAN

17 октября 2009 г.

Mojo-модули на CPAN• Mojo

• Mojo::Server::FCGI

• AnyEvent::Mojo

• Apache::Mojo, Apache2::Mojo

• Catalyst::Engine::Mojo,Squatting::On::Mojo

• MojoX::UserAgent

• MojoX::Routes::AsGraph

• MojoX::Session

• MojoX::Log::*

• MojoX::Renderer::*

• JSON

• TT

• CTTP2, HTP

17 октября 2009 г.

Стабильная версия,обратная

совместимость?

17 октября 2009 г.

Mojo 0.991252Последняя версия всегда доступна на github.com

17 октября 2009 г.

Обратная совместимость не гарантируется :)До первой стабильной версии

17 октября 2009 г.

Первый критичный баг

17 октября 2009 г.

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’);;};

17 октября 2009 г.

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’);;};

17 октября 2009 г.

test.pl

#!/usr/bin/perlwarn $_ while <STDIN>;

17 октября 2009 г.

script/test_bug daemon # OK

17 октября 2009 г.

script/test_bug daemon # OKscript/test_bug daemon_prefork # DIE

17 октября 2009 г.

Mojo::Server::Daemon::Prefork #323:

$SIG{HUP } = $SIG{INT } = $SIG{CHLD} = $SIG{TERM} = sub { exit 0 };

17 октября 2009 г.

Mojo::Server::Daemon::Prefork #323:

$SIG{HUP } = $SIG{INT } = $SIG{CHLD} = $SIG{TERM} = sub { exit 0 };

17 октября 2009 г.

Mojo::Server::Daemon::Prefork #323:

$SIG{HUP } = $SIG{INT } = $SIG{TERM } = sub { exit 0 };

$SIG{CHLD} = ‘IGNORE’;

17 октября 2009 г.

Документация

17 октября 2009 г.

ДокументацияНе очень :)

17 октября 2009 г.

«мне кажется документацию он никогда не напишет) он х**рит быстрее, чем можно писать документацию для него)»

FriendFeed форева!

17 октября 2009 г.

Полезная информация

• 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/

17 октября 2009 г.

Полезная информация

• 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/

17 октября 2009 г.

Bootylicious17 октября 2009 г.

Полезная информация

• irc://irc.perl.org/#mojo

• http://lists.kraih.com/cgi-bin/mailman/listinfo/mojo

• Twitter: @kraih, @vtivti, @sharifulin

17 октября 2009 г.

Последние новости• PSGI and Plack is the future of HTTP::Engine that

has support for servers like CGI, FastCGI, Apache, AnyEvent and Mojo.

• As usually @vtivti is the first to use our newest Mojolicious feature, ep templates now in Bootylicious.

• New #mod_perlite release looks great, #Mojolicious with CGI backend should "just work™" on it.

• Unicode support in #Mojolicious looks really great now.

17 октября 2009 г.

Опыт разработки на Mojo

17 октября 2009 г.

Mojolicious + MojoX::Renderer::TT17 октября 2009 г.

Mojo + JSON17 октября 2009 г.

Mojolicious::Lite + MojoX::Renderer::JSON

17 октября 2009 г.

Mojolicious::Lite + MojoX::Renderer::JSON + RSS

17 октября 2009 г.

Mojolicious + Mojo::Template17 октября 2009 г.

Mojolicious::Lite + other render17 октября 2009 г.

«Я никогда так быстро не делал сайты на Perl»

Анатолий Шарифулин :)

17 октября 2009 г.

«Можно ли на хостинге, где только FTP, Apache и CGI?»Постоянный вопрос, который задают мне

17 октября 2009 г.

Ответ: «Да!»

17 октября 2009 г.

Ответ: «Да!»Только я не проверял :)

17 октября 2009 г.

use Perlor die

17 октября 2009 г.

use Mojoor die

17 октября 2009 г.

JFDI

17 октября 2009 г.

any ‘/questions/’ => sub { shift->render( say => ‘sharifulin’, );};shagadelic;

17 октября 2009 г.

Дзякуй, кали ласка!Анатолий Шарифулин

RostovOnDon.pm

17 октября 2009 г.