Use restrictive placeholder in addition to optional for page number
This commit is contained in:
parent
07e7f69e90
commit
36d1fcd7fa
|
@ -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,20 +146,20 @@ group {
|
|||
group {
|
||||
under '/view';
|
||||
|
||||
get '/:page_number', {page_number => 1} => sub ($c) {
|
||||
my $this_page = $c->param('page_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);
|
||||
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(number => undef);
|
||||
|
||||
$c->stash(
|
||||
view_posts => $view_posts,
|
||||
this_page => $this_page,
|
||||
last_page => $last_page,
|
||||
base_path => $base_path
|
||||
);
|
||||
$c->stash(
|
||||
view_posts => $view_posts,
|
||||
this_page => $this_page,
|
||||
last_page => $last_page,
|
||||
base_path => $base_path
|
||||
);
|
||||
|
||||
$c->render();
|
||||
$c->render();
|
||||
};
|
||||
};
|
||||
|
||||
|
|
|
@ -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>
|
||||
<% } =%>
|
Loading…
Reference in a new issue