Mojolicious lite
Upcoming SlideShare
Loading in...5
×
 

Mojolicious lite

on

  • 2,798 views

A brief presentation about Mojolicious::Lite, a Perl module to create single file web apps, given at PtPW2010.

A brief presentation about Mojolicious::Lite, a Perl module to create single file web apps, given at PtPW2010.

Statistics

Views

Total Views
2,798
Views on SlideShare
2,772
Embed Views
26

Actions

Likes
0
Downloads
17
Comments
0

4 Embeds 26

http://www.slideshare.net 16
http://coderwall.com 7
http://www.linkedin.com 2
http://127.0.0.1 1

Accessibility

Categories

Upload Details

Uploaded via as Adobe PDF

Usage Rights

CC Attribution-ShareAlike LicenseCC Attribution-ShareAlike License

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

Mojolicious lite Mojolicious lite Presentation Transcript

  • Mini aplicac˜es web com ¸o Mojolicious::Lite Andr´ Santos e andrefs@cpan.org PtPW 2010 5 de Julho
  • Disclaimer [Web] developer profissional
  • Disclaimer [Web] developer profissional Perl::Newbie
  • Disclaimer [Web] developer profissional Perl::Newbie #{coisas certas} > #{coisas erradas}
  • Ruby
  • Ruby Perl
  • Ruby Ruby on Rails “open source MVC web app framework” Perl
  • Ruby Ruby on Rails “open source MVC web app framework” Perl Catalyst (outros)
  • Ruby Perl
  • Ruby Sinatra pequenas aplicac˜es web ¸o Perl
  • Ruby Sinatra pequenas aplicac˜es web ¸o Perl Mojolicious::Lite “micro web framework”
  • /Mojo.*/ Mojo Mojolicious Mojolicious::Lite
  • /Mojo.*/ Mojo Mojolicious Mojolicious::Lite criados por Sebastian Riedel tamb´m criador de Catalyst e developer RoR
  • /Mojo.*/ .---------------------------------------------------------------. | Fun! | ’---------------------------------------------------------------’ .---------------------------------------------------------------. | | | .----------------------------------------------’ | | .--------------------------------------------. | Application | | Mojolicious::Lite | | | ’--------------------------------------------’ | | .--------------------------------------------. | | | Mojolicious | ’----------------’ ’--------------------------------------------’ .---------------------------------------------------------------. | Mojo | ’---------------------------------------------------------------’ .-------. .-----------. .--------. .------------. .-------------. | CGI | | FastCGI | | PSGI | | HTTP 1.1 | | WebSocket | ’-------’ ’-----------’ ’--------’ ’------------’ ’-------------’
  • /Mojo.*/ Mojo “The box!” Encapsula as complexidades de CGI, FastCGI, PSGI, HTTP e WebSocket num s´ m´todo o e D´ suporte a frameworks web como a Mojolicious e Mojolicious::Lite
  • /Mojo.*/ Mojolicious “The web in a box!” framework MVC com API OO Perl depende apenas de Perl 5.8.1
  • Mojolicious::Lite Single file micro web apps framework ˜ NAO! N˜o apropriado para produc˜o, software a ¸a comercial, ...
  • Mojolicious::Lite Single file micro web apps framework ˜ NAO! N˜o apropriado para produc˜o, software a ¸a comercial, ... N˜o apropriado para aplicac˜es complexas a ¸o
  • Mojolicious::Lite Single file micro web apps framework ˜ NAO! N˜o apropriado para produc˜o, software a ¸a comercial, ... N˜o apropriado para aplicac˜es complexas a ¸o N˜o est´ bem documentado (ainda) a a
  • $ mojolicious generate lite_app [exist] ~/folder [write] ~/folder/myapp.pl [chmod] myapp.pl 744 $ myapp.pl ... generate Generate files and directories from templates. routes Show available routes. inflate Inflate embedded files to real files. version Show versions of installed modules. daemon_prefork Start application w/prefork HTTP 1.1 backend. fastcgi Start application with FastCGI backend. daemon Start application with HTTP 1.1 backend. cgi Start application with CGI backend. get Get file from URL. psgi Start application with PSGI backend. test Run unit tests.
  • $ cat myapp.pl #!/usr/bin/env perl use Mojolicious::Lite; get ’/’ => ’index’; get ’/:groovy’ => sub { my $self = shift; $self->render_text($self->param(’groovy’), layout => ’funky’); }; shagadelic; __DATA__ @@ index.html.ep % layout ’funky’; Yea baby! @@ layouts/funky.html.ep <!doctype html><html> <head><title>Funky!</title></head> <body><%== content %></body> </html>
  • $ cat myapp.pl #!/usr/bin/env perl use Mojolicious::Lite; get ’/’ => ’index’; get ’/:groovy’ => sub { my $self = shift; $self->render_text($self->param(’groovy’), layout => ’funky’); }; shagadelic; __DATA__ @@ index.html.ep % layout ’funky’; Yea baby! @@ layouts/funky.html.ep <!doctype html><html> <head><title>Funky!</title></head> <body><%== content %></body> </html>
  • $ cat myapp.pl #!/usr/bin/env perl use Mojolicious::Lite; get ’/’ => ’index’; get ’/:groovy’ => sub { my $self = shift; $self->render_text($self->param(’groovy’), layout => ’funky’); }; app->start; __DATA__ @@ index.html.ep % layout ’funky’; Yea baby! @@ layouts/funky.html.ep <!doctype html><html> <head><title>Funky!</title></head> <body><%== content %></body> </html>
  • Routes get ’/’ => ’index’ # GET ’/’ get ’/:groovy’ => sub # GET ’/anyword’
  • Routes get ’/’ => ’index’ # GET ’/’ get ’/:groovy’ => sub # GET ’/anyword’ get ’/perl’ # GET ’/perl’ any [qw/post delete/] ’/bar/:foo’ # ’ POST or DELETE ’/bar/*’ any ’/:foo’ => [foo => qr/+/] . # ’/2010’
  • Routes get ’/’ => ’index’ # GET ’/’ get ’/:groovy’ => sub # GET ’/anyword’ get ’/perl’ # GET ’/perl’ any [qw/post delete/] ’/bar/:foo’ # ’ POST or DELETE ’/bar/*’ any ’/:foo’ => [foo => qr/+/] . # ’/2010’ get ’/number/:num’ => {num => 42} get ’/path/(*everything)
  • Templates Sistema de templates pr´prio; ou o Template Toolkit, ...
  • Exemplos http://d.hatena.ne.jp/yukikimoto/20100220/1266588242 Short message BSS (150 loc) Image BSS (156 loc) Simple search (106 loc) Simple real time clock (133 loc) Simple real time chat (207 loc)
  • $ myapp.pl inflate [mkdir] ~/folder/templates/layouts [write] ~/folder/templates/layouts/funky.html. [exist] ~/folder/templates [write] ~/folder/templates/index.html.ep
  • Trabalho semelhante Sinatra on Perl, github.com/jtarchie/ sinatra-on-perl Schenker, github.com/spiritloose/Schenker Dancer, perldancer.org
  • Trabalho semelhante Sinatra on Perl, github.com/jtarchie/ sinatra-on-perl Schenker, github.com/spiritloose/Schenker Dancer, perldancer.org Mojolicious::Lite vs Dancer http://use.perl.org/~Alias/journal/
  • Questions o/