From 0bea8118bafd474b3b0e8e9b10034d3ccaf9c058 Mon Sep 17 00:00:00 2001 From: swag Date: Sat, 8 Oct 2022 22:39:54 -0400 Subject: [PATCH] Use url_for()->fragment() to make certain links jump to appropriate sections --- lib/PostText/Controller/Remark.pm | 10 ++++++---- templates/thread/by_id.html.ep | 2 +- templates/thread/by_page.html.ep | 3 ++- 3 files changed, 9 insertions(+), 6 deletions(-) diff --git a/lib/PostText/Controller/Remark.pm b/lib/PostText/Controller/Remark.pm index d06293e..f9547d5 100644 --- a/lib/PostText/Controller/Remark.pm +++ b/lib/PostText/Controller/Remark.pm @@ -29,6 +29,11 @@ sub create($self) { $self->stash(status => 400) } else { + my $thread_url = $self->url_for(single_thread => { + thread_id => $thread_id, + thread_page => $self->remark->last_page_for($thread_id) + })->fragment('remarks'); + $self->remark->create( $thread_id, $remark_author, @@ -39,10 +44,7 @@ sub create($self) { $self->thread->bump($thread_id); - return $self->redirect_to(single_thread => { - thread_id => $thread_id, - thread_page => $self->remark->last_page_for($thread_id) - }); + return $self->redirect_to($thread_url); } } diff --git a/templates/thread/by_id.html.ep b/templates/thread/by_id.html.ep index 5755b39..567c2f8 100644 --- a/templates/thread/by_id.html.ep +++ b/templates/thread/by_id.html.ep @@ -13,7 +13,7 @@ <%= link_to Remark => post_remark => {thread_id => $thread->{'id'}} %> <% if (my $first_remark = $remarks->[0]) { =%> -
+

Remarks

<% for my $remark (@{$remarks}) { =%>
diff --git a/templates/thread/by_page.html.ep b/templates/thread/by_page.html.ep index 667cee4..b5e007d 100644 --- a/templates/thread/by_page.html.ep +++ b/templates/thread/by_page.html.ep @@ -14,7 +14,8 @@

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