diff --git a/CHANGELOG.md b/CHANGELOG.md index 7483915..bf478ec 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,10 @@ Tyto - Littérateur # CURRENTLY IN DEV (in devel branch) ! +## [1.9.55] +- update (work in progress) tpl_files/styles.css default doc references +- New manage() code in modules.py + ## [1.9.54] - update (work in progress) tpl_files/styles.css default doc references - fix + updated "code:" and bcode "{{...}}" CSS classes output HTML diff --git a/debian/control b/debian/control index 8c6f858..4933e7a 100644 --- a/debian/control +++ b/debian/control @@ -1,5 +1,5 @@ Package: tyto -Version: 1.9.54 +Version: 1.9.55 Section: custom Priority: optional Architecture: all diff --git a/src/usr/bin/tyto b/src/usr/bin/tyto index 19af905..4c6f0a6 100755 --- a/src/usr/bin/tyto +++ b/src/usr/bin/tyto @@ -1,5 +1,5 @@ #!/usr/bin/env python3 -# version: 1.9.54 +# version: 1.9.55 # Tyto - Littérateur # Copyright (C) 2023 Cyrille Louarn diff --git a/src/var/lib/tyto/program/args.py b/src/var/lib/tyto/program/args.py index 13247ef..92b872c 100644 --- a/src/var/lib/tyto/program/args.py +++ b/src/var/lib/tyto/program/args.py @@ -91,6 +91,7 @@ def get_arguments(): if commands["modules"]["modules"]: for arg in commands["modules"]: commands["modules"][arg] = True + commands["modules"]["modules"] = False # Register options for arg in commands["options"]: diff --git a/src/var/lib/tyto/program/modules.py b/src/var/lib/tyto/program/modules.py index 0313bad..63402e4 100644 --- a/src/var/lib/tyto/program/modules.py +++ b/src/var/lib/tyto/program/modules.py @@ -36,8 +36,8 @@ import args, domain, langs, tools, debug, form # All are called from file with nginx in web page # #-------------------------------------------------# def manage(module): - global files, wrk_dir, asked, mod_write, wip_dir - + global files, wrk_dir, wip_dir, www_dir, mod_write + # Set directories wrk_dir = domain.wrk_dirs["modules"] wip_dir = domain.wip_dirs["template"] @@ -78,66 +78,77 @@ def manage(module): }, } + # Load/Create new modules in DB file + # ---------------------------------- cf_mod_load() mod_write = False + - # Check/Set raw files in modules/ - for mod in files: - # For all modules to reset, confirm once - if os.path.exists(files[mod]["wrk"]): - if module == "all": - try: asked - except: form.ask_reset_modules() ; asked = True - - elif mod != module: - continue + # 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 - mod_write = True - files[mod]["set"](mod) - tools.create_file(files[mod]["wrk"], files[mod]["usr"]) - cid = tools.get_HID(files[mod]["wrk"], True) - cf_mod_set("RAWS", mod, cid) + + # 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: + files[mod]["set"](mod) + mod_write = True + tools.create_file(files[mod]["wrk"], files[mod]["usr"]) + cid = tools.get_HID(files[mod]["wrk"], True) + cf_mod_set("RAWS", mod, cid) + os.path.exists(files[mod]["wip"]) and os.remove(files[mod]["wip"]) + new_mod_raw = False + debug.out(250, mod, files[mod]["wrk"], True, 0, False) + + # Reload DB if updated + if mod_write: + cf_mod_write() + cf_mod_load() + mod_write = False - cf_mod_write() - if args.action == "new": - debug.out(250, module, wrk_dir, True, 0, False) - # When an article is "wip" - # - create html modules - # - - if not already exists - # - - if raw module has changed + # From wip process, after article convertion + # Create HTML modules in wip§ server + # - if not exist or raw file has changed + # ------------------------------------------ if module == "wip": for mod in files: - if os.path.exists(files[mod]["wip"]): - raw_cid = tools.get_HID(files[mod]["wrk"], True) - try: db_id = cf_mod.get("RAWS", mod) - except: db_id = "" - if raw_cid == db_id: - continue - else: - cf_mod_set("RAWS", mod, raw_cid) - mod_write = True + if not os.path.exists(files[mod]["wip"]): + create_htmls(mod) + continue - create_htmls(mod) + raw_cid = tools.get_HID(files[mod]["wrk"], True) + try: db_id = cf_mod.get("RAWS", mod) + except: db_id = "" + if raw_cid != db_id: + cf_mod_set("RAWS", mod, raw_cid) + mod_write = True + create_htmls(mod) - cf_mod_write() + # Reload DB if updated + if mod_write: + cf_mod_write() + cf_mod_load() + mod_write = False + return + + + # When user wants to create again HTML module in wip/ server + # ---------------------------------------------------------- + if args.action == "wip": + create_htmls(module) - # When user wants to force update HTML modules - # using wip [MODULE] ; called in wip.py - elif module == "update": - # Create again ALL modules in wip/template - if args.commands["modules"]["modules"]: - for mod in files: - if os.path.exists(files[mod]["wip"]): - create_htmls(mod) - # Create again specific module from command line - else: - for mod in args.commands["modules"]: - if args.commands["modules"][mod]: - if os.path.exists(files[mod]["wip"]): - create_htmls(mod) - #=======================================# # Manage modules configuration ini file #====================================== @@ -353,7 +364,7 @@ def create_htmls(mod): html_file = "%s\n%s"%(html_file, line) tools.create_file(files[mod]["wip"], html_file) - debug.out(250, mod, wip_dir, True, 0, False) + debug.out(250, mod, files[mod]["wip"], True, 0, False) #==============================================# diff --git a/src/var/lib/tyto/program/new.py b/src/var/lib/tyto/program/new.py index 5e51de2..3d3ec5c 100644 --- a/src/var/lib/tyto/program/new.py +++ b/src/var/lib/tyto/program/new.py @@ -25,6 +25,10 @@ import args, domain, form, modules, sitemap + +#========================================# +# Manage new domain and modules creation # +#----------------------------------------# def manage(): if args.commands["targets"]["domain"]: domain.set_name() @@ -37,14 +41,10 @@ def manage(): return domain.is_active() - if args.commands["modules"]["modules"]: - modules.manage("all") - return - - args.commands["modules"]["metas"] and modules.manage("metas") - args.commands["modules"]["header"] and modules.manage("header") - args.commands["modules"]["navbar"] and modules.manage("navbar") - args.commands["modules"]["sidebar"] and modules.manage("sidebar") - args.commands["modules"]["footer"] and modules.manage("footer") + + # Some modules was set in arguments + for mod in args.commands["modules"]: + if args.commands["modules"][mod]: + modules.manage(mod) args.commands["targets"]["sitemap"] and sitemap.create() diff --git a/src/var/lib/tyto/program/show.py b/src/var/lib/tyto/program/show.py index 14df49d..4808386 100644 --- a/src/var/lib/tyto/program/show.py +++ b/src/var/lib/tyto/program/show.py @@ -36,11 +36,7 @@ def manage(): # "all" is not a valid argument here if args.commands["targets"]["all"]: debug.out(2, "all ?", "", True, 2, True) - - # Avoid error where "modules" is for "all", not a real module - if args.commands["modules"]["modules"]: - args.commands["modules"]["modules"] = False - + # User selected modules for arg in args.commands["modules"]: if args.commands["modules"][arg]: diff --git a/src/var/lib/tyto/program/wip.py b/src/var/lib/tyto/program/wip.py index bc8e8b2..9ae892d 100644 --- a/src/var/lib/tyto/program/wip.py +++ b/src/var/lib/tyto/program/wip.py @@ -43,10 +43,10 @@ def manage(): elif args.commands["targets"]["*.tyto"]: article() - elif args.set_module: - for set_module in args.commands["modules"]: - if args.commands["modules"][set_module]: - modules.manage("update") + + for mod in args.commands["modules"]: + if args.commands["modules"][mod]: + modules.manage(mod) #======================================================================# diff --git a/src/var/lib/tyto/tpl_files/styles.css b/src/var/lib/tyto/tpl_files/styles.css index fc1c1fe..64cfcc2 100644 --- a/src/var/lib/tyto/tpl_files/styles.css +++ b/src/var/lib/tyto/tpl_files/styles.css @@ -52,6 +52,20 @@ h6.tyto {} ul.tyto {} ol.tyto {} li.tyto {} + +/* Words tags */ +br.tyto {} +hr.tyto {} +strong.tyto {} +bold.tyto {} +q.tyto {} +cite.tyto {} +u.tyto {} +em.tyto {} +i.tyto {} +del.tyto {} +span.tyto {} + /* - BlockCode "{{...}}" * defaylt "bcode". If Class set: "bcode" is replaced. i.e pre.MYCSS_pre