From 2f760d4d27848dfd4b5aa4c83ccc53342e5e3bf3 Mon Sep 17 00:00:00 2001 From: Cyrille LOUARN Date: Tue, 2 Jan 2024 15:01:52 +0100 Subject: [PATCH] [1.9.57] 'All' done ! --- CHANGELOG.md | 13 +++- README.md | 14 ++-- debian/control | 2 +- src/usr/bin/tyto | 2 +- src/var/lib/tyto/program/args.py | 1 + src/var/lib/tyto/program/help.py | 8 +- src/var/lib/tyto/program/post.py | 6 +- src/var/lib/tyto/program/publish.py | 61 +++++++++++---- src/var/lib/tyto/program/show.py | 4 + src/var/lib/tyto/program/sitemap.py | 3 +- src/var/lib/tyto/program/tools.py | 3 +- src/var/lib/tyto/program/wip.py | 99 ++++++++++++------------ src/var/lib/tyto/translations/logs_en.py | 4 +- src/var/lib/tyto/translations/logs_fr.py | 4 +- 14 files changed, 137 insertions(+), 87 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7c1c815..ed0fce2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,14 +2,19 @@ Tyto - Littérateur - Repository: https://forge.a-lec.org/echolib/tyto-litterateur/ -- Issues: https://forge.a-lec.org/echolib/tyto-litterateur/issues -- Changelog: -- License: -- Documentation: https://forge.a-lec.org/echolib/tyto-litterateur/src/branch/master/LICENSE +- Issues: https://forge.a-lec.org/echolib/tyto-litterateur/issues +- License: https://forge.a-lec.org/echolib/tyto-litterateur/src/branch/master/LICENSE - Development: https://forge.a-lec.org/echolib/tyto-litterateur/src/branch/devel # CURRENTLY IN DEV (in devel branch) ! +## [1.9.57] +- new "css" target. +- - With [help] : show references styles +- - with [show] : show styles.css in wip/ server +- fix publish and wip code for multiple articles in command line +- added [all] argument for [publish] : publish again all published article + ## [1.9.56] - update HTML output for bcodes and codes markers - update styles.css default references (tpl_files) diff --git a/README.md b/README.md index 07243db..dcb4350 100644 --- a/README.md +++ b/README.md @@ -18,11 +18,15 @@ tyto help words anchor # Create new domain - create a domain directory, like www.domain.tld -- Go to this directory +- go to this directory - type `tyto new domain` - type `tyto check domain` and PLEASE, CHECK configuration file -- create in new directory domain ".../articles/", an articl file [myfile].tyto (see help) -- type `wip myfile.tyto` + +# Create an article +- go to domain directory ".../articles/" +- create an article file [myfile].tyto (see `tyto help article`) +- type `tyto wip myfile.tyto` +- [myfile].html is created in wip/ domain server directory ## Exemple d'article .tyto commenté @@ -93,7 +97,7 @@ file: PyF # Code dans un texte # ! Les marqueurs d'ouverture et de fermeture de code sont sur la MEME LIGNE - {`
  • Une entée de liste
  • `} => + {`
  • Une entrée de liste
  • `} => # ! Dans certains cas, il faut ajouter un espace après le 1er marqueur # et/ou avant le second. Ils seront automatiquement supprimés @@ -187,7 +191,7 @@ Citation complète dans un paragraphe
  • # Code dans un texte
  • # ! Les marqueurs d'ouverture et de fermeture de code sont sur la MEME LIGNE
  • -
  • {` <li>Une entée de liste</li> `} => <code>
  • +
  • {` <li>Une entrée de liste</li> `} => <code>
  • # ! Dans certains cas, il faut ajouter un espace après le 1er marqueur
  • # et/ou avant le second. Ils seront automatiquement supprimés
  • diff --git a/debian/control b/debian/control index e10a6c9..803bba9 100644 --- a/debian/control +++ b/debian/control @@ -1,5 +1,5 @@ Package: tyto -Version: 1.9.56 +Version: 1.9.57 Section: custom Priority: optional Architecture: all diff --git a/src/usr/bin/tyto b/src/usr/bin/tyto index 8160062..27938d1 100755 --- a/src/usr/bin/tyto +++ b/src/usr/bin/tyto @@ -1,5 +1,5 @@ #!/usr/bin/env python3 -# version: 1.9.56 +# version: 1.9.57 # Tyto - Littérateur # Copyright (C) 2023 Cyrille Louarn diff --git a/src/var/lib/tyto/program/args.py b/src/var/lib/tyto/program/args.py index af0b05e..f82fc20 100644 --- a/src/var/lib/tyto/program/args.py +++ b/src/var/lib/tyto/program/args.py @@ -49,6 +49,7 @@ def get_arguments(): "all" : False, "domain" : False, "sitemap" : False, + "css" : False, }, "modules" : { "modules" : False, diff --git a/src/var/lib/tyto/program/help.py b/src/var/lib/tyto/program/help.py index 6077eba..7d2b9f5 100644 --- a/src/var/lib/tyto/program/help.py +++ b/src/var/lib/tyto/program/help.py @@ -24,7 +24,7 @@ #---------------------------------------------------------------------- import sys -import args, langs +import args, langs, show # # @@ -46,6 +46,7 @@ def manage(): "anchor" : langs.logs.help_anc, "raw" : langs.logs.help_raw, "article" : langs.logs.help_article, + "css" : "", } norepeat = \ @@ -73,5 +74,8 @@ def manage(): for arg in range(2, len(sys.argv)): if sys.argv[arg] in helps: print(helps[sys.argv[arg]]) - + + # CSS references + if args.commands["targets"]["css"]: + show.contents_file("/var/lib/tyto/tpl_files/styles.css", True) diff --git a/src/var/lib/tyto/program/post.py b/src/var/lib/tyto/program/post.py index a5f611b..9f7a5be 100644 --- a/src/var/lib/tyto/program/post.py +++ b/src/var/lib/tyto/program/post.py @@ -166,9 +166,9 @@ def cf_create(): cf_write() -# -# -# +#=============================================# +# Set and reset vars (when multiple articles) # +#---------------------------------------------# def set_default_vars(): global anchors, block_tags, icodes, options_marks global needed_tags, option_tags, titles diff --git a/src/var/lib/tyto/program/publish.py b/src/var/lib/tyto/program/publish.py index df6cc61..4d846cb 100644 --- a/src/var/lib/tyto/program/publish.py +++ b/src/var/lib/tyto/program/publish.py @@ -25,7 +25,8 @@ # File: /var/lib/tyto/program/publish.py #---------------------------------------------------------------------- -import os +import os, configparser +from pathlib import Path import domain, args, wip, post, debug, tools, sitemap, feed @@ -34,39 +35,69 @@ import domain, args, wip, post, debug, tools, sitemap, feed #--------------------------------------------------------# def manage(): domain.is_active() + wip.in_dir_articles() global out - if args.article: - wip.in_dir_articles() - - # Multiple targets ("all"): out is False - # (out to exit on error at single target) - out = not(args.targets) - article() + # Multiple targets ("all"): out is False + # (out to exit on error at single target) + out = not(args.commands["targets"]["all"]) + + if args.commands["targets"]["all"]: + articles() + + elif args.commands["targets"]["*.tyto"]: + for article_item in args.commands["targets"]["*.tyto"]: + article(article_item) # Copy sitemap if activated and exists if domain.conf["sitemaps"]: sitemap.create() - args.article == "sitemap.tyto" - article() + article("sitemap.tyto") feed.create() tools.copy_template_dir("www") +#========================================================# +# With "all", publish (again) already published articles # +#--------------------------------------------------------# +def articles(): + for db_uri in Path(domain.wrk_dirs["db"]).rglob('*.ini'): + db_uri = domain.wrk_dirs["db"] + db_uri.name + # TMP load neede datas from DB article + cf = configparser.ConfigParser() + cf.read(db_uri) + + datas = \ + { + "wrk_tgt" : cf.get("URIS", "wrk").rsplit(domain.wrk_dirs["articles"])[1], + "wip_uri" : cf.get("URIS", "wip"), + "www_hid" : cf.get("HASHES", "www"), + } + + # Filter from DB + if datas["wrk_tgt"] == "sitemap.tyto" or \ + not os.path.exists(datas["wip_uri"]) or \ + not datas["www_hid"]: + continue + + # Publish (again) this article + article(datas["wrk_tgt"]) + + #==============================# # Set DB, check and copy files # #------------------------------# -def article(): - post.set_uri(args.article) - post.exists(args.article) +def article(article_item): + 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"%args.article, post.uid, True, 2, out) + debug.out(12, "wip %s"%article_item, post.uid, True, 2, out) post.cf_load() if not check_db(): - debug.out(12, "wip %s"%args.article, post.uri, True, 2, out) + debug.out(12, "wip %s"%article_item, post.uri, True, 2, out) copy_wip_to_www() post.cf_set("HASHES", "www", DB["hash_wip"]) diff --git a/src/var/lib/tyto/program/show.py b/src/var/lib/tyto/program/show.py index 3537f81..403e54b 100644 --- a/src/var/lib/tyto/program/show.py +++ b/src/var/lib/tyto/program/show.py @@ -60,6 +60,10 @@ def manage(): if args.commands["targets"]["sitemap"]: contents_file(domain.wrk_dirs["articles"] + "sitemap.tyto", True) + # CSS styles in wip/ server + if args.commands["targets"]["css"]: + contents_file(domain.srv_wip_files["styles"], True) + #=======================================# # Read content of file # diff --git a/src/var/lib/tyto/program/sitemap.py b/src/var/lib/tyto/program/sitemap.py index 5d5f129..cc0be24 100644 --- a/src/var/lib/tyto/program/sitemap.py +++ b/src/var/lib/tyto/program/sitemap.py @@ -75,8 +75,7 @@ def create(): ) tools.create_file(domain.wrk_dirs["articles"] + "sitemap.tyto", sitemap_tyto) - args.article = "sitemap.tyto" - wip.article() + wip.article("sitemap.tyto") #===============================# diff --git a/src/var/lib/tyto/program/tools.py b/src/var/lib/tyto/program/tools.py index 138a5a3..bfca103 100644 --- a/src/var/lib/tyto/program/tools.py +++ b/src/var/lib/tyto/program/tools.py @@ -232,6 +232,5 @@ def get_articles(): ) for uri in files: - args.article = uri.rsplit(root_dir)[1] - wip.article() + wip.article(uri.rsplit(root_dir)[1]) diff --git a/src/var/lib/tyto/program/wip.py b/src/var/lib/tyto/program/wip.py index fff17bf..55e6cd5 100644 --- a/src/var/lib/tyto/program/wip.py +++ b/src/var/lib/tyto/program/wip.py @@ -41,7 +41,8 @@ def manage(): # Treat target article elif args.commands["targets"]["*.tyto"]: - article() + for article_item in args.commands["targets"]["*.tyto"]: + article(article_item) for mod in args.commands["modules"]: @@ -73,61 +74,59 @@ def articles(): # Create Full HTML page # # Create article DB with values # #--------------------------------# -def article(): +def article(article_item): in_dir_articles() - for article_item in args.commands["targets"]["*.tyto"]: - post.set_uri(article_item) - - # Exit in single article mode if not exists - if not args.commands["targets"]["all"]: - post.exists(article_item) + post.set_uri(article_item) - - post.set_datas() - - # Check Tyto file format, create post values - if not check.tyto_format(): - return + # Exit in single article mode if not exists + if not args.commands["targets"]["all"]: + post.exists(article_item) + + post.set_datas() - # Create server wip/ directories - domain.create_srv_dirs("wip") + # Check Tyto file format, create post values + if not check.tyto_format(): + return + + # Create server wip/ directories + domain.create_srv_dirs("wip") + + # Convert article + convert_article() - # Convert article - convert_article() - - # Create Full HTML Page - page.create() + # Create Full HTML Page + page.create() + + # Create DB article + create_db() + + # Copy files to server wip/ + tools.copy_to_srv(page.article) + tools.copy_template_dir("wip") - # Create DB article - create_db() - - # Copy files to server wip/ - tools.copy_to_srv(page.article) - tools.copy_template_dir("wip") - - # Write values to article DB - post.cf_set("HASHES", "wip", post.datas["cid"]) - post.cf_set("DATES", "wip", page.pub_date) - # Copy stats - for stat in check.stats: - for name in check.stats[stat]: - post.cf_set("STATS_%s"%stat.upper(), - name, - str(check.stats[stat][name]) - ) - - - post.cf_write() - - # Check/create modules (metas, header, navbar, sidebar, footer) - modules.manage("wip") - - # Mainly for sitemap, as created at publish - if not args.action == "publish": - debug.out(250, post.needed_tags["title"], - domain.wip + post.datas["srv_target"], True, 0, False - ) + # Write values to article DB + post.cf_set("HASHES", "wip", post.datas["cid"]) + post.cf_set("DATES", "wip", page.pub_date) + # Copy stats + for stat in check.stats: + for name in check.stats[stat]: + post.cf_set("STATS_%s"%stat.upper(), + name, + str(check.stats[stat][name]) + ) + + post.cf_write() + + # Check/create modules (metas, header, navbar, sidebar, footer) + modules.manage("wip") + + # Mainly for sitemap, as created at publish + if not args.action == "publish": + debug.out(250, post.needed_tags["title"], + domain.wip + post.datas["srv_target"], True, 0, False + ) + #===========================# # Convert article processes # diff --git a/src/var/lib/tyto/translations/logs_en.py b/src/var/lib/tyto/translations/logs_en.py index ab9e09e..55ae6a1 100644 --- a/src/var/lib/tyto/translations/logs_en.py +++ b/src/var/lib/tyto/translations/logs_en.py @@ -214,7 +214,7 @@ tyto [ACTION] [ARGUMENTS] start > activate current domain stop > deactivate current domain check ? + [domain] : check current domain - show > show files contents [domain], [MODULES]... + show > show files contents [domain], [MODULES], [css]... wip ? create HTML in "wip/" server publish ? publish in "www/" server @@ -222,6 +222,7 @@ tyto [ACTION] [ARGUMENTS] domain > create new/check domain [abc].tyto > target [abc].tyto (multiples) all > [wip] : target all .tyto files in current domain + [publish] : publish again all published articles [MODULES] : (Useless with [publish]) metas > target metas module @@ -237,6 +238,7 @@ tyto [ACTION] [ARGUMENTS] - [help] * : * multiples. Documentation "?" > see argument name before "?" + css > show styles.css default references all > show all helps modules > use modules article > write .tyto article diff --git a/src/var/lib/tyto/translations/logs_fr.py b/src/var/lib/tyto/translations/logs_fr.py index 7aaef22..03bfe31 100644 --- a/src/var/lib/tyto/translations/logs_fr.py +++ b/src/var/lib/tyto/translations/logs_fr.py @@ -214,7 +214,7 @@ tyto [ACTION] [ARGUMENTS] start > activer le domain actuel stop > désactiver le domaine actuel check ? + [domain] : vérifier le domaine actuel - show > montre le contenu des fichiers [domain], [MODULES]... + show > montre le contenu des fichiers [domain], [MODULES], [css]... wip ? créer de l'HTML dans le serveur "wip/" publish ? publier dans le serveur "www/" @@ -222,6 +222,7 @@ tyto [ACTION] [ARGUMENTS] domain > créer/vérifier un domaine [nom].tyto > cible le fichier [nom].tyto (plusieurs possibles) all > [wip] : cible tous les fichiers .tyto du domaine courant + [publish] : publie tous les article déjà publiés [MODULES] : (inutiles avec [publish]) metas > cible le module metas @@ -237,6 +238,7 @@ tyto [ACTION] [ARGUMENTS] - [help] * : * multiples. Documentation "?" > voir le nom de l'argument avant le signe "?" + css > voir les références par défaut de styles.css all > montre toutes les informations d'aides modules > utiliser les modules article > écrire un article .tyto