Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added support for multiple "templates" and "public" directories to Mo…
…jolicious (closes #286)
- Loading branch information
Showing
13 changed files
with
148 additions
and
63 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
use Mojo::Base -strict; | ||
|
||
# Disable Bonjour, IPv6 and libev | ||
BEGIN { | ||
$ENV{MOJO_NO_BONJOUR} = $ENV{MOJO_NO_IPV6} = 1; | ||
$ENV{MOJO_IOWATCHER} = 'Mojo::IOWatcher'; | ||
} | ||
|
||
# "You are hereby conquered. | ||
# Please line up in order of how much beryllium it takes to kill you." | ||
use Test::More tests => 20; | ||
|
||
use Mojolicious::Lite; | ||
use Test::Mojo; | ||
|
||
# More paths | ||
push @{app->renderer->paths}, app->home->rel_dir('templates2'); | ||
push @{app->static->paths}, app->home->rel_dir('public2'); | ||
|
||
# GET /twenty_three | ||
get '/twenty_three' => '23'; | ||
|
||
# GET /fourty_two | ||
get '/fourty_two' => '42'; | ||
|
||
my $t = Test::Mojo->new; | ||
|
||
# GET /twenty_three (templates) | ||
$t->get_ok('/twenty_three')->status_is(200) | ||
->header_is(Server => 'Mojolicious (Perl)') | ||
->header_is('X-Powered-By' => 'Mojolicious (Perl)')->content_is("23\n"); | ||
|
||
# GET /fourty_two (templates2) | ||
$t->get_ok('/fourty_two')->status_is(200) | ||
->header_is(Server => 'Mojolicious (Perl)') | ||
->header_is('X-Powered-By' => 'Mojolicious (Perl)') | ||
->content_is("The answer is 42.\n"); | ||
|
||
# GET /hello.txt (public) | ||
$t->get_ok('/hello.txt')->status_is(200) | ||
->header_is(Server => 'Mojolicious (Perl)') | ||
->header_is('X-Powered-By' => 'Mojolicious (Perl)') | ||
->content_is("Hello Mojo from a static file!\n"); | ||
|
||
# GET /hello3.txt (public2) | ||
$t->get_ok('/hello3.txt')->status_is(200) | ||
->header_is(Server => 'Mojolicious (Perl)') | ||
->header_is('X-Powered-By' => 'Mojolicious (Perl)') | ||
->content_is("Hello Mojo from... ALL GLORY TO THE HYPNOTOAD!\n"); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Hello Mojo from... ALL GLORY TO THE HYPNOTOAD! |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
%# "Oh no! Can we switch back using four or more bodies? | ||
%# I'm not sure. I'm afraid we need to use... MATH." | ||
The answer is <%= 40 + 2 %>. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
005568f
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was missing this very much. Thanks!