From a71e2e58e60ab4d12428f897a55808b49168e211 Mon Sep 17 00:00:00 2001 From: Cyrille L Date: Wed, 18 Jan 2023 00:38:56 +0100 Subject: [PATCH] some fixes --- src/var/lib/tyto/program/check.py | 35 ++++++++++++++++--------------- src/var/lib/tyto/program/tyto.py | 5 ++--- 2 files changed, 20 insertions(+), 20 deletions(-) diff --git a/src/var/lib/tyto/program/check.py b/src/var/lib/tyto/program/check.py index e7a098b..a047a3e 100644 --- a/src/var/lib/tyto/program/check.py +++ b/src/var/lib/tyto/program/check.py @@ -459,12 +459,14 @@ def check_headers(post_header): ) # snpic (set image to share to social networks) + #---------------------------------------------- if snpic_name: continue tag = tyto.headers[11] # snpic: if line.startswith(tag): snpic_name = post_header[ln - 1].rsplit(tag)[1].lstrip() + for ln, line in enumerate(post_header, 1): - if re.search(r"^image:\s+hello$", line): + if re.search(r"^image:\s+%s$"%snpic_name, line): image_uri = post_header[ln].lstrip() check_file_uri('image', image_uri, ln + 1) snshare = True @@ -472,7 +474,7 @@ def check_headers(post_header): break if not snshare: tyto.exiting("10", '%s %s'%(tyto.headers[6], snpic_name), True) - + # Exit if error in optional tags #------------------------------- if post_err: @@ -519,7 +521,7 @@ def check_file_uri(filetype, filename, ln): fileuri = domain_files + filename[1: len(filename)] elif filename.startswith('/'): - fileuri = domain_articles + filename[1: len(filename)] + fileuri = tyto.post_dir + filename[1: len(filename)] else: fileuri = tyto.post_dir + filename @@ -604,23 +606,22 @@ def check_content(post_bottom): # Check for all match _TAGS:NAME from content in header #------------------------------------------------------ + set_tags = () for ln, line in enumerate(post_bottom): - for tag in tyto.content_tags: - htag = tag[1: len(tag)] + for htag in tyto.head_tags: + match = False + ptag = '_%s'%htag - if line.startswith(tag): - tag_id = line.rsplit(':', 1)[1].rsplit(' ')[0] - - match = False + if line.startswith(ptag): + ptag_set = line.rsplit(':', 1)[1].lstrip() # Get set tag + if ptag_set in set_tags: continue for hline in post_header: - if hline.startswith(htag): - htag_id = hline.rsplit(':', 1)[1].lstrip() - if htag_id == tag_id: - match = True - break - - if not match: - tyto.exiting("10", "%s %s"%(htag, tag_id), True) + if re.search(r"^%s\s+%s$"%(htag,ptag_set), hline): + match = True + set_tags = (ptag_set) + + if match: continue + else: tyto.exiting("10", "%s %s"%(htag, ptag_set), True) # Template Tags (warning for not paired symbols) diff --git a/src/var/lib/tyto/program/tyto.py b/src/var/lib/tyto/program/tyto.py index 57c9c7d..cb67c4c 100644 --- a/src/var/lib/tyto/program/tyto.py +++ b/src/var/lib/tyto/program/tyto.py @@ -178,9 +178,8 @@ quote_tags = [ ('_lang:', 'lang') ] -# Tags to check for header in content -content_tags = ("_image:", '_raw:') - +# Tags to check in header in content _TAG +head_tags = ("image:", "raw:") #=======# # TOOLS #