From 06946a5c46102b6360a6b145f5b8e1545686c332 Mon Sep 17 00:00:00 2001 From: Cyrille L Date: Mon, 6 Mar 2023 17:00:37 +0100 Subject: [PATCH] Added directory source to database. Fix wip/publish for subfolders articles --- src/var/lib/tyto/program/check.py | 13 ++++++++----- src/var/lib/tyto/program/html.py | 12 ++++++------ src/var/lib/tyto/program/publish.py | 2 ++ src/var/lib/tyto/program/wip.py | 15 ++++++--------- 4 files changed, 22 insertions(+), 20 deletions(-) diff --git a/src/var/lib/tyto/program/check.py b/src/var/lib/tyto/program/check.py index 3fa1aa9..8471ff3 100644 --- a/src/var/lib/tyto/program/check.py +++ b/src/var/lib/tyto/program/check.py @@ -63,12 +63,14 @@ def manage_check(target): ext_src = os.path.splitext(target) # Get uri after articles/ (no starting / in value) - global src_post_short_uri, srv_post_short_uri + global src_post_short_uri, srv_post_short_uri, direc_src global srv_post_wip_uri, srv_post_www_uri src_post_short_uri = db.uri_file.rsplit(db.domain_articles)[1] srv_post_short_uri = src_post_short_uri.replace(ext_src[1], '.html') srv_post_wip_uri = db.srv_wip + srv_post_short_uri srv_post_www_uri = db.srv_www + srv_post_short_uri + direc_src = src_post_short_uri.split("/")[-1] + direc_src = src_post_short_uri.rsplit(direc_src)[0] # Get sub_uri for HTML global sub_uri @@ -80,11 +82,11 @@ def manage_check(target): # Set HTTP link for wip and www global http_www, http_wip if srv_post_short_uri.endswith('index.html'): - http_www = "%s/"%db.domain_www_url - http_wip = '%s/'%db.domain_wip_url + http_www = "%s/%s"%(db.domain_www_url, direc_src) + http_wip = '%s/%s'%(db.domain_wip_url, direc_src) else: - http_www = "%s%s"%(db.domain_www_url, srv_post_short_uri) - http_wip = '%s%s'%(db.domain_wip_url, srv_post_short_uri) + http_www = "%s/%s"%(db.domain_www_url, srv_post_short_uri) + http_wip = '%s/%s'%(db.domain_wip_url, srv_post_short_uri) # Start checking processes #------------------------- @@ -665,6 +667,7 @@ def create_database(): 'post_wip = "%s"\n'%srv_post_wip_uri + \ 'post_www = "%s"\n'%srv_post_www_uri + \ '\n' + \ + 'direc_src = "%s"\n'%direc_src + \ 'short_src = "%s"\n'%src_post_short_uri + \ 'short_srv = "%s"\n'%srv_post_short_uri + \ 'sub_uri = "%s"\n'%sub_uri + \ diff --git a/src/var/lib/tyto/program/html.py b/src/var/lib/tyto/program/html.py index 5ac2f57..e5b5efd 100644 --- a/src/var/lib/tyto/program/html.py +++ b/src/var/lib/tyto/program/html.py @@ -218,6 +218,7 @@ def create_sidebar(option): except: logs.out("1", 'Sidebar load file', True) + pub_opts = ('www', 'pub') if option == 'wip': target = db.wip_sidebar elif option == 'www': target = db.www_sidebar elif option == 'pub': target = db.www_sidebar @@ -272,7 +273,7 @@ def create_sidebar(option): if not os.path.exists(post_wip): logs.out("24", 'in wip: %s'%post_wip, False) continue - elif option == 'www': + elif option in pub_opts: if not hash_www == hash_chk: logs.out("30", '%s "%s"'%(line, title), False) continue @@ -296,12 +297,12 @@ def create_sidebar(option): logs.out("35", '"%s": %s'%(title, line), False) # Create HTML list for this article - link_title = '%s [@%s]'%(about, author) + link_title = '%s [%s]'%(about, author) sidebar_list = sidebar_list + \ '