[1.9.23] - new quote process (HTML prepared at 'check')

This commit is contained in:
Cyrille L 2023-10-14 11:11:47 +02:00
parent ea99dcd1ae
commit 8843fd3f76
10 changed files with 135 additions and 35 deletions

View File

@ -9,6 +9,9 @@ Tyto - Littérateur
# CURRENTLY IN DEV !
## [1.9.23]
- new quote process (HTML prepared at 'check')
## [1.9.22]
- new bcode process (html prepared for wip)
- new post database management values

View File

@ -1,6 +1,6 @@
#!/usr/bin/env python3
# Version: 1.9.22
# Updated: 2023-10-13 1697190846
# Version: 1.9.23
# Updated: 2023-10-14 1697274575
# Tyto - Littérateur
# Copyright (C) 2023 Cyrille Louarn <echolib+tyto@a-lec.org>
@ -94,7 +94,8 @@ prog_files = {
"show",
"tools",
"tyto",
"userset"
"userset",
"wip"
}
lang_files = {
"logs_en",

View File

@ -812,8 +812,8 @@ def cf_update_values():
post.cf_set("STATS_TEXTS", "tyto_coms", str(post.stats_tyto_text_coms))
post.cf_set("STATS_TEXTS", "html_coms", str(post.stats_html_coms))
post.cf_set("STATS_TEXTS", "titles", str(post.stats_titles))
#post.cf_set("STATS_TEXTS", "bcodes_lines", str(post.stats_bcodes_lines))
post.cf_set("STATS_TEXTS", "bcodes", str(post.ptags_stats["bcodes"]))
post.cf_set("STATS_TEXTS", "bcodes_lines", str(post.stats_bcodes_lines))
post.cf_set("STATS_TEXTS", "quotes", str(post.ptags_stats["quotes"]))
# Founds from header tags
post.cf_set("STATS_TEXTS", "links", str(post.stats_text_links))

View File

@ -312,17 +312,11 @@ value2s_ext_uris = ("http", "ftp")
# text_contents
# =============
# Start lines tags
bcodes = ("{{", "}}")
quotes = ("[[", "]]")
parags = ("((", "))")
lists = ("<<", ">>", "=", "+")
# Paired markers
ptags = (
("{{", "}}", "bcodes"),
("[[", "]]", "quotes"),
("((", "))", "parags"),
("((", "))", "parags", '<p class="%s">', "</p>"),
("<<", ">>", "lists" ),
)
@ -347,8 +341,7 @@ html_brline = ("|", '<br class="%s%s">')
html_hrline = ("--", '<hr class="%s%s">')
text_comments = (";;", "<!--")
html_parag_start = (parags[0], '<p class="%s%s">')
html_parag_close = (parags[1], '</p>')
quote_metas = ("cite:", "date:", "book:", "lang:", "link:")
# Specifics convertion
words_markers = \

View File

@ -108,3 +108,8 @@ code_line = '<p class="bcode">' + \
image_link = '<a href="%s" class="%s" target="%s" alt="%s" title="%s">%s</a>'
a_link = '<a href="%s" class="%s" target="%s" title="%s">%s</a>'
quote = """<blockquote class="%s"%s%s%s>%s
%s%s
%s
</blockquote>"""

View File

@ -32,23 +32,25 @@
# file program :
#--------------------------
import tyto, tools, post
import tyto, tools, post, domain
#===========================#
# bcode #
# Used by check module that #
# convert raw lines to HTML #
#---------------------------#
#=========================================================#
# Prepared HTML datas in post Database at 'check' process #====================
# Return new string to be converted to one line base64 #
#---------------------------------------------------------#
#===================#
# Create HTML bcode #
# convert raw lines #
#-------------------#
def bcode(lines):
lines = lines.rsplit("\n")
html_lines = ""
html_bcode = ""
for ln, line in enumerate(lines):
if ln == 0:
css = tools.get_css(line, post.bcodes[0])
if ln == 0: # Opened marker
css = tools.get_css(line, post.ptags[0][0])
continue
if ln == len(lines) - 1:
if ln == len(lines) - 1: # Closed marker
continue
# Count lines (add this to all other bcodes)
@ -59,22 +61,106 @@ def bcode(lines):
fc = len(line) - len(line.lstrip())
line = tyto.code_line%(ln, line[fc:])
if not html_lines: html_lines = line
else: html_lines = "%s\n%s"%(html_lines, line)
if not html_bcode: html_bcode = line
else: html_bcode = "%s\n%s"%(html_bcode, line)
html_lines = tyto.code_bcode%(css, html_lines)
#print(html_lines)
return html_lines
html_bcode = tyto.code_bcode%(css, html_bcode)
#print(html_bcode)
return html_bcode
#
#
#
#===================#
# Create HTML quote #
# convert raw lines #
#-------------------#
def quote(lines):
print("wip!")
print(lines)
lines = lines.rsplit("\n")
# Template
html_quote = "<!-- Quote -->"
block_time_on = block_time_off = ""
blockquote_cite = blockquote_lang = blockquote_title = ""
footer_cite = footer_book = footer_date = ""
footer = "%s%s%s"
# Metas datas
metas = post.quote_metas
cite = date = book = lang = link = ""
return lines
# Construct blockquote HTML
for ln, line in enumerate(lines):
line = line.lstrip()
# Open Marker (Unused in HTML). Get user CSS class
if ln == 0:
css = tools.get_css(line, post.ptags[1][0])
continue
# Closed marker (Unused in HTML)
elif ln == len(lines) - 1:
continue
# Meta is set. Get datas. (Unused line in HTML)
elif line.startswith(metas):
if line.startswith(metas[0]) and not cite:
try: cite = line.rsplit(metas[0])[1].lstrip()
except: cite = ""
elif line.startswith(metas[1]) and not date:
try: date = line.rsplit(metas[1])[1].lstrip()
except: date = ""
elif line.startswith(metas[2]) and not book:
try: book = line.rsplit(metas[2])[1].lstrip()
except: book = ""
elif line.startswith(metas[3]) and not lang:
try: lang = line.rsplit(metas[3])[1].lstrip()
except: lang = ""
elif line.startswith(metas[4]) and not link:
try: link = line.rsplit(metas[4])[1].lstrip()
except: link = ""
continue
# Real content quote
else:
html_quote = "%s\n%s"%(html_quote, line)
# Create template from datas
# <blockquote> tag
if link:
blockquote_cite = ' cite="%s"'%link
cite = cite or "Source"
footer = '<a class="%s quote" href="%s" target="_blank">%s</a>'%(
domain.css, link, footer
)
if lang:
blockquote_lang = ' lang="%s"'%lang
# <footer> tag
if book: footer_book = ' - %s'%book
if cite: footer_cite = '-- %s'%cite
if date:
footer_date = ' (%s)'%date
block_time_on = '\n<time datetime="%s">'%date
block_time_off = '\n</time>'
if date or book or cite:
blockquote_title = ' title="%s%s%s"'%(
footer_cite, footer_book, footer_date
)
footer = '<footer class="quote">\n' + \
'<p class="quote">' + \
footer%(footer_cite, footer_book, footer_date) + \
'</p>\n</footer>'
html_quote = tyto.quote%(
css,
blockquote_cite, blockquote_lang, blockquote_title,
block_time_on,
html_quote,
block_time_off,
footer
)
print(html_quote)
return html_quote
#============================#
@ -84,3 +170,15 @@ def quote(lines):
#----------------------------#
def code(lines):
print("soon...")
#
# Not Yet done, soon...
#
def paragraphs():
# Paragraph is set
if line.startswith(post.ptags[2][0]):
p_css = tools.get_css(line, post.ptags[2][0])
html_quote = "%s\n%s"%(html_quote, post.ptags[2][3]%p_css)
elif line.startswith(post.ptags[2][1]):
html_quote = "%s\n%s"%(html_quote, post.ptags[2][4])