Do max_pages for threads

This commit is contained in:
swagg boi 2023-10-28 11:34:44 -04:00
parent b11a616d90
commit 16a561346d
4 changed files with 12 additions and 3 deletions

View file

@ -61,7 +61,7 @@ tests locally:
## TODOs ## TODOs
1. Hide ancient posts 1. Hide ancient posts (test this, dev DB is broken fuck)
1. Put a link to search_page somewhere 1. Put a link to search_page somewhere
1. "All new posts flagged" mode (require approval for new posts) 1. "All new posts flagged" mode (require approval for new posts)
1. Tests for mod-only user? 1. Tests for mod-only user?

View file

@ -1,4 +1,5 @@
{ {
max_thread_pages => 10,
threads_per_page => 5, threads_per_page => 5,
remarks_per_page => 5, remarks_per_page => 5,
results_per_page => 5, results_per_page => 5,

View file

@ -104,6 +104,10 @@ sub startup($self) {
$self->page->per_page($results_per_page) $self->page->per_page($results_per_page)
} }
if (my $max_thread_pages = $self->config->{'max_thread_pages'}) {
$self->thread->max_pages($max_thread_pages)
}
$self->asset->process; $self->asset->process;
push @{$self->commands->namespaces}, 'PostText::Command'; push @{$self->commands->namespaces}, 'PostText::Command';

View file

@ -2,7 +2,7 @@ package PostText::Model::Thread;
use Mojo::Base -base, -signatures; use Mojo::Base -base, -signatures;
has [qw{pg hr}]; has [qw{pg hr max_pages}];
has per_page => 5; has per_page => 5;
@ -57,7 +57,11 @@ sub last_page($self) {
# Add a page for 'remainder' posts # Add a page for 'remainder' posts
$last_page++ if $thread_count % $self->per_page; $last_page++ if $thread_count % $self->per_page;
$last_page; if ($max_pages) {
$last_page = $max_pages if $last_page > $max_pages
}
return $last_page;
} }
sub count($self) { sub count($self) {