From 42bd5a40d81b0139d5cc9fd507026abae72707fe Mon Sep 17 00:00:00 2001 From: Cyrille L Date: Fri, 18 Nov 2022 11:09:45 +0100 Subject: [PATCH] wip: ABBRs converted to base64 --- src/var/lib/tyto/program/check.py | 2 +- src/var/lib/tyto/program/wip.py | 45 ++++++++++++++++++++++--------- 2 files changed, 33 insertions(+), 14 deletions(-) diff --git a/src/var/lib/tyto/program/check.py b/src/var/lib/tyto/program/check.py index 1f185b3..c4e1f0c 100644 --- a/src/var/lib/tyto/program/check.py +++ b/src/var/lib/tyto/program/check.py @@ -1115,7 +1115,7 @@ def create_DB(post_db): if stats_abbrs_uniq > 0: for n in range(1,stats_abbrs_uniq+1): m = 'abbr_%s'%n - domain.append_f(post_db,'%s = %s'%(m,globals()[m])) + domain.append_f(post_db,'%s = %s'%(m,globals()[m])) # Statistics Post conf lines_conf = '' diff --git a/src/var/lib/tyto/program/wip.py b/src/var/lib/tyto/program/wip.py index 4220b50..38eec70 100644 --- a/src/var/lib/tyto/program/wip.py +++ b/src/var/lib/tyto/program/wip.py @@ -95,6 +95,7 @@ def manage_wip(file_post, Force): wip_titles( wip_html.rsplit('\n')) wip_words_markers(wip_html) wip_anchors( wip_html) + wip_abbrs( wip_html) # After all, convert protected contents wip_links( wip_html) @@ -234,6 +235,25 @@ def wip_links(article): wip_html = article +# +# +# +def wip_abbrs(article): + global wip_html + + abbr_fmt = '%s' + all_vars = set(globals()) + + for var in all_vars: + if var.startswith('abbr_'): + abbr = globals()[var] + abbr_b64 = abbr_fmt%(domain.domain_css, abbr[1], abbr[2]) + convert_to_b64(abbr_b64) + print('B64 for %s :> %s'%(abbr[1], b64_content)) + article = article.replace(abbr[0], b64_content) + + wip_html = article + #======================================# # Words Markers (strongs, emphasis...) # #--------------------------------------# @@ -356,11 +376,13 @@ def convert_quote(bQuote): # main quote content else: - if quote_html: quote_html = '%s\n%s'%(quote_html, line) - else : quote_html = line + if quote_html: quote_html = '%s\n%s'%(quote_html, line) + else : quote_html = line if not cite : author_show = 'NC' - if year and book: author_show = '%s%s%s'%(author_show, book_show, year_show) + if year and book: author_show = '%s%s%s'%( + author_show, book_show, year_show + ) if cite or link: author_show = '%s%s'%(cite, author_show) @@ -393,17 +415,16 @@ def convert_quote(bQuote): ) else: if year: quote_html = ''%( - year, blockquote - ) - else: quote_html = blockquote - - #print('> Quote_HTML:\n', quote_html) + year, blockquote + ) + else : quote_html = blockquote + #=================================# # Return datas in quote from line # #---------------------------------# def quote_data(line): - return line.split(' ',1)[1].lstrip() + return line.split(' ', 1)[1].lstrip() #=========================# @@ -437,10 +458,8 @@ def convert_bcodes(article, fm, lm, css): ) continue - if bCode: - bCode_lines = '%s%s\n'%(bCode_lines, line) - else: - article_temp = '%s%s\n'%(article_temp, line) + if bCode: bCode_lines = '%s%s\n'%(bCode_lines, line) + else : article_temp = '%s%s\n'%(article_temp, line) #====================================# # Protect bCodes contents to base64 #