diff --git a/CHANGELOG.md b/CHANGELOG.md index 3648880..9ab09b1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,13 @@ Tyto - Littérateur # CURRENTLY IN DEV (in devel branch) ! +## [1.9.38] +- Moved: HTML footer in div site_container +- fix: main title in HTML page h1 +- Fill Article HTML metas datas +- Working on files copies to wip server with "wip" command +- - some changes in post DB and check process + ## [1.9.37] - Preparing full HTML Page - Some fixes diff --git a/README.md b/README.md index 116e566..b971008 100644 --- a/README.md +++ b/README.md @@ -236,22 +236,24 @@ _code:codetest # Placer le logo de l'article _image:logo -# Marqueur avec options -# ! Les images dans cet exemple sont affichées à la suite -# Placer "|", ou mettez une image dans un paragraphe "((...))" -# ou appliquer un style css de type display:block -# les options des marqueurs: +# les options du marqueur: # - c=CLASS < Sinon la classe est celle du domaine # - w=WIDTH < longueur (si pas d'unité : défaut "px") # - h=HEIGHT < Comme w= # - f=Ma légende sous l'image (ajoute
) # - - Recommandé d'utiliser cette option en dernier + +# ! Les images dans cet exemple sont affichées horizontalement +# Placer "|", ou mettez chaque image dans un paragraphe "((...))" +# ou définir un style css de type display:block pour les afficher verticalement (( _image:mypic _image:mypic c=MYCSS - _image:mypic c=PIC w=60em h=30% f=echolib sur une chaise )) +# Une image avec légende (
) (jamais dans un paragraphe) +_image:mypic c=PIC w=60em h=30% f=echolib sur une chaise + ``` ## Output HTML @@ -311,7 +313,7 @@ _image:logo -

mycite +

Here, i am

@@ -361,10 +363,10 @@ Here, i am

Les images

- +

-Text Alt -Text Alt -

Text Alt
echolib sur une chaise
+Text Alt +Text Alt

+
Text Alt
echolib sur une chaise
``` diff --git a/debian/control b/debian/control index 8759485..50e74c9 100644 --- a/debian/control +++ b/debian/control @@ -1,5 +1,5 @@ Package: tyto -Version: 1.9.37 +Version: 1.9.38 Section: custom Priority: optional Architecture: all diff --git a/src/usr/bin/tyto b/src/usr/bin/tyto index 53ba68a..aabcf33 100755 --- a/src/usr/bin/tyto +++ b/src/usr/bin/tyto @@ -1,5 +1,5 @@ #!/usr/bin/env python3 -# Version: 1.9.37 +# Version: 1.9.38 # Updated: 2023-11-11 1699742831 # Tyto - Littérateur diff --git a/src/var/lib/tyto/program/__pycache__/check.cpython-311.pyc b/src/var/lib/tyto/program/__pycache__/check.cpython-311.pyc index c0188e5..21b5b06 100644 Binary files a/src/var/lib/tyto/program/__pycache__/check.cpython-311.pyc and b/src/var/lib/tyto/program/__pycache__/check.cpython-311.pyc differ diff --git a/src/var/lib/tyto/program/__pycache__/debug.cpython-311.pyc b/src/var/lib/tyto/program/__pycache__/debug.cpython-311.pyc index 4395ed2..9f03236 100644 Binary files a/src/var/lib/tyto/program/__pycache__/debug.cpython-311.pyc and b/src/var/lib/tyto/program/__pycache__/debug.cpython-311.pyc differ diff --git a/src/var/lib/tyto/program/__pycache__/post.cpython-311.pyc b/src/var/lib/tyto/program/__pycache__/post.cpython-311.pyc index be2fc03..e6a8ccd 100644 Binary files a/src/var/lib/tyto/program/__pycache__/post.cpython-311.pyc and b/src/var/lib/tyto/program/__pycache__/post.cpython-311.pyc differ diff --git a/src/var/lib/tyto/program/__pycache__/tools.cpython-311.pyc b/src/var/lib/tyto/program/__pycache__/tools.cpython-311.pyc index 1349020..6e9b21d 100644 Binary files a/src/var/lib/tyto/program/__pycache__/tools.cpython-311.pyc and b/src/var/lib/tyto/program/__pycache__/tools.cpython-311.pyc differ diff --git a/src/var/lib/tyto/program/__pycache__/tyto.cpython-311.pyc b/src/var/lib/tyto/program/__pycache__/tyto.cpython-311.pyc index 467b6a1..7fec1f0 100644 Binary files a/src/var/lib/tyto/program/__pycache__/tyto.cpython-311.pyc and b/src/var/lib/tyto/program/__pycache__/tyto.cpython-311.pyc differ diff --git a/src/var/lib/tyto/program/__pycache__/wip.cpython-311.pyc b/src/var/lib/tyto/program/__pycache__/wip.cpython-311.pyc index b29415b..13fe706 100644 Binary files a/src/var/lib/tyto/program/__pycache__/wip.cpython-311.pyc and b/src/var/lib/tyto/program/__pycache__/wip.cpython-311.pyc differ diff --git a/src/var/lib/tyto/program/check.py b/src/var/lib/tyto/program/check.py index 285d5a2..b6dd512 100644 --- a/src/var/lib/tyto/program/check.py +++ b/src/var/lib/tyto/program/check.py @@ -314,6 +314,7 @@ def ol_tags(): if not post.logo[1]: src_uri = "%stemplate/%s"%(domain.www_url, domain.logo) post.logo = (post.logo[0], src_uri) + post.cf_set("HEADERS", "logo", src_uri) return True @@ -589,7 +590,7 @@ def is_value2_file_exists(ln, tag, val2): # Add file to [SOURCE_FILES] post database stats_total_files += 1 - post.cf_set("SOURCE_FILES", "file_%s"%stats_total_files, src_uri) + post.cf_set("SOURCE_FILES", "file_%s"%stats_total_files, value2_uri) post.cf_set("STATS_FILE", "files", str(stats_total_files)) return True @@ -1120,11 +1121,14 @@ def cf_update_values(part): web_target = web_target[:-10] if not web_target.startswith("/"): web_target = "/" + web_target - post.cf_set("FILE", "id", post.uri_id) - post.cf_set("FILE", "uri", post.uri) - post.cf_set("FILE", "db", post.cf_uri) - post.cf_set("FILE", "target", post.wrk_target) - post.cf_set("FILE", "web", web_target) + + # Create HTML local sub uri + post.cf_set("FILE", "id", post.uri_id) + post.cf_set("FILE", "uri", post.uri) + post.cf_set("FILE", "db", post.cf_uri) + post.cf_set("FILE", "target", post.wrk_target) + post.cf_set("FILE", "web", web_target) + post.cf.set("FILE", "sub_uri", post.wrk_target.count('/') * "../" or "./") # [WIP] # ----- diff --git a/src/var/lib/tyto/program/debug.py b/src/var/lib/tyto/program/debug.py index 90c9b44..3587bbd 100644 --- a/src/var/lib/tyto/program/debug.py +++ b/src/var/lib/tyto/program/debug.py @@ -48,11 +48,9 @@ import langs, args #-----------------------------------# def out(nbr, var, val, show, color, stop): args.get_options() - if not show: - # Show only warn and error logs - show = args.dlogs or args.erron and color > 0 - if not show: + logit = show or args.erron and color > 0 or args.dlogs + if not logit: return nbr # COlors diff --git a/src/var/lib/tyto/program/post.py b/src/var/lib/tyto/program/post.py index 8b9e3ff..ac28397 100644 --- a/src/var/lib/tyto/program/post.py +++ b/src/var/lib/tyto/program/post.py @@ -83,7 +83,7 @@ def is_article(target): wrk_target = uri.rsplit(domain.wrk_articles)[1] # Set web target, replace last .tyto with .html - web_target= wrk_target[:-4] + "html" + web_target = wrk_target[:-4] + "html" # Load Database, get and compare values cf_load() @@ -248,12 +248,16 @@ def cf_datas(): www_uri = cf_get("WWW", "uri", False) www_static = cf_get("WWW", "static", True) - global set_title, set_about, set_date, set_author - set_title = cf.get("HEADERS", "title") - set_about = cf.get("HEADERS", "about") - set_date = cf.get("HEADERS", "date") - set_tags = cf.get("HEADERS", "tags") - set_author = cf.get("HEADERS", "authors") + global set_title, set_about, set_date, set_tags, set_author + set_title = cf_get("HEADERS", "title", False) + set_about = cf_get("HEADERS", "about", False) + set_date = cf_get("HEADERS", "date", False) + set_tags = cf_get("HEADERS", "tags", False) + set_author = cf_get("HEADERS", "authors", False) + + global sub_uri, www_logo + sub_uri = cf_get("FILE", "sub_uri", False) + www_logo = cf_get("HEADERS", "logo", False) #===============================# diff --git a/src/var/lib/tyto/program/tools.py b/src/var/lib/tyto/program/tools.py index a2ab867..827eff3 100644 --- a/src/var/lib/tyto/program/tools.py +++ b/src/var/lib/tyto/program/tools.py @@ -33,8 +33,8 @@ #-------------------------- from hashlib import blake2b -import sys, os, configparser, datetime, time, base64 -import args, debug, domain, post +import sys, os, configparser, datetime, time, base64, shutil +import args, langs, debug, domain, post #=========================================# @@ -123,18 +123,35 @@ def create_dirs(path): #----------------------------# def create_file(file_path, contents): up = bool(os.path.exists(file_path)) - try: with open(file_path, "w") as f: f.write(contents) except: - # Exit at error + # Exit if not created debug.out(7, "False", file_path, True, 2, True) # log "update" or "new" file_name = os.path.basename(file_path) if up: debug.out(207, file_name, file_path, False, 0, False) - else: debug.out(206, file_name, file_path, False, 0, False) + else: debug.out(206, file_name, file_path, True, 0, False) + + +#============# +# Copy files # +#------------# +def copy_files(src, dst): + # Copy file, check if dst exists + up = bool(os.path.exists(dst)) + try: + shutil.copy2(src, dst, follow_symlinks=False) + except: + debug.out(7, langs.logs.copy, dst, True, 2, False) + return + + # log "update" or "new" + file_name = os.path.basename(src) + if up: debug.out(207, file_name, dst, False, 0, False) + else: debug.out(206, file_name, dst, True, 0, False) #===========================================# @@ -142,8 +159,7 @@ def create_file(file_path, contents): #-------------------------------------------# def update_ini_file(file_path, section, key, val): # Exit if no file - if not os.path.exists(file_path): - debug.out(5, "False", file_path, True, 2, True) + os.path.exists(file_path) or debug.out(5, "False", file_path, True, 2, True) # Load ini file config = configparser.ConfigParser() diff --git a/src/var/lib/tyto/program/tyto.py b/src/var/lib/tyto/program/tyto.py index 4a1c135..8aab998 100644 --- a/src/var/lib/tyto/program/tyto.py +++ b/src/var/lib/tyto/program/tyto.py @@ -107,7 +107,7 @@ code_line = '

