Use restrictive placeholder in addition to optional for page number

This commit is contained in:
swagg boi 2022-04-07 22:14:24 -04:00
parent 07e7f69e90
commit 36d1fcd7fa
3 changed files with 15 additions and 44 deletions

View file

@ -126,11 +126,11 @@ group {
group {
under '/spam';
get '/:page_number', {page_number => 1} => sub ($c) {
my $this_page = $c->param('page_number');
get '/:number', [number => qr/[0-9]+/], {number => 1} => sub ($c) {
my $this_page = $c->param('number');
my $last_page = $c->message->get_last_page('spam');
my $view_posts = $c->message->get_spam($this_page);
my $base_path = $c->url_for(page_number => undef);
my $base_path = $c->url_for(number => undef);
$c->stash(
view_posts => $view_posts,
@ -146,11 +146,11 @@ group {
group {
under '/view';
get '/:page_number', {page_number => 1} => sub ($c) {
my $this_page = $c->param('page_number');
get '/:number', [number => qr/[0-9]+/], {number => 1} => sub ($c) {
my $this_page = $c->param('number');
my $last_page = $c->message->get_last_page('spam');
my $view_posts = $c->message->get_spam($this_page);
my $base_path = $c->url_for(page_number => undef);
my $base_path = $c->url_for(number => undef);
$c->stash(
view_posts => $view_posts,

View file

@ -1,29 +0,0 @@
% layout 'default';
% title 'View';
<h2>Messages from the World Wide Web</h2>
<div class="articles">
<% for my $post (@$view_posts) { =%>
<article>
<span class="message_id field">
<%= link_to "#@$post[4]" => "/message/@$post[4]" %>
</span>
<h3><%= @$post[0] %></h3>
<div class="message field">
<blockquote><p><%= @$post[2] %></p></blockquote>
</div>
<div class="name field">
<p style="margin: 0 0 0 0;">
- <%= @$post[1] %>
<% if (@$post[3]) { =%>
(<%= link_to Homepage => @$post[3] %>)
<% } =%>
</p>
</div>
</article>
<% } =%>
</div>
<% if ($last_page && $last_page != 1) { =%>
<nav>
<%= pagination $this_page, $last_page, '?page={page}' %>
</nav>
<% } =%>