[1.9.20] - 'check', updated logo and added 'abbr:' processes
This commit is contained in:
parent
9393bdc01a
commit
afa2546abb
|
@ -9,6 +9,11 @@ Tyto - Littérateur
|
|||
|
||||
# CURRENTLY IN DEV !
|
||||
|
||||
## [1.9.20]
|
||||
- working on 'check' process
|
||||
- - updated 'logo:' process
|
||||
- - added 'abbr:' process
|
||||
|
||||
## [1.9.19]
|
||||
- working on 'check' process
|
||||
- - Added post 'logo: URI' (for social network share + opt show on page)
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
#!/usr/bin/env python3
|
||||
# Version: 1.9.19
|
||||
# Updated: 2023-10-05 1696512944
|
||||
# Version: 1.9.20
|
||||
# Updated: 2023-10-06 1696580458
|
||||
# Tyto - Littérateur
|
||||
|
||||
# Copyright (C) 2023 Cyrille Louarn <echolib+tyto@a-lec.org>
|
||||
|
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
@ -254,9 +254,11 @@ def is_valid_date(date):
|
|||
# Written using 3 lines #
|
||||
#----------------------------#
|
||||
def ml_tags():
|
||||
global value1
|
||||
|
||||
value1 = ""
|
||||
R_tag = post.ml_tags[3] # raw:
|
||||
C_tag = post.ml_tags[4] # code:
|
||||
A_tag = post.ml_tags[5] # abbr:
|
||||
|
||||
c = 0 # Continue for next x lines, as tags are 3 lines values
|
||||
for ln, line in enumerate(headers):
|
||||
|
@ -266,6 +268,7 @@ def ml_tags():
|
|||
|
||||
if not line or line.isspace() or line.startswith("#"): continue
|
||||
|
||||
# link:
|
||||
if line.startswith(post.ml_tags[0]):
|
||||
post.stats_links += 1
|
||||
if not ml_tag_values(ln, post.ml_tags[0], post.stats_links):
|
||||
|
@ -273,6 +276,7 @@ def ml_tags():
|
|||
|
||||
c = 2 ; continue
|
||||
|
||||
# file:
|
||||
elif line.startswith(post.ml_tags[2]):
|
||||
post.stats_files += 1
|
||||
if not ml_tag_values(ln, post.ml_tags[2], post.stats_files):
|
||||
|
@ -280,13 +284,32 @@ def ml_tags():
|
|||
|
||||
c = 2 ; continue
|
||||
|
||||
# image:
|
||||
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
|
||||
# image: logo is reserved for post logo
|
||||
if value1 == "logo":
|
||||
debug.out(56, "%s) 'logo'"%(ln+1), post.uri, True, 2, False)
|
||||
return False
|
||||
|
||||
c = 2 ; continue
|
||||
|
||||
# ABBRS:
|
||||
elif line.startswith(post.ml_tags[5]):
|
||||
post.stats_abbrs += 1
|
||||
if not ml_tag_values(ln, post.ml_tags[5], post.stats_abbrs):
|
||||
return False # value errors
|
||||
|
||||
c = 2 ; continue
|
||||
|
||||
|
||||
# value1 must not starts with "_", as used by Tyto
|
||||
if value1.startswith("_"):
|
||||
debug.out(56, "%s) '_...'"%(ln+1), post.uri, True, 2, False)
|
||||
return False
|
||||
|
||||
return True
|
||||
|
||||
|
||||
|
@ -298,7 +321,7 @@ def ml_tags():
|
|||
# Return True/False (if no value) #
|
||||
#----------------------------------------#
|
||||
def ml_tag_values(ln, tag, stats):
|
||||
global value2
|
||||
global value1, value2
|
||||
|
||||
# Get 3 lines values
|
||||
value1 = headers[ln].rsplit(":")[1].lstrip()
|
||||
|
@ -360,6 +383,13 @@ def ml_tag_values(ln, tag, stats):
|
|||
value2, "%%s", "%%s", value3, "%%s"
|
||||
)
|
||||
|
||||
elif tag == post.ml_tags[5]:
|
||||
section = "ABBRS"
|
||||
post.stats_text_abbrs += post.text_contents.count(tyto_value)
|
||||
html_value = '<abbr class="%s" title="%s">%s</abbr>'%(
|
||||
domain.css, value2, value3
|
||||
)
|
||||
|
||||
post.cf.set(section, link_var, tyto_value)
|
||||
post.cf.set(section, html_var, html_value)
|
||||
|
||||
|
@ -376,8 +406,6 @@ def ml_tag_values(ln, tag, stats):
|
|||
def is_value2_file_exists(ln, tag, val2):
|
||||
global value2, src_uri
|
||||
|
||||
print("check: val2", tag, val2)
|
||||
|
||||
# uri "@..." means generic folders
|
||||
if val2[0].startswith("@"):
|
||||
if val2[1] == "/": val2 = val2[2:]
|
||||
|
@ -549,14 +577,15 @@ def titles():
|
|||
elif line.lstrip().startswith(post.text_comments):
|
||||
post.stats_html_coms += 1
|
||||
|
||||
# Add stat for [] when user wants to show logo in post
|
||||
# Add stat + html for [IMAGES] when user wants to show logo in post
|
||||
elif line.lstrip().startswith("_image:logo"):
|
||||
post.stats_text_images += 1
|
||||
link_var = "image_%s"%(post.stats_images+1)
|
||||
link_val = "_image:logo"
|
||||
html_var = "html_%s"%(post.stats_images+1)
|
||||
html_val = '<a href="%s" class="%s" target="%s" alt="%s">%s</a>'%(
|
||||
post.logo[1], "%%s", "%%s", post.title[1], "%%s")
|
||||
post.logo[1], "%%s", "%%s", post.title[1], "%%s"
|
||||
)
|
||||
post.cf.set("IMAGES", link_var, link_val)
|
||||
post.cf.set("IMAGES", html_var, html_val)
|
||||
|
||||
|
@ -603,6 +632,7 @@ def cf_update_values():
|
|||
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", "images", str(post.stats_images))
|
||||
post.cf.set("STATS_HEADERS", "abbrs", str(post.stats_abbrs))
|
||||
|
||||
post.cf.set("STATS_TEXTS", "lines", str(post.text_lines))
|
||||
post.cf.set("STATS_TEXTS", "tyto_coms", str(post.stats_tyto_text_coms))
|
||||
|
@ -611,6 +641,7 @@ def cf_update_values():
|
|||
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))
|
||||
post.cf.set("STATS_TEXTS", "abbrs", str(post.stats_text_abbrs))
|
||||
|
||||
with open(post.cf_uri, "w") as f:
|
||||
post.cf.write(f)
|
||||
|
|
|
@ -94,6 +94,7 @@ def out(nbr, var, val, show, color, stop):
|
|||
53 : langs.logs.err_post_paired,
|
||||
54 : langs.logs.err_post_indent,
|
||||
55 : langs.logs.err_post_in_tag,
|
||||
56 : langs.logs.err_post_datatag,
|
||||
# WARNINGS (100-200)
|
||||
100 : langs.logs.warn_no_dom,
|
||||
101 : langs.logs.domain_created,
|
||||
|
|
|
@ -227,7 +227,7 @@ stats_total_files = 0
|
|||
stats_text_links = 0
|
||||
stats_text_files = 0
|
||||
stats_text_images = 0
|
||||
|
||||
stats_text_abbrs = 0
|
||||
|
||||
|
||||
#=============================#
|
||||
|
|
Binary file not shown.
|
@ -65,6 +65,7 @@ err_post_data = "Donnée manquante"
|
|||
err_post_title = "Titre invalide"
|
||||
err_post_paired = "Marqueurs non apairés"
|
||||
err_post_in_tag = "Marqueurs sans contenu"
|
||||
err_post_datatag= "Donnée réservée"
|
||||
err_post_indent = "Ligne non indentée"
|
||||
|
||||
# Warnings
|
||||
|
|
Loading…
Reference in New Issue