From 30d2f60daac76fa0ae1b0c4516a8df3d54c0e97f Mon Sep 17 00:00:00 2001
From: Cyrille L
Date: Sun, 4 Dec 2022 17:00:45 +0100
Subject: [PATCH] html, wip: fixes for bcodes, and others found
---
src/var/lib/tyto/program/check.py | 3 +-
src/var/lib/tyto/program/html.py | 51 +++++++++++--------------------
src/var/lib/tyto/program/wip.py | 22 ++++++-------
3 files changed, 30 insertions(+), 46 deletions(-)
diff --git a/src/var/lib/tyto/program/check.py b/src/var/lib/tyto/program/check.py
index f389de9..c68f163 100644
--- a/src/var/lib/tyto/program/check.py
+++ b/src/var/lib/tyto/program/check.py
@@ -91,7 +91,7 @@ def post_IDs(file_post):
else:
for i in range(0,slash):
weburi = '%s../'%weburi
-
+
# Get Hash from article's content
global hash_chk
hash_chk = get_filesum(post_uri, True)
@@ -1227,6 +1227,7 @@ def create_DB(post_db):
'post_tmp = "%s"'%post_tmp,
'post_url = "%s"'%post_url,
'post_srv = "%s"'%post_srv,
+ 'web_uri = "%s"'%weburi,
'\n# Article Status',
'post_chk = (\'%s\', \'%s\')'%(hash_chk,time_chk),
'post_wip = (\'%s\', \'%s\')'%(hash_wip,time_wip),
diff --git a/src/var/lib/tyto/program/html.py b/src/var/lib/tyto/program/html.py
index 4638c06..32d538d 100644
--- a/src/var/lib/tyto/program/html.py
+++ b/src/var/lib/tyto/program/html.py
@@ -77,7 +77,7 @@ def html_main_page(wip_html):
tags = '%s,%s'%(domain.domain_tags, post_tags)
icon = '/template/favicon.png'
logo = '/template/%s'%domain.domain_logo
- f_css = '/template/styles.css'
+ f_css = '%stemplate/styles.css'%web_uri
f_rss = '/rss.xml'
i_rss = 'RSS 2.0. %s %s %s'%(
domain.domain_title, domain.sep_titles, domain.domain_name
@@ -183,7 +183,7 @@ def html_main_page(wip_html):
trans[9][fl], post_author
) + \
' , %s\n'%trans[10][fl] + \
- ' %s\n'%post_date + \
+ ' %s\n'%sdb_date + \
'
\n' + \
' \n'
@@ -215,7 +215,7 @@ def html_main_page(wip_html):
' \n' + \
' - URL:\n' + \
' \n' + \
+ ' href="/"\n' + \
' title="%s">%s\n'%(
domain.domain_title, domain.domain_url
) + \
@@ -255,10 +255,8 @@ def html_main_page(wip_html):
# Create file if not exists
#--------------------------
files_tpl = [
- [ '%smetas.html'%domain.srv_wip_template, metas ],
[ '%sheader.html'%domain.srv_wip_template, headers ],
- [ '%sfooter.html'%domain.srv_wip_template, footers ],
- [ '%saside.html'%domain.srv_wip_template, asides ]
+ [ '%sfooter.html'%domain.srv_wip_template, footers ]
]
for file_tpl in files_tpl:
@@ -278,16 +276,9 @@ def html_main_page(wip_html):
# Add tab metas in page
#----------------------
- if os.path.exists(files_tpl[0][0]):
- metas_datas = open(files_tpl[0][0], 'r').read()
- for meta_line in metas_datas.rsplit('\n'):
- page = '%s\n%s%s'%(page, 6*' ', meta_line)
- else:
- # No file: use this default
- for meta in metas.rsplit('\n'):
- page = '%s\n%s%s'%(page, 6*' ', meta)
- msg_log = 'Use default metas in page. Unused file: %s'%files_tpl[0][0]
- log.append_f(check.post_logs, msg_log, 0)
+ # No file: use this default
+ for meta in metas.rsplit('\n'):
+ page = '%s\n%s%s'%(page, 6*' ', meta)
page = '%s\n%s\n'%(page, 4*' ') + \
'\n%s'%(
@@ -296,15 +287,16 @@ def html_main_page(wip_html):
# Add tab header in page
#-----------------------
- if os.path.exists(files_tpl[1][0]):
- headers_datas = open(files_tpl[1][0], 'r').read()
+ if os.path.exists(files_tpl[0][0]):
+ headers_datas = open(files_tpl[0][0], 'r').read()
for header_line in headers_datas.rsplit('\n'):
page = '%s\n%s%s'%(page, 6*' ', header_line)
else:
# No file: use this default
for header in headers.rsplit('\n'):
page = '%s\n%s%s'%(page, 6*' ', header)
- msg_log = 'Use default header in page. Unused file: %s'%files_tpl[1][0]
+
+ msg_log = 'Use default header in page. Unused file: %s'%files_tpl[0][0]
log.append_f(check.post_logs, msg_log, 0)
# Add tab article in page
@@ -319,28 +311,21 @@ def html_main_page(wip_html):
# Add latest-posts in page
#-------------------------
- if os.path.exists(files_tpl[3][0]):
- asides_datas = open(files_tpl[3][0], 'r').read()
- for aside_line in asides_datas.rsplit('\n'):
- page = '%s\n%s%s'%(page, 8*' ', aside_line)
- else:
- # No file: use this default
- for aside in asides.rsplit('\n'):
- page = '%s\n%s%s'%(page, 8*' ', aside)
-
- msg_log = 'Use default sidebar in page. Unused file: %s'%files_tpl[3][0]
- log.append_f(check.post_logs, msg_log, 0)
+ # No file: use this default
+ for aside in asides.rsplit('\n'):
+ page = '%s\n%s%s'%(page, 8*' ', aside)
+
page = '%s\n%s'%(page, 6*' ')
# Add footer in page
#-------------------
- if os.path.exists(files_tpl[2][0]):
- footers_datas = open(files_tpl[2][0], 'r').read()
+ if os.path.exists(files_tpl[1][0]):
+ footers_datas = open(files_tpl[1][0], 'r').read()
for footer_line in footers_datas.rsplit('\n'):
page = '%s\n%s%s'%(page, 4*' ', footer_line)
else:
# No file: use this default
for footer in footers.rsplit('\n'):
page = '%s\n%s%s'%(page, 4*' ', footer)
- msg_log = 'Use default footer in page. Unused file: %s'%files_tpl[2][0]
+ msg_log = 'Use default footer in page. Unused file: %s'%files_tpl[1][0]
log.append_f(check.post_logs, msg_log, 0)
diff --git a/src/var/lib/tyto/program/wip.py b/src/var/lib/tyto/program/wip.py
index 60d03ec..69030fc 100644
--- a/src/var/lib/tyto/program/wip.py
+++ b/src/var/lib/tyto/program/wip.py
@@ -178,8 +178,8 @@ def wip_begin_markers(wip_lines):
['^>>\s' , '' , True ],
[r'^\($|\(\s' , '
' , True ],
['^\)$|^\)\s' , '
' , False],
- ['^\[\[$|^\[\[\s' , '', True ],
- ['^\]\]$|^\]\]\s' , '
' , False]
+ ['^\[\[$|^\[\[\s' , '',True ],
+ ['^\]\]$|^\]\]\s' , '
' , False]
]
for line in wip_lines:
@@ -624,10 +624,9 @@ def wip_bruts(article):
# Convert each lines to HTML, add to string
for ln, bline in enumerate(brut_datas.rsplit('\n'), 1):
- brut_line_html = '' + \
- '%s'%ln + \
- '%s'%bline + \
- ''
+ brut_line_html = ' %s
'%(
+ ln, bline, bline
+ )
if brut_html: brut_html = '%s\n%s'%(brut_html,brut_line_html)
else : brut_html = brut_line_html
@@ -635,9 +634,9 @@ def wip_bruts(article):
get_css(line)
# Add first and last HTML tags to string
- brut_html = '\n'%(
+ brut_html = '\n'%(
css_set, brut[2]) + \
- '%s\n
'%brut_html
+ '%s\n'%brut_html
# Replace line
if wip_html: wip_html = '%s\n%s'%(wip_html, brut_html)
@@ -680,10 +679,9 @@ def convert_bcodes(article, fm, lm, css):
if bCode:
bCode_ln += 1
- line = '' + \
- '%s'%bCode_ln + \
- '%s'%line + \
- ''
+ line = ' %s
'%(
+ bCode_ln, line, line
+ )
if bCode_lines: bCode_lines = '%s\n%s'%(bCode_lines, line)
else : bCode_lines = line
else: