2022-07-22 18:37:31 -04:00
|
|
|
#!/usr/bin/env perl
|
|
|
|
|
|
|
|
# PostText v0.1
|
|
|
|
# Jul 22
|
|
|
|
|
|
|
|
use Mojolicious::Lite -signatures;
|
2022-07-28 21:13:26 -04:00
|
|
|
use Mojo::Pg;
|
|
|
|
|
|
|
|
# Load the local modules too
|
|
|
|
use lib 'lib';
|
|
|
|
use PostText::Model::Thread;
|
|
|
|
|
|
|
|
# Load Mojo plugins
|
|
|
|
plugin 'Config';
|
|
|
|
|
|
|
|
# Helpers
|
|
|
|
helper pg => sub {
|
|
|
|
state $pg = Mojo::Pg->new(app->config->{app->mode}{'pg_string'})
|
|
|
|
};
|
|
|
|
|
|
|
|
# Begin routing
|
|
|
|
under sub ($c) {
|
|
|
|
$c->session(expires => time() + 1800);
|
|
|
|
|
|
|
|
1;
|
|
|
|
};
|
2022-07-22 18:37:31 -04:00
|
|
|
|
2022-07-28 20:44:47 -04:00
|
|
|
# Root redirect
|
|
|
|
get '/', sub ($c) { $c->redirect_to('view') };
|
|
|
|
|
|
|
|
get '/view', sub ($c) {
|
|
|
|
$c->render()
|
2022-07-22 18:37:31 -04:00
|
|
|
};
|
|
|
|
|
2022-07-28 21:13:26 -04:00
|
|
|
app->secrets(app->config->{'secrets'}) || die $@;
|
|
|
|
|
2022-07-29 22:15:14 -04:00
|
|
|
app->pg->migrations->from_dir('migrations')->migrate();
|
|
|
|
|
2022-07-22 18:37:31 -04:00
|
|
|
app->start();
|