From 47592b6108fb7de683408c724ca6ae78c37a970c Mon Sep 17 00:00:00 2001 From: Cyrille L Date: Mon, 16 Jan 2023 10:46:23 +0100 Subject: [PATCH] indev: changed code for managing tyto.metas.html and metas.html --- src/var/lib/tyto/program/domain.py | 57 +--------------- src/var/lib/tyto/program/html.py | 102 +++++++++++++++++++++++++---- 2 files changed, 89 insertions(+), 70 deletions(-) diff --git a/src/var/lib/tyto/program/domain.py b/src/var/lib/tyto/program/domain.py index bba8e5b..3988417 100644 --- a/src/var/lib/tyto/program/domain.py +++ b/src/var/lib/tyto/program/domain.py @@ -435,7 +435,7 @@ def create_domain(target, option): #create_sidebar(option) #html.manage_configs('sidebar', 'Force') #html.manage_configs('navbar', 'Force') - #html.manage_configs('metas', 'Force') + html.manage_configs('metas', 'Force') html.manage_configs('footer', 'Force') print(' │') @@ -443,62 +443,7 @@ def create_domain(target, option): print(' │ Domain is ready. Have fun, writers ! │') print(' └──────────────────────────────────────┘') - -#========================================# -# Create metas.html with default content # -#----------------------------------------# -def create_metas_file(option): - metas_load = tyto.metas_load - metas_tags = '\n' + \ - '\n' + \ - '\n' + \ - '' - - - # Create new file, or ask if exists - ask = ' ├ Use default tyto.metas.html ? ' - log = ' ├ Create file: %s'%metas_load - if os.path.exists(metas_load): - if option == '-i': return # Continue to create template/metas.html - res = input(ask) - if not res in ['y', 'Y']: return - - tyto.set_file(metas_load, 'new', metas_tags) - print(log) - - #==============================# # sidebar load file translated # #------------------------------# diff --git a/src/var/lib/tyto/program/html.py b/src/var/lib/tyto/program/html.py index a1160fc..5226840 100644 --- a/src/var/lib/tyto/program/html.py +++ b/src/var/lib/tyto/program/html.py @@ -139,6 +139,19 @@ def create_metas_page(): def create_main_page(target, article_bottom): global main_page + # Check needed footer.html + footer_file = '%sfooter.html'%srv_wip_tpl + if not os.path.exists(footer_file): + tyto.exiting("1", footer_file, True) + + # Check optional metas.html + metas_file = '%smetas.html'%srv_wip_tpl + if not os.path.exists(metas_file): + tyto.exiting("24", '(user metas tags): '%metas_file, True) + + # Check for menu bar + create_navbar('-n', navbars_dir) + # Create link for website's logo #------------------------------- logo_html = '\n'%(15 * " ") + \ '%s'%(8 * " ") - # Check for menu bar - create_navbar('-n', navbars_dir) #-----------------------# # Create main HTML Page # @@ -188,9 +199,6 @@ def create_main_page(target, article_bottom): ' \n' + \ '' - footer_file = '%sfooter.html'%srv_wip_tpl - if not os.path.exists(footer_file): - tyto.exiting("1", footer_file, True) #====================================# # Create HTML menu from root folders # @@ -248,14 +256,82 @@ def create_navbar(option, target): # Create metas.html from tyto.metas.html # #----------------------------------------# def create_user_metas(option): - domain.create_metas_file("-i") # Ensure config file exists + metas_tags = \ + '\n' + \ + '\n' + \ + '\n' + \ + '' - metas_html = '%smetas.html'%srv_wip_tpl - user_metas = '' - metas_used = ('