1
0
Fork 0
mirror of https://framagit.org/framasoft/mobilizon.git synced 2024-12-23 08:22:50 +00:00
mobilizon/lib/service/metadata/actor.ex
Thomas Citharel 66e67aa816
Redirect properly to correct endpoint depending on content-type
Signed-off-by: Thomas Citharel <tcit@tcit.fr>
2019-03-04 17:20:18 +01:00

25 lines
915 B
Elixir

defimpl Mobilizon.Service.Metadata, for: Mobilizon.Actors.Actor do
alias Phoenix.HTML
alias Phoenix.HTML.Tag
alias Mobilizon.Actors.Actor
require Logger
def build_tags(%Actor{} = actor) do
actor
|> do_build_tags()
|> Enum.map(&HTML.safe_to_string/1)
|> Enum.reduce("", fn tag, acc -> acc <> tag end)
end
defp do_build_tags(%Actor{} = actor) do
[
Tag.tag(:meta, property: "og:title", content: Actor.display_name_and_username(actor)),
Tag.tag(:meta, property: "og:url", content: actor.url),
Tag.tag(:meta, property: "og:description", content: actor.summary),
Tag.tag(:meta, property: "og:type", content: "profile"),
Tag.tag(:meta, property: "profile:username", content: actor.preferred_username),
Tag.tag(:meta, property: "og:image", content: actor.avatar_url),
Tag.tag(:meta, property: "twitter:card", content: "summary")
]
end
end