diff --git a/CHANGELOG.md b/CHANGELOG.md index b74bc2c..acf3b96 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,10 @@ Tyto - Littérateur # CURRENTLY IN DEV ! +## [1.9.17] +- working on 'check' process +- - dev on checking file used in some post header tags + ## [1.9.16] - working on 'check' process - - dev: post database values (lots are missing) diff --git a/src/usr/bin/tyto b/src/usr/bin/tyto index 348c3ac..daba6a8 100755 --- a/src/usr/bin/tyto +++ b/src/usr/bin/tyto @@ -1,6 +1,6 @@ #!/usr/bin/env python3 -# Version: 1.9.16 -# Updated: 2023-10-03 1696344805 +# Version: 1.9.17 +# Updated: 2023-10-03 1696349064 # Tyto - Littérateur # Copyright (C) 2023 Cyrille Louarn 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 886576d..66025eb 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__/post.cpython-311.pyc b/src/var/lib/tyto/program/__pycache__/post.cpython-311.pyc index 8e5f981..4716b55 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/check.py b/src/var/lib/tyto/program/check.py index 9251f9c..39a9597 100644 --- a/src/var/lib/tyto/program/check.py +++ b/src/var/lib/tyto/program/check.py @@ -32,7 +32,7 @@ # file program : #-------------------------- -import sys +import sys, os from dateutil.parser import parse import args, domain, langs, debug, post, tools @@ -306,8 +306,10 @@ def ml_tag_values(ln, tag, stats): return False # Check value2 link for some tags (file, image...) - if tag in post.value2s_uri(): - if not is_value2_file_exists(ln+2, tag) + if tag in post.value2s_uri \ + and not value2.startswith(post.value2s_ext_uris): + if not is_value2_file_exists(ln+2, tag, value2): + return False # Convert values to HTML (put in post database) html_value = '%s'%( @@ -334,18 +336,39 @@ def ml_tag_values(ln, tag, stats): #================================# # Check value2 uri for some tags # +# uri starts with: # +# - @... for generic articles/ # +# - /... for root work directory # +# - ... for post directory # #--------------------------------# -def is_value2_file_exists(ln, tag): - # check first char if "@" to check file in generic folders - print("post: value2", ln, value2) +def is_value2_file_exists(ln, tag, value2): + # uri "@..." means generic folders + if value2[0].startswith("@"): + # Set defaut directory for files in /files + wrk_df = domain.wrk_files + + # Set directory for images in /images + if tag == post.ml_tags[1]: # image: + wrk_df = domain.wrk_images - # Set defaut directory for files in /files - wrk_df = domain.wrk_file - - # Set directory for images in /images - if tag == post.ml_tags[1]: # image: - wrk_df = domain.wrk_images + value2 = value2[1:] + + # uri "/..." means from wrk root folder + elif value2[0].startswith("/"): + wrk_df = domain.wrk_articles + value2 = value2[1:] + # uri "..." means from legacy post folder + else: + wrk_df = os.path.dirname(post.uri) + "/" + + # Check if file exists + file_uri = wrk_df + value2 + if not os.path.exists(file_uri): + post.error = \ + debug.out(5, "%s) %s"%(ln, tag), file_uri, True, 2, False) + return False + return True @@ -474,12 +497,10 @@ def titles(): # Count Tyto Comments elif line.startswith("#"): - print("?? tyto_coms", line) post.stats_tyto_text_coms += 1 # Count HTML comments elif line.startswith(post.text_comments): - print("?? html_coms", line) post.stats_html_coms += 1 return True diff --git a/src/var/lib/tyto/program/post.py b/src/var/lib/tyto/program/post.py index d03ffd0..5a8aced 100644 --- a/src/var/lib/tyto/program/post.py +++ b/src/var/lib/tyto/program/post.py @@ -181,6 +181,7 @@ ml_marks = { # Markers with uri in value2 value2s_uri = (ml_tags[1], ml_tags[2], ml_tags[3]) +value2s_ext_uris = ("http", "ftp") # text_contents # =============