From 658279379afab8801161eb3df1b6896513eb30a7 Mon Sep 17 00:00:00 2001 From: Pavel Mineev Date: Wed, 15 Jan 2020 10:22:00 +0300 Subject: [PATCH] Update email templates (#550) * Update email templates * Fix README * fix detail * fix typo * Changes connected with comment at issue https://github.com/umputun/remark/issues/494#issuecomment-570801318 * Unify styles between templates * remove breaking words * use the same prefix for parent and child --- README.md | 6 +- backend/app/notify/email.go | 122 +++++++++++++++++++++++++++--------- 2 files changed, 95 insertions(+), 33 deletions(-) diff --git a/README.md b/README.md index c8d2bd0c..01700ff2 100644 --- a/README.md +++ b/README.md @@ -193,7 +193,9 @@ _this is the recommended way to run remark42_ ##### Deprecated -
deprecated options +
+deprecated options + | Command line | Replacement | Environment | Replacement | Default | Description | Deprecation version | | ------------------ | ------------- | ------------------ | ------------- | ------- | -------------- | ------------------- | | auth.email.host | smtp.host | AUTH_EMAIL_HOST | SMTP_HOST | | smtp host | 1.5.0 | @@ -209,7 +211,7 @@ _this is the recommended way to run remark42_ Most of the parameters have sane defaults and don't require customization. There are only a few parameters user has to define: 1. `SECRET` - secret key, can be any long and hard-to-guess string. -2. `REMARK_URL` - url pointing to your remark42 server, i.e. `https://demo.reamark42.com` +2. `REMARK_URL` - url pointing to your remark42 server, i.e. `https://demo.remark42.com` 3. At least one pair of `AUTH__CID` and `AUTH__CSEC` defining oauth2 provider(s) The minimal `docker-compose.yml` has to include all required parameters: diff --git a/backend/app/notify/email.go b/backend/app/notify/email.go index 9ad622f3..2f6b1b88 100644 --- a/backend/app/notify/email.go +++ b/backend/app/notify/email.go @@ -74,13 +74,18 @@ type emailMessage struct { // msgTmplData store data for message from request template execution type msgTmplData struct { - CommentUser string - ParentUser string - CommentText string - CommentLink string - PostTitle string - Email string - UnsubscribeLink string + UserName string + UserPicture string + CommentText string + CommentLink string + CommentDate string + ParentUserName string + ParentUserPicture string + ParentCommentText string + ParentCommentLink string + PostTitle string + Email string + UnsubscribeLink string } // verifyTmplData store data for verification message template execution @@ -99,17 +104,65 @@ const ( - + + -
-

Remark42

-
-

New reply from {{.CommentUser}} on your comment{{if .PostTitle}} to "{{.PostTitle}}"{{end}}

-
{{.CommentText}}
-

Sent to {{.Email}} for {{.ParentUser}}

Unsubscribe

+
+

Remark42

+
New reply from {{.UserName}} on your comment{{if .PostTitle}} to «{{.PostTitle}}»{{ end }}
+
+
+
+ + {{.ParentUserName}} + {{.CommentDate}} + Show +
+
+ {{.ParentCommentText}} +
+
+
+
+ +
+ {{.UserName}} +
+
+ {{.CommentDate}} +
+ Reply +
+
+ {{.CommentText}} +
+
+
+
+ Sent to {{.Email}} for {{.ParentUserName}} +
+ Unsubscribe + +
[{{.CommentDate}}]
+
+
-
` @@ -120,16 +173,17 @@ const ( -
-

Remark42

-

Confirmation for {{.User}} on site {{.Site}}

-
-

TOKEN

-

Copy and paste this text into “token” field on comments page

-

{{.Token}}

+ +
+

Remark42

+

Confirmation for {{.User}} on site {{.Site}}

+
+

TOKEN

+

Copy and paste this text into “token” field on comments page

+

{{.Token}}

+
+

Sent to {{.Email}}

-

Sent to {{.Email}}

-
` @@ -240,15 +294,21 @@ func (e *Email) buildMessageFromRequest(req Request) (string, error) { if err != nil { return "", errors.Wrapf(err, "error creating token for unsubscribe link") } + commentUrlPrefix := req.Comment.Locator.URL + uiNav msg := bytes.Buffer{} err = e.msgTmpl.Execute(&msg, msgTmplData{ - CommentUser: req.Comment.User.Name, - ParentUser: req.parent.User.Name, - CommentText: req.Comment.Text, - CommentLink: req.Comment.Locator.URL + uiNav + req.Comment.ID, - PostTitle: req.Comment.PostTitle, - Email: req.Email, - UnsubscribeLink: unsubscribeLink, + UserName: req.Comment.User.Name, + UserPicture: req.Comment.User.Picture, + CommentText: req.Comment.Text, + CommentLink: commentUrlPrefix + req.Comment.ID, + CommentDate: req.Comment.Timestamp.Format("02.01.2006 at 15:04"), + ParentUserName: req.parent.User.Name, + ParentUserPicture: req.parent.User.Picture, + ParentCommentText: req.parent.Text, + ParentCommentLink: commentUrlPrefix + req.parent.ID, + PostTitle: req.Comment.PostTitle, + Email: req.Email, + UnsubscribeLink: unsubscribeLink, }) if err != nil { return "", errors.Wrapf(err, "error executing template to build comment reply message")