[fix] encrypt the light page
This commit is contained in:
parent
1a2e692a02
commit
e19c64393a
@ -473,6 +473,7 @@ def build_gallery(settings, gallery_settings, gallery_path, template):
|
|||||||
link=gallery_path,
|
link=gallery_path,
|
||||||
name=gallery_path.split('/', 1)[-1]
|
name=gallery_path.split('/', 1)[-1]
|
||||||
).encode("Utf-8")
|
).encode("Utf-8")
|
||||||
|
|
||||||
open(Path("build").joinpath(gallery_path, "index.html"), "wb").write(html)
|
open(Path("build").joinpath(gallery_path, "index.html"), "wb").write(html)
|
||||||
|
|
||||||
if gallery_settings.get("password"):
|
if gallery_settings.get("password"):
|
||||||
@ -485,6 +486,7 @@ def build_gallery(settings, gallery_settings, gallery_path, template):
|
|||||||
gallery=gallery_settings,
|
gallery=gallery_settings,
|
||||||
ciphertext=str(encrypted, 'utf-8'),
|
ciphertext=str(encrypted, 'utf-8'),
|
||||||
).encode("Utf-8")
|
).encode("Utf-8")
|
||||||
|
|
||||||
open(Path("build").joinpath(gallery_path, "index.html"), "wb").write(html)
|
open(Path("build").joinpath(gallery_path, "index.html"), "wb").write(html)
|
||||||
|
|
||||||
# XXX shouldn't this be a call to build_gallery?
|
# XXX shouldn't this be a call to build_gallery?
|
||||||
@ -522,6 +524,20 @@ def build_gallery(settings, gallery_settings, gallery_path, template):
|
|||||||
|
|
||||||
open(Path("build").joinpath(gallery_light_path, "index.html"), "wb").write(html)
|
open(Path("build").joinpath(gallery_light_path, "index.html"), "wb").write(html)
|
||||||
|
|
||||||
|
if gallery_settings.get("password"):
|
||||||
|
light_template_to_render = light_templates.get_template("encrypted.html")
|
||||||
|
template_to_render = encrypted_template
|
||||||
|
password = gallery_settings.get("password")
|
||||||
|
index_plain = Path("build").joinpath(gallery_light_path, "index.html")
|
||||||
|
encrypted = check_output('cat %s | openssl enc -e -base64 -A -aes-256-cbc -pass pass:"%s"' % (index_plain, password), shell=True)
|
||||||
|
html = light_template_to_render.render(
|
||||||
|
settings=settings,
|
||||||
|
gallery=gallery_settings,
|
||||||
|
ciphertext=str(encrypted, 'utf-8'),
|
||||||
|
).encode("Utf-8")
|
||||||
|
|
||||||
|
open(Path("build").joinpath(gallery_light_path, "index.html"), "wb").write(html)
|
||||||
|
|
||||||
|
|
||||||
def build_index(settings, galleries_cover, templates, gallery_path='', sub_index=False, gallery_settings={}):
|
def build_index(settings, galleries_cover, templates, gallery_path='', sub_index=False, gallery_settings={}):
|
||||||
index_template = templates.get_template("index.html")
|
index_template = templates.get_template("index.html")
|
||||||
|
@ -296,3 +296,70 @@ span.left img, span.right img {
|
|||||||
.clear {
|
.clear {
|
||||||
clear: both;
|
clear: both;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.staticrypt-hr {
|
||||||
|
margin-top: 20px;
|
||||||
|
margin-bottom: 20px;
|
||||||
|
border: 0;
|
||||||
|
border-top: 1px solid #eee;
|
||||||
|
}
|
||||||
|
|
||||||
|
.staticrypt-page {
|
||||||
|
width: 360px;
|
||||||
|
padding: 8% 0 0;
|
||||||
|
margin: auto;
|
||||||
|
box-sizing: border-box;
|
||||||
|
}
|
||||||
|
|
||||||
|
.staticrypt-form {
|
||||||
|
position: relative;
|
||||||
|
z-index: 1;
|
||||||
|
background: #FFFFFF;
|
||||||
|
max-width: 360px;
|
||||||
|
margin: 0 auto 100px;
|
||||||
|
padding: 45px;
|
||||||
|
text-align: center;
|
||||||
|
box-shadow: 0 0 20px 0 rgba(0, 0, 0, 0.2), 0 5px 5px 0 rgba(0, 0, 0, 0.24);
|
||||||
|
}
|
||||||
|
|
||||||
|
.staticrypt-form input {
|
||||||
|
outline: 0;
|
||||||
|
background: #292525;
|
||||||
|
width: 100%;
|
||||||
|
border: 0;
|
||||||
|
margin: 0 0 15px;
|
||||||
|
padding: 15px;
|
||||||
|
box-sizing: border-box;
|
||||||
|
font-size: 14px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.staticrypt-form .staticrypt-decrypt-button {
|
||||||
|
text-transform: uppercase;
|
||||||
|
outline: 0;
|
||||||
|
background: #91C25F;
|
||||||
|
width: 100%;
|
||||||
|
border: 0;
|
||||||
|
padding: 15px;
|
||||||
|
color: #FFFFFF;
|
||||||
|
font-size: 14px;
|
||||||
|
cursor: pointer;
|
||||||
|
}
|
||||||
|
|
||||||
|
.staticrypt-html {
|
||||||
|
height: 100%;
|
||||||
|
}
|
||||||
|
|
||||||
|
.staticrypt-body {
|
||||||
|
background: #FFF; /* fallback for old browsers */
|
||||||
|
font-family: "Arial", sans-serif;
|
||||||
|
}
|
||||||
|
|
||||||
|
.staticrypt-instructions {
|
||||||
|
margin-top: -1em;
|
||||||
|
margin-bottom: 1em;
|
||||||
|
}
|
||||||
|
|
||||||
|
.staticrypt-title {
|
||||||
|
font-size: 1.5em;
|
||||||
|
}
|
||||||
|
|
||||||
|
3
prosopopee/themes/light/static/js/crypto-js.min.js
vendored
Normal file
3
prosopopee/themes/light/static/js/crypto-js.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
69
prosopopee/themes/light/templates/encrypted.html
Normal file
69
prosopopee/themes/light/templates/encrypted.html
Normal file
@ -0,0 +1,69 @@
|
|||||||
|
{% if settings.settings.light_mode %}
|
||||||
|
{% set pathstatic = "." %}
|
||||||
|
{% else %}
|
||||||
|
{% set pathstatic = ".." %}
|
||||||
|
{% endif %}
|
||||||
|
<!doctype html>
|
||||||
|
<html class="staticrypt-html">
|
||||||
|
<head>
|
||||||
|
<meta charset="utf-8">
|
||||||
|
<title>{{ gallery.title }} · {{ settings.title }}</title>
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||||
|
|
||||||
|
<!-- do not cache this page -->
|
||||||
|
<meta http-equiv="cache-control" content="max-age=0"/>
|
||||||
|
<meta http-equiv="cache-control" content="no-cache"/>
|
||||||
|
<meta http-equiv="expires" content="0"/>
|
||||||
|
<meta http-equiv="expires" content="Tue, 01 Jan 1980 1:00:00 GMT"/>
|
||||||
|
<meta http-equiv="pragma" content="no-cache"/>
|
||||||
|
<link type="text/css" rel="stylesheet" href="{{ pathstatic }}/static/css/style-page.css" media="screen,projection"/>
|
||||||
|
</head>
|
||||||
|
|
||||||
|
<body class="staticrypt-body">
|
||||||
|
<div class="staticrypt-page">
|
||||||
|
<div class="staticrypt-form">
|
||||||
|
<div class="staticrypt-instructions">
|
||||||
|
<p class="staticrypt-title">{{ gallery.title }}</p>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<hr class="staticrypt-hr">
|
||||||
|
|
||||||
|
<form id="staticrypt-form" action="#" method="post">
|
||||||
|
<div id="error" style="color: red; padding-bottom: 10px; height: 20px;"></div>
|
||||||
|
<input id="staticrypt-password"
|
||||||
|
type="password"
|
||||||
|
name="password"
|
||||||
|
placeholder="passphrase"
|
||||||
|
autofocus/>
|
||||||
|
|
||||||
|
<input type="submit" class="staticrypt-decrypt-button" value="ENTER"/>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
<footer>
|
||||||
|
<p>Generated using <a href="https://github.com/psycojoker/prosopopee">Prosopopée</a> · content under <a href="https://creativecommons.org/licenses/by-sa/3.0/">CC-BY-SA</a> · atom logo by <a href="https://thenounproject.com/jjjon/">Jonathan Li</a> under <a href="https://creativecommons.org/licenses/by/3.0/">CC-BY</a></p>
|
||||||
|
</footer>
|
||||||
|
<script type="text/javascript" src="{{ pathstatic }}/static/js/crypto-js.min.js" charset="utf-8"></script>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
document.getElementById('staticrypt-form').addEventListener('submit', function(e) {
|
||||||
|
e.preventDefault();
|
||||||
|
|
||||||
|
var passphrase = document.getElementById('staticrypt-password').value,
|
||||||
|
encryptedMsg = '{{ ciphertext }}';
|
||||||
|
|
||||||
|
try{
|
||||||
|
var plainHTML = CryptoJS.AES.decrypt(encryptedMsg, passphrase).toString(CryptoJS.enc.Utf8);
|
||||||
|
}
|
||||||
|
catch(err) {
|
||||||
|
document.getElementById("error").innerHTML = "Wrong keyword entry."
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
document.write(plainHTML);
|
||||||
|
document.close();
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
</body>
|
||||||
|
</html>
|
@ -8,6 +8,7 @@
|
|||||||
{% set pathstatic = ".." %}
|
{% set pathstatic = ".." %}
|
||||||
{% else %}
|
{% else %}
|
||||||
{% set pathstatic = "." %}
|
{% set pathstatic = "." %}
|
||||||
|
{% set audio = Audio(section.image) %}
|
||||||
{{ audio.copy() }}
|
{{ audio.copy() }}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% set audio = Audio(section.image) %}
|
{% set audio = Audio(section.image) %}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user