From 31e1f382f145e50fc46bfc5d8d0d542574367f31 Mon Sep 17 00:00:00 2001 From: Cyrille LOUARN Date: Thu, 18 Jan 2024 08:43:45 +0100 Subject: [PATCH] publish: template log, sitemap and feed created with article --- src/var/lib/tyto/program/debug.py | 1 + src/var/lib/tyto/program/publish.py | 23 ++++++++++++++++++----- src/var/lib/tyto/program/tools.py | 1 + src/var/lib/tyto/translations/logs_en.py | 1 + src/var/lib/tyto/translations/logs_fr.py | 1 + 5 files changed, 22 insertions(+), 5 deletions(-) diff --git a/src/var/lib/tyto/program/debug.py b/src/var/lib/tyto/program/debug.py index 9eb4c03..4f5138f 100644 --- a/src/var/lib/tyto/program/debug.py +++ b/src/var/lib/tyto/program/debug.py @@ -77,6 +77,7 @@ def set_messages(): 206 : langs.logs.inf_file_upd, 207 : langs.logs.inf_dir_create, 208 : langs.logs.inf_add_item, + 209 : langs.logs.inf_dir_copy, 210 : langs.logs.inf_check_post, 211 : langs.logs.inf_wip_process, 212 : langs.logs.inf_mod_process, diff --git a/src/var/lib/tyto/program/publish.py b/src/var/lib/tyto/program/publish.py index 4d846cb..58d3542 100644 --- a/src/var/lib/tyto/program/publish.py +++ b/src/var/lib/tyto/program/publish.py @@ -50,11 +50,16 @@ def manage(): article(article_item) # Copy sitemap if activated and exists - if domain.conf["sitemaps"]: - sitemap.create() - article("sitemap.tyto") + try: + map_feed + if domain.conf["sitemaps"]: + sitemap.create() + article("sitemap.tyto") + + feed.create() + except: + pass - feed.create() tools.copy_template_dir("www") @@ -89,21 +94,29 @@ def articles(): # Set DB, check and copy files # #------------------------------# def article(article_item): + # Set True to create feed and sitemap + global map_feed + try: map_feed + except: map_feed = False + post.set_uri(article_item) post.exists(article_item) db_uri = domain.wrk_dirs["db"] + post.uid + ".ini" if not bool(os.path.exists(db_uri)): debug.out(12, "wip %s"%article_item, post.uid, True, 2, out) - + return + post.cf_load() if not check_db(): debug.out(12, "wip %s"%article_item, post.uri, True, 2, out) + return copy_wip_to_www() post.cf_set("HASHES", "www", DB["hash_wip"]) post.cf_set("DATES", "www", pub_date) post.cf_write() debug.out(250, DB["article_title"], DB["uri_www"], True, 0, False) + mam_feed = True #=========================== diff --git a/src/var/lib/tyto/program/tools.py b/src/var/lib/tyto/program/tools.py index 5d5aeb4..ba4db71 100644 --- a/src/var/lib/tyto/program/tools.py +++ b/src/var/lib/tyto/program/tools.py @@ -200,6 +200,7 @@ def copy_template_dir(process): create_dirs(dst_dirs[process]) shutil.copytree(src_dirs[process], dst_dirs[process], dirs_exist_ok=True) + debug.out(209, "wip/template/", dst_dirs[process], True, 0, False) #====================================================# diff --git a/src/var/lib/tyto/translations/logs_en.py b/src/var/lib/tyto/translations/logs_en.py index 37ed282..76e0363 100644 --- a/src/var/lib/tyto/translations/logs_en.py +++ b/src/var/lib/tyto/translations/logs_en.py @@ -82,6 +82,7 @@ inf_domain_conf = "Configuring domain" inf_file_upd = "File updated" inf_file_create = "File created" inf_dir_create = "Directory created" +inf_dir_copy = "Directory copied" inf_check_post = "Checking article" inf_wip_process = "Converting" inf_mod_process = "Checking modules" diff --git a/src/var/lib/tyto/translations/logs_fr.py b/src/var/lib/tyto/translations/logs_fr.py index 57954b4..be1417d 100644 --- a/src/var/lib/tyto/translations/logs_fr.py +++ b/src/var/lib/tyto/translations/logs_fr.py @@ -82,6 +82,7 @@ inf_domain_conf = "Configuration du domaine" inf_file_upd = "Fichier mis à jour" inf_file_create = "Fichier créé" inf_dir_create = "Dossier créé" +inf_dir_copy = "Dossier copié" inf_check_post = "Vérification de l'article" inf_wip_process = "Conversion" inf_mod_process = "Vérification des modules"