From d008f6e78fc856842f8916e98de774f23322663c Mon Sep 17 00:00:00 2001 From: Cyrille L Date: Fri, 6 Jan 2023 16:27:46 +0100 Subject: [PATCH] wip: added option 'again' to wip all already wip articles (indev) --- src/usr/bin/tyto | 15 ++++++------- src/var/lib/tyto/program/tyto.py | 3 ++- src/var/lib/tyto/program/wip.py | 36 ++++++++++++++++++++++++++++---- 3 files changed, 42 insertions(+), 12 deletions(-) diff --git a/src/usr/bin/tyto b/src/usr/bin/tyto index 8d97ea0..7479021 100755 --- a/src/usr/bin/tyto +++ b/src/usr/bin/tyto @@ -50,13 +50,14 @@ actions = { # Dict for Options options = { - '-a' : 'Add', 'add' : 'Add', - '-R' : "Remove", 'remove' : "Remove", - '-n' : "New", 'new' : "New", - '-e' : "Edit", 'edit' : "Edit", - '-F' : "Force", 'force' : "Force", - '-s' : "Show", - '-d' : 'DB' + '-a' : 'Add', 'add' : 'Add', + '-R' : "Remove", 'remove' : "Remove", + '-n' : "New", 'new' : "New", + '-e' : "Edit", 'edit' : "Edit", + '-F' : "Force", 'force' : "Force", + '-s' : "Show", + '-d' : 'DB', + 'again': 'Again' } # Set Argument 2 or 3 diff --git a/src/var/lib/tyto/program/tyto.py b/src/var/lib/tyto/program/tyto.py index ad41223..c155ffd 100644 --- a/src/var/lib/tyto/program/tyto.py +++ b/src/var/lib/tyto/program/tyto.py @@ -28,7 +28,8 @@ arguments = ( '-e', 'edit', '-n', 'new', '-F', 'force', - '-d' + '-d', + 'again' ) # Settings diff --git a/src/var/lib/tyto/program/wip.py b/src/var/lib/tyto/program/wip.py index 772e23c..3cbea08 100644 --- a/src/var/lib/tyto/program/wip.py +++ b/src/var/lib/tyto/program/wip.py @@ -20,6 +20,32 @@ import os, re import tyto, html def manage_wip(target, option): + global post_db, hash_post + + #----------------------------------------- + # Option 'Again' to wip again, based on DB + #----------------------------------------- + if option == 'Again': + ask = '' + ask = input(":? wip again all already converted articles ? ") + if not ask in ['y', 'Y']: + return + + # Load domain configuration DB + exec(open(tyto.domain_conf).read(),globals()) + for post_db in os.listdir(domain_db): + if post_db.endswith('.conf'): + # Load DB + post_db = '%s%s'%(domain_db, post_db) + exec(open(post_db).read(),globals()) + print("->", root_uri) + hash_post = tyto.get_filesum(post_db, True) # From content file + wip_article(root_uri) + return + + #------------------------ + # Per article with target + #------------------------ # target needed if not target: tyto.exiting("5", '', True) @@ -30,10 +56,12 @@ def manage_wip(target, option): tyto.exiting("4", '', True) # Load DB - exec(open(tyto.post_db).read(),globals()) + post_db = tyto.post_db + hash_post = tyto.hash_post + exec(open(post_db).read(),globals()) # Exit if article has changed - if hash_chk != tyto.hash_post: tyto.exiting("9", '', True) + if hash_chk != hash_post: tyto.exiting("9", '', True) # In any case, if Force if option == 'Force': @@ -91,11 +119,11 @@ def wip_article(target): print(article_bottom) # Get article DB in html.py - html.set_page(tyto.post_db) + html.set_page(post_db) print(html.main_page) # Replace in DB hash_wip and date_wip - tyto.replace_in_db(tyto.post_db, 'wip', tyto.hash_post) + tyto.replace_in_db(post_db, 'wip', hash_post) #=================================#