From ecef8c10476a448da9f1cffb52c6457e6e40a1c0 Mon Sep 17 00:00:00 2001 From: Cyrille L Date: Thu, 24 Nov 2022 12:12:10 +0100 Subject: [PATCH] html: convert date in FR + file aside.html --- src/var/lib/tyto/program/html.py | 58 ++++++++++++++++++++++---------- 1 file changed, 41 insertions(+), 17 deletions(-) diff --git a/src/var/lib/tyto/program/html.py b/src/var/lib/tyto/program/html.py index 6cc1a0f..40e98d4 100644 --- a/src/var/lib/tyto/program/html.py +++ b/src/var/lib/tyto/program/html.py @@ -23,15 +23,17 @@ Tyto = 'Tyto - Littérateur' tytogen = 'https://git.a-lec.org/echolib/tyto-litterateur' tytourl = 'https://tyto.echolib.re' trans = [ - [ 'Licence', 'License' ], # 0 - [ 'Générateur', 'Generator' ], # 1 - [ 'À propos de', 'About' ], # 2 - [ 'Envoyer un courriel à', 'Send a mail to' ], # 3 - [ 'Détails de la licence', 'License\'s details'], # 4 - [ 'Courriel', 'Mail' ], # 5 - [ 'Site web généré par %s'%Tyto, 'Website generated by %s'%Tyto ], # 6 - [ 'Syndication de', 'Syndication of' ], # 7 - [ 'Site officiel de %s'%Tyto, 'Official website of %s'%Tyto ] # 8 + [ 'Licence', 'License' ], # 0 + [ 'Générateur', 'Generator' ], # 1 + [ 'À propos de', 'About' ], # 2 + [ 'Envoyer un courriel à', 'Send a mail to' ], # 3 + [ 'Détails de la licence', 'License\'s details'], # 4 + [ 'Courriel', 'Mail' ], # 5 + [ 'Site web généré par %s'%Tyto, 'Website generated by %s'%Tyto ], # 6 + [ 'Syndication de', 'Syndication of' ], # 7 + [ '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(): global fl # fl = field lang + global post_date # Default FR/fr if re.match('fr', domain.domain_lang, re.IGNORECASE): fl = 0 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 # # includes wip.html # #------------------------# def html_main_page(wip_html): + global post_date + # Source DB variables 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' log.append_f(check.post_logs, msg_log, 1) - # Check here for template files + # Check for template files (styles, logo...) files_uri = ( '%s%s'%(domain.srv_wip, icon[1:len(icon)]), '%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 translations() - # External URL in metas (if exists) + # External URL in metas (if exists in config domain) if domain.domain_exturl: relme = '\n'%( domain.domain_exturl @@ -95,6 +105,8 @@ def html_main_page(wip_html): else: relme = '' + # Metas in HTML page + #------------------- metas = '\n' + \ '\n'%scale + \ '\n' + \ @@ -144,16 +156,18 @@ def html_main_page(wip_html): '\n' - # Article (in section, including aside) + # Article (in section) #-------------------------------------- articles = '
\n' + \ '
\n'%( - post_ID, domain.domain_css + post_ID, domain.domain_css ) + \ '
\n' + \ '

\n' + \ - ' %s\n'%(post_author, post_author) + \ - ' - \n' + \ + ' %s %s\n'%( + post_author, trans[9][fl], post_author + ) + \ + ' , %s\n'%trans[10][fl] + \ ' %s\n'%post_date + \ '

\n' + \ '
\n' @@ -229,6 +243,7 @@ def html_main_page(wip_html): [ '%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 ] ] for file_tpl in files_tpl: @@ -289,8 +304,17 @@ def html_main_page(wip_html): # Add latest-posts in page #------------------------- - for aside in asides.rsplit('\n'): - page = '%s\n%s%s'%(page, 8*' ', aside) + 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) page = '%s\n%s
'%(page, 6*' ') # Add footer in page