From bd4fad3c586b6a7587ecbc521026cf8eb9114e6c Mon Sep 17 00:00:00 2001 From: Thomas Citharel Date: Fri, 15 Oct 2021 15:58:49 +0200 Subject: [PATCH] Improve emails Signed-off-by: Thomas Citharel --- .../email/date/event_tz_date.html.heex | 8 ++ .../email/date/event_tz_date.text.eex | 1 + .../email/date/event_tz_date_range.html.heex | 14 +++ lib/web/templates/email/email.html.heex | 6 +- .../templates/email/event_updated.html.heex | 18 +--- .../templates/email/event_updated.text.eex | 11 +-- .../email/notification_each_week.html.heex | 22 ++--- .../email/notification_each_week.text.eex | 6 +- .../email/on_day_notification.html.heex | 14 +-- .../email/on_day_notification.text.eex | 7 +- .../participation/card/_metadata.html.heex | 91 +++++++++++++++++++ .../participation/card/_picture.html.heex | 12 +++ .../email/participation/card/_title.html.heex | 33 +++++++ .../email/participation/event_card.html.heex | 24 +++++ lib/web/views/email_view.ex | 7 ++ 15 files changed, 211 insertions(+), 63 deletions(-) create mode 100644 lib/web/templates/email/date/event_tz_date.html.heex create mode 100644 lib/web/templates/email/date/event_tz_date.text.eex create mode 100644 lib/web/templates/email/date/event_tz_date_range.html.heex create mode 100644 lib/web/templates/email/participation/card/_metadata.html.heex create mode 100644 lib/web/templates/email/participation/card/_picture.html.heex create mode 100644 lib/web/templates/email/participation/card/_title.html.heex create mode 100644 lib/web/templates/email/participation/event_card.html.heex diff --git a/lib/web/templates/email/date/event_tz_date.html.heex b/lib/web/templates/email/date/event_tz_date.html.heex new file mode 100644 index 000000000..95970b390 --- /dev/null +++ b/lib/web/templates/email/date/event_tz_date.html.heex @@ -0,0 +1,8 @@ +<%= if @event.options.timezone == nil do %> + <%= @date |> datetime_tz_convert(@timezone) |> datetime_to_string(@locale , :short) %> +<% else %> + <%= @date |> datetime_tz_convert(@event.options.timezone) |> datetime_to_string(@locale, :short) %>
+ <%= if @event.options.timezone != @timezone do %> + <%= gettext "🌐 %{timezone} %{offset}", timezone: @event.options.timezone, offset: @date |> datetime_tz_convert(@event.options.timezone) |> Cldr.DateTime.Formatter.zone_gmt() %> + <% end %> +<% end %> diff --git a/lib/web/templates/email/date/event_tz_date.text.eex b/lib/web/templates/email/date/event_tz_date.text.eex new file mode 100644 index 000000000..9129eb8e3 --- /dev/null +++ b/lib/web/templates/email/date/event_tz_date.text.eex @@ -0,0 +1 @@ +<%= if @event.options.timezone == nil do %><%= @date |> datetime_tz_convert(@timezone) |> datetime_to_string(@locale) %><% else %><%= if @event.options.timezone != @timezone do %><%= gettext "%{date_time} (%{timezone} %{offset})", date_time: @date |> datetime_tz_convert(@event.options.timezone) |> datetime_to_string(@locale), timezone: @event.options.timezone, offset: @date |> datetime_tz_convert(@event.options.timezone) |> Cldr.DateTime.Formatter.zone_gmt() %><% else %><%= gettext "%{date_time} (in your timezone %{timezone} %{offset})", date_time: @date |> datetime_tz_convert(@event.options.timezone) |> datetime_to_string(@locale), timezone: @event.options.timezone, offset: @date |> datetime_tz_convert(@event.options.timezone) |> Cldr.DateTime.Formatter.zone_gmt() %><% end %><% end %> diff --git a/lib/web/templates/email/date/event_tz_date_range.html.heex b/lib/web/templates/email/date/event_tz_date_range.html.heex new file mode 100644 index 000000000..d76e9abff --- /dev/null +++ b/lib/web/templates/email/date/event_tz_date_range.html.heex @@ -0,0 +1,14 @@ +<%= cond do %> + <%= @end_date == nil -> %> + <%= render("date/event_tz_date.html", date: @start_date, event: @event, timezone: @timezone, locale: @locale) %> + <% is_same_day?(@start_date, @end_date) -> %> + <%= gettext "On %{date} from %{start_time} to %{end_time}", date: datetime_to_date_string(@start_date, @locale), start_time: datetime_to_time_string(@start_date, @locale), end_time: datetime_to_time_string(@end_date, @locale) %>
+ <%= if @event.options.timezone != @timezone do %> + <%= gettext "🌐 %{timezone} %{offset}", timezone: @event.options.timezone, offset: Cldr.DateTime.Formatter.zone_gmt(@start_date) %> + <% end %> + <% true -> %> + <%= gettext "From the %{start} to the %{end}", start: datetime_to_string(@start_date, @locale, :short), end: datetime_to_string(@end_date, @locale, :short) %>
+ <%= if @event.options.timezone != @timezone do %> + <%= gettext "🌐 %{timezone} %{offset}", timezone: @event.options.timezone, offset: Cldr.DateTime.Formatter.zone_gmt(@start_date) %> + <% end %> +<% end %> diff --git a/lib/web/templates/email/email.html.heex b/lib/web/templates/email/email.html.heex index e2248ca8d..675908d73 100644 --- a/lib/web/templates/email/email.html.heex +++ b/lib/web/templates/email/email.html.heex @@ -42,7 +42,9 @@ div[style*="margin: 16px 0;"] { margin: 0 !important; } <%= if @jsonLDMetadata do %> - + <% end %> @@ -59,7 +61,7 @@ - {"#{ + {"#{ diff --git a/lib/web/templates/email/event_updated.html.heex b/lib/web/templates/email/event_updated.html.heex index db700b522..ef2cf54e1 100644 --- a/lib/web/templates/email/event_updated.html.heex +++ b/lib/web/templates/email/event_updated.html.heex @@ -74,21 +74,7 @@ <%= gettext "Start" %> - <%= if @event.options.timezone == nil do %> - <%= @event.begins_on |> datetime_tz_convert(@timezone) |> datetime_to_string(@locale) %> - <% else %> - - <%= if @event.options.timezone != @timezone do %> - <%# Event with different timezone than user %> - <%= @event.begins_on |> datetime_tz_convert(@event.options.timezone) |> datetime_to_string(@locale) %>
- <%= gettext "🌐 %{timezone} %{offset}", timezone: @event.options.timezone, offset: @event.begins_on |> datetime_tz_convert(@event.options.timezone) |> Cldr.DateTime.Formatter.zone_gmt() %> - <% else %> - <%# Event with same timezone than user %> - <%= @event.begins_on |> datetime_tz_convert(@event.options.timezone) |> datetime_to_string(@locale) %>
- <%= gettext "In your timezone (%{timezone} %{offset})", timezone: @event.options.timezone, offset: @event.begins_on |> datetime_tz_convert(@event.options.timezone) |> Cldr.DateTime.Formatter.zone_gmt() %> - <% end %> -
- <% end %> + <%= render("date/event_tz_date.html", event: @event, date: @event.begins_on, timezone: @timezone, locale: @locale) %> <% end %> @@ -98,7 +84,7 @@ <%= gettext "End" %> - <%= @event.ends_on |> datetime_tz_convert(@timezone) |> datetime_to_string(@locale) %> + <%= render("date/event_tz_date.html", event: @event, date: @event.ends_on, timezone: @timezone, locale: @locale) %> <% end %> diff --git a/lib/web/templates/email/event_updated.text.eex b/lib/web/templates/email/event_updated.text.eex index 26184e592..cf0733f35 100644 --- a/lib/web/templates/email/event_updated.text.eex +++ b/lib/web/templates/email/event_updated.text.eex @@ -14,16 +14,9 @@ <%= if MapSet.member?(@changes, :title) do %> <%= gettext "New title: %{title}", title: @event.title %> <% end %> -<%= if MapSet.member?(@changes, :begins_on) do %><%= cond do %><% @event.options.timezone != nil and @event.options.timezone != @timezone -> %><%# Event with different timezone than user %> - <%= gettext "Start %{begins_on} (🌐 %{timezone} %{offset})", begins_on: @event.begins_on |> datetime_tz_convert(@event.options.timezone) |> datetime_to_string(@locale), timezone: @event.options.timezone, offset: @event.begins_on |> datetime_tz_convert(@event.options.timezone) |> Cldr.DateTime.Formatter.zone_gmt() %> -<%# Event with same timezone than user %><% @event.options.timezone != nil and @event.options.timezone == @timezone -> %> - <%= gettext "Start %{begins_on} (your timezone)", begins_on: @event.begins_on |> datetime_tz_convert(@event.options.timezone) |> datetime_to_string(@locale) %> -<%# Event with no timezone (show in user timezone) %><% true -> %> - <%= gettext "Start %{begins_on}", begins_on: @event.begins_on |> datetime_tz_convert(@timezone) |> datetime_to_string(@locale) %> +<%= if MapSet.member?(@changes, :begins_on) do %><%= render("date/event_tz_date.text", event: @event, date: @event.begins_on, timezone: @timezone, locale: @locale) %> <% end %> -<% end %> -<%= if MapSet.member?(@changes, :ends_on) && !is_nil(@event.ends_on) do %> - <%= gettext "End %{ends_on}", ends_on: @event.ends_on |> datetime_tz_convert(@timezone) |> datetime_to_string(@locale) %> +<%= if MapSet.member?(@changes, :ends_on) && !is_nil(@event.ends_on) do %><%= render("date/event_tz_date.text", event: @event, date: @event.ends_on, timezone: @timezone, locale: @locale) %> <% end %> <%= gettext "Visit the updated event page: %{link}", link: Routes.page_url(Mobilizon.Web.Endpoint, :event, @event.uuid) %> <%= ngettext "Would you wish to cancel your attendance, visit the event page through the link above and click the « Attending » button.", "Would you wish to cancel your attendance to one or several events, visit the event pages through the links above and click the « Attending » button.", 1 %> diff --git a/lib/web/templates/email/notification_each_week.html.heex b/lib/web/templates/email/notification_each_week.html.heex index fcb41a7ab..d21b3e082 100644 --- a/lib/web/templates/email/notification_each_week.html.heex +++ b/lib/web/templates/email/notification_each_week.html.heex @@ -10,7 +10,7 @@

- <%= gettext "What's up this week?" %> + <%= gettext "On the agenda this week" %>

@@ -40,27 +40,17 @@ - + <%= if @total > 1 do %> -