emails: add email template viewer
This commit is contained in:
parent
b662fad09e
commit
195f0bb5d8
3 changed files with 110 additions and 0 deletions
17
emails/email-template-viewer.html
Normal file
17
emails/email-template-viewer.html
Normal file
|
@ -0,0 +1,17 @@
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<title>Email Template Viewer</title>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<h1>Email Template Viewer</h1>
|
||||||
|
Here is a list of the templates available:
|
||||||
|
<ul>
|
||||||
|
{% for template in templates %}
|
||||||
|
{% if template != 'email-template-viewer' %}
|
||||||
|
<li><a href="{{template}}">{{template}}</a></li>
|
||||||
|
{% endif %}
|
||||||
|
{% endfor %}
|
||||||
|
</ul>
|
||||||
|
</body>
|
||||||
|
</html>
|
87
tools/email-viewer/emails.py
Normal file
87
tools/email-viewer/emails.py
Normal file
|
@ -0,0 +1,87 @@
|
||||||
|
from flask import Flask, render_template
|
||||||
|
import datetime
|
||||||
|
import os
|
||||||
|
|
||||||
|
tmpl_dir = '../../emails'
|
||||||
|
|
||||||
|
app = Flask(__name__, template_folder=tmpl_dir)
|
||||||
|
|
||||||
|
@app.template_filter()
|
||||||
|
def user_reference_filter(value):
|
||||||
|
return value
|
||||||
|
|
||||||
|
@app.template_filter()
|
||||||
|
def admin_reference(value):
|
||||||
|
return value
|
||||||
|
|
||||||
|
@app.template_filter()
|
||||||
|
def repository_reference(value):
|
||||||
|
return value
|
||||||
|
|
||||||
|
@app.template_filter()
|
||||||
|
def team_reference(value):
|
||||||
|
return value
|
||||||
|
|
||||||
|
app.jinja_env.filters['user_reference'] = user_reference_filter
|
||||||
|
app.jinja_env.filters['admin_reference'] = admin_reference
|
||||||
|
app.jinja_env.filters['repository_reference'] = repository_reference
|
||||||
|
app.jinja_env.filters['team_reference'] = team_reference
|
||||||
|
|
||||||
|
|
||||||
|
def app_link_handler(url=None, title=None):
|
||||||
|
""" Just because it is in the original email tempaltes """
|
||||||
|
return 'http://example.com/example'
|
||||||
|
|
||||||
|
def render_with_options(template=None):
|
||||||
|
""" Pass a bunch of common variables when rendering templates """
|
||||||
|
return render_template(template, username="exampleuser", user_reference="testing",
|
||||||
|
app_logo="https://quay.io/static/img/quay-horizontal-color.svg", token="sdf8SdfKGRME9dse_dfdf",
|
||||||
|
app_link=app_link_handler, namespace="booboo", repository="foobar", organization="buynlarge",
|
||||||
|
admin_usernames=["lazercat", "booboocoreos"], teamname="creators", inviter="devtable")
|
||||||
|
|
||||||
|
def get_templates():
|
||||||
|
""" Return a list of the available templates """
|
||||||
|
return [t.replace('.html', '') for t in os.listdir('../../emails')]
|
||||||
|
|
||||||
|
@app.route("/")
|
||||||
|
def template_test():
|
||||||
|
return render_template('email-template-viewer.html', templates=get_templates())
|
||||||
|
|
||||||
|
@app.route("/changeemail")
|
||||||
|
def changeemail():
|
||||||
|
return render_with_options('changeemail.html');
|
||||||
|
|
||||||
|
@app.route("/confirmemail")
|
||||||
|
def confirmemail():
|
||||||
|
return render_with_options('confirmemail.html');
|
||||||
|
|
||||||
|
@app.route("/emailchanged")
|
||||||
|
def emailchanged():
|
||||||
|
return render_with_options('emailchanged.html');
|
||||||
|
|
||||||
|
@app.route("/orgrecovery")
|
||||||
|
def orgrecovery():
|
||||||
|
return render_with_options('orgrecovery.html');
|
||||||
|
|
||||||
|
@app.route("/passwordchanged")
|
||||||
|
def passwordchanged():
|
||||||
|
return render_with_options('passwordchanged.html');
|
||||||
|
|
||||||
|
@app.route("/paymentfailure")
|
||||||
|
def paymentfailure():
|
||||||
|
return render_with_options('paymentfailure.html');
|
||||||
|
|
||||||
|
@app.route("/recovery")
|
||||||
|
def recovery():
|
||||||
|
return render_with_options('recovery.html');
|
||||||
|
|
||||||
|
@app.route("/repoauthorizeemail")
|
||||||
|
def repoauthorizeemail():
|
||||||
|
return render_with_options('repoauthorizeemail.html');
|
||||||
|
|
||||||
|
@app.route("/teaminvite")
|
||||||
|
def teaminvite():
|
||||||
|
return render_with_options('teaminvite.html');
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
app.run(debug=True)
|
6
tools/email-viewer/requirements.txt
Normal file
6
tools/email-viewer/requirements.txt
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
Flask==0.10.1
|
||||||
|
Jinja2==2.7.2
|
||||||
|
MarkupSafe==0.18
|
||||||
|
Werkzeug==0.9.4
|
||||||
|
itsdangerous==0.23
|
||||||
|
wsgiref==0.1.2
|
Reference in a new issue