mirror of
https://github.com/philomena-dev/philomena.git
synced 2024-11-24 04:27:59 +01:00
fix 'go to post' links
This commit is contained in:
parent
14d693e2c1
commit
e313460917
4 changed files with 14 additions and 4 deletions
|
@ -7,7 +7,7 @@ defmodule PhilomenaWeb.TopicController do
|
|||
|
||||
plug :load_and_authorize_resource, model: Forum, id_name: "forum_id", id_field: "short_name", persisted: true
|
||||
|
||||
def show(conn, %{"id" => slug}) do
|
||||
def show(conn, %{"id" => slug} = params) do
|
||||
forum = conn.assigns.forum
|
||||
topic =
|
||||
Topic
|
||||
|
@ -18,6 +18,16 @@ defmodule PhilomenaWeb.TopicController do
|
|||
conn = conn |> assign(:topic, topic)
|
||||
%{page_number: page} = conn.assigns.pagination
|
||||
|
||||
page =
|
||||
with {post_id, _extra} <- Integer.parse(params["post_id"] || ""),
|
||||
[post] <- Post |> where(id: ^post_id) |> Repo.all()
|
||||
do
|
||||
div(post.topic_position, 25) + 1
|
||||
else
|
||||
_ ->
|
||||
page
|
||||
end
|
||||
|
||||
posts =
|
||||
Post
|
||||
|> where(topic_id: ^conn.assigns.topic.id)
|
||||
|
|
|
@ -26,7 +26,7 @@ h1 Discussion Forums
|
|||
strong
|
||||
=> link(forum.last_post.topic.title, to: Routes.forum_topic_path(@conn, :show, forum, forum.last_post.topic))
|
||||
br
|
||||
=> link("Go to post", to: Routes.forum_topic_path(@conn, :show, forum, forum.last_post.topic, post_id: forum.last_post.id))
|
||||
=> link("Go to post", to: Routes.forum_topic_path(@conn, :show, forum, forum.last_post.topic, post_id: forum.last_post.id) <> "#post_#{forum.last_post.id}")
|
||||
' by
|
||||
=> render PhilomenaWeb.UserAttributionView, "_anon_user.html", object: forum.last_post
|
||||
br
|
||||
|
|
|
@ -46,7 +46,7 @@ h1 = @forum.name
|
|||
td.table--communication-list__stats.hide-mobile = topic.post_count
|
||||
td.table--communication-list__last-post
|
||||
= if topic.last_post do
|
||||
=> link("Go to post", to: Routes.forum_topic_path(@conn, :show, @forum, topic, post_id: topic.last_post) <> "post_#{topic.last_post.id}")
|
||||
=> link("Go to post", to: Routes.forum_topic_path(@conn, :show, @forum, topic, post_id: topic.last_post) <> "#post_#{topic.last_post.id}")
|
||||
' by
|
||||
= render PhilomenaWeb.UserAttributionView, "_anon_user.html", object: topic.last_post
|
||||
br
|
||||
|
|
|
@ -13,7 +13,7 @@ div
|
|||
/ | because:
|
||||
/ =<> post.edit_reason
|
||||
div
|
||||
- link_path = Routes.forum_topic_path(@conn, :show, @post.topic.forum, @post.topic, post_id: @post.id) <> "post_#{@post.id}"
|
||||
- link_path = Routes.forum_topic_path(@conn, :show, @post.topic.forum, @post.topic, post_id: @post.id) <> "#post_#{@post.id}"
|
||||
a.communication__interaction title="Link to post" href=link_path
|
||||
i.fa.fa-link>
|
||||
' Link
|
||||
|
|
Loading…
Reference in a new issue