Skip to content

Commit

Permalink
Implement Reply model
Browse files Browse the repository at this point in the history
  • Loading branch information
swaggboi committed Aug 20, 2022
1 parent a5599ce commit 3bec9a7
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 2 deletions.
6 changes: 5 additions & 1 deletion PostText.pl
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
# Load the local modules too
use lib 'lib';
use PostText::Model::Thread;
use PostText::Model::Reply;

# Load Mojo plugins
plugin 'Config';
Expand All @@ -25,6 +26,10 @@
state $thread = PostText::Model::Thread->new(pg => shift->pg)
};

helper reply => sub {
state $reply = PostText::Model::Reply->new(pg => shift->pg)
};

# Begin routing
under sub ($c) {
$c->session(expires => time() + 31536000);
Expand Down Expand Up @@ -94,7 +99,6 @@
app->pg->migrations->from_dir('migrations')->migrate(4);

if (my $threads_per_page = app->config->{'threads_per_page'}) {
say $threads_per_page;
app->thread->threads_per_page($threads_per_page);
}

Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ Run the tests locally (against development environment)

## TODOs

1. Make a view for single threads(!!)
1. Default 'threads per page' is broken if config file isn't correct
(should pick up the default value wtf)
1. Pick a date format
1. Reply model
16 changes: 16 additions & 0 deletions lib/PostText/Model/Reply.pm
Original file line number Diff line number Diff line change
@@ -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;

0 comments on commit 3bec9a7

Please sign in to comment.