From: Dirk Koopman Date: Sat, 21 Oct 2017 16:08:45 +0000 (+0100) Subject: add dxweb app X-Git-Url: http://dxcluster.org/gitweb/gitweb.cgi?a=commitdiff_plain;h=acf26488adcdf8852419818897405d10f895e16a;p=spider.git add dxweb app --- diff --git a/dxweb/d_x_web.conf b/dxweb/d_x_web.conf new file mode 100644 index 00000000..43ae1744 --- /dev/null +++ b/dxweb/d_x_web.conf @@ -0,0 +1,4 @@ +{ + perldoc => 1, + secrets => ['ac82f00b5490aa599f88feafe6b3af4014aefb5a'] +} diff --git a/dxweb/lib/DXWeb.pm b/dxweb/lib/DXWeb.pm new file mode 100644 index 00000000..68c5dcdb --- /dev/null +++ b/dxweb/lib/DXWeb.pm @@ -0,0 +1,21 @@ +package DXWeb; +use Mojo::Base 'Mojolicious'; + +# This method will run once at server start +sub startup { + my $self = shift; + + # Load configuration from hash returned by "my_app.conf" + my $config = $self->plugin('Config'); + + # Documentation browser under "/perldoc" + $self->plugin('PODRenderer') if $config->{perldoc}; + + # Router + my $r = $self->routes; + + # Normal route to controller + $r->get('/')->to('example#welcome'); +} + +1; diff --git a/dxweb/lib/DXWeb/Controller/Example.pm b/dxweb/lib/DXWeb/Controller/Example.pm new file mode 100644 index 00000000..e701b7bf --- /dev/null +++ b/dxweb/lib/DXWeb/Controller/Example.pm @@ -0,0 +1,12 @@ +package DXWeb::Controller::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/dxweb/public/index.html b/dxweb/public/index.html new file mode 100644 index 00000000..e74bb5f0 --- /dev/null +++ b/dxweb/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/dxweb/script/dxweb b/dxweb/script/dxweb new file mode 100755 index 00000000..4200773d --- /dev/null +++ b/dxweb/script/dxweb @@ -0,0 +1,11 @@ +#!/usr/bin/env perl + +use strict; +use warnings; + +use FindBin; +BEGIN { unshift @INC, "$FindBin::Bin/../lib" } +use Mojolicious::Commands; + +# Start command line interface for application +Mojolicious::Commands->start_app('DXWeb'); diff --git a/dxweb/t/basic.t b/dxweb/t/basic.t new file mode 100644 index 00000000..f6b2a686 --- /dev/null +++ b/dxweb/t/basic.t @@ -0,0 +1,9 @@ +use Mojo::Base -strict; + +use Test::More; +use Test::Mojo; + +my $t = Test::Mojo->new('DXWeb'); +$t->get_ok('/')->status_is(200)->content_like(qr/Mojolicious/i); + +done_testing(); diff --git a/dxweb/templates/example/welcome.html.ep b/dxweb/templates/example/welcome.html.ep new file mode 100644 index 00000000..1efd0982 --- /dev/null +++ b/dxweb/templates/example/welcome.html.ep @@ -0,0 +1,13 @@ +% 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", + <%= link_to 'click here' => url_for %> to reload the page or + <%= link_to 'here' => '/index.html' %> to move forward to a static page. + % if (config 'perldoc') { + To learn more, you can also browse through the documentation + <%= link_to 'here' => '/perldoc' %>. + % } +

diff --git a/dxweb/templates/layouts/default.html.ep b/dxweb/templates/layouts/default.html.ep new file mode 100644 index 00000000..599c5568 --- /dev/null +++ b/dxweb/templates/layouts/default.html.ep @@ -0,0 +1,5 @@ + + + <%= title %> + <%= content %> +