Add basic metadata to opengraph preview

Also refactor datetime & address utils

Signed-off-by: Thomas Citharel <tcit@tcit.fr>
This commit is contained in:
Thomas Citharel
2021-06-22 13:15:21 +02:00
parent eee2d63309
commit 8caf1e302b
9 changed files with 376 additions and 53 deletions

View File

@@ -3,6 +3,7 @@ defmodule Mobilizon.Service.Metadata.Utils do
Tools to convert tags to string.
"""
alias Mobilizon.Service.{Address, DateTime}
alias Mobilizon.Service.Formatter.HTML, as: HTMLFormatter
alias Phoenix.HTML
import Mobilizon.Web.Gettext
@@ -52,6 +53,9 @@ defmodule Mobilizon.Service.Metadata.Utils do
gettext("The event organizer didn't add any description.")
end
defdelegate datetime_to_string(datetime, locale \\ "en", format \\ :medium), to: DateTime
defdelegate render_address(address), to: Address
defp maybe_slice(description, limit) do
if String.length(description) > limit do
description