' + \ '

' image_link = '' + \ - '%s%s' + \ + '%s%s' + \ '%s' a_link = '%s' diff --git a/src/var/lib/tyto/program/wip.py b/src/var/lib/tyto/program/wip.py index 1ffbec9..167ebf1 100644 --- a/src/var/lib/tyto/program/wip.py +++ b/src/var/lib/tyto/program/wip.py @@ -35,7 +35,7 @@ # file program : #-------------------------- -import sys, os, configparser +import sys, os, configparser, shutil import args, debug, tyto, tools, post, domain, check, langs @@ -88,49 +88,103 @@ def is_article(target): # Create full page page_html_create() + + # Copy article files + create_files() - print("\n> wip:", target) - print(html_post) + #print() + #print(html_post) #=======================# # Create full page HTML # #-----------------------# def page_html_create(): + global page_html + page_html = \ page_tpl%( post.set_title, domain.title, domain.lang, nginx_mods%("metas"), - metas_post, + metas_post%( + domain.www_url, + domain.lang, + domain.mail, + domain.license, + post.set_title, + post.set_author, + post.set_about, + post.set_tags, + post.cf.get("WWW", "web"), + post.sub_uri, domain.styles, + os.path.splitext(domain.favicon)[1][1:], post.sub_uri, domain.favicon, + domain.www_url, domain.rss, domain.title, + domain.title, + post.set_title, + post.cf.get("WWW", "web"), + post.set_about, + post.www_logo, + datepub, + post.set_title, post.set_author, domain.sep, domain.title + ), nginx_mods%("header"), nginx_mods%("navbar"), post.cf.get("WWW", "web"), - langs.site.permalink, langs.logs.pp, post.set_title, post.cf.get("WWW", "web"), - post.set_title, post.set_author, domain.title, + langs.site.permalink, langs.logs.pp, post.cf.get("WWW", "web"), + post.set_title, html_post, footer_post, nginx_mods%("sidebar"), nginx_mods%("footer") ) + - print() - print(page_html) +#========================================# +# Create and copy files for this article # +#----------------------------------------# +def create_files(): + # Copy files used by article + for key, src_uri in post.cf.items("SOURCE_FILES"): + dst_uri = src_uri.replace(domain.wrk_articles, domain.wip) + + wip_dirs = dst_uri.rsplit(os.path.basename(src_uri))[0] or domain.wip + + tools.create_dirs(wip_dirs) + tools.copy_files(src_uri, dst_uri) + + # Create source post wip dirs and html file + wip_dirs = \ + post.wip_uri.rsplit(os.path.basename(post.wip_uri))[0] or domain.wip + tools.create_dirs(wip_dirs) + tools.create_file(post.wip_uri, page_html) + # Copy domain work template directory + shutil.copytree(domain.wrk_tpl, + domain.wip_tpl, + dirs_exist_ok=True) + # Copy source file if article_code is True in domain config + if domain.article_code: + tools.copy_files(post.uri, + os.path.join(domain.wip, post.wrk_target) + ) + #===========================================# # Check full article contents (head + text) # # In error case, exit or return if targetS # #-------------------------------------------# def convert(target): - global targets, raw_post + global targets, raw_post, datepub targets = args.targets # Target is a tyto article format if not post.is_article(target): return False + datepub = tools.nowdate() + # Check/create wip server directories # Exit on error ! for key, directory in domain.cf.items("WIP_DIRS"): @@ -176,7 +230,7 @@ def convert(target): value_replace("ICODES", False, True) value_replace("BCODES", False, True) value_replace("CODES", False, True) - + footer_post_create() return True @@ -358,7 +412,9 @@ def images(): #
%s, %s%s

