Adding initial project to build the project from.

This commit is contained in:
sergiotarxz 2021-04-17 20:05:40 +02:00
parent 1df8ae8764
commit d3cedf05b5
Signed by: sergiotarxz
GPG Key ID: E5903508B6510AC2
11 changed files with 132 additions and 0 deletions

39
Makefile.PL Normal file
View File

@ -0,0 +1,39 @@
## Please see file perltidy.ERR
## Please see file perltidy.ERR
use ExtUtils::MakeMaker;
WriteMakefile(
NAME => 'BeastBB',
VERSION => '0.1',
INST_SCRIPT => './bin',
INST_BIN => './bin',
test => { TESTS => 't/*.t' },
);
package MY {
sub top_targets {
my $self = shift;
my $return = $self->SUPER::top_targets(@_);
$return = [ split /\n/, $return ];
for my $i ( keys @$return ) {
$return->[$i] .= ' install_frontend'
if $return->[$i] =~ /^all :/;
}
return join "\n", @$return;
}
sub postamble {
return
"\n"
. "install_frontend:\n"
. "\tif [ ! -e blib/BeastBB/public ]; then "
. "mkdir -pv blib/BeastBB/public; "
. "fi;"
. "if [ ! -e blib/BeastBB/templates ]; then "
. "mkdir -pv blib/BeastBB/templates; "
. "fi; "
. "cp -rfv templates/* blib/BeastBB/templates; "
. "cp -rfv public/* blib/BeastBB/public; ";
}
}

9
bin/beastbb Executable file
View File

@ -0,0 +1,9 @@
#!/usr/bin/env perl
use strict;
use warnings;
use Mojolicious::Commands;
# Start command line interface for application
Mojolicious::Commands->start_app('BeastBB');

2
lib/BeastBB.conf Normal file
View File

@ -0,0 +1,2 @@
{
}

24
lib/BeastBB.pm Normal file
View File

@ -0,0 +1,24 @@
package BeastBB;
use Mojo::Base 'Mojolicious';
use Mojo::File;
use Data::Dumper;
sub startup {
my $self = shift;
my $config = $self->plugin(
'Config',
file => Mojo::File::curfile->dirname->child('BeastBB.conf')->to_string
);
$self->secrets( $config->{secrets} );
my $r = $self->routes;
$r->get('/')->to('example#welcome');
@{ $self->renderer->paths() } =
( Mojo::File::curfile->dirname->child('BeastBB')->child('templates')->to_string );
@{ $self->static->paths() } =
( Mojo::File::curfile->dirname->child('BeastBB')->child('public')->to_string );
STDERR->print(Data::Dumper::Dumper $self->static->paths());
STDERR->print(Data::Dumper::Dumper $self->renderer->paths());
}
1;

View File

@ -0,0 +1,11 @@
package BeastBB::Controller::Example;
use Mojo::Base 'Mojolicious::Controller';
sub welcome {
my $self = shift;
$self->render(
msg => 'Welcome to the Mojolicious real-time web framework!' );
}
1;

3
migrations/1/down.sql Normal file
View File

@ -0,0 +1,3 @@
DROP INDEX username_index_users;
DROP INDEX matrix_address_index_users;
DROP TABLE users;

10
migrations/1/up.sql Normal file
View File

@ -0,0 +1,10 @@
create table users (
id SERIAL PRIMARY KEY,
username TEXT UNIQUE,
matrix_address TEXT UNIQUE,
is_confirmed INT[1] DEFAULT false,
"privileges" HSTORE
);
CREATE INDEX username_index_users ON users username;
CREATE INDEX matrix_address_index_users ON users matrix_address;

11
public/index.html Normal file
View 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>

9
t/basic.t Normal file
View File

@ -0,0 +1,9 @@
use Mojo::Base -strict;
use Test::More;
use Test::Mojo;
my $t = Test::Mojo->new('BeastBB');
$t->get_ok('/')->status_is(200)->content_like(qr/Mojolicious/i);
done_testing();

View File

@ -0,0 +1,9 @@
% 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.
</p>

View File

@ -0,0 +1,5 @@
<!DOCTYPE html>
<html>
<head><title><%= title %></title></head>
<body><%= content %></body>
</html>