From a1fbf3a1a50b75ee37842d676db21b7b5457aa99 Mon Sep 17 00:00:00 2001 From: Cyrille L Date: Mon, 6 Mar 2023 11:22:31 +0100 Subject: [PATCH] Added: publish [all]. Publish one by one is needed first --- README.md | 2 +- src/var/lib/tyto/program/infos.py | 2 ++ src/var/lib/tyto/program/publish.py | 56 +++++++++++++++++++++++++---- src/var/lib/tyto/program/wip.py | 11 ++++-- 4 files changed, 61 insertions(+), 10 deletions(-) diff --git a/README.md b/README.md index 8691781..ce6158b 100644 --- a/README.md +++ b/README.md @@ -8,7 +8,7 @@ Pour obtenir de l'aide, taper juste la commande tyto # Obligatoires uniques title: Titre about: Infos de l'article -author: Autheur +author: Auteur tags: mots-clé-1,mots-clé-2 date: YYYY-MM-DD (AAAA-MM-JJ) diff --git a/src/var/lib/tyto/program/infos.py b/src/var/lib/tyto/program/infos.py index 324c59d..50135ed 100644 --- a/src/var/lib/tyto/program/infos.py +++ b/src/var/lib/tyto/program/infos.py @@ -72,6 +72,8 @@ def tyto(target): ' publish : Create page in www server\n\n' ' - [target] according to [action]\n' ' all : Convert again all already converted articles\n' + ' template: - Create navbar/sidebar/metas/footer in www server\n' + ' - Copy wip/template/ files to www server\n' ' domain : Create/Show config file\n' ' [file] : URI of an article\'s file (autocompletion is your friend)\n' ' footer : Create/Show footer HTML config\'s file\n' diff --git a/src/var/lib/tyto/program/publish.py b/src/var/lib/tyto/program/publish.py index 9084f8f..5a17b9e 100644 --- a/src/var/lib/tyto/program/publish.py +++ b/src/var/lib/tyto/program/publish.py @@ -73,8 +73,13 @@ def manage_publish(target): if err_pub: sys.exit(1) - # Let's publish - #-------------- + publish_article() + + +# +# Let's publish +# +def publish_article(): # Copy wip page to www page shutil.copy2(db.post_wip, db.post_www) logs.out("33", db.post_www, False) @@ -170,8 +175,47 @@ def create_template(option): html.create_user_footer('pub') -#================================# -# Publish template in www server # -#--------------------------------# +#============================================# +# Option 'all' to publish again, based on DB # +#--------------------------------------------# def create_all(option): - print('> argument all', option) + ask = '' + ask = input(" ├ Publish again all already published articles ? ") + if not ask in ['y', 'Y']: + return + + # Load domain configuration DB + published = False + for post_db in os.listdir(db.articles_db): + if post_db.endswith('.conf'): + # Load DB + post_db = '%s%s'%(db.articles_db, post_db) + exec(open(post_db).read(),globals()) + args.target = post_src.rsplit('%s/'%db.in_dir)[1] + importlib.reload(db) + + # Conditions to publish + if not db.hash_www: + continue + + print(':> [%s] | %s'%(db.title, db.post_src)) + hash_post = tyto.get_filesum(db.post_src, True) # From content file + + if not db.hash_chk: + logs.out("25", db.uri_file, False) + continue + + if db.hash_chk != db.hash_post: + logs.out("9", db.uri_file, False) + continue + + if db.hash_wip != db.hash_chk: + logs.out("30", db.uri_file, False) + continue + + published = True + publish_article() + + if not published: + logs.out("28", '(publish)', True) + return diff --git a/src/var/lib/tyto/program/wip.py b/src/var/lib/tyto/program/wip.py index 297e10f..dc99af4 100644 --- a/src/var/lib/tyto/program/wip.py +++ b/src/var/lib/tyto/program/wip.py @@ -35,7 +35,7 @@ def manage_wip(target): #--------------------------------------- if target == 'all': ask = '' - ask = input(":? wip again all already converted articles ? ") + ask = input(" ├ Wip again all already converted articles ? ") if not ask in ['y', 'Y']: return @@ -47,9 +47,14 @@ def manage_wip(target): exec(open(post_db).read(),globals()) args.target = post_src.rsplit('%s/'%db.in_dir)[1] importlib.reload(db) + if not db.hash_wip: + continue + print(':> [%s] | %s'%(db.title, db.post_src)) - if not db.hash_wip: continue hash_post = tyto.get_filesum(db.post_src, True) # From content file + if hash_post != db.hash_chk: + logs.out("25", db.uri_file, False) + ocontinue wip_article(db.post_src) return @@ -77,7 +82,7 @@ def manage_wip(target): if db.hash_chk != db.hash_post: logs.out("9", target, True) # Compare and check file - if db.hash_wip != db.hash_chk: + if db.hash_wip != db.hash_chk: # Article has changed wip_article(db.uri_file) else: if not os.path.exists(db.post_wip):