Mini aplicac˜es web com
            ¸o
Mojolicious::Lite
         Andr´ Santos
              e
       andrefs@cpan.org

  ...
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
 ...
/Mojo.*/
.---------------------------------------------------------------.
|                             Fun!             ...
/Mojo.*/

Mojo
  “The box!”
  Encapsula as complexidades de CGI,
  FastCGI, PSGI, HTTP e WebSocket num
  s´ m´todo
   o e
...
/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         ...
Mojolicious::Lite

Single file micro web apps framework
 ˜
NAO!
    N˜o apropriado para produc˜o, software
      a         ...
Mojolicious::Lite

Single file micro web apps framework
 ˜
NAO!
    N˜o apropriado para produc˜o, software
      a         ...
$ mojolicious generate lite_app
  [exist] ~/folder
  [write] ~/folder/myapp.pl
  [chmod] myapp.pl 744
$ myapp.pl
  ...
  g...
$ cat myapp.pl
#!/usr/bin/env perl
use Mojolicious::Lite;

get ’/’ => ’index’;
get ’/:groovy’ => sub {
    my $self = shif...
$ cat myapp.pl
#!/usr/bin/env perl
use Mojolicious::Lite;

get ’/’ => ’index’;
get ’/:groovy’ => sub {
    my $self = shif...
$ cat myapp.pl
#!/usr/bin/env perl
use Mojolicious::Lite;

get ’/’ => ’index’;
get ’/:groovy’ => sub {
    my $self = shif...
Routes
   get ’/’ => ’index’ # GET ’/’
   get ’/:groovy’ => sub
   # GET ’/anyword’
Routes
   get ’/’ => ’index’ # GET ’/’
   get ’/:groovy’ => sub
   # GET ’/anyword’
   get ’/perl’ # GET ’/perl’
   any [q...
Routes
   get ’/’ => ’index’ # GET ’/’
   get ’/:groovy’ => sub
   # GET ’/anyword’
   get ’/perl’ # GET ’/perl’
   any [q...
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 lo...
$ myapp.pl inflate


 [mkdir]   ~/folder/templates/layouts
 [write]   ~/folder/templates/layouts/funky.html.
 [exist]   ~/...
Trabalho semelhante
   Sinatra on Perl,
   github.com/jtarchie/
   sinatra-on-perl
   Schenker,
   github.com/spiritloose/...
Trabalho semelhante
   Sinatra on Perl,
   github.com/jtarchie/
   sinatra-on-perl
   Schenker,
   github.com/spiritloose/...
Questions




            o/
Upcoming SlideShare
Loading in...5
×

Mojolicious lite

2,189

Published on

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

Published in: Technology
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total Views
2,189
On Slideshare
0
From Embeds
0
Number of Embeds
2
Actions
Shares
0
Downloads
18
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

Mojolicious lite

  1. 1. Mini aplicac˜es web com ¸o Mojolicious::Lite Andr´ Santos e andrefs@cpan.org PtPW 2010 5 de Julho
  2. 2. Disclaimer [Web] developer profissional
  3. 3. Disclaimer [Web] developer profissional Perl::Newbie
  4. 4. Disclaimer [Web] developer profissional Perl::Newbie #{coisas certas} > #{coisas erradas}
  5. 5. Ruby
  6. 6. Ruby Perl
  7. 7. Ruby Ruby on Rails “open source MVC web app framework” Perl
  8. 8. Ruby Ruby on Rails “open source MVC web app framework” Perl Catalyst (outros)
  9. 9. Ruby Perl
  10. 10. Ruby Sinatra pequenas aplicac˜es web ¸o Perl
  11. 11. Ruby Sinatra pequenas aplicac˜es web ¸o Perl Mojolicious::Lite “micro web framework”
  12. 12. /Mojo.*/ Mojo Mojolicious Mojolicious::Lite
  13. 13. /Mojo.*/ Mojo Mojolicious Mojolicious::Lite criados por Sebastian Riedel tamb´m criador de Catalyst e developer RoR
  14. 14. /Mojo.*/ .---------------------------------------------------------------. | Fun! | ’---------------------------------------------------------------’ .---------------------------------------------------------------. | | | .----------------------------------------------’ | | .--------------------------------------------. | Application | | Mojolicious::Lite | | | ’--------------------------------------------’ | | .--------------------------------------------. | | | Mojolicious | ’----------------’ ’--------------------------------------------’ .---------------------------------------------------------------. | Mojo | ’---------------------------------------------------------------’ .-------. .-----------. .--------. .------------. .-------------. | CGI | | FastCGI | | PSGI | | HTTP 1.1 | | WebSocket | ’-------’ ’-----------’ ’--------’ ’------------’ ’-------------’
  15. 15. /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
  16. 16. /Mojo.*/ Mojolicious “The web in a box!” framework MVC com API OO Perl depende apenas de Perl 5.8.1
  17. 17. Mojolicious::Lite Single file micro web apps framework ˜ NAO! N˜o apropriado para produc˜o, software a ¸a comercial, ...
  18. 18. 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
  19. 19. 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
  20. 20. $ 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.
  21. 21. $ 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>
  22. 22. $ 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>
  23. 23. $ 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>
  24. 24. Routes get ’/’ => ’index’ # GET ’/’ get ’/:groovy’ => sub # GET ’/anyword’
  25. 25. 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’
  26. 26. 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)
  27. 27. Templates Sistema de templates pr´prio; ou o Template Toolkit, ...
  28. 28. 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)
  29. 29. $ myapp.pl inflate [mkdir] ~/folder/templates/layouts [write] ~/folder/templates/layouts/funky.html. [exist] ~/folder/templates [write] ~/folder/templates/index.html.ep
  30. 30. Trabalho semelhante Sinatra on Perl, github.com/jtarchie/ sinatra-on-perl Schenker, github.com/spiritloose/Schenker Dancer, perldancer.org
  31. 31. 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/
  32. 32. Questions o/
  1. A particular slide catching your eye?

    Clipping is a handy way to collect important slides you want to go back to later.

×