From 1d3322c75b1c1cce281bd902f852f9dd90c7e489 Mon Sep 17 00:00:00 2001 From: Cyrille L Date: Mon, 6 Mar 2023 15:26:12 +0100 Subject: [PATCH] navbar creation. Complete rewrite --- src/var/lib/tyto/program/html.py | 165 ++++++++++++++++++++++--------- 1 file changed, 120 insertions(+), 45 deletions(-) diff --git a/src/var/lib/tyto/program/html.py b/src/var/lib/tyto/program/html.py index 3af42c8..e04db08 100644 --- a/src/var/lib/tyto/program/html.py +++ b/src/var/lib/tyto/program/html.py @@ -340,12 +340,16 @@ def create_sidebar(option): logs.out("33", target, False) -#====================================# -# Create HTML menu from root folders # -#------------------------------------# +#==================================# +# Create HTML navbar from config # +# If no index in src: STOP # +# For wip, create if no index.html # +# for publish all/navbar, STOP # +#----------------------------------# def create_navbar(option): domain.domain_needed() + # more confitions to pass try: db.navbar_load if not os.path.exists(db.navbar_load): @@ -353,24 +357,32 @@ def create_navbar(option): except: logs.out("1", 'Navbar load file', True) + # Set target from option + pub_opts = ('www', 'pub') if option == 'wip': target = db.wip_navbar elif option == 'www': target = db.www_navbar elif option == 'pub': target = db.www_navbar - # If content in sidebar, go True - navbar_new = False - navbar_has = False + # If content and error + navbar_new = False + navbar_has = False + e_src_index = False + e_www_index = False # If error, do not create file in www server + # Set first HTML line menu_html = '%s\n'%(menu_html, 8 * ' ', 6 * ' ') + tyto.set_file(target, 'New', menu_html) + print(' ├ Create file: %s'%target) + ''' #========================================================# # Create metas.html from _configs/tyto.metas.html # @@ -529,6 +604,6 @@ def create_user_footer(option): if user_footer: user_footer = "%s\n %s"%(user_footer, line) else: user_footer = ' %s'%line - tyto.set_file(target, True, user_footer) + tyto.set_file(target, 'New', user_footer) print(log_load)