From be460ab80c01344a6f4120cff6962ea612cf024a Mon Sep 17 00:00:00 2001 From: sergiotarxz Date: Sat, 23 May 2020 02:55:54 +0200 Subject: [PATCH 1/4] Initial commit --- README.md | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 README.md diff --git a/README.md b/README.md new file mode 100644 index 0000000..f600229 --- /dev/null +++ b/README.md @@ -0,0 +1,2 @@ +# TorChat + From 7973ff50c08345f39084bb52d660cd4a6cebf56f Mon Sep 17 00:00:00 2001 From: sergiotarxz Date: Sat, 23 May 2020 03:01:46 +0200 Subject: [PATCH 2/4] Mojo project. --- lib/TorChat.pm | 21 +++++++++++++++++++++ lib/TorChat/Controller/Example.pm | 12 ++++++++++++ public/index.html | 11 +++++++++++ script/tor_chat | 11 +++++++++++ t/basic.t | 9 +++++++++ templates/example/welcome.html.ep | 13 +++++++++++++ templates/layouts/default.html.ep | 5 +++++ tor_chat.conf | 4 ++++ 8 files changed, 86 insertions(+) create mode 100644 lib/TorChat.pm create mode 100644 lib/TorChat/Controller/Example.pm create mode 100644 public/index.html create mode 100755 script/tor_chat create mode 100644 t/basic.t create mode 100644 templates/example/welcome.html.ep create mode 100644 templates/layouts/default.html.ep create mode 100644 tor_chat.conf diff --git a/lib/TorChat.pm b/lib/TorChat.pm new file mode 100644 index 0000000..27c562a --- /dev/null +++ b/lib/TorChat.pm @@ -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; diff --git a/lib/TorChat/Controller/Example.pm b/lib/TorChat/Controller/Example.pm new file mode 100644 index 0000000..18e561d --- /dev/null +++ b/lib/TorChat/Controller/Example.pm @@ -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; 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/tor_chat b/script/tor_chat new file mode 100755 index 0000000..9e2675c --- /dev/null +++ b/script/tor_chat @@ -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'); diff --git a/t/basic.t b/t/basic.t new file mode 100644 index 0000000..ba9ae8c --- /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('TorChat'); +$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..1efd098 --- /dev/null +++ b/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/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 %> + diff --git a/tor_chat.conf b/tor_chat.conf new file mode 100644 index 0000000..aede70e --- /dev/null +++ b/tor_chat.conf @@ -0,0 +1,4 @@ +{ + perldoc => 1, + secrets => ['9c563c6b3a97c2c33de090152e3313ebe14cde9b'] +} From eb5aaca6476cfaa8cadcf921112baacd0c085456 Mon Sep 17 00:00:00 2001 From: sergiotarxz Date: Sat, 23 May 2020 03:03:09 +0200 Subject: [PATCH 3/4] Added .proverc --- .proverc | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 .proverc diff --git a/.proverc b/.proverc new file mode 100644 index 0000000..c96eebc --- /dev/null +++ b/.proverc @@ -0,0 +1,2 @@ +-I lib +-j4 From af1df5f3f49e074bcd1d9723e1ea93c0c5c21375 Mon Sep 17 00:00:00 2001 From: sergiotarxz Date: Sat, 23 May 2020 03:04:56 +0200 Subject: [PATCH 4/4] Deleted configuration. --- tor_chat.conf | 4 ---- 1 file changed, 4 deletions(-) delete mode 100644 tor_chat.conf diff --git a/tor_chat.conf b/tor_chat.conf deleted file mode 100644 index aede70e..0000000 --- a/tor_chat.conf +++ /dev/null @@ -1,4 +0,0 @@ -{ - perldoc => 1, - secrets => ['9c563c6b3a97c2c33de090152e3313ebe14cde9b'] -}