[1.9.17] - Working on 'check', check set header post tags file
This commit is contained in:
parent
1aab0bd8fe
commit
ad632fc63d
|
@ -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)
|
||||
|
|
|
@ -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 <echolib+tyto@a-lec.org>
|
||||
|
|
Binary file not shown.
Binary file not shown.
|
@ -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 = '<a href="%s" class="%s" target="%s" alt="%s">%s</a>'%(
|
||||
|
@ -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
|
||||
|
|
|
@ -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
|
||||
# =============
|
||||
|
|
Loading…
Reference in New Issue