html: convert date in FR + file aside.html

This commit is contained in:
Cyrille L 2022-11-24 12:12:10 +01:00
parent 3e3885edf6
commit ecef8c1047
1 changed files with 41 additions and 17 deletions

View File

@ -23,15 +23,17 @@ Tyto = 'Tyto - Littérateur'
tytogen = 'https://git.a-lec.org/echolib/tyto-litterateur' tytogen = 'https://git.a-lec.org/echolib/tyto-litterateur'
tytourl = 'https://tyto.echolib.re' tytourl = 'https://tyto.echolib.re'
trans = [ trans = [
[ 'Licence', 'License' ], # 0 [ 'Licence', 'License' ], # 0
[ 'Générateur', 'Generator' ], # 1 [ 'Générateur', 'Generator' ], # 1
[ 'À propos de', 'About' ], # 2 [ 'À propos de', 'About' ], # 2
[ 'Envoyer un courriel à', 'Send a mail to' ], # 3 [ 'Envoyer un courriel à', 'Send a mail to' ], # 3
[ 'Détails de la licence', 'License\'s details'], # 4 [ 'Détails de la licence', 'License\'s details'], # 4
[ 'Courriel', 'Mail' ], # 5 [ 'Courriel', 'Mail' ], # 5
[ 'Site web généré par %s'%Tyto, 'Website generated by %s'%Tyto ], # 6 [ 'Site web généré par %s'%Tyto, 'Website generated by %s'%Tyto ], # 6
[ 'Syndication de', 'Syndication of' ], # 7 [ 'Syndication de', 'Syndication of' ], # 7
[ 'Site officiel de %s'%Tyto, 'Official website of %s'%Tyto ] # 8 [ 'Site officiel de %s'%Tyto, 'Official website of %s'%Tyto ], # 8
[ 'Écrit par', 'Written by' ], # 9
[ 'le ', 'on '] # 10
] ]
#=======================================# #=======================================#
@ -40,17 +42,25 @@ trans = [
#---------------------------------------# #---------------------------------------#
def translations(): def translations():
global fl # fl = field lang global fl # fl = field lang
global post_date
# Default FR/fr # Default FR/fr
if re.match('fr', domain.domain_lang, re.IGNORECASE): fl = 0 if re.match('fr', domain.domain_lang, re.IGNORECASE): fl = 0
else : fl = 1 else : fl = 1
# Change date format for FR
if fl == 0:
fr_date = post_date.rsplit('-')
print(">>>>", fr_date)
post_date = fr_date[2] + '/' + fr_date[1] + '/' + fr_date[0]
#========================# #========================#
# Create FULL HTML5 Page # # Create FULL HTML5 Page #
# includes wip.html # # includes wip.html #
#------------------------# #------------------------#
def html_main_page(wip_html): def html_main_page(wip_html):
global post_date
# Source DB variables # Source DB variables
post_db = exec(open(check.curr_post_db).read(),globals()) post_db = exec(open(check.curr_post_db).read(),globals())
@ -73,7 +83,7 @@ def html_main_page(wip_html):
msg_log = 'Unregistred logo in configuration domain' msg_log = 'Unregistred logo in configuration domain'
log.append_f(check.post_logs, msg_log, 1) log.append_f(check.post_logs, msg_log, 1)
# Check here for template files # Check for template files (styles, logo...)
files_uri = ( files_uri = (
'%s%s'%(domain.srv_wip, icon[1:len(icon)]), '%s%s'%(domain.srv_wip, icon[1:len(icon)]),
'%s%s'%(domain.srv_wip, f_css[1:len(f_css)]), '%s%s'%(domain.srv_wip, f_css[1:len(f_css)]),
@ -87,7 +97,7 @@ def html_main_page(wip_html):
# Set some terms from lang domain # Set some terms from lang domain
translations() translations()
# External URL in metas (if exists) # External URL in metas (if exists in config domain)
if domain.domain_exturl: if domain.domain_exturl:
relme = '<link rel="me" type="text/html" href="%s">\n'%( relme = '<link rel="me" type="text/html" href="%s">\n'%(
domain.domain_exturl domain.domain_exturl
@ -95,6 +105,8 @@ def html_main_page(wip_html):
else: else:
relme = '' relme = ''
# Metas in HTML page
#-------------------
metas = '<meta charset="UTF-8" />\n' + \ metas = '<meta charset="UTF-8" />\n' + \
'<meta name="viewport" content="%s">\n'%scale + \ '<meta name="viewport" content="%s">\n'%scale + \
'<meta name="robots" content="all">\n' + \ '<meta name="robots" content="all">\n' + \
@ -144,16 +156,18 @@ def html_main_page(wip_html):
'</header>\n' '</header>\n'
# Article (in section, including aside) # Article (in section)
#-------------------------------------- #--------------------------------------
articles = '<section id="page-wrapper">\n' + \ articles = '<section id="page-wrapper">\n' + \
' <article id="article_%s" class="%s">\n'%( ' <article id="article_%s" class="%s">\n'%(
post_ID, domain.domain_css post_ID, domain.domain_css
) + \ ) + \
' <div id="metas">\n' + \ ' <div id="metas">\n' + \
' <p>\n' + \ ' <p>\n' + \
' <span id="%s">%s</span>\n'%(post_author, post_author) + \ ' <span id="%s">%s %s</span>\n'%(
' <span id="sep"> - </span>\n' + \ post_author, trans[9][fl], post_author
) + \
' <span id="sep">, %s</span>\n'%trans[10][fl] + \
' <span id="date">%s</span>\n'%post_date + \ ' <span id="date">%s</span>\n'%post_date + \
' </p>\n' + \ ' </p>\n' + \
' </div>\n' ' </div>\n'
@ -229,6 +243,7 @@ def html_main_page(wip_html):
[ '%smetas.html'%domain.srv_wip_template, metas ], [ '%smetas.html'%domain.srv_wip_template, metas ],
[ '%sheader.html'%domain.srv_wip_template, headers ], [ '%sheader.html'%domain.srv_wip_template, headers ],
[ '%sfooter.html'%domain.srv_wip_template, footers ], [ '%sfooter.html'%domain.srv_wip_template, footers ],
[ '%saside.html'%domain.srv_wip_template, asides ]
] ]
for file_tpl in files_tpl: for file_tpl in files_tpl:
@ -289,8 +304,17 @@ def html_main_page(wip_html):
# Add latest-posts in page # Add latest-posts in page
#------------------------- #-------------------------
for aside in asides.rsplit('\n'): if os.path.exists(files_tpl[3][0]):
page = '%s\n%s%s'%(page, 8*' ', aside) 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)
page = '%s\n%s</section>'%(page, 6*' ') page = '%s\n%s</section>'%(page, 6*' ')
# Add footer in page # Add footer in page