From 49ac069ae601701b826cef0d0f6a280288622ce6 Mon Sep 17 00:00:00 2001 From: Cyrille L Date: Tue, 25 Apr 2023 01:05:39 +0200 Subject: [PATCH] [0.10.3] --- README.md | 7 +- src/var/lib/tyto/program/args.py | 139 +++++++++++++---------- src/var/lib/tyto/program/infos.py | 76 +++++++++---- src/var/lib/tyto/translations/site_en.py | 3 +- src/var/lib/tyto/translations/site_fr.py | 2 + 5 files changed, 136 insertions(+), 91 deletions(-) diff --git a/README.md b/README.md index 8af7217..cbefdfd 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ Pour obtenir de l'aide, taper juste la commande tyto ## Répertoire de code du projet Tyto -TODO +https://git.a-lec.org/echolib/tyto-litterateur ## Comment définir les métas ``` @@ -51,8 +51,9 @@ abbr: abbrev ### Écrire des titres ``` -# Les titres HTML vont de 1 à 6. -# Utiliser #N, où N est entre 1 et 6. +# Les titres HTML vont de 1 à 6 mais h1 est utilisé pour afficher +# le titre de l'article. +# Utiliser #N, où N est entre 1 et 5. (h+1 en HTML) # Si du contenu existe entre les titres, une
est ajoutée # Source diff --git a/src/var/lib/tyto/program/args.py b/src/var/lib/tyto/program/args.py index 656df18..c5ba5aa 100644 --- a/src/var/lib/tyto/program/args.py +++ b/src/var/lib/tyto/program/args.py @@ -41,76 +41,81 @@ import infos # tyto [action] [target] #---------------------------- actions = \ -( -'check', -'edit', -'edit-about', -'edit-db', -'edit-wip', -'edit-www', -'help', -'new', -'show', -'show-about', -'show-db', -'show-wip', -'show-www', -'status', -'wip', -'publish' -) + ( + 'check', + 'edit', + 'edit-about', + 'edit-db', + 'edit-wip', + 'edit-www', + 'new', + 'show', + 'show-about', + 'show-db', + 'show-wip', + 'show-www', + 'status', + 'wip', + 'publish' + ) option = \ -( -'--static', -) + ( + '--static', + ) pass_actions = ('new') # Actions that needs to check for article's database pass_db = \ -( -'check', -'edit', -'edit-db', -'edit-wip', -'edit-www', -'publish', -'show', -'show-about', -'show-db', -'show-wip', -'show-www', -'status', -'wip', -) + ( + 'check', + 'edit', + 'edit-db', + 'edit-wip', + 'edit-www', + 'publish', + 'show', + 'show-about', + 'show-db', + 'show-wip', + 'show-www', + 'status', + 'wip', + ) pass_targets = \ -( -'added', -'again', -'updated', -'domain', -'footer', -'metas', -'navbar', -'sidebar', -'stats', -'template' -) + ( + 'added', + 'again', + 'updated', + 'domain', + 'footer', + 'metas', + 'navbar', + 'sidebar', + 'stats', + 'template' + ) pass_status = \ -( -'domain', -) + ( + 'domain', + ) -multi_chk = ('added', 'again', 'updated') +multi_chk = \ + ( + 'added', + 'again', + 'updated' + ) -''' -action = '' -target = '' -option = '' -''' +helps = \ + ( + 'domains', + 'version', + 'help' + ) # action @@ -120,19 +125,27 @@ except: action = '' # With no argument, show help if not action: - infos.tyto(target) + infos.tyto('full') sys.exit(0) +elif action in helps: + infos.tyto(action) + # Unused argument [action] -if action in actions: act_err = False -else: act_err = True +elif action in actions: + act_err = False + +else: + act_err = True # target #------- -try: target = sys.argv[2] -except: target = '' - +try: + target = sys.argv[2] +except: + infos.tyto('full') + sys.exit(0) # option try: option = sys.argv[3] diff --git a/src/var/lib/tyto/program/infos.py b/src/var/lib/tyto/program/infos.py index 976614b..e6e5f51 100644 --- a/src/var/lib/tyto/program/infos.py +++ b/src/var/lib/tyto/program/infos.py @@ -33,7 +33,7 @@ #********************************************************************** -import os, importlib +import os, sys, importlib import langs importlib.reload(langs) @@ -43,9 +43,11 @@ CR = '\033[1;31m' CY = '\033[1;33m' CG = '\033[1;32m' -def tyto(target): - noinfos = False +# +# Show Version +# +def version(): # Show Version tytobin = open('/usr/bin/tyto').read() for line in tytobin.rsplit('\n'): @@ -54,6 +56,10 @@ def tyto(target): break +#==========================================# +# List all found domain in local directory # +#------------------------------------------" +def list_domains(): # Show domains list try: has_domains = True @@ -68,34 +74,56 @@ def tyto(target): print('! No directory > %s/'%db_domains) if has_domains: - list_domains = (()) for folder in os.listdir(db_domains): domain_local_uri = '%s/%s'%(db_domains, folder) + if os.path.isdir(domain_local_uri): + line = ' - %s >'%folder + + # Check configuration file and load domain_conf = '%s/domain_config.bkp'%domain_local_uri - if os.path.exists(domain_conf): + if not os.path.exists(domain_conf): + line = '%s %sUnknown%s ?'%(line, CR, CS) + + else: try: exec(open(domain_conf).read(),globals()) + line = '%s %sConfig%s > '%(line, CG, CS) except: - continue - if os.path.exists(directory): - dir_domain = '%s%s%s'%(CG, directory, CS) - else: - dir_domain = '%s%s%s'%(CR, directory, CS) - list_domains = \ - (('%s > %s > %s'%(folder, dir_domain, www_url)),) - - if list_domains: - print('# %s %ss %s'%( - langs.site.reg_domains, - langs.site.fo, - user - ) - ) - for domain in list_domains: - print(' - %s'%domain) + pass + + try: + if os.path.exists(directory): + line = '%s %s%s%s'%(line, CG, directory, CS) + else: + line = '%s %s%s%s'%(line, CR, directory, CS) + except: + line = '%s %sNo root%s > '%(line, CR, CS) + + try: + line = '%s %s'%(line, www_url) + except: + line = '%s %sNo URL%s > '%(line, CR, CS) + + print(line) + +# +# --help [full] +# +def tyto(target): + if target == "full": + version() + list_domains() + print(langs.site.args_helps) + elif target == 'help': + print(langs.site.args_helps) - # Show arguments help - print(langs.site.args_helps) + elif target == 'domains': + list_domains() + + elif target == 'version': + version() + + sys.exit(0) diff --git a/src/var/lib/tyto/translations/site_en.py b/src/var/lib/tyto/translations/site_en.py index e488d86..b601422 100644 --- a/src/var/lib/tyto/translations/site_en.py +++ b/src/var/lib/tyto/translations/site_en.py @@ -273,7 +273,8 @@ args_helps = """\n# New domain : new : [domain] Créer un domaine ou le modifier via le formulaire [sidebar, navbar, footer, metas] Create and replace with default module configuration file - + [filename] (no .tyto) Create article in current folder + # Show contents file (with line number) show : Show source file, source configuration module show-about: [footer] Show description footer file diff --git a/src/var/lib/tyto/translations/site_fr.py b/src/var/lib/tyto/translations/site_fr.py index dcb8b0b..8e26243 100644 --- a/src/var/lib/tyto/translations/site_fr.py +++ b/src/var/lib/tyto/translations/site_fr.py @@ -274,6 +274,8 @@ args_helps = """\n# Nouveau domaine : new : [domain] Créer un domaine ou le modifier via le formulaire [sidebar, navbar, footer, metas] Créer ou remplacer le fichier de configuration du module par le défaut + [filename] (sans .tyto) Créer un article dans le + dossier actuel # Afficher un fichier (avec numéros de ligne) show : Fichier source, module de configuration