[1.10.0] 5000! 'manage footer_about.html'

This commit is contained in:
Cyrille L 2024-01-04 17:32:11 +01:00
parent bceb629467
commit 83e8f5eab3
6 changed files with 56 additions and 31 deletions

View File

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

2
debian/control vendored
View File

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

View File

@ -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 <echolib+tyto@a-lec.org>
@ -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]()

View File

@ -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 + \
'</a>]'
# If footer_about.html exists, insert its contents replacing site about
domain.conf["about"] = '<p id="footer_about_p">%s</p>'%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%(
# <h2>
@ -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 = """
<h2 id="footer_title">%s %s</h2>
<div id="footer_about_menu">
<div id="footer_about">
<p id="footer_about_p">%s</p>
%s
</div>
<nav id="footer_menu" aria-labelledby="navigation-3">
<ul id="footer_items">

View File

@ -312,6 +312,12 @@ help_modules = """
- [wip [MODULE]]
Create (again) this [MODULE]
# Note. "footer_about.html"
footer_about.html file in domain "modules/" directory is optional. If
created, site description in footer will be replaced with its contents.
If this file is updated, footer.html in "wip/" server will be generated
again automatically.
! For these modules to be shown in website, you must add in the nginx
configuration file (/etc/nginx/sites-available/DOMAIN.TLD):

View File

@ -319,6 +319,12 @@ help_modules = """
- [wip [MODULE]]
(re)générer uniquement le [MODULE] concerné
# Note. "footer_about.html"
Le fichier footer_about.html dans le dossier "modules/" du domaine est
optionnel. Si, il est créé, la description du site dans le pied de page
sera remplacée par son contenu. Si ce fichier est modifié, le pied de page
(footer.html) dans le serveur "wip/" sera généré à nouveau automatiquement.
! Pour que ces modules puissent être affichés dans les pages du site, il
faut ajouter dans le fichier de configuration du serveur nginx
(/etc/nginx/sites-available/DOMAINE.TLD) :