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'} %>

+
+
+<% } =%>