2019-03-04 16:20:18 +00:00
|
|
|
defimpl Mobilizon.Service.Metadata, for: Mobilizon.Actors.Actor do
|
|
|
|
alias Phoenix.HTML.Tag
|
|
|
|
alias Mobilizon.Actors.Actor
|
2019-05-28 08:51:02 +00:00
|
|
|
alias MobilizonWeb.MediaProxy
|
2019-03-04 16:20:18 +00:00
|
|
|
|
|
|
|
def build_tags(%Actor{} = actor) do
|
2019-05-22 12:12:11 +00:00
|
|
|
tags = [
|
2019-03-04 16:20:18 +00:00
|
|
|
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: "twitter:card", content: "summary")
|
|
|
|
]
|
2019-05-22 12:12:11 +00:00
|
|
|
|
|
|
|
if is_nil(actor.avatar) do
|
|
|
|
tags
|
|
|
|
else
|
2019-05-28 08:51:02 +00:00
|
|
|
tags ++
|
|
|
|
[Tag.tag(:meta, property: "og:image", content: actor.avatar.url |> MediaProxy.url())]
|
2019-05-22 12:12:11 +00:00
|
|
|
end
|
2019-03-04 16:20:18 +00:00
|
|
|
end
|
|
|
|
end
|