@@ -3,7 +3,7 @@ defimpl Mobilizon.Service.Metadata, for: Mobilizon.Actors.Actor do
|
||||
alias Mobilizon.Actors.Actor
|
||||
alias Mobilizon.Web.MediaProxy
|
||||
|
||||
def build_tags(%Actor{} = actor) do
|
||||
def build_tags(%Actor{} = actor, _locale \\ "en") do
|
||||
tags = [
|
||||
Tag.tag(:meta, property: "og:title", content: Actor.display_name_and_username(actor)),
|
||||
Tag.tag(:meta, property: "og:url", content: actor.url),
|
||||
|
||||
@@ -2,7 +2,7 @@ defimpl Mobilizon.Service.Metadata, for: Mobilizon.Conversations.Comment do
|
||||
alias Phoenix.HTML.Tag
|
||||
alias Mobilizon.Conversations.Comment
|
||||
|
||||
def build_tags(%Comment{} = comment) do
|
||||
def build_tags(%Comment{} = comment, _locale \\ "en") do
|
||||
[
|
||||
Tag.tag(:meta, property: "og:title", content: comment.actor.preferred_username),
|
||||
Tag.tag(:meta, property: "og:url", content: comment.url),
|
||||
|
||||
@@ -4,9 +4,10 @@ defimpl Mobilizon.Service.Metadata, for: Mobilizon.Events.Event do
|
||||
alias Mobilizon.Events.Event
|
||||
alias Mobilizon.Web.JsonLD.ObjectView
|
||||
alias Mobilizon.Web.MediaProxy
|
||||
import Mobilizon.Web.Gettext
|
||||
|
||||
def build_tags(%Event{} = event) do
|
||||
event = Map.put(event, :description, process_description(event.description))
|
||||
def build_tags(%Event{} = event, locale \\ "en") do
|
||||
event = Map.put(event, :description, process_description(event.description, locale))
|
||||
|
||||
tags = [
|
||||
Tag.content_tag(:title, event.title <> " - Mobilizon"),
|
||||
@@ -39,7 +40,14 @@ defimpl Mobilizon.Service.Metadata, for: Mobilizon.Events.Event do
|
||||
]
|
||||
end
|
||||
|
||||
defp process_description(description) do
|
||||
defp process_description(nil, locale), do: process_description("", locale)
|
||||
|
||||
defp process_description("", locale) do
|
||||
Gettext.put_locale(locale)
|
||||
gettext("The event organizer didn't add any description.")
|
||||
end
|
||||
|
||||
defp process_description(description, _locale) do
|
||||
description
|
||||
|> HtmlSanitizeEx.strip_tags()
|
||||
|> String.slice(0..200)
|
||||
|
||||
@@ -3,5 +3,5 @@ defprotocol Mobilizon.Service.Metadata do
|
||||
Build tags
|
||||
"""
|
||||
|
||||
def build_tags(entity)
|
||||
def build_tags(entity, locale \\ "en")
|
||||
end
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
defimpl Mobilizon.Service.Metadata, for: Mobilizon.Tombstone do
|
||||
alias Mobilizon.Tombstone
|
||||
|
||||
def build_tags(%Tombstone{}) do
|
||||
def build_tags(%Tombstone{}, _locale \\ "en") do
|
||||
[]
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user