This commit is contained in:
Cyrille L 2023-12-31 18:03:39 +01:00
parent b6686a0ebd
commit 33a4c24e47
9 changed files with 97 additions and 71 deletions

View File

@ -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

2
debian/control vendored
View File

@ -1,5 +1,5 @@
Package: tyto
Version: 1.9.54
Version: 1.9.55
Section: custom
Priority: optional
Architecture: all

View File

@ -1,5 +1,5 @@
#!/usr/bin/env python3
# version: 1.9.54
# version: 1.9.55
# Tyto - Littérateur
# Copyright (C) 2023 Cyrille Louarn <echolib+tyto@a-lec.org>

View File

@ -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"]:

View File

@ -36,7 +36,7 @@ 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"]
@ -78,65 +78,76 @@ def manage(module):
},
}
# Load/Create new modules in DB file
# ----------------------------------
cf_mod_load()
mod_write = False
# Check/Set raw files in modules/
# 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
# Always check if raw modules exist or create them
# ------------------------------------------------
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
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)
elif mod != module:
continue
# Reload DB if updated
if mod_write:
cf_mod_write()
cf_mod_load()
mod_write = False
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)
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 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)
# When user wants to create again HTML module in wip/ server
# ----------------------------------------------------------
if args.action == "wip":
create_htmls(module)
#=======================================#
@ -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)
#==============================================#

View File

@ -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()

View File

@ -37,10 +37,6 @@ def manage():
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]:

View File

@ -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)
#======================================================================#

View File

@ -53,6 +53,20 @@ h6.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
* - "code::NAME" (file content) -> "::NAME"