Clean up on thread->by_id
This commit is contained in:
parent
a220c233fa
commit
e8d3e716ce
|
@ -51,32 +51,21 @@ sub by_id($self) {
|
|||
$last_page = $self->remark->last_page_for($thread_id);
|
||||
$remarks = $self->remark->by_page_for($thread_id, $this_page);
|
||||
|
||||
if (my $thread_body = $thread->{'body'}) {
|
||||
$self->stash(
|
||||
thread => $thread,
|
||||
base_path => $base_path,
|
||||
this_page => $this_page,
|
||||
last_page => $last_page,
|
||||
remarks => $remarks
|
||||
)
|
||||
}
|
||||
else {
|
||||
$self->stash(
|
||||
thread => {},
|
||||
remarks => [],
|
||||
status => 404,
|
||||
error => 'Thread not found 🤷'
|
||||
)
|
||||
}
|
||||
$self->stash(
|
||||
thread => $thread,
|
||||
base_path => $base_path,
|
||||
this_page => $this_page,
|
||||
last_page => $last_page,
|
||||
remarks => $remarks
|
||||
);
|
||||
|
||||
$self->stash(status => 404, error => 'Thread not found 🤷')
|
||||
unless keys %{$thread};
|
||||
|
||||
# Check for remarks or thread page number to make sure
|
||||
# remark->by_page_for did its job
|
||||
unless ((my $first_remark = $remarks->[0]) || 1 >= $this_page) {
|
||||
$self->stash(
|
||||
status => 404,
|
||||
error => 'Page not found 🕵️'
|
||||
)
|
||||
}
|
||||
$self->stash(status => 404, error => 'Page not found 🕵️')
|
||||
unless 1 >= $this_page || scalar @{$remarks};
|
||||
|
||||
$self->render;
|
||||
}
|
||||
|
|
|
@ -1,12 +1,12 @@
|
|||
% layout 'default';
|
||||
% title my $thread_id = $thread->{'id'} ? "Thread #$thread_id" : '?';
|
||||
<h2 class="page-title"><%= title %></h2>
|
||||
<% if (my $thread_id = $thread->{'id'}) { =%>
|
||||
<% if (keys %{$thread}) { =%>
|
||||
<main class="pager">
|
||||
<article class="post">
|
||||
<h3 class="post__title">
|
||||
<%= $thread->{'title'} %>
|
||||
<span class="post__id">#<%= $thread_id %></span>
|
||||
<span class="post__id">#<%= $thread->{'id'} %></span>
|
||||
</h3>
|
||||
<h4 class="post__date"><%= $thread->{'date'} %></h4>
|
||||
<h5 class="post__author"><%= $thread->{'author'} %></h5>
|
||||
|
@ -38,7 +38,7 @@
|
|||
</article>
|
||||
</main>
|
||||
<% } =%>
|
||||
<% if (my $first_remark = $remarks->[0]) { =%>
|
||||
<% if (scalar @{$remarks}) { =%>
|
||||
<section class="pager" id="remarks">
|
||||
<h3 class="pager__title">Remarks</h3>
|
||||
<% for my $remark (@{$remarks}) { =%>
|
||||
|
|
Loading…
Reference in New Issue
Block a user