From 2c2895c3a32bdcfe7a893e3ff1c8a3e1a7c08949 Mon Sep 17 00:00:00 2001 From: Quentin Schulz Date: Sat, 9 Jan 2021 14:03:33 +0100 Subject: [PATCH 01/11] move remove_superficial_options into utils This move makes sense if one wants to reuse remove_superficial_options since it can be not specific to cache.py only. This prepares prosopopee for Pillow support. Signed-off-by: Quentin Schulz --- prosopopee/cache.py | 16 ++-------------- prosopopee/utils.py | 14 ++++++++++++++ 2 files changed, 16 insertions(+), 14 deletions(-) diff --git a/prosopopee/cache.py b/prosopopee/cache.py index d7f6c731..614cbc82 100644 --- a/prosopopee/cache.py +++ b/prosopopee/cache.py @@ -1,21 +1,9 @@ import os import json -CACHE_VERSION = 2 - +from .utils import remove_superficial_options -def remove_superficial_options(options): - cleaned_options = options.copy() - del cleaned_options["name"] - if "text" in cleaned_options: - del cleaned_options["text"] - if "type" in cleaned_options: - del cleaned_options["type"] - if "size" in cleaned_options: - del cleaned_options["size"] - if "float" in cleaned_options: - del cleaned_options["float"] - return cleaned_options +CACHE_VERSION = 2 class Cache: diff --git a/prosopopee/utils.py b/prosopopee/utils.py index 848c2af9..6e9e1ec1 100644 --- a/prosopopee/utils.py +++ b/prosopopee/utils.py @@ -10,6 +10,20 @@ import ruamel.yaml as yaml +def remove_superficial_options(options): + cleaned_options = options.copy() + del cleaned_options["name"] + if "text" in cleaned_options: + del cleaned_options["text"] + if "type" in cleaned_options: + del cleaned_options["type"] + if "size" in cleaned_options: + del cleaned_options["size"] + if "float" in cleaned_options: + del cleaned_options["float"] + return cleaned_options + + class CustomFormatter(logging.Formatter): """Logging Formatter to add colors""" From 330fcd414df4b2bf418ad76945892b1a8ca640ba Mon Sep 17 00:00:00 2001 From: Quentin Schulz Date: Sat, 13 Feb 2021 14:32:27 +0100 Subject: [PATCH 02/11] prosopopee: do not dump cache when doing a dry run Dry runs (`prosopopee test`) shouldn't dump the cache since nothing's done except creating the HTML files which means the cache is more or less meaningless in that case. Let's dump the cache only when doing a normal build run. Signed-off-by: Quentin Schulz --- prosopopee/prosopopee.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/prosopopee/prosopopee.py b/prosopopee/prosopopee.py index dc56ba18..e315c7d5 100644 --- a/prosopopee/prosopopee.py +++ b/prosopopee/prosopopee.py @@ -880,10 +880,12 @@ def main(): open(Path("build").joinpath("feed.xml"), "wb").write(xml) build_index(settings, front_page_galleries_cover, templates) - CACHE.cache_dump() if DEFAULTS["test"] is True: logging.info("Success: HTML file building without error") + sys.exit(0) + + CACHE.cache_dump() if __name__ == "__main__": From ef3a5eea89d1283d53412fd6ea58d6f6e82dbc7a Mon Sep 17 00:00:00 2001 From: Quentin Schulz Date: Sat, 13 Feb 2021 14:41:59 +0100 Subject: [PATCH 03/11] themes: remove unnecessary calls to copy() For images, calls to copy() is only needed when later in the template {{ image }} is used. Removing those copy() as they trigger creation of thumbnails that will never be used. Signed-off-by: Quentin Schulz --- prosopopee/themes/exposure/templates/index.html | 1 - prosopopee/themes/exposure/templates/opengraph.html | 1 - prosopopee/themes/exposure/templates/sections/author.html | 1 - prosopopee/themes/exposure/templates/sections/panorama.html | 1 - prosopopee/themes/light/templates/index.html | 1 - prosopopee/themes/light/templates/opengraph.html | 1 - prosopopee/themes/light/templates/sections/author.html | 1 - prosopopee/themes/light/templates/sections/bordered-picture.html | 1 - prosopopee/themes/light/templates/sections/full-picture.html | 1 - prosopopee/themes/light/templates/sections/panorama.html | 1 - prosopopee/themes/light/templates/sections/paragraph.html | 1 - prosopopee/themes/light/templates/sections/pictures-group.html | 1 - prosopopee/themes/material/templates/index.html | 1 - prosopopee/themes/material/templates/opengraph.html | 1 - prosopopee/themes/material/templates/sections/author.html | 1 - 15 files changed, 15 deletions(-) diff --git a/prosopopee/themes/exposure/templates/index.html b/prosopopee/themes/exposure/templates/index.html index 5f41099d..08df9547 100644 --- a/prosopopee/themes/exposure/templates/index.html +++ b/prosopopee/themes/exposure/templates/index.html @@ -52,7 +52,6 @@

{{ gallery.title }}

{% else %} {% set cover = Image(gallery.cover) %} - {{ cover.copy() }} {% if no_big_gallery_cover %} {% else %} diff --git a/prosopopee/themes/exposure/templates/opengraph.html b/prosopopee/themes/exposure/templates/opengraph.html index 6632a209..0f9df5a7 100644 --- a/prosopopee/themes/exposure/templates/opengraph.html +++ b/prosopopee/themes/exposure/templates/opengraph.html @@ -1,6 +1,5 @@ {% set absolute_url = settings.url + "/" + link + "/" %} {% set cover = Image(gallery.cover) %} -{{ cover.copy() }} diff --git a/prosopopee/themes/exposure/templates/sections/author.html b/prosopopee/themes/exposure/templates/sections/author.html index fb51ed04..449812f2 100644 --- a/prosopopee/themes/exposure/templates/sections/author.html +++ b/prosopopee/themes/exposure/templates/sections/author.html @@ -1,5 +1,4 @@ {% set image = Image(section.image) %} -{{ image.copy() }}
diff --git a/prosopopee/themes/exposure/templates/sections/panorama.html b/prosopopee/themes/exposure/templates/sections/panorama.html index e019744d..c20a3dcd 100644 --- a/prosopopee/themes/exposure/templates/sections/panorama.html +++ b/prosopopee/themes/exposure/templates/sections/panorama.html @@ -1,5 +1,4 @@ {% set image = Image(section.image) %} -{{ image.copy() }}
diff --git a/prosopopee/themes/light/templates/index.html b/prosopopee/themes/light/templates/index.html index 75d4f332..f18d4205 100644 --- a/prosopopee/themes/light/templates/index.html +++ b/prosopopee/themes/light/templates/index.html @@ -39,7 +39,6 @@

{{ gallery.title }}

{{ video.copy() }} {% else %} {% set cover = Image(gallery.cover) %} - {{ cover.copy() }} {% endif %} {% if video %}