From 83e8f5eab3d791b2c50bf03b5bea88a9b31c6517 Mon Sep 17 00:00:00 2001 From: Cyrille LOUARN Date: Thu, 4 Jan 2024 17:32:11 +0100 Subject: [PATCH] [1.10.0] 5000! 'manage footer_about.html' --- CHANGELOG.md | 5 ++- debian/control | 2 +- src/usr/bin/tyto | 29 +++++++++--------- src/var/lib/tyto/program/modules.py | 39 +++++++++++++++--------- src/var/lib/tyto/translations/logs_en.py | 6 ++++ src/var/lib/tyto/translations/logs_fr.py | 6 ++++ 6 files changed, 56 insertions(+), 31 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 57e5928..8f75117 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,9 +8,12 @@ Tyto - Littérateur # CURRENTLY IN DEV (in devel branch) ! +## [1.10.0] +- added management of optional footer_about.html file created by user (see [help modules]) + ## [1.9.58] - added [wip --static] to create static/ website server ('hidden' tool) -- - replace nginx comments modules call with contents modules in articles +- - replace nginx comments modules calls with contents modules in articles ## [1.9.57] - new "css" target. diff --git a/debian/control b/debian/control index 0884438..c0de372 100644 --- a/debian/control +++ b/debian/control @@ -1,5 +1,5 @@ Package: tyto -Version: 1.9.58 +Version: 1.10.0 Section: custom Priority: optional Architecture: all diff --git a/src/usr/bin/tyto b/src/usr/bin/tyto index 648b617..4262f18 100755 --- a/src/usr/bin/tyto +++ b/src/usr/bin/tyto @@ -1,5 +1,6 @@ #!/usr/bin/env python3 -# version: 1.9.58 +# version: 1.10.0 +# date: 2024/01/04 17:18:36 # Tyto - Littérateur # Copyright (C) 2023 Cyrille Louarn @@ -35,9 +36,9 @@ def check_install(): # Settings error = False lib_tyto = "/var/lib/tyto/%s" - + log_m = "! Tyto installation. Unused" - + # Files trees files = { "program" : ( @@ -66,7 +67,7 @@ def check_install(): "site_en", ), } - + for d in files: tyto_dir = lib_tyto%d if not os.path.exists(tyto_dir): @@ -96,7 +97,6 @@ if not __name__ == "__main__": # Check installed files check_install() - # Load some Tyto libs import langs, debug, args, domain @@ -134,16 +134,15 @@ import check, help, new, wip, publish, show # From command line [ACTION], do do = { - "check" : check.manage, - "help" : help.manage, - "new" : new.manage, - "publish" : publish.manage, - "wip" : wip.manage, - "show" : show.manage, - "start" : domain.manage, - "stop" : domain.manage, - - } + "check" : check.manage, + "help" : help.manage, + "new" : new.manage, + "publish" : publish.manage, + "wip" : wip.manage, + "show" : show.manage, + "start" : domain.manage, + "stop" : domain.manage, + } # Test for errors in python module file (without try) #do[args.action]() diff --git a/src/var/lib/tyto/program/modules.py b/src/var/lib/tyto/program/modules.py index 63402e4..b28eb82 100644 --- a/src/var/lib/tyto/program/modules.py +++ b/src/var/lib/tyto/program/modules.py @@ -75,6 +75,7 @@ def manage(module): "wip" : wip_dir + "footer.html", "www" : www_dir + "footer.html", "set" : set_footer_raw, + "usr" : wrk_dir + "footer_about.html", }, } @@ -84,24 +85,29 @@ def manage(module): cf_mod_load() mod_write = False + # Specific for footer_about.html + # ------------------------------ + try: fid = cf_mod.get("RAWS", "footer_usr") + except: fid = "" + fcid = "" + if os.path.exists(files["footer"]["usr"]): + fcid = tools.get_HID(files["footer"]["usr"], True) + if fcid != fid: + os.remove(files["footer"]["wrk"]) + cf_mod_set("RAWS", "footer_usr", fcid) + mod_write = True # Force create new raw module if new + [MODULE] is set from command line # ---------------------------------------------------------------------- - new_mod_raw = False if args.action == "new" and \ module in files and \ os.path.exists(files[module]["wrk"]): - raw_cid = tools.get_HID(files[module]["wrk"], True) - try: db_id = cf_mod.get("RAWS", module) - except: db_id = "" - if raw_cid != db_id: - new_mod_raw = True - - + os.remove(files[module]["wrk"]) + # Always check if raw modules exist or create them # ------------------------------------------------ for mod in files: - if not os.path.exists(files[mod]["wrk"]) or new_mod_raw: + if not os.path.exists(files[mod]["wrk"]): files[mod]["set"](mod) mod_write = True tools.create_file(files[mod]["wrk"], files[mod]["usr"]) @@ -116,8 +122,7 @@ def manage(module): cf_mod_write() cf_mod_load() mod_write = False - - + # From wip process, after article convertion # Create HTML modules in wip§ server # - if not exist or raw file has changed @@ -143,7 +148,6 @@ def manage(module): mod_write = False return - # When user wants to create again HTML module in wip/ server # ---------------------------------------------------------- if args.action == "wip": @@ -235,6 +239,7 @@ def set_header_raw(mod): files[mod]["www"], ) + header_raw + #===============================# # Set navbar.raw with help only # #-------------------------------# @@ -317,6 +322,13 @@ def set_footer_raw(mod): '%s'%langs.site.source_code + \ ']' + # If footer_about.html exists, insert its contents replacing site about + domain.conf["about"] = ''%domain.conf["about"] + footer_about_file = wrk_dir + "footer_about.html" + if os.path.exists(footer_about_file): + with open(footer_about_file, "r") as fa: + domain.conf["about"] = fa.read() + # Create full footer_raw contents footer_raw = footer_raw%( #

@@ -381,7 +393,6 @@ def create_navbar_html(html_file): # Item has a "title" set with # as separator set_dir = line.rstrip() - # Set_dir begins with "/" ; apply correction if set_dir.startswith("/"): set_dir = set_dir[1:] if set_dir.endswith("/"): set_dir = set_dir[:-1] @@ -609,7 +620,7 @@ footer_raw = """