From 47a5eb538202994e09f0c66804a6d42b9f022554 Mon Sep 17 00:00:00 2001 From: Paulo Reis Date: Thu, 15 Dec 2016 17:22:39 +0000 Subject: [PATCH 1/7] Add a new layout and body template for e-mails. --- .../Email/Bodies/SingleCTAEmailBody.coffee | 26 ++ .../coffee/Features/Email/EmailBuilder.coffee | 30 +- .../Layouts/BaseWithHeaderEmailLayout.coffee | 378 ++++++++++++++++++ 3 files changed, 420 insertions(+), 14 deletions(-) create mode 100644 services/web/app/coffee/Features/Email/Bodies/SingleCTAEmailBody.coffee create mode 100644 services/web/app/coffee/Features/Email/Layouts/BaseWithHeaderEmailLayout.coffee diff --git a/services/web/app/coffee/Features/Email/Bodies/SingleCTAEmailBody.coffee b/services/web/app/coffee/Features/Email/Bodies/SingleCTAEmailBody.coffee new file mode 100644 index 0000000000..98a0ffe30d --- /dev/null +++ b/services/web/app/coffee/Features/Email/Bodies/SingleCTAEmailBody.coffee @@ -0,0 +1,26 @@ +_ = require("underscore") +settings = require "settings-sharelatex" + +module.exports = _.template """ + + +
+
+

+ <%= title %> +

+
 
+

+ <%= greeting %> +

+

+ <%= message %> +

+
 
+
+
+ View project +
+
+
+""" diff --git a/services/web/app/coffee/Features/Email/EmailBuilder.coffee b/services/web/app/coffee/Features/Email/EmailBuilder.coffee index 70d11e219b..908aac53f1 100644 --- a/services/web/app/coffee/Features/Email/EmailBuilder.coffee +++ b/services/web/app/coffee/Features/Email/EmailBuilder.coffee @@ -1,6 +1,12 @@ _ = require('underscore') + PersonalEmailLayout = require("./Layouts/PersonalEmailLayout") NotificationEmailLayout = require("./Layouts/NotificationEmailLayout") +BaseWithHeaderEmailLayout = require("./Layouts/BaseWithHeaderEmailLayout") + +SingleCTAEmailBody = require("./Bodies/SingleCTAEmailBody") + + settings = require("settings-sharelatex") @@ -107,9 +113,9 @@ If you didn't request a password reset, let us know. templates.projectInvite = subject: _.template "<%= project.name %> - shared by <%= owner.email %>" - layout: NotificationEmailLayout + layout: BaseWithHeaderEmailLayout type:"notification" - plainTextTemplate: _.template """ + plainTextTemplate: plainTextTpl: """ Hi, <%= owner.email %> wants to share '<%= project.name %>' with you. Follow this link to view the project: <%= inviteUrl %> @@ -118,18 +124,14 @@ Thank you #{settings.appName} - <%= siteUrl %> """ - compiledTemplate: _.template """ -

Hi, <%= owner.email %> wants to share '<%= project.name %>' with you

-
- - - View Project - - -
-

Thank you

-

#{settings.appName}

-""" + compiledTemplate: (opts) -> + SingleCTAEmailBody({ + title: "#{ opts.project.name } – shared by #{ opts.owner.email }" + greeting: "Hi," + message: "#{ opts.owner.email } wants to share “#{ opts.project.name }” with you." + ctaURL: opts.inviteUrl + }) + templates.completeJoinGroupAccount = diff --git a/services/web/app/coffee/Features/Email/Layouts/BaseWithHeaderEmailLayout.coffee b/services/web/app/coffee/Features/Email/Layouts/BaseWithHeaderEmailLayout.coffee new file mode 100644 index 0000000000..7b68d3bf49 --- /dev/null +++ b/services/web/app/coffee/Features/Email/Layouts/BaseWithHeaderEmailLayout.coffee @@ -0,0 +1,378 @@ +_ = require("underscore") +settings = require "settings-sharelatex" + +module.exports = _.template """ + + + + + + + + + Project invite + + + + + + + + +
+
+ +
+
+ + +
+
+

