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 %>
-
+
<%= for participation <- @participations do %>
- -
-
- <%= participation.event.begins_on |> datetime_tz_convert(@timezone) |> datetime_to_string(@locale) %>
-
-
- <%= participation.event.title %>
-
+
-
+ <%= render("participation/event_card.html", event: participation.event, timezone: @timezone, locale: @locale) %>
<% end %>
<% else %>
-
- <%= @participation.event.begins_on |> datetime_tz_convert(@timezone) |> datetime_to_string(@locale) %>
-
-
- <%= @participation.event.title %>
-
+ <%= render("participation/event_card.html", event: @participation.event, timezone: @timezone, locale: @locale) %>
<% end %>
|
diff --git a/lib/web/templates/email/notification_each_week.text.eex b/lib/web/templates/email/notification_each_week.text.eex
index f0f2fc303..2ea9c6df6 100644
--- a/lib/web/templates/email/notification_each_week.text.eex
+++ b/lib/web/templates/email/notification_each_week.text.eex
@@ -1,11 +1,11 @@
-<%= gettext "What's up this week?" %>
+<%= gettext "On the agenda this week" %>
==
<%= ngettext "You have one event this week:", "You have %{total} events this week:", @total, total: @total %>
<%= if @total > 1 do %>
<%= for participation <- @participations do %>
- - <%= participation.event.begins_on |> datetime_tz_convert(@timezone) |> datetime_to_string(@locale) %> - <%= participation.event.title %> <%= Routes.page_url(Mobilizon.Web.Endpoint, :event, participation.event.uuid) %>
+ - <%= render("date/event_tz_date.text", event: participation.event, date: participation.event.begins_on, timezone: @timezone, locale: @locale) %> - <%= participation.event.title %> <%= Routes.page_url(Mobilizon.Web.Endpoint, :event, participation.event.uuid) %>
<% end %>
<% else %>
- <%= @participation.event.begins_on |> datetime_tz_convert(@timezone) |> datetime_to_string(@locale) %> - <%= @participation.event.title %> <%= Routes.page_url(Mobilizon.Web.Endpoint, :event, @participation.event.uuid) %>
+ <%= render("date/event_tz_date.text", event: @participation.event, date: @participation.event.begins_on, timezone: @timezone, locale: @locale) %> - <%= @participation.event.title %> <%= Routes.page_url(Mobilizon.Web.Endpoint, :event, @participation.event.uuid) %>
<% end %>
<%= 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.", @total %>
diff --git a/lib/web/templates/email/on_day_notification.html.heex b/lib/web/templates/email/on_day_notification.html.heex
index 0ace1ecb7..70bf7daee 100644
--- a/lib/web/templates/email/on_day_notification.html.heex
+++ b/lib/web/templates/email/on_day_notification.html.heex
@@ -45,22 +45,12 @@
<%= for participation <- @participations do %>
-
-
- <%= participation.event.begins_on |> DateTime.shift_zone!(@timezone) |> datetime_to_time_string(@locale) %>
-
-
- <%= participation.event.title %>
-
+ <%= render("participation/event_card.html", event: participation.event, timezone: @timezone, locale: @locale) %>
<% end %>
<% else %>
-
- <%= @participation.event.begins_on |> DateTime.shift_zone!(@timezone) |> datetime_to_time_string(@locale) %>
-
-
- <%= @participation.event.title %>
-
+ <%= render("participation/event_card.html", event: @participation.event, timezone: @timezone, locale: @locale) %>
<% end %>
diff --git a/lib/web/templates/email/on_day_notification.text.eex b/lib/web/templates/email/on_day_notification.text.eex
index b902f2646..0747c291f 100644
--- a/lib/web/templates/email/on_day_notification.text.eex
+++ b/lib/web/templates/email/on_day_notification.text.eex
@@ -1,14 +1,11 @@
<%= gettext "What's up today?" %>
==
-
<%= ngettext "You have one event today:", "You have %{total} events today:", @total, total: @total %>
-
<%= if @total > 1 do %>
<%= for participation <- @participations do %>
- - <%= participation.event.begins_on |> DateTime.shift_zone!(@timezone) |> datetime_to_time_string(@locale) %> - <%= participation.event.title %> <%= Routes.page_url(Mobilizon.Web.Endpoint, :event, participation.event.uuid) %>
+ - <%= render("date/event_tz_date.text", event: participation.event, date: participation.event.begins_on, timezone: @timezone, locale: @locale) %> - <%= participation.event.title %> <%= Routes.page_url(Mobilizon.Web.Endpoint, :event, participation.event.uuid) %>
<% end %>
<% else %>
- <%= DateTime.shift_zone!(@participation.event.begins_on, @timezone) |> datetime_to_time_string(@locale) %> - <%= @participation.event.title %> <%= Routes.page_url(Mobilizon.Web.Endpoint, :event, @participation.event.uuid) %>
+ <%= render("date/event_tz_date.text", event: @participation.event, date: @participation.event.begins_on, timezone: @timezone, locale: @locale) %> - <%= @participation.event.title %> <%= Routes.page_url(Mobilizon.Web.Endpoint, :event, @participation.event.uuid) %>
<% end %>
-
<%= 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.", @total %>
diff --git a/lib/web/templates/email/participation/card/_metadata.html.heex b/lib/web/templates/email/participation/card/_metadata.html.heex
new file mode 100644
index 000000000..a031d468b
--- /dev/null
+++ b/lib/web/templates/email/participation/card/_metadata.html.heex
@@ -0,0 +1,91 @@
+
+
+
+
+
+
+ |
+
+
+
+
+
+
+
+
+
+
+
+
+
+ |
+
+
+ <%= render("date/event_tz_date_range.html", event: @event, start_date: datetime_tz_convert(@event.begins_on, @event.options.timezone), end_date: datetime_tz_convert(@event.ends_on, @event.options.timezone), timezone: @timezone, locale: @locale) %>
+
+ |
+
+
+ <%= if @event.physical_address do %>
+
+
+
+
+ |
+
+
+ <%= render_address(@event.physical_address) %>
+
+ |
+
+
+ <% end %>
+ <%= if @event.options.is_online do %>
+
+
+
+ |
+
+
+ <%= gettext "Online event" %>
+
+ |
+
+ <% end %>
+
+
+
+
+
+ |
+
+
+
+
+
+
+
+ |
+
+
+
diff --git a/lib/web/templates/email/participation/card/_picture.html.heex b/lib/web/templates/email/participation/card/_picture.html.heex
new file mode 100644
index 000000000..81fa88104
--- /dev/null
+++ b/lib/web/templates/email/participation/card/_picture.html.heex
@@ -0,0 +1,12 @@
+
diff --git a/lib/web/templates/email/participation/card/_title.html.heex b/lib/web/templates/email/participation/card/_title.html.heex
new file mode 100644
index 000000000..a1d3cbc7f
--- /dev/null
+++ b/lib/web/templates/email/participation/card/_title.html.heex
@@ -0,0 +1,33 @@
+
+
+
+
+
+ <%= cond do %>
+ <% @event.attributed_to != nil and @event.attributed_to.avatar != nil && @event.attributed_to.avatar.url != nil -> %>
+
+ <% @event.organizer_actor.avatar != nil and @event.organizer_actor.avatar.url != nil -> %>
+
+ <% true -> %>
+ <% end %>
+
+
+ |
+
+
+
diff --git a/lib/web/templates/email/participation/event_card.html.heex b/lib/web/templates/email/participation/event_card.html.heex
new file mode 100644
index 000000000..f29110548
--- /dev/null
+++ b/lib/web/templates/email/participation/event_card.html.heex
@@ -0,0 +1,24 @@
+<%= if @event.picture do %>
+
+ <%= render("participation/card/_picture.html", event: @event) %>
+
+<% end %>
+<%= render("participation/card/_title.html", event: @event) %>
+<%= render("participation/card/_metadata.html", event: @event, timezone: @timezone, locale: @locale) %>
+<%= if @event.description do %>
+
+
+ <%= gettext("Details") %>
+
+
+ <%= process_description(@event.description) %>
+
+ <%= if String.length(@event.description) > 200 do %>
+
+
+ <%= gettext("Read more") %>
+
+
+ <% end %>
+
+<% end %>
diff --git a/lib/web/views/email_view.ex b/lib/web/views/email_view.ex
index fda7b4c51..2c7cd285d 100644
--- a/lib/web/views/email_view.ex
+++ b/lib/web/views/email_view.ex
@@ -1,8 +1,10 @@
defmodule Mobilizon.Web.EmailView do
use Mobilizon.Web, :view
+ alias Mobilizon.Service.Address
alias Mobilizon.Service.DateTime, as: DateTimeRenderer
import Mobilizon.Web.Gettext
+ import Mobilizon.Service.Metadata.Utils, only: [process_description: 1]
defdelegate datetime_to_string(datetime, locale \\ "en", format \\ :medium),
to: DateTimeRenderer
@@ -10,6 +12,11 @@ defmodule Mobilizon.Web.EmailView do
defdelegate datetime_to_time_string(datetime, locale \\ "en", format \\ :short),
to: DateTimeRenderer
+ defdelegate datetime_to_date_string(datetime, locale \\ "en", format \\ :short),
+ to: DateTimeRenderer
+
defdelegate datetime_tz_convert(datetime, timezone), to: DateTimeRenderer
defdelegate datetime_relative(datetime, locale \\ "en"), to: DateTimeRenderer
+ defdelegate render_address(address), to: Address
+ defdelegate is_same_day?(one, two), to: DateTimeRenderer
end