From 2054de053e2600aaaa37c2f366688df3561b0206 Mon Sep 17 00:00:00 2001 From: swaggboi Date: Fri, 2 Sep 2022 18:11:23 -0400 Subject: [PATCH] Return last remark with Remark form --- PostText.pl | 8 ++++++-- README.md | 2 +- templates/list_page.html.ep | 3 ++- templates/thread_id.html.ep | 35 ++++++++++++++++++++++++----------- 4 files changed, 33 insertions(+), 15 deletions(-) diff --git a/PostText.pl b/PostText.pl index 25af5bb..7310a4a 100755 --- a/PostText.pl +++ b/PostText.pl @@ -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(); }; diff --git a/README.md b/README.md index 8c4c979..f2d8d0b 100644 --- a/README.md +++ b/README.md @@ -24,9 +24,9 @@ Run the tests locally (against development environment) ## TODOs -1. Return the last remark with remark form 1. Method names may need to be shortened, should use POD instead to describe their function +1. Single remark view ## Crazy future ideas diff --git a/templates/list_page.html.ep b/templates/list_page.html.ep index d3c495b..805a3da 100644 --- a/templates/list_page.html.ep +++ b/templates/list_page.html.ep @@ -5,7 +5,8 @@ <% for my $thread (@$threads) { =%>
- <%= link_to "#$thread->{'id'}", remark_page => {thread_id => $thread->{'id'}} %> + <%= link_to "#$thread->{'id'}", + remark_page => {thread_id => $thread->{'id'}} %>

<%= %$thread{'title'} %>

<%= %$thread{'date'} %>

diff --git a/templates/thread_id.html.ep b/templates/thread_id.html.ep index 164e7bf..d981a4c 100644 --- a/templates/thread_id.html.ep +++ b/templates/thread_id.html.ep @@ -1,17 +1,6 @@ % layout 'main'; % title 'New Remark';

<%= title %>

-
-
- - <%= link_to "#$thread->{'id'}", remark_page => {thread_id => $thread->{'id'}} %> - -

<%= %$thread{'title'} %>

-

<%= %$thread{'date'} %>

-
<%= %$thread{'author'} %>
-

<%= %$thread{'body'} %>

-
-
<%= label_for name => 'Author' %> @@ -34,3 +23,27 @@
<%= submit_button 'Post', class => 'post button' %>
+
+

Thread

+
+ + <%= link_to "#$thread->{'id'}", + remark_page => {thread_id => $thread->{'id'}} %> + +

<%= %$thread{'title'} %>

+

<%= %$thread{'date'} %>

+
<%= %$thread{'author'} %>
+

<%= %$thread{'body'} %>

+
+
+<% if (my $last_remark_id = $last_remark->{'id'}) { =%> +
+

Last Remark

+
+ #<%= $last_remark_id %> +

<%= $last_remark->{'date'} %>

+
<%= $last_remark->{'author'} %>
+

<%= $last_remark->{'body'} %>

+
+
+<% } =%>