diff --git a/Makefile.PL b/Makefile.PL new file mode 100644 index 0000000..65d42ce --- /dev/null +++ b/Makefile.PL @@ -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; "; + } +} diff --git a/bin/beastbb b/bin/beastbb new file mode 100755 index 0000000..1e12c9b --- /dev/null +++ b/bin/beastbb @@ -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'); diff --git a/lib/BeastBB.conf b/lib/BeastBB.conf new file mode 100644 index 0000000..2c63c08 --- /dev/null +++ b/lib/BeastBB.conf @@ -0,0 +1,2 @@ +{ +} diff --git a/lib/BeastBB.pm b/lib/BeastBB.pm new file mode 100644 index 0000000..5356c51 --- /dev/null +++ b/lib/BeastBB.pm @@ -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; diff --git a/lib/BeastBB/Controller/Example.pm b/lib/BeastBB/Controller/Example.pm new file mode 100644 index 0000000..7710b1b --- /dev/null +++ b/lib/BeastBB/Controller/Example.pm @@ -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; diff --git a/migrations/1/down.sql b/migrations/1/down.sql new file mode 100644 index 0000000..53f66b0 --- /dev/null +++ b/migrations/1/down.sql @@ -0,0 +1,3 @@ +DROP INDEX username_index_users; +DROP INDEX matrix_address_index_users; +DROP TABLE users; diff --git a/migrations/1/up.sql b/migrations/1/up.sql new file mode 100644 index 0000000..72dcdd0 --- /dev/null +++ b/migrations/1/up.sql @@ -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; 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/t/basic.t b/t/basic.t new file mode 100644 index 0000000..fdb7d0c --- /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('BeastBB'); +$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..0a67219 --- /dev/null +++ b/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/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 %> +