diff --git a/src/EventHub.Domain.Shared/Web/EventHubExternalUrls.cs b/src/EventHub.Domain.Shared/Web/EventHubExternalUrls.cs index 4df9730..e6d8c7a 100644 --- a/src/EventHub.Domain.Shared/Web/EventHubExternalUrls.cs +++ b/src/EventHub.Domain.Shared/Web/EventHubExternalUrls.cs @@ -8,6 +8,7 @@ namespace EventHub.Web public const string EhAdmin = "https://localhost:44307"; public const string EhWww = "https://localhost:44308"; #else + // TODO: Change these production links public const string EhAccount = "https://localhost:44313"; public const string EhApi = "https://localhost:44362"; public const string EhAdmin = "https://localhost:44307"; diff --git a/src/EventHub.Domain/Emailing/EmailTemplateDefinitionProvider.cs b/src/EventHub.Domain/Emailing/EmailTemplateDefinitionProvider.cs index 77be90e..fc8842e 100644 --- a/src/EventHub.Domain/Emailing/EmailTemplateDefinitionProvider.cs +++ b/src/EventHub.Domain/Emailing/EmailTemplateDefinitionProvider.cs @@ -8,7 +8,18 @@ namespace EventHub.Emailing { context.Add( new TemplateDefinition( - EmailTemplates.EventRegistration + EmailTemplates.Layout, + isLayout: true + ).WithVirtualFilePath( + "/Emailing/Templates/Layout.tpl", + isInlineLocalized: true + ) + ); + + context.Add( + new TemplateDefinition( + EmailTemplates.EventRegistration, + layout: EmailTemplates.Layout ).WithVirtualFilePath( "/Emailing/Templates/EventRegistration.tpl", isInlineLocalized: true @@ -17,7 +28,8 @@ namespace EventHub.Emailing context.Add( new TemplateDefinition( - EmailTemplates.EventReminder + EmailTemplates.EventReminder, + layout: EmailTemplates.Layout ).WithVirtualFilePath( "/Emailing/Templates/EventReminder.tpl", isInlineLocalized: true @@ -26,7 +38,8 @@ namespace EventHub.Emailing context.Add( new TemplateDefinition( - EmailTemplates.NewEventCreated + EmailTemplates.NewEventCreated, + layout: EmailTemplates.Layout ).WithVirtualFilePath( "/Emailing/Templates/NewEventCreated.tpl", isInlineLocalized: true @@ -35,7 +48,8 @@ namespace EventHub.Emailing context.Add( new TemplateDefinition( - EmailTemplates.EventTimingChanged) + EmailTemplates.EventTimingChanged, + layout: EmailTemplates.Layout) .WithVirtualFilePath( "/Emailing/Templates/EventTimingChanged.tpl", isInlineLocalized: true diff --git a/src/EventHub.Domain/Emailing/EmailTemplates.cs b/src/EventHub.Domain/Emailing/EmailTemplates.cs index 7add2c5..be07d18 100644 --- a/src/EventHub.Domain/Emailing/EmailTemplates.cs +++ b/src/EventHub.Domain/Emailing/EmailTemplates.cs @@ -2,6 +2,8 @@ namespace EventHub.Emailing { public static class EmailTemplates { + public const string Layout = "EventHub.Event.Layout"; + public const string EventRegistration = "EventHub.Event.Registration"; public const string EventReminder = "EventHub.Event.Reminder"; diff --git a/src/EventHub.Domain/Emailing/EventHubEmailTemplateRenderingEngine.cs b/src/EventHub.Domain/Emailing/EventHubEmailTemplateRenderingEngine.cs new file mode 100644 index 0000000..e36aeec --- /dev/null +++ b/src/EventHub.Domain/Emailing/EventHubEmailTemplateRenderingEngine.cs @@ -0,0 +1,38 @@ +using System; +using System.Collections.Generic; +using System.Threading.Tasks; +using EventHub.Web; +using JetBrains.Annotations; +using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.Localization; +using Volo.Abp.DependencyInjection; +using Volo.Abp.TextTemplating; + +namespace EventHub.Emailing +{ + [Dependency(ServiceLifetime.Transient, ReplaceServices = true)] + [ExposeServices(typeof(ITemplateRenderer), typeof(TemplateRenderer), typeof(EventHubEmailTemplateRenderingEngine))] + public class EventHubEmailTemplateRenderingEngine : TemplateRenderer + { + public EventHubEmailTemplateRenderingEngine(ITemplateContentProvider templateContentProvider, ITemplateDefinitionManager templateDefinitionManager, IStringLocalizerFactory stringLocalizerFactory) : base(templateContentProvider, templateDefinitionManager, stringLocalizerFactory) + { + } + + public override async Task RenderAsync( + [NotNull] string templateName, + [CanBeNull] object model = null, + [CanBeNull] string cultureName = null, + [CanBeNull] Dictionary globalContext = null) + { + if (globalContext == null) + { + globalContext = new Dictionary(); + } + + globalContext["current_year"] = DateTime.Today.Year; + globalContext["app_url"] = EventHubExternalUrls.EhWww; + + return await base.RenderAsync(templateName, model, cultureName, globalContext); + } + } +} \ No newline at end of file diff --git a/src/EventHub.Domain/Emailing/Templates/EventRegistration.tpl b/src/EventHub.Domain/Emailing/Templates/EventRegistration.tpl index c126b4a..0122747 100644 --- a/src/EventHub.Domain/Emailing/Templates/EventRegistration.tpl +++ b/src/EventHub.Domain/Emailing/Templates/EventRegistration.tpl @@ -1,157 +1,43 @@ - - - - - - Eventhub - - - - - - - - - - -
-
-
- -

