From cc0d43e4c95e853b1a17c8614117ee6de6da34be Mon Sep 17 00:00:00 2001 From: Cyrille LOUARN Date: Wed, 4 Oct 2023 01:02:29 +0200 Subject: [PATCH] [1.9.18] - image tag, value 2 uri check, fix domain conf file --- CHANGELOG.md | 7 ++ src/usr/bin/tyto | 4 +- .../program/__pycache__/check.cpython-311.pyc | Bin 22436 -> 24583 bytes .../__pycache__/domain.cpython-311.pyc | Bin 24602 -> 24618 bytes .../program/__pycache__/post.cpython-311.pyc | Bin 5950 -> 6036 bytes src/var/lib/tyto/program/check.py | 77 ++++++++++++------ src/var/lib/tyto/program/domain.py | 8 +- src/var/lib/tyto/program/post.py | 19 +++-- 8 files changed, 79 insertions(+), 36 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index acf3b96..c43af1a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,13 @@ Tyto - Littérateur # CURRENTLY IN DEV ! +## [1.9.18] +- working on 'check' process +- - added image: tag +- - added value 2 (tag line 2) uri check (generic, root, post) +- - some corrections for domain config file +- - prepared html values for wip + ## [1.9.17] - working on 'check' process - - dev on checking file used in some post header tags diff --git a/src/usr/bin/tyto b/src/usr/bin/tyto index daba6a8..110e81f 100755 --- a/src/usr/bin/tyto +++ b/src/usr/bin/tyto @@ -1,6 +1,6 @@ #!/usr/bin/env python3 -# Version: 1.9.17 -# Updated: 2023-10-03 1696349064 +# Version: 1.9.18 +# Updated: 2023-10-04 1696374079 # 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 66025eb73031a19726c90b3851c2e63bd205dea5..c1016f5aa71c42277fa99d70c7cbdcd05ff8b9f5 100644 GIT binary patch delta 3992 zcmbVOdu&tJ8NV;z>sK5<<462VNR4q!$fG0y3V9Gh2n9kyfGJh#<)+|}hVI@QNK<<; zEmgBFs3Bh~q5`X@C5(wNsIpC)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A{Ql>BA=p=qL`wTqMRZ( zS&Gq7kReJxg(1oyMJ38Gg)x{xQ+0C+;}3quUz1}6wdL94GjkKuQ?06)tgJLyioAf< z7Wse(ZxG?Td8VKsBjcILtA%7IUlbB!Qm~!;TqugmKQzeMHQvqB$91x`unD8lL7Hi%SwqisMW2OA>S9(=u~XCmV>W3f_VVr&g4J?VTJfs>oFi)W-R~!0|y~a=zFWbrI1E41y0pq`(aXDfod;MS!J& L2Ly{$fo1^!_Yhut delta 348 zcmbQDzfX^MIWI340}v#c%A~4HFPfU>pTZEO0K|$wtdufYm(hSzIZ8i;F_=M9Wpf_m4}Qj~$?1aHf=pIcn#@IBKqnP> zg9x9^8wCX!RS!qI`1?9~`o(f_MZ0KRDo>sxD$i8{6k`P9;vJKZiry9zlez&$AJ|!V nct0=zi3W}je3N&IZIKohxxgTB15AG4Qx;%p-~quRRiI`7gU(N; diff --git a/src/var/lib/tyto/program/check.py b/src/var/lib/tyto/program/check.py index 39a9597..5355c42 100644 --- a/src/var/lib/tyto/program/check.py +++ b/src/var/lib/tyto/program/check.py @@ -237,7 +237,6 @@ def is_valid_date(date): # Written using 3 lines # #----------------------------# def ml_tags(): - I_tag = post.ml_tags[1] # image: R_tag = post.ml_tags[3] # raw: C_tag = post.ml_tags[4] # code: A_tag = post.ml_tags[5] # abbr: @@ -263,7 +262,13 @@ def ml_tags(): return False # value errors c = 2 ; continue - + + elif line.startswith(post.ml_tags[1]): + post.stats_images += 1 + if not ml_tag_values(ln, post.ml_tags[1], post.stats_images): + return False # value errors + + c = 2 ; continue return True @@ -276,6 +281,8 @@ def ml_tags(): # Return True/False (if no value) # #----------------------------------------# def ml_tag_values(ln, tag, stats): + global value2 + # Get 3 lines values value1 = headers[ln].rsplit(":")[1].lstrip() value2 = headers[ln+1].lstrip() @@ -312,9 +319,7 @@ def ml_tag_values(ln, tag, stats): return False # Convert values to HTML (put in post database) - html_value = '%s'%( - value2, css, "%%s", value3, value1 - ) + link_var = "%s_%s"%(tag.replace(":", ""), stats) html_var = "html_%s"%stats @@ -322,11 +327,23 @@ def ml_tag_values(ln, tag, stats): if tag == post.ml_tags[0]: section = "LINKS" post.stats_text_links += post.text_contents.count(tyto_value) + html_value = '%s'%( + value2, css, "%%s", value3, value1 + ) elif tag == post.ml_tags[2]: section = "FILES" post.stats_text_files += post.text_contents.count(tyto_value) + html_value = '%s'%( + value2, css, "%%s", value3, value1 + ) + elif tag == post.ml_tags[1]: + section = "IMAGES" + post.stats_text_images += post.text_contents.count(tyto_value) + html_value = '%s'%( + value2, css, "%%s", value3, "%%s" + ) post.cf.set(section, link_var, tyto_value) post.cf.set(section, html_var, html_value) @@ -341,34 +358,45 @@ def ml_tag_values(ln, tag, stats): # - /... for root work directory # # - ... for post directory # #--------------------------------# -def is_value2_file_exists(ln, tag, value2): +def is_value2_file_exists(ln, tag, val2): + global value2 + # uri "@..." means generic folders - if value2[0].startswith("@"): - # Set defaut directory for files in /files - wrk_df = domain.wrk_files - + if val2[0].startswith("@"): + if val2[1] == "/": val2 = val2[2:] + else: val2 = val2[1:] + + #Set directory for files + test_uri = os.path.join(domain.wrk_files + val2) + value2 = src_uri = os.path.join("/files", val2) + # Set directory for images in /images if tag == post.ml_tags[1]: # image: - wrk_df = domain.wrk_images - - value2 = value2[1:] + test_uri = os.path.join(domain.wrk_images, val2) + value2 = src_uri = os.path.join("/images", val2) # uri "/..." means from wrk root folder - elif value2[0].startswith("/"): - wrk_df = domain.wrk_articles - value2 = value2[1:] + elif val2[0].startswith("/"): + val2 = val2[1:] + test_uri = os.path.join(domain.wrk_articles, val2) + src_uri = value2 # uri "..." means from legacy post folder else: - wrk_df = os.path.dirname(post.uri) + "/" + test_uri = os.path.dirname(post.uri) + "/" + val2 + value2 = "./" + val2 + src_uri = test_uri.rsplit("articles/")[1] # Check if file exists - file_uri = wrk_df + value2 - if not os.path.exists(file_uri): + if not os.path.exists(test_uri): post.error = \ - debug.out(5, "%s) %s"%(ln, tag), file_uri, True, 2, False) + debug.out(5, "%s) %s"%(ln, tag), test_uri, True, 2, False) return False - + + # Add file to [SOURCE_FILES] post database + post.stats_total_files += 1 + post.cf.set("SOURCE_FILES", "file_%s"%post.stats_total_files, src_uri) + return True @@ -523,10 +551,10 @@ def cf_update_values(): post.cf.set("HEADERS", "tags", post.tags[1]) post.cf.set("HEADERS", "authors", post.author[1]) post.cf.set("HEADERS", "sitemap", str(sitemap)) - post.cf.set("HEADERS", "static", str(domain.static)) post.cf.set("CHECK", "hash", post.wrk_id) post.cf.set("CHECK", "date", chk_date) + post.cf.set("CHECK", "static", str(domain.static)) post.cf.set("WIP", "web", "%s%s"%(domain.wip_url, post.wrk_target)) post.cf.set("WIP", "uri", "%s%s"%(domain.wip, post.wrk_target)) @@ -537,11 +565,13 @@ def cf_update_values(): stats_tyto_all_coms = post.stats_tyto_text_coms + post.stats_tyto_head_coms post.cf.set("STATS_FILE", "lines", str(post.lines)) post.cf.set("STATS_FILE", "tyto_coms", str(stats_tyto_all_coms)) + post.cf.set("STATS_FILE", "files", str(post.stats_total_files)) post.cf.set("STATS_HEADERS", "lines", str(post.head_lines)) + post.cf.set("STATS_HEADERS", "tyto_coms", str(post.stats_tyto_head_coms)) post.cf.set("STATS_HEADERS", "links", str(post.stats_links)) post.cf.set("STATS_HEADERS", "files", str(post.stats_files)) - post.cf.set("STATS_HEADERS", "tyto_coms", str(post.stats_tyto_head_coms)) + post.cf.set("STATS_HEADERS", "images", str(post.stats_images)) post.cf.set("STATS_TEXTS", "lines", str(post.text_lines)) post.cf.set("STATS_TEXTS", "tyto_coms", str(post.stats_tyto_text_coms)) @@ -549,6 +579,7 @@ def cf_update_values(): post.cf.set("STATS_TEXTS", "titles", str(post.stats_titles)) post.cf.set("STATS_TEXTS", "links", str(post.stats_text_links)) post.cf.set("STATS_TEXTS", "files", str(post.stats_text_files)) + post.cf.set("STATS_TEXTS", "images", str(post.stats_text_images)) with open(post.cf_uri, "w") as f: post.cf.write(f) diff --git a/src/var/lib/tyto/program/domain.py b/src/var/lib/tyto/program/domain.py index f42fa9f..e0a25f3 100644 --- a/src/var/lib/tyto/program/domain.py +++ b/src/var/lib/tyto/program/domain.py @@ -110,9 +110,9 @@ def cf_exists(): #=========================================# -# Guess and return www_url from name # +# Guess and return wip_url from name # #-----------------------------------------# -def create_www_url(): +def create_wip_url(): www_url = "https://www-wip.%s/" len_cn = name.count(".") @@ -605,9 +605,9 @@ except: # Domain Configuration directory wrk_dir = user_dir.rsplit("articles/")[0] wrk_articles = os.path.join(wrk_dir, "articles/") +wrk_images = os.path.join(wrk_dir, "articles/images/") +wrk_files = os.path.join(wrk_dir, "articles/files/") wrk_tpl = os.path.join(wrk_dir, "template/") -wrk_images = os.path.join(wrk_dir, "images/") -wrk_files = os.path.join(wrk_dir, "files/") wrk_mods = os.path.join(wrk_dir, "modules/") wrk_db = os.path.join(wrk_dir, ".db/") diff --git a/src/var/lib/tyto/program/post.py b/src/var/lib/tyto/program/post.py index 5a8aced..733cc30 100644 --- a/src/var/lib/tyto/program/post.py +++ b/src/var/lib/tyto/program/post.py @@ -174,9 +174,10 @@ snpic = ("snpic:", False) # Multiple lines (3) ml_tags = ("link:", "image:", "file:", "raw:", "code:", "abbr:") ml_marks = { - "link:" : "__", - "file:" : "--", - "abbr:" : "::" + "link:" : "__", + "file:" : "--", + "image:" : "_image:", + "abbr:" : "::" } # Markers with uri in value2 @@ -223,8 +224,11 @@ stats_raws = 0 stats_codes = 0 stats_abbrs = 0 -stats_text_links = 0 -stats_text_files = 0 +stats_total_files = 0 + +stats_text_links = 0 +stats_text_files = 0 +stats_text_images = 0 @@ -236,11 +240,10 @@ ini_template = """[DOMAIN] [FILE] [HEADERS] -static = snpic = [CHECK] -static +static = [WIP] static = @@ -260,6 +263,8 @@ static = [ABBRS] +[SOURCE_FILES] + [STATS_FILE] [STATS_HEADERS]