From 4e20f74907fdd529954108dfda4b77155e96af68 Mon Sep 17 00:00:00 2001 From: Thomas Nonglaton Date: Sat, 3 Jun 2017 12:32:43 +0200 Subject: [PATCH 1/2] Avoid failure if no sections is specified in gallery --- prosopopee/prosopopee.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/prosopopee/prosopopee.py b/prosopopee/prosopopee.py index 0be5fae..146ad88 100644 --- a/prosopopee/prosopopee.py +++ b/prosopopee/prosopopee.py @@ -441,10 +441,10 @@ def build_gallery(settings, gallery_settings, gallery_path, template): Audio.base_dir = Path(".").joinpath(gallery_path) Audio.target_dir = Path(".").joinpath("build", gallery_path) - - for x in gallery_settings['sections']: - if x['type'] not in gallery_settings: - gallery_settings[x['type'] + '_enabled'] = True + if gallery_settings.get("sections"): + for x in gallery_settings['sections']: + if x['type'] not in gallery_settings: + gallery_settings[x['type'] + '_enabled'] = True template_to_render = page_template if gallery_settings.get("static") else gallery_index_template @@ -547,7 +547,7 @@ def main(): error(os.system("which rsync > /dev/null") == 0, "I can't locate the rsync, " "please install the 'rsync' package.\n") error(Path("build").exists(), "Please build the website before launch deployment") - + r_dest = settings["settings"]["deploy"]["dest"] if settings["settings"]["deploy"]["others"]: r_others = settings["settings"]["deploy"]["others"] From 2eb4f8a15a415150093c976b4ff2389d21695123 Mon Sep 17 00:00:00 2001 From: Thomas Nonglaton Date: Sat, 3 Jun 2017 13:23:56 +0200 Subject: [PATCH 2/2] Allow reverse & normal order in index --- prosopopee/prosopopee.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/prosopopee/prosopopee.py b/prosopopee/prosopopee.py index 146ad88..6e4bb66 100644 --- a/prosopopee/prosopopee.py +++ b/prosopopee/prosopopee.py @@ -391,7 +391,7 @@ def process_directory(gallery_name, settings, parent_templates, parent_gallery_p process_directory(subgallery.name, settings, subgallery_templates, gallery_path) ) - build_index(settings, sub_page_galleries_cover, subgallery_templates, gallery_path, sub_index=True) + build_index(settings, sub_page_galleries_cover, subgallery_templates, gallery_path, sub_index=True, gallery_settings=gallery_settings) gallery_cover['sub_gallery'] = sub_page_galleries_cover return gallery_cover @@ -496,10 +496,13 @@ def build_gallery(settings, gallery_settings, gallery_path, template): open(Path("build").joinpath(gallery_light_path, "index.html"), "w").write(html) -def build_index(settings, galleries_cover, templates, gallery_path='', sub_index=False): +def build_index(settings, galleries_cover, templates, gallery_path='', sub_index=False, gallery_settings={}): index_template = templates.get_template("index.html") - - galleries_cover = reversed(sorted(filter(lambda x: x != {}, galleries_cover), key=lambda x: x["date"])) + reverse = gallery_settings.get('reverse', settings.get('reverse', True)) + if reverse: + galleries_cover = reversed(sorted(filter(lambda x: x != {}, galleries_cover), key=lambda x: x["date"])) + else: + galleries_cover = sorted(filter(lambda x: x != {}, galleries_cover), key=lambda x: x["date"]) # this should probably be a factory Image.base_dir = Path(".").joinpath(gallery_path)