Clean-up 404 for remark->by_id

This commit is contained in:
swag 2023-05-29 00:14:47 -04:00
parent f8bdcc9201
commit a220c233fa
2 changed files with 6 additions and 11 deletions

View File

@ -6,15 +6,10 @@ sub by_id($self) {
my $remark_id = $self->param('remark_id'); my $remark_id = $self->param('remark_id');
my $remark = $self->remark->by_id($remark_id); my $remark = $self->remark->by_id($remark_id);
if (my $remark_id = $remark->{'id'}) { $self->stash(remark => $remark);
$self->stash(remark => $remark)
} $self->stash(error => 'Remark not found 🤷')
else { unless keys %{$remark};
$self->stash(
remark => {},
error => 'Remark not found 🤷'
)
}
$self->render; $self->render;
} }

View File

@ -1,12 +1,12 @@
% layout 'default'; % layout 'default';
% title my $remark_id = $remark->{'id'} ? "Remark #$remark_id" : '?'; % title my $remark_id = $remark->{'id'} ? "Remark #$remark_id" : '?';
<h2 class="page-title"><%= title %></h2> <h2 class="page-title"><%= title %></h2>
<% if (my $remark_id = $remark->{'id'}) { =%> <% if (keys %{$remark}) { =%>
<main class="pager"> <main class="pager">
<article class="post"> <article class="post">
<h4 class="post__title"> <h4 class="post__title">
<%= $remark->{'date'} %> <%= $remark->{'date'} %>
<span class="post__id">#<%= $remark_id %></span> <span class="post__id">#<%= $remark->{'id'} %></span>
</h4> </h4>
<h5 class="post__author"><%= $remark->{'author'} %></h5> <h5 class="post__author"><%= $remark->{'author'} %></h5>
<div class="post__body"> <div class="post__body">