templates: use plaintext instead of fancy HTML

This commit is contained in:
Adhityaa Chandrasekar 2019-01-23 02:07:45 -05:00
parent 0cdba65e48
commit 3677d43aab
6 changed files with 22 additions and 188 deletions

View File

@ -2,8 +2,8 @@ package main
import (
"fmt"
"html/template"
"os"
"text/template"
)
var headerTemplate *template.Template
@ -20,9 +20,9 @@ var templates map[string]*template.Template
func smtpTemplatesLoad() error {
var err error
headerTemplate, err = template.New("header").Parse(`MIME-Version: 1.0
Content-Type: text/html; charset=UTF-8
From: {{.FromAddress}}
From: Commento <{{.FromAddress}}>
To: {{.ToName}} <{{.ToAddress}}>
Content-Type: text/plain; charset=UTF-8
Subject: {{.Subject}}
`)
@ -39,9 +39,9 @@ Subject: {{.Subject}}
for _, name := range names {
var err error
templates[name] = template.New(name)
templates[name], err = template.ParseFiles(fmt.Sprintf("%s/templates/%s.html", os.Getenv("STATIC"), name))
templates[name], err = template.ParseFiles(fmt.Sprintf("%s/templates/%s.txt", os.Getenv("STATIC"), name))
if err != nil {
logger.Errorf("cannot parse %s/templates/%s.html: %v", os.Getenv("STATIC"), name, err)
logger.Errorf("cannot parse %s/templates/%s.txt: %v", os.Getenv("STATIC"), name, err)
return errorMalformedTemplate
}
}

View File

@ -5,7 +5,7 @@ DEVEL_BUILD_DIR = $(BUILD_DIR)/devel
PROD_BUILD_DIR = $(BUILD_DIR)/prod
TEMPLATES_SRC_DIR = .
TEMPLATES_SRC_FILES = $(wildcard $(TEMPLATES_SRC_DIR)/*.html)
TEMPLATES_SRC_FILES = $(wildcard $(TEMPLATES_SRC_DIR)/*.txt)
TEMPLATES_DEVEL_BUILD_DIR = $(DEVEL_BUILD_DIR)/templates
TEMPLATES_DEVEL_BUILD_FILES = $(patsubst $(TEMPLATES_SRC_DIR)/%, $(TEMPLATES_DEVEL_BUILD_DIR)/%, $(TEMPLATES_SRC_FILES))
TEMPLATES_PROD_BUILD_DIR = $(PROD_BUILD_DIR)/templates
@ -20,12 +20,12 @@ clean:
devel-templates: $(TEMPLATES_DEVEL_BUILD_FILES)
$(TEMPLATES_DEVEL_BUILD_FILES): $(TEMPLATES_DEVEL_BUILD_DIR)/%.html: $(TEMPLATES_SRC_DIR)/%.html
$(TEMPLATES_DEVEL_BUILD_FILES): $(TEMPLATES_DEVEL_BUILD_DIR)/%.txt: $(TEMPLATES_SRC_DIR)/%.txt
cp $^ $@;
prod-templates: $(TEMPLATES_PROD_BUILD_FILES)
$(TEMPLATES_PROD_BUILD_FILES): $(TEMPLATES_PROD_BUILD_DIR)/%.html: $(TEMPLATES_SRC_DIR)/%.html
$(TEMPLATES_PROD_BUILD_FILES): $(TEMPLATES_PROD_BUILD_DIR)/%.txt: $(TEMPLATES_SRC_DIR)/%.txt
cp $^ $@;
$(shell mkdir -p $(TEMPLATES_DEVEL_BUILD_DIR) $(TEMPLATES_PROD_BUILD_DIR))

View File

@ -1,90 +0,0 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<title>Commento: Verify your email address</title>
</head>
<body leftmargin="0" marginwidth="0" topmargin="0" marginheight="0" offset="0" style="margin: 0pt auto; padding: 0px; background:#f8f9fa;">
<table id="main" width="100%" height="100%" cellpadding="0" cellspacing="0" border="0" bgcolor="#f8f9fa">
<tbody>
<tr>
<td valign="top">
<table cellpadding="0" width="580" cellspacing="0" border="0" bgcolor="#f8f9fa" align="center" style="margin:0 auto; table-layout: fixed;">
<tbody>
<tr>
<td colspan="4">
<table width="100%" cellpadding="0" cellspacing="0" border="0" style="background: white; border-radius: 4px; box-shadow: 0 1px 3px rgba(50, 50, 93, .15), 0 1px 0 rgba(0, 0, 0, .02); margin-top: 30px;">
<tbody>
<tr><td height="40"></td></tr>
<tr style='font-family: -apple-system,BlinkMacSystemFont,"Segoe UI","Roboto","Oxygen","Ubuntu","Cantarell","Fira Sans","Droid Sans","Helvetica Neue",sans-serif; color:#495057; font-size:14px; line-height:20px; margin-top:20px;'>
<td colspan="2" valign="top" align="center" style="padding-left:90px; padding-right:90px;">
<table width="100%" cellpadding="0" cellspacing="0" border="0" bgcolor="#ffffff">
<tbody>
<tr><td height="30"></td></tr>
<!-- Title -->
<tr>
<td align="center">
<span style="font-size:22px;line-height: 24px;">
Verify your email address
</span>
</td>
</tr>
<tr><td height="24"></td></tr>
<!-- Main content -->
<tr>
<td align="center">
<span style="color:#48545d;font-size:14px;line-height:24px;">
In order to start using Commento, you need to first confirm your email address. Click the link below to do that.
</span>
</td>
</tr>
<tr><td height="20"></td></tr>
<!-- Button -->
<tr>
<td valign="top" width="48%" align="center">
<span>
<a href="{{.Origin}}/api/owner/confirm-hex?confirmHex={{.ConfirmHex}}" style="display:block; padding:15px 25px; background-color:#007aff; color:#ffffff; border-radius:3px; text-decoration:none;">Verify Email Address</a>
</span>
</td>
</tr>
<tr><td height="20"></td></tr>
</tbody>
</table>
</td>
</tr>
<tr><td height="60"></td></tr>
</tbody>
</table>
<table width="100%" cellpadding="0" cellspacing="0" border="0">
<tbody>
<tr><td height="10"></td></tr>
<tr>
<td valign="top" align="center">
<span style='font-family: -apple-system,BlinkMacSystemFont,"Segoe UI","Roboto","Oxygen","Ubuntu","Cantarell","Fira Sans","Droid Sans","Helvetica Neue",sans-serif; color:#9EB0C9; font-size:10px;'>
If you did not sign up for this account you can safely ignore this email and the account will be automatically deleted.
</span>
</td>
</tr>
</tbody>
</table>
</td>
</tr>
</tbody>
</table>
</td>
</tr>
</tbody>
</table>
</body>
</html>

View File

@ -0,0 +1,7 @@
Hi,
You recently registered a new Commento account with this email address. If you wish to complete registration, use the link below:
{{.Origin}}/api/owner/confirm-hex?confirmHex={{.ConfirmHex}}
If you did not do initiate this, you can ignore this email.

View File

@ -1,90 +0,0 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<title>Commento: Reset your password</title>
</head>
<body leftmargin="0" marginwidth="0" topmargin="0" marginheight="0" offset="0" style="margin: 0pt auto; padding: 0px; background:#f8f9fa;">
<table id="main" width="100%" height="100%" cellpadding="0" cellspacing="0" border="0" bgcolor="#f8f9fa">
<tbody>
<tr>
<td valign="top">
<table cellpadding="0" width="580" cellspacing="0" border="0" bgcolor="#f8f9fa" align="center" style="margin:0 auto; table-layout: fixed;">
<tbody>
<tr>
<td colspan="4">
<table width="100%" cellpadding="0" cellspacing="0" border="0" style="background: white; border-radius: 4px; box-shadow: 0 1px 3px rgba(50, 50, 93, .15), 0 1px 0 rgba(0, 0, 0, .02); margin-top: 30px;">
<tbody>
<tr><td height="40"></td></tr>
<tr style='font-family: -apple-system,BlinkMacSystemFont,"Segoe UI","Roboto","Oxygen","Ubuntu","Cantarell","Fira Sans","Droid Sans","Helvetica Neue",sans-serif; color:#495057; font-size:14px; line-height:20px; margin-top:20px;'>
<td colspan="2" valign="top" align="center" style="padding-left:90px; padding-right:90px;">
<table width="100%" cellpadding="0" cellspacing="0" border="0" bgcolor="#ffffff">
<tbody>
<tr><td height="30"></td></tr>
<!-- Title -->
<tr>
<td align="center">
<span style="font-size:22px;line-height: 24px;">
Reset your Password
</span>
</td>
</tr>
<tr><td height="24"></td></tr>
<!-- Main content -->
<tr>
<td align="center">
<span style="color:#48545d;font-size:14px;line-height:24px;">
Someone (probably you) recently initiated the procedure to reset your Commento account password. To complete this, click the link below and set your new password.
</span>
</td>
</tr>
<tr><td height="20"></td></tr>
<!-- Button -->
<tr>
<td valign="top" width="48%" align="center">
<span>
<a href="{{.Origin}}/reset-password?hex={{.ResetHex}}" style="display:block; padding:15px 25px; background-color:#007aff; color:#ffffff; border-radius:3px; text-decoration:none;">Reset Password</a>
</span>
</td>
</tr>
<tr><td height="20"></td></tr>
</tbody>
</table>
</td>
</tr>
<tr><td height="60"></td></tr>
</tbody>
</table>
<table width="100%" cellpadding="0" cellspacing="0" border="0">
<tbody>
<tr><td height="10"></td></tr>
<tr>
<td valign="top" align="center">
<span style='font-family: -apple-system,BlinkMacSystemFont,"Segoe UI","Roboto","Oxygen","Ubuntu","Cantarell","Fira Sans","Droid Sans","Helvetica Neue",sans-serif; color:#9EB0C9; font-size:10px;'>
If you did not initiate this request, you can safely ignore this email.
</span>
</td>
</tr>
</tbody>
</table>
</td>
</tr>
</tbody>
</table>
</td>
</tr>
</tbody>
</table>
</body>
</html>

7
templates/reset-hex.txt Normal file
View File

@ -0,0 +1,7 @@
Hi,
Someone (probably you) recently initiated the procedure to reset your Commento account password. To do this, use the link below:
{{.Origin}}/reset-password?hex={{.ResetHex}}
If you did not initiate this request, you can safely ignore this email.