\n'%( post.set_date, post.set_author, link_post_code ) + \ @@ -903,11 +959,9 @@ def navbar_html_create(srv): html_index_srv_uri = os.path.join(html_indexes[srv], folder) html_index_srv_uri = os.path.join(html_index_srv_uri, "index.html") if not os.path.exists(html_index_srv_uri): - post.error = \ debug.out(5, 'Navbar. %s) "%s"'%( ln, html_index_srv_uri.rsplit(domain.srv_name)[1] - ), domain.wrk_navbar, True, 2, False) - return False + ), domain.wrk_navbar, True, 1, False) # Load post configuration file in tmp module # return if unused or post errors @@ -1011,13 +1065,11 @@ def sidebar_html_create(srv): wrk_post[:-4] + "html" ) - # Unused HTML post + # Unused index.html in srv if not os.path.exists(srv_post_uri): - post.error = \ debug.out(5, "Sidebar. %s) %s"%( ln, wrk_post - ), srv_post_uri, True, 2, False) - return False + ), srv_post_uri, True, 1, False) # Load post configuration file in tmp module # return if unused or post errors @@ -1047,8 +1099,7 @@ def sidebar_html_create(srv): post.error = \ debug.out(9, 'Sidebar', domain.wrk_sidebar, True, 2, False) return False - - + tools.create_file(modules["sidebar"][srv], module_sidebar%sidebar_html) return True @@ -1094,7 +1145,7 @@ def fill_footer_raw(): ) # Create copyright line - cur_date = tools.nowdate().rsplit("-")[0] + cur_date = datepub.rsplit("-")[0] dom_date = domain.date.rsplit("-")[0] if cur_date != dom_date: dates = "%s-%s"%(dom_date, cur_date) else: dates = cur_date @@ -1167,7 +1218,7 @@ metas_post = """ - + @@ -1175,7 +1226,7 @@ metas_post = """ -%s + @@ -1250,7 +1301,7 @@ page_tpl = """

-%s (%s) - %s +%s

%s @@ -1261,10 +1312,10 @@ page_tpl = """ %s - - %s + + """ diff --git a/src/var/lib/tyto/tpl_files/styles.css b/src/var/lib/tyto/tpl_files/styles.css index a551c53..5bc316a 100644 --- a/src/var/lib/tyto/tpl_files/styles.css +++ b/src/var/lib/tyto/tpl_files/styles.css @@ -37,8 +37,7 @@ a.site_menu_link {} /* div contains
and