Add search bar and fix max_thread_pages

This commit is contained in:
swaggboi 2023-11-01 09:12:54 -04:00
parent 16a561346d
commit 6744498b4d
4 changed files with 20 additions and 3 deletions

View File

@ -61,8 +61,8 @@ tests locally:
## TODOs ## TODOs
1. Hide ancient posts (test this, dev DB is broken fuck) 1. Winter/Christmas/New Years background
1. Put a link to search_page somewhere 1. Make CAPTCHA preserve search query
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

@ -32,7 +32,7 @@ body {
/* background-image: url('/images/topwwbackground.gif'); */ /* background-image: url('/images/topwwbackground.gif'); */
/* Spooky time! */ /* Spooky time! */
background-image: url('/images/halloween_background_1.gif'); background-image: url('/images/halloween_background_1.gif');
/* Christmas */ /* Christmas/New Years-ish? */
/* background-image: url('/images/windowstars.gif'); */ /* background-image: url('/images/windowstars.gif'); */
width: 95vmin; width: 95vmin;
margin: 0 auto; margin: 0 auto;

View File

@ -53,6 +53,7 @@ sub by_page($self, $this_page = 1) {
sub last_page($self) { sub last_page($self) {
my $thread_count = $self->count; my $thread_count = $self->count;
my $last_page = int($thread_count / $self->per_page); my $last_page = int($thread_count / $self->per_page);
my $max_pages = $self->max_pages;
# 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;

View File

@ -12,6 +12,22 @@
<h2 class="page-title"><%= title %></h2> <h2 class="page-title"><%= title %></h2>
<% if (scalar @{$threads}) { =%> <% if (scalar @{$threads}) { =%>
<main class="pager"> <main class="pager">
<%= form_for search_page => (class => 'form-body'), begin %>
<div class="form-field">
<% if (my $error = validation->error('q')) { =%>
<p class="field-with-error">Must be between <%= $error->[2] %>
and <%= $error->[3] %> characters.</p>
<% } =%>
<%= label_for search => 'Search' %>
<%= text_field q => (
id => 'search',
maxlength => 2047,
minlength => 1,
required => undef
) %>
</div>
<button type="submit" class="form-button">Search</button>
<% end %>
<% for my $thread (@{$threads}) { =%> <% for my $thread (@{$threads}) { =%>
<article class="post"> <article class="post">
<h3 class="post__title"> <h3 class="post__title">