2020-01-26 21:36:50 +01:00
|
|
|
defmodule Mobilizon.Web.EmailView do
|
2022-04-05 12:16:22 +02:00
|
|
|
use Phoenix.View,
|
|
|
|
root: "lib/web/templates",
|
|
|
|
pattern: "**/*",
|
|
|
|
namespace: Mobilizon.Web
|
2019-09-30 18:18:04 +02:00
|
|
|
|
2022-10-31 13:00:45 +01:00
|
|
|
alias Mobilizon.Actors.Actor
|
2021-10-15 15:58:49 +02:00
|
|
|
alias Mobilizon.Service.Address
|
2021-06-22 13:15:21 +02:00
|
|
|
alias Mobilizon.Service.DateTime, as: DateTimeRenderer
|
2022-04-05 12:16:22 +02:00
|
|
|
alias Mobilizon.Web.Router.Helpers, as: Routes
|
2020-01-26 21:36:50 +01:00
|
|
|
import Mobilizon.Web.Gettext
|
2021-10-15 15:58:49 +02:00
|
|
|
import Mobilizon.Service.Metadata.Utils, only: [process_description: 1]
|
2022-10-31 13:00:45 +01:00
|
|
|
import Phoenix.HTML, only: [raw: 1, html_escape: 1, safe_to_string: 1]
|
2019-10-01 13:08:09 +02:00
|
|
|
|
2021-06-22 13:15:21 +02:00
|
|
|
defdelegate datetime_to_string(datetime, locale \\ "en", format \\ :medium),
|
|
|
|
to: DateTimeRenderer
|
2020-02-18 08:57:00 +01:00
|
|
|
|
2021-06-22 13:15:21 +02:00
|
|
|
defdelegate datetime_to_time_string(datetime, locale \\ "en", format \\ :short),
|
|
|
|
to: DateTimeRenderer
|
2020-11-16 18:28:52 +01:00
|
|
|
|
2021-10-15 15:58:49 +02:00
|
|
|
defdelegate datetime_to_date_string(datetime, locale \\ "en", format \\ :short),
|
|
|
|
to: DateTimeRenderer
|
|
|
|
|
2021-06-22 13:15:21 +02:00
|
|
|
defdelegate datetime_tz_convert(datetime, timezone), to: DateTimeRenderer
|
|
|
|
defdelegate datetime_relative(datetime, locale \\ "en"), to: DateTimeRenderer
|
2021-10-15 15:58:49 +02:00
|
|
|
defdelegate render_address(address), to: Address
|
|
|
|
defdelegate is_same_day?(one, two), to: DateTimeRenderer
|
2022-10-31 13:00:45 +01:00
|
|
|
defdelegate display_name_and_username(actor), to: Actor
|
|
|
|
defdelegate display_name(actor), to: Actor
|
|
|
|
defdelegate preferred_username_and_domain(actor), to: Actor
|
|
|
|
|
|
|
|
@spec escape_html(String.t()) :: String.t()
|
|
|
|
def escape_html(string) do
|
|
|
|
string
|
|
|
|
|> html_escape()
|
|
|
|
|> safe_to_string()
|
|
|
|
end
|
|
|
|
|
|
|
|
def escaped_display_name_and_username(actor) do
|
|
|
|
actor
|
|
|
|
|> Actor.display_name_and_username()
|
|
|
|
|> escape_html()
|
|
|
|
end
|
2018-10-11 17:37:39 +02:00
|
|
|
end
|