+ SHARELATEX +

+
+
+
+
 
+
+
 
+ + <%= body %> + +
+
 
+

ShareLaTeX • www.sharelatex.com

+
+
+ +
+
+ +
                                                           
+ + + +""" From 7dfc2c61a6b3137f95e8d1e7d7668778b7122b7e Mon Sep 17 00:00:00 2001 From: Paulo Reis Date: Fri, 16 Dec 2016 10:06:56 +0000 Subject: [PATCH 2/7] Make the CTA button text configurable. --- .../coffee/Features/Email/Bodies/SingleCTAEmailBody.coffee | 4 +++- services/web/app/coffee/Features/Email/EmailBuilder.coffee | 3 ++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/services/web/app/coffee/Features/Email/Bodies/SingleCTAEmailBody.coffee b/services/web/app/coffee/Features/Email/Bodies/SingleCTAEmailBody.coffee index 98a0ffe30d..07954e2162 100644 --- a/services/web/app/coffee/Features/Email/Bodies/SingleCTAEmailBody.coffee +++ b/services/web/app/coffee/Features/Email/Bodies/SingleCTAEmailBody.coffee @@ -17,7 +17,9 @@ module.exports = _.template """
 
- View project + + <%= ctaText %> +
diff --git a/services/web/app/coffee/Features/Email/EmailBuilder.coffee b/services/web/app/coffee/Features/Email/EmailBuilder.coffee index 908aac53f1..dd908c9d42 100644 --- a/services/web/app/coffee/Features/Email/EmailBuilder.coffee +++ b/services/web/app/coffee/Features/Email/EmailBuilder.coffee @@ -115,7 +115,7 @@ templates.projectInvite = subject: _.template "<%= project.name %> - shared by <%= owner.email %>" layout: BaseWithHeaderEmailLayout type:"notification" - plainTextTemplate: plainTextTpl: """ + plainTextTemplate: """ Hi, <%= owner.email %> wants to share '<%= project.name %>' with you. Follow this link to view the project: <%= inviteUrl %> @@ -129,6 +129,7 @@ Thank you title: "#{ opts.project.name } – shared by #{ opts.owner.email }" greeting: "Hi," message: "#{ opts.owner.email } wants to share “#{ opts.project.name }” with you." + ctaText: "View project" ctaURL: opts.inviteUrl }) From 2234c438a165d299baa754f456e8036958fc28dc Mon Sep 17 00:00:00 2001 From: Paulo Reis Date: Fri, 16 Dec 2016 12:16:33 +0000 Subject: [PATCH 3/7] Support a secondary message in the single CTA email template. --- .../coffee/Features/Email/Bodies/SingleCTAEmailBody.coffee | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/services/web/app/coffee/Features/Email/Bodies/SingleCTAEmailBody.coffee b/services/web/app/coffee/Features/Email/Bodies/SingleCTAEmailBody.coffee index 07954e2162..6d0756596c 100644 --- a/services/web/app/coffee/Features/Email/Bodies/SingleCTAEmailBody.coffee +++ b/services/web/app/coffee/Features/Email/Bodies/SingleCTAEmailBody.coffee @@ -22,6 +22,12 @@ module.exports = _.template """ + <% if (secondaryMessage) { %> +
 
+

+ <%= secondaryMessage %> +

+ <% } %> From 0fe3664a820a173de07c05a30a130570475ed4be Mon Sep 17 00:00:00 2001 From: Paulo Reis Date: Fri, 16 Dec 2016 12:16:45 +0000 Subject: [PATCH 4/7] Use the new template in the reset pwd email. --- .../coffee/Features/Email/EmailBuilder.coffee | 35 ++++++------------- .../Layouts/BaseWithHeaderEmailLayout.coffee | 4 ++- 2 files changed, 13 insertions(+), 26 deletions(-) diff --git a/services/web/app/coffee/Features/Email/EmailBuilder.coffee b/services/web/app/coffee/Features/Email/EmailBuilder.coffee index dd908c9d42..97a1023e3b 100644 --- a/services/web/app/coffee/Features/Email/EmailBuilder.coffee +++ b/services/web/app/coffee/Features/Email/EmailBuilder.coffee @@ -84,31 +84,15 @@ Thank you #{settings.appName} - <%= siteUrl %> """ - compiledTemplate: _.template """ -

Password Reset

-

-We got a request to reset your #{settings.appName} password. -

-

- -
- -If you ignore this message, your password won't be changed. -

-If you didn't request a password reset, let us know. - -

-

Thank you

-

#{settings.appName}

-""" + compiledTemplate: (opts) -> + SingleCTAEmailBody({ + title: "Password Reset" + greeting: "Hi," + message: "We got a request to reset your #{settings.appName} password." + secondaryMessage: "If you ignore this message, your password won't be changed.
If you didn't request a password reset, let us know." + ctaText: "Reset password" + ctaURL: opts.setNewPasswordUrl + }) templates.projectInvite = @@ -129,6 +113,7 @@ Thank you title: "#{ opts.project.name } – shared by #{ opts.owner.email }" greeting: "Hi," message: "#{ opts.owner.email } wants to share “#{ opts.project.name }” with you." + secondaryMessage: null ctaText: "View project" ctaURL: opts.inviteUrl }) diff --git a/services/web/app/coffee/Features/Email/Layouts/BaseWithHeaderEmailLayout.coffee b/services/web/app/coffee/Features/Email/Layouts/BaseWithHeaderEmailLayout.coffee index 7b68d3bf49..6d25df2197 100644 --- a/services/web/app/coffee/Features/Email/Layouts/BaseWithHeaderEmailLayout.coffee +++ b/services/web/app/coffee/Features/Email/Layouts/BaseWithHeaderEmailLayout.coffee @@ -362,7 +362,9 @@ module.exports = _.template """
 
-

ShareLaTeX • www.sharelatex.com

+

+ #{ settings.appName} • #{ settings.siteUrl } +

From ca5040882f5134c436a4460997ab2629cbc2f21d Mon Sep 17 00:00:00 2001 From: Paulo Reis Date: Fri, 16 Dec 2016 14:57:59 +0000 Subject: [PATCH 5/7] Use the new template in the join group email. --- .../coffee/Features/Email/EmailBuilder.coffee | 32 +++++++------------ 1 file changed, 12 insertions(+), 20 deletions(-) diff --git a/services/web/app/coffee/Features/Email/EmailBuilder.coffee b/services/web/app/coffee/Features/Email/EmailBuilder.coffee index 97a1023e3b..c083334bed 100644 --- a/services/web/app/coffee/Features/Email/EmailBuilder.coffee +++ b/services/web/app/coffee/Features/Email/EmailBuilder.coffee @@ -67,7 +67,7 @@ ShareLaTeX Co-founder templates.passwordResetRequested = subject: _.template "Password Reset - #{settings.appName}" - layout: NotificationEmailLayout + layout: BaseWithHeaderEmailLayout type:"notification" plainTextTemplate: _.template """ Password Reset @@ -122,7 +122,7 @@ Thank you templates.completeJoinGroupAccount = subject: _.template "Verify Email to join <%= group_name %> group" - layout: NotificationEmailLayout + layout: BaseWithHeaderEmailLayout type:"notification" plainTextTemplate: _.template """ Hi, please verify your email to join the <%= group_name %> and get your free premium account @@ -133,23 +133,15 @@ Thank You #{settings.appName} - <%= siteUrl %> """ - compiledTemplate: _.template """ -

Hi, please verify your email to join the <%= group_name %> and get your free premium account

-
- -
-

Thank you

-

#{settings.appName}

-""" - + compiledTemplate: (opts) -> + SingleCTAEmailBody({ + title: "Verify Email to join #{ opts.group_name } group" + greeting: "Hi," + message: "please verify your email to join the #{ opts.group_name } group and get your free premium account." + secondaryMessage: null + ctaText: "Verify now" + ctaURL: opts.completeJoinUrl + }) module.exports = templates: templates @@ -165,4 +157,4 @@ module.exports = html: template.layout(opts) text: template?.plainTextTemplate?(opts) type:template.type - } + } \ No newline at end of file From 869f729132ff170fb2b5c1d3d904cb307ba1aba8 Mon Sep 17 00:00:00 2001 From: Paulo Reis Date: Fri, 16 Dec 2016 15:15:06 +0000 Subject: [PATCH 6/7] Fix forgotten templating function. --- services/web/app/coffee/Features/Email/EmailBuilder.coffee | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/services/web/app/coffee/Features/Email/EmailBuilder.coffee b/services/web/app/coffee/Features/Email/EmailBuilder.coffee index c083334bed..0a5f653178 100644 --- a/services/web/app/coffee/Features/Email/EmailBuilder.coffee +++ b/services/web/app/coffee/Features/Email/EmailBuilder.coffee @@ -99,7 +99,7 @@ templates.projectInvite = subject: _.template "<%= project.name %> - shared by <%= owner.email %>" layout: BaseWithHeaderEmailLayout type:"notification" - plainTextTemplate: """ + plainTextTemplate: _.template """ Hi, <%= owner.email %> wants to share '<%= project.name %>' with you. Follow this link to view the project: <%= inviteUrl %> From d6fcc21ab571267d61827e1f0f6f0c6f0c8e67cb Mon Sep 17 00:00:00 2001 From: Paulo Reis Date: Fri, 16 Dec 2016 17:04:26 +0000 Subject: [PATCH 7/7] Add support for GMail go-to actions in the single CTA template. --- .../Email/Bodies/SingleCTAEmailBody.coffee | 15 +++++++++++++++ .../app/coffee/Features/Email/EmailBuilder.coffee | 6 ++++++ 2 files changed, 21 insertions(+) diff --git a/services/web/app/coffee/Features/Email/Bodies/SingleCTAEmailBody.coffee b/services/web/app/coffee/Features/Email/Bodies/SingleCTAEmailBody.coffee index 6d0756596c..00a878c276 100644 --- a/services/web/app/coffee/Features/Email/Bodies/SingleCTAEmailBody.coffee +++ b/services/web/app/coffee/Features/Email/Bodies/SingleCTAEmailBody.coffee @@ -31,4 +31,19 @@ module.exports = _.template """ +<% if (gmailGoToAction) { %> + +<% } %> """ diff --git a/services/web/app/coffee/Features/Email/EmailBuilder.coffee b/services/web/app/coffee/Features/Email/EmailBuilder.coffee index 0a5f653178..306aad3d2a 100644 --- a/services/web/app/coffee/Features/Email/EmailBuilder.coffee +++ b/services/web/app/coffee/Features/Email/EmailBuilder.coffee @@ -92,6 +92,7 @@ Thank you secondaryMessage: "If you ignore this message, your password won't be changed.
If you didn't request a password reset, let us know." ctaText: "Reset password" ctaURL: opts.setNewPasswordUrl + gmailGoToAction: null }) @@ -116,6 +117,10 @@ Thank you secondaryMessage: null ctaText: "View project" ctaURL: opts.inviteUrl + gmailGoToAction: + target: opts.inviteUrl + name: "View project" + description: "Join #{ opts.project.name } at ShareLaTeX" }) @@ -141,6 +146,7 @@ Thank You secondaryMessage: null ctaText: "Verify now" ctaURL: opts.completeJoinUrl + gmailGoToAction: null }) module.exports =