Clean up remark->create plus new 404 behavior

This commit is contained in:
swagg boi 2023-05-29 00:45:40 -04:00
parent 957885a38e
commit 7cf9981973
2 changed files with 8 additions and 3 deletions

View file

@ -57,6 +57,9 @@ sub create($self) {
last_remark => $last_remark last_remark => $last_remark
); );
$self->stash(status => 404, error => 'Thread not found 🤷')
unless keys %{$thread};
return $self->render; return $self->render;
} }

View file

@ -1,6 +1,7 @@
% layout 'default'; % layout 'default';
% title 'New Remark'; % title 'New Remark';
<h2 class="page-title"><%= title %></h2> <h2 class="page-title"><%= title %></h2>
<% if (keys %{$thread}) { =%>
<form method="post" class="form-body"> <form method="post" class="form-body">
<div class="form-field"> <div class="form-field">
<% if (my $error = validation->error('author')) { =%> <% if (my $error = validation->error('author')) { =%>
@ -49,7 +50,8 @@
</div> </div>
</article> </article>
</section> </section>
<% if (my $last_remark_id = $last_remark->{'id'}) { =%> <% } =%>
<% if (keys %{$last_remark}) { =%>
<section class="pager"> <section class="pager">
<h3 class="pager__title">Last Remark</h3> <h3 class="pager__title">Last Remark</h3>
<article class="post"> <article class="post">
@ -57,8 +59,8 @@
<span> <span>
<%= $last_remark->{'date'} %> <%= $last_remark->{'date'} %>
</span> </span>
<%= link_to "#$last_remark_id", single_remark => <%= link_to "#$last_remark->{'id'}", single_remark =>
{remark_id => $last_remark_id}, (class => 'post__id') %> {remark_id => $last_remark->{'id'}}, (class => 'post__id') %>
</h4> </h4>
<h5 class="post__author"><%= $last_remark->{'author'} %></h5> <h5 class="post__author"><%= $last_remark->{'author'} %></h5>
<div class="post__body"> <div class="post__body">