Implement Reply model

This commit is contained in:
swaggboi 2022-08-19 22:42:30 -04:00
parent a5599ce259
commit 3bec9a71f1
3 changed files with 22 additions and 2 deletions

View File

@ -10,6 +10,7 @@ use Data::Dumper; # For your debugging pleasure
# Load the local modules too # Load the local modules too
use lib 'lib'; use lib 'lib';
use PostText::Model::Thread; use PostText::Model::Thread;
use PostText::Model::Reply;
# Load Mojo plugins # Load Mojo plugins
plugin 'Config'; plugin 'Config';
@ -25,6 +26,10 @@ helper thread => sub {
state $thread = PostText::Model::Thread->new(pg => shift->pg) state $thread = PostText::Model::Thread->new(pg => shift->pg)
}; };
helper reply => sub {
state $reply = PostText::Model::Reply->new(pg => shift->pg)
};
# Begin routing # Begin routing
under sub ($c) { under sub ($c) {
$c->session(expires => time() + 31536000); $c->session(expires => time() + 31536000);
@ -94,7 +99,6 @@ app->secrets(app->config->{'secrets'}) || die $@;
app->pg->migrations->from_dir('migrations')->migrate(4); app->pg->migrations->from_dir('migrations')->migrate(4);
if (my $threads_per_page = app->config->{'threads_per_page'}) { if (my $threads_per_page = app->config->{'threads_per_page'}) {
say $threads_per_page;
app->thread->threads_per_page($threads_per_page); app->thread->threads_per_page($threads_per_page);
} }

View File

@ -24,7 +24,7 @@ Run the tests locally (against development environment)
## TODOs ## TODOs
1. Make a view for single threads(!!)
1. Default 'threads per page' is broken if config file isn't correct 1. Default 'threads per page' is broken if config file isn't correct
(should pick up the default value wtf) (should pick up the default value wtf)
1. Pick a date format 1. Pick a date format
1. Reply model

View File

@ -0,0 +1,16 @@
#!/usr/bin/env perl
package PostText::Model::Reply;
use Mojo::Base -base, -signatures;
has 'pg';
sub new($class, $pg, $pg_reference) {
bless {
$pg => $pg_reference,
replies_per_page => 5
}, $class
}
1;