commit d144db93107992a2979443298d8a95bf2e3dba63 Author: Luc Didry Date: Sun Feb 9 17:27:32 2014 +0100 First import after mojo generate app diff --git a/lib/Lutim.pm b/lib/Lutim.pm new file mode 100644 index 0000000..910fb35 --- /dev/null +++ b/lib/Lutim.pm @@ -0,0 +1,18 @@ +package Lutim; +use Mojo::Base 'Mojolicious'; + +# This method will run once at server start +sub startup { + my $self = shift; + + # Documentation browser under "/perldoc" + $self->plugin('PODRenderer'); + + # Router + my $r = $self->routes; + + # Normal route to controller + $r->get('/')->to('example#welcome'); +} + +1; diff --git a/lib/Lutim/Example.pm b/lib/Lutim/Example.pm new file mode 100644 index 0000000..45d2b25 --- /dev/null +++ b/lib/Lutim/Example.pm @@ -0,0 +1,12 @@ +package Lutim::Example; +use Mojo::Base 'Mojolicious::Controller'; + +# This action will render a template +sub welcome { + my $self = shift; + + # Render template "example/welcome.html.ep" with message + $self->render(msg => 'Welcome to the Mojolicious real-time web framework!'); +} + +1; diff --git a/public/index.html b/public/index.html new file mode 100644 index 0000000..e74bb5f --- /dev/null +++ b/public/index.html @@ -0,0 +1,11 @@ + + + + Welcome to the Mojolicious real-time web framework! + + +

Welcome to the Mojolicious real-time web framework!

+ This is the static document "public/index.html", + click here to get back to the start. + + diff --git a/script/lutim b/script/lutim new file mode 100755 index 0000000..08b5fd5 --- /dev/null +++ b/script/lutim @@ -0,0 +1,11 @@ +#!/usr/bin/env perl + +use strict; +use warnings; + +use FindBin; +BEGIN { unshift @INC, "$FindBin::Bin/../lib" } + +# Start command line interface for application +require Mojolicious::Commands; +Mojolicious::Commands->start_app('Lutim'); diff --git a/t/basic.t b/t/basic.t new file mode 100644 index 0000000..5f257e5 --- /dev/null +++ b/t/basic.t @@ -0,0 +1,9 @@ +use Mojo::Base -strict; + +use Test::More; +use Test::Mojo; + +my $t = Test::Mojo->new('Lutim'); +$t->get_ok('/')->status_is(200)->content_like(qr/Mojolicious/i); + +done_testing(); diff --git a/templates/example/welcome.html.ep b/templates/example/welcome.html.ep new file mode 100644 index 0000000..f77e8a2 --- /dev/null +++ b/templates/example/welcome.html.ep @@ -0,0 +1,7 @@ +% layout 'default'; +% title 'Welcome'; +

<%= $msg %>

+This page was generated from the template "templates/example/welcome.html.ep" +and the layout "templates/layouts/default.html.ep", +click here to reload the page or +here to move forward to a static page. diff --git a/templates/layouts/default.html.ep b/templates/layouts/default.html.ep new file mode 100644 index 0000000..599c556 --- /dev/null +++ b/templates/layouts/default.html.ep @@ -0,0 +1,5 @@ + + + <%= title %> + <%= content %> +