EventHub

- -
- -
- -

{{model.title}}

- -
- - - - - - - -
- - - - - - -
- - - - - - -
-
- - - - - - -
-

- Hi, -

-

- Great news! You attended the "{{model.title}}" event. -

-
- - - - - - - - -
- -

Start Time

-

{{model.start_time}}

-
- -

End Time

-

{{model.end_time}}

-
-

- Event Details -

-
- -

- Thank you,
EventHub -

-
-
-
-
- -
- - - - - - - - - - -
-
- Home -
-
-
- info@eventhub.abp.io - EventHub - Powered by Volosoft -
-
-
- - -
- - - \ No newline at end of file +

+ {{model.title}}

+

+ Hi,

+

+ Great news! You attended the "{{model.title}}" event. +

+

+

+ + + + + + + + +
+ +

+ Start Time

+

+ {{model.start_time}}

+
+ +

+ End Time

+

+ {{model.end_time}}

+
+

+ Event + Details +

+
+

\ No newline at end of file diff --git a/src/EventHub.Domain/Emailing/Templates/EventReminder.tpl b/src/EventHub.Domain/Emailing/Templates/EventReminder.tpl index 75f611e..6092a9e 100644 --- a/src/EventHub.Domain/Emailing/Templates/EventReminder.tpl +++ b/src/EventHub.Domain/Emailing/Templates/EventReminder.tpl @@ -1,157 +1,32 @@ - - - - - - Eventhub - - - - - - - - - - -
-
-
- -

EventHub

- -
- -
- -

{{model.title}} event will start soon

- -
- - - - - - - -
- - - - - - -
- - - - - - -
-
- - - - - - -
-

- Hi {{model.user_name}}, -

-

- The "{{model.title}}" event will start very soon. -

-
- - - - - - - - -
- -

Start Time

-

{{model.start_time}}

-
- -

End Time

-

{{model.end_time}}

-
-

- Event Details -

-
- -

- Thank you,
EventHub -

-
-
-
-
- -
- - - - - - - - - - -
-
- Home -
-
-
- info@eventhub.abp.io - EventHub - Powered by Volosoft -
-
-
- - -
- - - \ No newline at end of file +

+ {{model.title}}

+

+ Hi {{model.user_name}},

