Return last remark with Remark form

This commit is contained in:
swaggboi 2022-09-02 18:11:23 -04:00
parent 0e315c296b
commit 2054de053e
4 changed files with 33 additions and 15 deletions

View File

@ -128,9 +128,13 @@ group {
} }
} }
my $thread = $c->thread->get_thread_by_id($thread_id); my $thread = $c->thread->get_thread_by_id($thread_id);
my $last_remark = $c->remark->last_remark($thread_id);
$c->stash(thread => $thread); $c->stash(
thread => $thread,
last_remark => $last_remark
);
return $c->render(); return $c->render();
}; };

View File

@ -24,9 +24,9 @@ Run the tests locally (against development environment)
## TODOs ## TODOs
1. Return the last remark with remark form
1. Method names may need to be shortened, should use POD instead to 1. Method names may need to be shortened, should use POD instead to
describe their function describe their function
1. Single remark view
## Crazy future ideas ## Crazy future ideas

View File

@ -5,7 +5,8 @@
<% for my $thread (@$threads) { =%> <% for my $thread (@$threads) { =%>
<article class="thread"> <article class="thread">
<span class="id"> <span class="id">
<%= link_to "#$thread->{'id'}", remark_page => {thread_id => $thread->{'id'}} %> <%= link_to "#$thread->{'id'}",
remark_page => {thread_id => $thread->{'id'}} %>
</span> </span>
<h3 class="title"><%= %$thread{'title'} %></h3> <h3 class="title"><%= %$thread{'title'} %></h3>
<h4 class="date"><%= %$thread{'date'} %></h4> <h4 class="date"><%= %$thread{'date'} %></h4>

View File

@ -1,17 +1,6 @@
% layout 'main'; % layout 'main';
% title 'New Remark'; % title 'New Remark';
<h2><%= title %></h2> <h2><%= title %></h2>
<div class="threads">
<article class="thread">
<span class="id">
<%= link_to "#$thread->{'id'}", remark_page => {thread_id => $thread->{'id'}} %>
</span>
<h3 class="title"><%= %$thread{'title'} %></h3>
<h4 class="date"><%= %$thread{'date'} %></h4>
<h5 class="author"><%= %$thread{'author'} %></h5>
<p class="body"><%= %$thread{'body'} %></p>
</article>
</div>
<form method="post"> <form method="post">
<div class="name field"> <div class="name field">
<%= label_for name => 'Author' %> <%= label_for name => 'Author' %>
@ -34,3 +23,27 @@
</div> </div>
<%= submit_button 'Post', class => 'post button' %> <%= submit_button 'Post', class => 'post button' %>
</form> </form>
<div class="threads">
<h3>Thread</h3>
<article class="thread">
<span class="id">
<%= link_to "#$thread->{'id'}",
remark_page => {thread_id => $thread->{'id'}} %>
</span>
<h3 class="title"><%= %$thread{'title'} %></h3>
<h4 class="date"><%= %$thread{'date'} %></h4>
<h5 class="author"><%= %$thread{'author'} %></h5>
<p class="body"><%= %$thread{'body'} %></p>
</article>
</div>
<% if (my $last_remark_id = $last_remark->{'id'}) { =%>
<div class="remarks">
<h3>Last Remark</h3>
<article class="remark">
<span class="id">#<%= $last_remark_id %></span>
<h4 class="date"><%= $last_remark->{'date'} %></h4>
<h5 class="author"><%= $last_remark->{'author'} %></h5>
<p class="body"><%= $last_remark->{'body'} %></p>
</article>
</div>
<% } =%>