philomena/lib/philomena_web/views/post_view.ex

20 lines
416 B
Elixir
Raw Normal View History

2019-10-06 23:31:48 +02:00
defmodule PhilomenaWeb.PostView do
2019-11-27 02:45:57 +01:00
alias Philomena.Attribution
2019-10-06 23:31:48 +02:00
use PhilomenaWeb, :view
2019-11-27 02:45:57 +01:00
def markdown_safe_author(object) do
Philomena.Markdown.escape("@" <> author_name(object))
2019-11-27 02:45:57 +01:00
end
defp author_name(object) do
2019-11-27 05:52:49 +01:00
cond do
Attribution.anonymous?(object) || !object.user ->
PhilomenaWeb.UserAttributionView.anonymous_name(object)
true ->
object.user.name
2019-11-27 02:45:57 +01:00
end
end
2019-10-06 23:31:48 +02:00
end