Use url_for()->fragment() to make certain links jump to appropriate sections

This commit is contained in:
swag 2022-10-08 22:39:54 -04:00
parent 7e05af4c4b
commit 0bea8118ba
3 changed files with 9 additions and 6 deletions

View File

@ -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);
}
}

View File

@ -13,7 +13,7 @@
<%= link_to Remark => post_remark => {thread_id => $thread->{'id'}} %>
</nav>
<% if (my $first_remark = $remarks->[0]) { =%>
<div class="remarks">
<div class="remarks" id="remarks">
<h3>Remarks</h3>
<% for my $remark (@{$remarks}) { =%>
<article class="remark">

View File

@ -14,7 +14,8 @@
<p class="body"><%= truncate_text $thread->{'body'} %></p>
<nav class="remarks">
<%= link_to Remark => post_remark => {thread_id => $thread->{'id'}} %>
<%= link_to single_thread => {thread_id => $thread->{'id'}}, begin %>
<%= link_to url_for(single_thread => {thread_id => $thread->{'id'}})
->fragment('remarks'), begin %>
(<%= $thread->{'remark_count'} %> remarks)
<% end %>
</nav>