add pgp key option

This commit is contained in:
Yannik Schmidt
2020-09-10 02:35:12 +02:00
parent 896315ce43
commit 77cbce717d
3 changed files with 34 additions and 9 deletions

View File

@@ -60,3 +60,5 @@ DISABLE_MAIN_LINKS = False
NAVBAR_LINKS = [ ("Navbar-Item1", "/target"), ("Navbar-Item2", "/target2") ] NAVBAR_LINKS = [ ("Navbar-Item1", "/target"), ("Navbar-Item2", "/target2") ]
IMPRESSUM_IS_CONTACT = True IMPRESSUM_IS_CONTACT = True
PGP_PUB_KEY_FILE = None

View File

@@ -431,7 +431,11 @@ def init():
@app.route("/contact") @app.route("/contact")
def contact(): def contact():
return flask.render_template("contact.html", conf=app.config) key=None
if app.config['PGP_PUB_KEY_FILE']:
with open(os.path.join(app.config["CONTENT_DIR"], app.config['PGP_PUB_KEY_FILE'])) as f:
key = f.read().strip()
return flask.render_template("contact.html", conf=app.config, PGP_KEY=key)
@app.route("/contact-api", methods=['POST']) @app.route("/contact-api", methods=['POST'])
def contactAPI(): def contactAPI():

View File

@@ -12,7 +12,7 @@
</head> </head>
<body> <body class="bg-secondary">
{% include 'navbar.html' %} {% include 'navbar.html' %}
{% include 'progress_window.html' %} {% include 'progress_window.html' %}
<div id="main-container" class="container" style="margin-top: 4vw;"> <div id="main-container" class="container" style="margin-top: 4vw;">
@@ -25,13 +25,13 @@
<form id="contact-form" name="contact-form"> <form id="contact-form" name="contact-form">
<!-- action="contact-api" method="POST" enctype='application/json'> --> <!-- action="contact-api" method="POST" enctype='application/json'> -->
<div class="row"> <div class="row">
<div class="col-md-6"> <div class="col-md-6 mt-2">
<div class="md-form mb-0"> <div class="md-form mb-0">
<input placeholder="{{ conf['CONTACT_PLACEHOLDER_NAME'] }}" <input placeholder="{{ conf['CONTACT_PLACEHOLDER_NAME'] }}"
type="text" id="name" name="name" class="form-control"> type="text" id="name" name="name" class="form-control">
</div> </div>
</div> </div>
<div class="col-md-6"> <div class="col-md-6 mt-2">
<div class="md-form mb-0"> <div class="md-form mb-0">
<input type="text" id="email" name="email" class="form-control" <input type="text" id="email" name="email" class="form-control"
placeholder="{{ conf['CONTACT_PLACEHOLDER_EMAIL'] }}"> placeholder="{{ conf['CONTACT_PLACEHOLDER_EMAIL'] }}">
@@ -51,26 +51,45 @@
<div class="row mt-2"> <div class="row mt-2">
<div class="col-md-12"> <div class="col-md-12">
<div class="md-form"> <div class="md-form">
<textarea type="text" id="message" name="message" rows="2" <textarea type="text" id="message" name="message" rows="10"
placeholder="{{ conf['CONTACT_PLACEHOLDER_TEXTAREA'] }}" placeholder="{{ conf['CONTACT_PLACEHOLDER_TEXTAREA'] }}"
class="form-control md-textarea"></textarea> class="form-control md-textarea"></textarea>
</div> </div>
</div> </div>
</div> </div>
</form> </form>
<div class="text-center text-md-left mt-2"> <div class="text-center text-md-left mt-4">
<a class="btn btn-primary" onclick="submitContactForm()">Send</a> <a class="btn btn-light w-50" onclick="submitContactForm()">Absenden</a>
</div> </div>
<div class="status"></div> <div class="status"></div>
</div> </div>
<div class="border p-3 col-md-3 text-center"> <div class="border p-3 col-md-3 text-center bg-special">
<ul class="list-unstyled mb-0"> <ul class="list-unstyled mb-0">
<li><i class="fas fa-envelope mt-4 fa-2x"></i> <li><i class="fas fa-envelope mt-4 fa-2x"></i>
<p>Wir freuen uns auf ihre Nachricht!</p></br> <p>Wir freuen uns auf ihre Nachricht!</p></br>
{% if conf['CONTACT_EMAIL'] %} {% if conf['CONTACT_EMAIL'] %}
<p>Selbsverständlich können sie uns auch per Mail kontaktieren.</p></br> <p>Selbsverständlich können sie uns auch per Mail kontaktieren.</p></br>
<a href="mailto:{{ conf['CONTACT_EMAIL'] }}">{{ conf['CONTACT_EMAIL'] }}</a> <a type="button" class="btn btn-light p-3 w-75"
href="mailto:{{ conf['CONTACT_EMAIL'] }}">{{ conf['CONTACT_EMAIL'] }}</a>
{% endif %}
{% if PGP_KEY %}
<script>
function copyPGP(){
navigator.clipboard.writeText("{{ PGP_KEY }}")
cur = document.getElementById("pgp").innerHTML
document.getElementById("pgp").innerHTML = "Kopiert!"
setTimeout(() => {
document.getElementById("pgp").innerHTML = "PGP Key" }, 2000);
}
</script>
<style>
.pgp{
}
</style>
<a id="pgp" onclick="copyPGP()" type="button"
class="pgp btn btn-light p-3 mt-3 w-75">PGP Key</a>
{% endif %} {% endif %}
</li> </li>
</ul> </ul>