aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorrubenwardy <rw@rubenwardy.com>2019-01-04 19:17:04 +0000
committerrubenwardy <rw@rubenwardy.com>2019-01-04 19:17:04 +0000
commit014370ea067d3abaef1eddde15bd3fa3fbafd2a3 (patch)
tree599c2f469650a0dc035be497525048a4936849fc
parentfbf374ff5d72722d14f07cc4ee71a5182212db94 (diff)
downloadcheatdb-014370ea067d3abaef1eddde15bd3fa3fbafd2a3.tar.xz
Add email template
-rw-r--r--app/tasks/emails.py8
-rw-r--r--app/templates/emails/base.html64
-rw-r--r--app/templates/emails/verify.html22
3 files changed, 85 insertions, 9 deletions
diff --git a/app/tasks/emails.py b/app/tasks/emails.py
index ba3215a..faeeb9d 100644
--- a/app/tasks/emails.py
+++ b/app/tasks/emails.py
@@ -15,7 +15,7 @@
# along with this program. If not, see <https://www.gnu.org/licenses/>.
-from flask import *
+from flask import render_template
from flask_mail import Message
from app import mail
from app.tasks import celery
@@ -32,8 +32,10 @@ def sendVerifyEmail(newEmail, token):
def sendEmailRaw(to, subject, text, html):
from flask_mail import Message
msg = Message(subject, recipients=to)
+
if text:
msg.body = text
- if html:
- msg.html = html
+
+ html = html or text
+ msg.html = render_template("emails/base.html", subject=subject, content=html)
mail.send(msg)
diff --git a/app/templates/emails/base.html b/app/templates/emails/base.html
new file mode 100644
index 0000000..ebdf85a
--- /dev/null
+++ b/app/templates/emails/base.html
@@ -0,0 +1,64 @@
+<!doctype html>
+<html>
+<head>
+ <style>
+ .btn {
+ display: inline-block !important;
+ color: #fff !important;
+ font-weight: 400;
+ text-align: center;
+ vertical-align: middle;
+ -webkit-user-select: none;
+ -moz-user-select: none;
+ -ms-user-select: none;
+ user-select: none;
+ background-color: transparent;
+ border: 1px solid transparent;
+ border-top-color: transparent;
+ border-bottom-color: transparent;
+ border-left-color: transparent;
+ padding: 0.375rem 0.75rem;
+ font-size: 0.9375rem;
+ line-height: 1.5;
+ border-radius: 0.25rem;
+ -webkit-transition: color 0.15s ease-in-out, background-color 0.15s ease-in-out, border-color 0.15s ease-in-out, -webkit-box-shadow 0.15s ease-in-out;
+ transition: color 0.15s ease-in-out, background-color 0.15s ease-in-out, border-color 0.15s ease-in-out, -webkit-box-shadow 0.15s ease-in-out;
+ transition: color 0.15s ease-in-out, background-color 0.15s ease-in-out, border-color 0.15s ease-in-out, box-shadow 0.15s ease-in-out;
+ transition: color 0.15s ease-in-out, background-color 0.15s ease-in-out, border-color 0.15s ease-in-out, box-shadow 0.15s ease-in-out, -webkit-box-shadow 0.15s ease-in-out;
+ background-color: #2C3E50;
+ border-color: #2C3E50;
+ text-decoration: none;
+ }
+
+ .btn:hover {
+ color: #fff;
+ background-color: #1e2b37;
+ border-color: #1a252f;
+ }
+
+ .btn:focus {
+ -webkit-box-shadow: 0 0 0 0.2rem rgba(76, 91, 106, 0.5);
+ box-shadow: 0 0 0 0.2rem rgba(76, 91, 106, 0.5);
+ outline: 0;
+ }
+ </style>
+</head>
+<body>
+ <div style="font-family: 'Arial', 'sans-serif'; max-width: 700px; margin: auto; padding: 0;">
+ <div style="background: #2C3E50; padding: 1.2rem 1.2rem 1.2rem 2em; color: white;">
+ <h1 style="margin: 0; font-size: 120%; font-weight: normal;">ContentDB</h1>
+ </div>
+ <div style="padding: 2em; background: white;">
+ {% block content %}
+ <h2 style="margin-top: 0;">{{ subject }}</h2>
+
+ {{ content | safe }}
+ {% endblock %}
+
+ <div style="margin-top: 3em;font-size: 80%;color: #666;">
+ ContentDB &copy; rubenwardy
+ </div>
+ </div>
+ </div>
+</body>
+</html>
diff --git a/app/templates/emails/verify.html b/app/templates/emails/verify.html
index a08b174..38d488b 100644
--- a/app/templates/emails/verify.html
+++ b/app/templates/emails/verify.html
@@ -1,4 +1,7 @@
-<h1>Hello!</h1>
+{% extends "emails/base.html" %}
+
+{% block content %}
+<h2 style="margin-top: 0;">Hello!</h2>
<p>
This email has been sent to you because someone (hopefully you)
@@ -6,12 +9,19 @@
</p>
<p>
- If this was you, then please click this link to verify the address:
- <a href="{{ url_for('verify_email_page', token=token, _external=True) }}">
- {{ url_for('verify_email_page', token=token, _external=True) }}
- </a>
+ If it wasn't you, then just delete this email.
</p>
<p>
- If it wasn't you, then just delete this email.
+ If this was you, then please click this link to verify the address:
</p>
+
+<a class="btn" href="{{ url_for('verify_email_page', token=token, _external=True) }}">
+ Confirm Email Address
+</a>
+
+<p style="font-size: 80%;">
+ Or paste this into your browser: {{ url_for('verify_email_page', token=token, _external=True) }}
+<p>
+
+{% endblock %}