+

+ The "{{model.title}}" event will start very soon. +

+

+

+ + + + + + + + +
+ +

Start Time

+

{{model.start_time}}

+
+ +

End Time

+

{{model.end_time}}

+
+

+ Event Details +

+
+

\ No newline at end of file diff --git a/src/EventHub.Domain/Emailing/Templates/EventTimingChanged.tpl b/src/EventHub.Domain/Emailing/Templates/EventTimingChanged.tpl index 871c34b..2b26aad 100644 --- a/src/EventHub.Domain/Emailing/Templates/EventTimingChanged.tpl +++ b/src/EventHub.Domain/Emailing/Templates/EventTimingChanged.tpl @@ -1,157 +1,32 @@ - - - - - - Eventhub - - - - - - - - - - -
-
-
- -

EventHub

- -
- -
- -

{{model.title}} event time has been changed!

- -
- - - - - - - -
- - - - - - -
- - - - - - -
-
- - - - - - -
-

- Hi {{model.user_name}}, -

-

- The "{{model.title}}" event time just rescheduled. -

-
- - - - - - - - -
- -

Start Time

-

{{model.start_time}}

-
- -

End Time

-

{{model.end_time}}

-
-

- Event Details -

-
- -

- Thank you,
EventHub -

-
-
-
-
- -
- - - - - - - - - - -
-
- Home -
-
-
- info@eventhub.abp.io - EventHub - Powered by Volosoft -
-
-
- - -
- - - \ No newline at end of file +

+ {{model.title}}

+

+ Hi {{model.user_name}},

+

+ The "{{model.title}}" event time just rescheduled. +

+

+

+ + + + + + + + +
+ +

Start Time

+

{{model.start_time}}

+
+ +

End Time

+

{{model.end_time}}

+
+

+ Event Details +

+
+

\ No newline at end of file diff --git a/src/EventHub.Domain/Emailing/Templates/Layout.tpl b/src/EventHub.Domain/Emailing/Templates/Layout.tpl new file mode 100644 index 0000000..29667ee --- /dev/null +++ b/src/EventHub.Domain/Emailing/Templates/Layout.tpl @@ -0,0 +1,140 @@ + + + + + + + EventHub Email + + + + +
+ + + + + + + + + +
+ + + + +
+
+ + + + + +
+ + + Create an Event +
+ {{content}} +
+
+
+ + + + + + + +
+ +
+ +
+
+
+ + + \ No newline at end of file diff --git a/src/EventHub.Domain/Emailing/Templates/NewEventCreated.tpl b/src/EventHub.Domain/Emailing/Templates/NewEventCreated.tpl index d8bfd07..fc7be76 100644 --- a/src/EventHub.Domain/Emailing/Templates/NewEventCreated.tpl +++ b/src/EventHub.Domain/Emailing/Templates/NewEventCreated.tpl @@ -1,157 +1,32 @@ - - - - - - Eventhub - - - - - - - - - - -
-
-
- -

EventHub

- -
- -
- -

There is a new event that may interest you

- -
- - - - - - - -
- - - - - - -
- - - - - - -
-
- - - - - - -
-

- Hi {{model.user_name}}, -

-

- A new event called "{{model.title}}" has been created. -

-
- - - - - - - - -
- -

Start Time

-

{{model.start_time}}

-
- -

End Time

-

{{model.end_time}}

-
-

- Event Details -

-
- -

- Thank you,
EventHub -

-
-
-
-
- -
- - - - - - - - - - -
-
- Home -
-
-
- info@eventhub.abp.io - EventHub - Powered by Volosoft -
-
-
- - -
- - - \ No newline at end of file +

+ {{model.title}}

+

+ Hi {{model.user_name}},

+

+ A new event called "{{model.title}}" has been created. +

+

+

+ + + + + + + + +
+ +

Start Time

+

{{model.start_time}}

+
+ +

End Time

+

{{model.end_time}}

+
+

+ Event Details +

+
+

\ No newline at end of file