-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit aea450b
Showing
10 changed files
with
102 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
web: ./script/lrrr daemon --listen http://*:$PORT |
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,2 @@ | ||
requires 'Mojolicious' | ||
requires 'Mojolicious::Plugin::Authentication' |
Binary file not shown.
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,44 @@ | ||
package Lrrr; | ||
use Mojo::Base 'Mojolicious'; | ||
|
||
# This method will run once at server start | ||
sub startup { | ||
my $self = shift; | ||
|
||
# Documentation browser under "/perldoc" | ||
$self->plugin('PODRenderer'); | ||
|
||
# auth | ||
$self->plugin( authentication => { | ||
autoload_user => 1, | ||
load_user => sub { | ||
my $self = shift; | ||
my $uid = shift; | ||
|
||
return { | ||
'username' => 'foo', | ||
'password' => 'bar', | ||
'name' => 'Foo' | ||
} if($uid eq 'userid' || $uid eq 'useridwithextradata'); | ||
return undef; | ||
}, | ||
validate_user => sub { | ||
my $self = shift; | ||
my $username = shift || ''; | ||
my $password = shift || ''; | ||
my $extradata = shift || {}; | ||
|
||
return 'useridwithextradata' if($username eq 'foo' && $password eq 'bar' && ( $extradata->{'ohnoes'} || '' ) eq 'itsameme'); | ||
return 'userid' if($username eq 'foo' && $password eq 'bar'); | ||
return undef; | ||
}, | ||
}); | ||
|
||
# Router | ||
my $r = $self->routes; | ||
|
||
# Normal route to controller | ||
$r->get('/')->to('example#welcome'); | ||
} | ||
|
||
1; |
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,12 @@ | ||
package Lrrr::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; |
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,11 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<title>Welcome to the Mojolicious real-time web framework!</title> | ||
</head> | ||
<body> | ||
<h2>Welcome to the Mojolicious real-time web framework!</h2> | ||
This is the static document "public/index.html", | ||
<a href="/">click here</a> to get back to the start. | ||
</body> | ||
</html> |
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,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('Lrrr'); |
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,9 @@ | ||
use Mojo::Base -strict; | ||
|
||
use Test::More; | ||
use Test::Mojo; | ||
|
||
my $t = Test::Mojo->new('Lrrr'); | ||
$t->get_ok('/')->status_is(200)->content_like(qr/Mojolicious/i); | ||
|
||
done_testing(); |
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,7 @@ | ||
% layout 'default'; | ||
% title 'Welcome'; | ||
<h2><%= $msg %></h2> | ||
This page was generated from the template "templates/example/welcome.html.ep" | ||
and the layout "templates/layouts/default.html.ep", | ||
<a href="<%== url_for %>">click here</a> to reload the page or | ||
<a href="/index.html">here</a> to move forward to a static page. |
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,5 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head><title><%= title %></title></head> | ||
<body><%= content %></body> | ||
</html> |