From 914c0374e4523dd55588156bfa8aa7f92e3f621a Mon Sep 17 00:00:00 2001 From: Catalin Constantin Mititiuc Date: Thu, 30 Jul 2026 17:26:40 -0700 Subject: [PATCH] Initial commit --- .gitignore | 1 + cpanfile | 1 + cpanfile.snapshot | 122 +++++++++++++++++++++ mojo_app/lib/MojoApp.pm | 20 ++++ mojo_app/lib/MojoApp/Controller/Example.pm | 11 ++ mojo_app/mojo_app.yml | 3 + mojo_app/public/index.html | 11 ++ mojo_app/script/mojo_app | 11 ++ mojo_app/t/basic.t | 9 ++ mojo_app/templates/example/welcome.html.ep | 9 ++ mojo_app/templates/layouts/default.html.ep | 5 + 11 files changed, 203 insertions(+) create mode 100644 .gitignore create mode 100644 cpanfile create mode 100644 cpanfile.snapshot create mode 100644 mojo_app/lib/MojoApp.pm create mode 100644 mojo_app/lib/MojoApp/Controller/Example.pm create mode 100644 mojo_app/mojo_app.yml create mode 100644 mojo_app/public/index.html create mode 100755 mojo_app/script/mojo_app create mode 100644 mojo_app/t/basic.t create mode 100644 mojo_app/templates/example/welcome.html.ep create mode 100644 mojo_app/templates/layouts/default.html.ep diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..4083037 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +local diff --git a/cpanfile b/cpanfile new file mode 100644 index 0000000..8811399 --- /dev/null +++ b/cpanfile @@ -0,0 +1 @@ +requires 'Mojolicious' => '9.48', diff --git a/cpanfile.snapshot b/cpanfile.snapshot new file mode 100644 index 0000000..95f032b --- /dev/null +++ b/cpanfile.snapshot @@ -0,0 +1,122 @@ +# carton snapshot format: version 1.0 +DISTRIBUTIONS + Mojolicious-9.48 + pathname: S/SR/SRI/Mojolicious-9.48.tar.gz + provides: + Mojo undef + Mojo::Asset undef + Mojo::Asset::File undef + Mojo::Asset::Memory undef + Mojo::Base undef + Mojo::BaseUtil undef + Mojo::ByteStream undef + Mojo::Cache undef + Mojo::Collection undef + Mojo::Content undef + Mojo::Content::MultiPart undef + Mojo::Content::Single undef + Mojo::Cookie undef + Mojo::Cookie::Request undef + Mojo::Cookie::Response undef + Mojo::DOM undef + Mojo::DOM::CSS undef + Mojo::DOM::HTML undef + Mojo::Date undef + Mojo::DynamicMethods undef + Mojo::EventEmitter undef + Mojo::Exception undef + Mojo::File undef + Mojo::Headers undef + Mojo::HelloWorld undef + Mojo::Home undef + Mojo::IOLoop undef + Mojo::IOLoop::Client undef + Mojo::IOLoop::Server undef + Mojo::IOLoop::Stream undef + Mojo::IOLoop::Subprocess undef + Mojo::IOLoop::TLS undef + Mojo::JSON undef + Mojo::JSON::Pointer undef + Mojo::Loader undef + Mojo::Log undef + Mojo::Message undef + Mojo::Message::Request undef + Mojo::Message::Response undef + Mojo::Parameters undef + Mojo::Path undef + Mojo::Promise undef + Mojo::Reactor undef + Mojo::Reactor::EV undef + Mojo::Reactor::Poll undef + Mojo::SSE undef + Mojo::Server undef + Mojo::Server::CGI undef + Mojo::Server::Daemon undef + Mojo::Server::Hypnotoad undef + Mojo::Server::Morbo undef + Mojo::Server::Morbo::Backend undef + Mojo::Server::Morbo::Backend::Poll undef + Mojo::Server::PSGI undef + Mojo::Server::Prefork undef + Mojo::Template undef + Mojo::Transaction undef + Mojo::Transaction::HTTP undef + Mojo::Transaction::WebSocket undef + Mojo::URL undef + Mojo::Upload undef + Mojo::UserAgent undef + Mojo::UserAgent::CookieJar undef + Mojo::UserAgent::Proxy undef + Mojo::UserAgent::Server undef + Mojo::UserAgent::Transactor undef + Mojo::Util undef + Mojo::WebSocket undef + Mojolicious 9.48 + Mojolicious::Command undef + Mojolicious::Command::Author::cpanify undef + Mojolicious::Command::Author::generate undef + Mojolicious::Command::Author::generate::app undef + Mojolicious::Command::Author::generate::dockerfile undef + Mojolicious::Command::Author::generate::lite_app undef + Mojolicious::Command::Author::generate::makefile undef + Mojolicious::Command::Author::generate::plugin undef + Mojolicious::Command::Author::inflate undef + Mojolicious::Command::cgi undef + Mojolicious::Command::daemon undef + Mojolicious::Command::eval undef + Mojolicious::Command::get undef + Mojolicious::Command::prefork undef + Mojolicious::Command::psgi undef + Mojolicious::Command::routes undef + Mojolicious::Command::version undef + Mojolicious::Commands undef + Mojolicious::Controller undef + Mojolicious::Lite undef + Mojolicious::Plugin undef + Mojolicious::Plugin::Config undef + Mojolicious::Plugin::DefaultHelpers undef + Mojolicious::Plugin::EPLRenderer undef + Mojolicious::Plugin::EPRenderer undef + Mojolicious::Plugin::HeaderCondition undef + Mojolicious::Plugin::JSONConfig undef + Mojolicious::Plugin::Mount undef + Mojolicious::Plugin::NotYAMLConfig undef + Mojolicious::Plugin::TagHelpers undef + Mojolicious::Plugins undef + Mojolicious::Renderer undef + Mojolicious::Routes undef + Mojolicious::Routes::Match undef + Mojolicious::Routes::Pattern undef + Mojolicious::Routes::Route undef + Mojolicious::Sessions undef + Mojolicious::Static undef + Mojolicious::Types undef + Mojolicious::Validator undef + Mojolicious::Validator::Validation undef + Test::Mojo undef + ojo undef + requirements: + ExtUtils::MakeMaker 0 + IO::Socket::IP 0.37 + Sub::Util 1.41 + perl 5.016 diff --git a/mojo_app/lib/MojoApp.pm b/mojo_app/lib/MojoApp.pm new file mode 100644 index 0000000..3f38a44 --- /dev/null +++ b/mojo_app/lib/MojoApp.pm @@ -0,0 +1,20 @@ +package MojoApp; +use Mojo::Base 'Mojolicious', -signatures; + +# This method will run once at server start +sub startup ($self) { + + # Load configuration from config file + my $config = $self->plugin('NotYAMLConfig'); + + # Configure the application + $self->secrets($config->{secrets}); + + # Router + my $r = $self->routes; + + # Normal route to controller + $r->get('/')->to('Example#welcome'); +} + +1; diff --git a/mojo_app/lib/MojoApp/Controller/Example.pm b/mojo_app/lib/MojoApp/Controller/Example.pm new file mode 100644 index 0000000..b0ec283 --- /dev/null +++ b/mojo_app/lib/MojoApp/Controller/Example.pm @@ -0,0 +1,11 @@ +package MojoApp::Controller::Example; +use Mojo::Base 'Mojolicious::Controller', -signatures; + +# This action will render a template +sub welcome ($self) { + + # Render template "example/welcome.html.ep" with message + $self->render(msg => 'Welcome to the Mojolicious real-time web framework!'); +} + +1; diff --git a/mojo_app/mojo_app.yml b/mojo_app/mojo_app.yml new file mode 100644 index 0000000..3e771f6 --- /dev/null +++ b/mojo_app/mojo_app.yml @@ -0,0 +1,3 @@ +--- +secrets: + - EVSQKfOiLasBIiDnsmldafRdgOn4aB4lPa9m4KNjc7w_wKCN_6YdQtfWswvXHOTLZVK3yz5Dg9_xMF-XKUnuB0hQmGztMo1-9aJrOW-4n7PioUGef-DzpRt1Da6l4tCLHsvwzQ7xd0ya2v6Mszh4lLbSEEdptlQAiRe1esWb4QU diff --git a/mojo_app/public/index.html b/mojo_app/public/index.html new file mode 100644 index 0000000..e74bb5f --- /dev/null +++ b/mojo_app/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/mojo_app/script/mojo_app b/mojo_app/script/mojo_app new file mode 100755 index 0000000..b097e09 --- /dev/null +++ b/mojo_app/script/mojo_app @@ -0,0 +1,11 @@ +#!/usr/bin/env perl + +use strict; +use warnings; + +use Mojo::File qw(curfile); +use lib curfile->dirname->sibling('lib')->to_string; +use Mojolicious::Commands; + +# Start command line interface for application +Mojolicious::Commands->start_app('MojoApp'); diff --git a/mojo_app/t/basic.t b/mojo_app/t/basic.t new file mode 100644 index 0000000..c180e43 --- /dev/null +++ b/mojo_app/t/basic.t @@ -0,0 +1,9 @@ +use Mojo::Base -strict; + +use Test::More; +use Test::Mojo; + +my $t = Test::Mojo->new('MojoApp'); +$t->get_ok('/')->status_is(200)->content_like(qr/Mojolicious/i); + +done_testing(); diff --git a/mojo_app/templates/example/welcome.html.ep b/mojo_app/templates/example/welcome.html.ep new file mode 100644 index 0000000..0a67219 --- /dev/null +++ b/mojo_app/templates/example/welcome.html.ep @@ -0,0 +1,9 @@ +% 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. +

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