Mojo project.
This commit is contained in:
parent
be460ab80c
commit
7973ff50c0
21
lib/TorChat.pm
Normal file
21
lib/TorChat.pm
Normal file
@ -0,0 +1,21 @@
|
||||
package TorChat;
|
||||
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;
|
12
lib/TorChat/Controller/Example.pm
Normal file
12
lib/TorChat/Controller/Example.pm
Normal file
@ -0,0 +1,12 @@
|
||||
package TorChat::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;
|
11
public/index.html
Normal file
11
public/index.html
Normal file
@ -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>
|
11
script/tor_chat
Executable file
11
script/tor_chat
Executable file
@ -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('TorChat');
|
9
t/basic.t
Normal file
9
t/basic.t
Normal file
@ -0,0 +1,9 @@
|
||||
use Mojo::Base -strict;
|
||||
|
||||
use Test::More;
|
||||
use Test::Mojo;
|
||||
|
||||
my $t = Test::Mojo->new('TorChat');
|
||||
$t->get_ok('/')->status_is(200)->content_like(qr/Mojolicious/i);
|
||||
|
||||
done_testing();
|
13
templates/example/welcome.html.ep
Normal file
13
templates/example/welcome.html.ep
Normal file
@ -0,0 +1,13 @@
|
||||
% layout 'default';
|
||||
% title 'Welcome';
|
||||
<h2><%= $msg %></h2>
|
||||
<p>
|
||||
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' %>.
|
||||
% }
|
||||
</p>
|
5
templates/layouts/default.html.ep
Normal file
5
templates/layouts/default.html.ep
Normal file
@ -0,0 +1,5 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head><title><%= title %></title></head>
|
||||
<body><%= content %></body>
|
||||
</html>
|
4
tor_chat.conf
Normal file
4
tor_chat.conf
Normal file
@ -0,0 +1,4 @@
|
||||
{
|
||||
perldoc => 1,
|
||||
secrets => ['9c563c6b3a97c2c33de090152e3313ebe14cde9b']
|
||||
}
|
Loading…
Reference in New Issue
Block a user