From f2396c32a5bd1c9b49e073e3a23d0fa556e92019 Mon Sep 17 00:00:00 2001 From: Adrien Beudin Date: Tue, 3 Oct 2017 00:43:29 +0200 Subject: [PATCH] [enh] auto login --- prosopopee/prosopopee.py | 9 ++- .../themes/exposure/templates/encrypted.html | 12 +++- .../themes/exposure/templates/form.html | 2 +- .../exposure/templates/index-encrypted.html | 66 ------------------ .../themes/light/templates/encrypted.html | 51 +++++--------- prosopopee/themes/light/templates/form.html | 25 +++++++ .../themes/material/templates/encrypted.html | 14 ++-- .../themes/material/templates/form.html | 2 +- .../material/templates/index-encrypted.html | 69 ------------------- 9 files changed, 71 insertions(+), 179 deletions(-) delete mode 100644 prosopopee/themes/exposure/templates/index-encrypted.html create mode 100644 prosopopee/themes/light/templates/form.html delete mode 100644 prosopopee/themes/material/templates/index-encrypted.html diff --git a/prosopopee/prosopopee.py b/prosopopee/prosopopee.py index 116820c..f98417a 100644 --- a/prosopopee/prosopopee.py +++ b/prosopopee/prosopopee.py @@ -480,9 +480,9 @@ def build_gallery(settings, gallery_settings, gallery_path, template): open(Path("build").joinpath(gallery_path, "index.html"), "wb").write(html) if gallery_settings.get("password") or settings.get("password"): + form = base64.b64encode(from_template.render(gallery=gallery_settings, settings=settings).encode("Utf-8")) password = gallery_settings.get("password", settings.get("password")) index_plain = Path("build").joinpath(gallery_path, "index.html") - form = base64.b64encode(from_template.render(gallery=gallery_settings).encode("Utf-8")) encrypted = check_output('cat %s | openssl enc -e -base64 -A -aes-256-cbc -pass pass:"%s"' % (index_plain, password), shell=True) html = encrypted_template.render( settings=settings, @@ -531,7 +531,7 @@ def build_gallery(settings, gallery_settings, gallery_path, template): if gallery_settings.get("password") or settings.get("password"): light_template_to_render = light_templates.get_template("encrypted.html") from_template = light_templates.get_template("form.html") - form = base64.b64encode(from_template.render(gallery=gallery_settings).encode("Utf-8")) + form = base64.b64encode(from_template.render(gallery=gallery_settings, settings=settings).encode("Utf-8")) template_to_render = encrypted_template password = gallery_settings.get("password", settings.get("password")) index_plain = Path("build").joinpath(gallery_light_path, "index.html") @@ -548,6 +548,7 @@ def build_gallery(settings, gallery_settings, gallery_path, template): def build_index(settings, galleries_cover, templates, gallery_path='', sub_index=False, gallery_settings={}): index_template = templates.get_template("index.html") + form_template = templates.get_template("form.html") reverse = gallery_settings.get('reverse', settings["settings"].get('reverse', False)) if reverse: @@ -573,12 +574,14 @@ def build_index(settings, galleries_cover, templates, gallery_path='', sub_index open(Path("build").joinpath(gallery_path, "index.html"), "wb").write(html) if settings.get("password"): - index_template_to_render = templates.get_template("index-encrypted.html") + form = base64.b64encode(form_template.render(settings=settings).encode("Utf-8")) + index_template_to_render = templates.get_template("encrypted.html") password = settings.get("password") index_plain = Path("build").joinpath(gallery_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 = index_template_to_render.render( settings=settings, + form=str(form, 'utf-8'), ciphertext=str(encrypted, 'utf-8') ).encode("Utf-8") diff --git a/prosopopee/themes/exposure/templates/encrypted.html b/prosopopee/themes/exposure/templates/encrypted.html index 4293204..bbf2764 100644 --- a/prosopopee/themes/exposure/templates/encrypted.html +++ b/prosopopee/themes/exposure/templates/encrypted.html @@ -1,8 +1,13 @@ +{% if gallery %} +{% set pathstatic = ".." %} +{% else %} +{% set pathstatic = "." %} +{% endif %} - {{ gallery.title }} · {{ settings.title }} + {% if gallery %}{{ gallery.title }} · {% endif %}{{ settings.title }} @@ -11,10 +16,10 @@ - + - + - - - - diff --git a/prosopopee/themes/light/templates/encrypted.html b/prosopopee/themes/light/templates/encrypted.html index cf25e47..c230124 100644 --- a/prosopopee/themes/light/templates/encrypted.html +++ b/prosopopee/themes/light/templates/encrypted.html @@ -7,7 +7,7 @@ - {{ gallery.title }} · {{ settings.title }} + {% if gallery %}{{ gallery.title }} · {% endif %}{{ settings.title }} @@ -18,52 +18,39 @@ + + - - + diff --git a/prosopopee/themes/light/templates/form.html b/prosopopee/themes/light/templates/form.html new file mode 100644 index 0000000..f958c6c --- /dev/null +++ b/prosopopee/themes/light/templates/form.html @@ -0,0 +1,25 @@ + +
+
+
+

{% if gallery %}{{ gallery.title }}{% else %}{{ settings.title }}{% endif %}

+
+ +
+ +
+
+ + + +
+
+ +
+ diff --git a/prosopopee/themes/material/templates/encrypted.html b/prosopopee/themes/material/templates/encrypted.html index b16be9d..47272fa 100644 --- a/prosopopee/themes/material/templates/encrypted.html +++ b/prosopopee/themes/material/templates/encrypted.html @@ -1,8 +1,13 @@ +{% if gallery %} +{% set pathstatic = ".." %} +{% else %} +{% set pathstatic = "." %} +{% endif %} - {{ gallery.title }} · {{ settings.title }} + {% if gallery %}{{ gallery.title }} · {% endif %}{{ settings.title }} @@ -11,10 +16,10 @@ - - + + - + - - -