indev: navbar manage

This commit is contained in:
Cyrille L 2023-01-16 11:43:07 +01:00
parent 47592b6108
commit 7595e6cc43
3 changed files with 24 additions and 18 deletions

View File

@ -433,8 +433,8 @@ def create_domain(target, option):
# Force will ask to create in template
print('')
#create_sidebar(option)
#html.manage_configs('sidebar', 'Force')
#html.manage_configs('navbar', 'Force')
html.manage_configs('sidebar', 'Force')
html.manage_configs('navbar', 'Force')
html.manage_configs('metas', 'Force')
html.manage_configs('footer', 'Force')
@ -482,11 +482,8 @@ def create_sidebar(option):
if tyto.n == 0: sdb_load = sdb_load_fr
elif tyto.n == 1: sdb_load = sdb_load_en
ask = ' ├ Use default (empty) sidebar config ? '
log = ' ├ Create file: %s'%sidebar_load
# Create new file, or ask if exists
ask = ' ├ Use default (empty) sidebar config file ? '
ask = ' ├ Use default (empty) _configs/tyto.sidebar file ? '
log = ' ├ Create file: %s'%sidebar_load
if os.path.exists(sidebar_load):
@ -501,6 +498,7 @@ def create_sidebar(option):
# navbar load file translated #
#-----------------------------#
def create_navbar(option):
navbar_load = tyto.navbar_load
nav_load_fr = '# Pour : Tyto - Littérateur\n' + \
'# Type : fichier texte\n' + \
'# Description : Fichier utilisé par "tyto wip"\n' + \
@ -547,7 +545,7 @@ def create_navbar(option):
elif tyto.n == 1: nav_load = nav_load_en
# Create new file, or ask if exists
ask = ' ├ Use default (empty) navbar config file ? '
ask = ' ├ Use default (empty) _configs/tyto.navbar file ? '
log = ' ├ Create file: %s'%navbar_load
if os.path.exists(navbar_load):

View File

@ -34,10 +34,11 @@ Tytosrc = '(<a href="%s" '%Tytogit + \
navbar_file = '%snavbar.html'%srv_wip_tpl
#
# Manage fies for HTML
# (sidebar, metas, footer, navbar)
#
#==================================#
# Manage HTML files for user #
# (sidebar, metas, footer, navbar) #
#----------------------------------#
def manage_configs(target, option):
args1 = ('metas', 'sidebar', 'footer', 'navbar')
@ -50,13 +51,11 @@ def manage_configs(target, option):
if not option in opts and not option == '-i' and not option in args2:
tyto.exiting('11', '%s'%str(args2), True)
# Getting default file
actions = {
'sidebar' : domain.create_sidebar,
'navbar' : domain.create_navbar,
'metas' : create_user_metas,
'footer' : create_footer
'footer' : create_user_footer
}
actions[sys.argv[1]](option)
@ -218,6 +217,7 @@ def create_navbar(option, target):
except: tyto.exiting("1", '(navbar) %s'%navbar_load, True)
# Open HTML tags
empty = True
menu_html = '%s<nav id="site_menu">\n'%(6 * ' ') + \
'%s<ul id="site_menu_items">'%(8 * ' ')
@ -238,6 +238,7 @@ def create_navbar(option, target):
continue
# Add link to HTML structure
empty = False
menu_item = '\n%s<li class="site_menu_item">\n'%(10 * ' ') + \
'%s<a class="site_menu_link"\n'%(12 * ' ') + \
'%s'%title + \
@ -249,8 +250,14 @@ def create_navbar(option, target):
# Close HTML tags
menu_html = '\n%s\n%s</ul>\n%s</nav>\n'%(menu_html, 8 * ' ', 6 * ' ')
tyto.set_file(navbar_file, 'new', menu_html)
if empty:
tyto.exiting("29", '(navbar): %s'%navbar_load, False)
tyto.set_file(navbar_file, 'new', '')
else:
tyto.set_file(navbar_file, 'new', menu_html)
log_html = ' ├ Create file: %s'%navbar_file
print(log_html)
#========================================#
# Create metas.html from tyto.metas.html #
@ -345,7 +352,7 @@ def create_user_metas(option):
#=========================================#
# Create generic footer from domain datas #
#-----------------------------------------#
def create_footer(option):
def create_user_footer(option):
try:
tyto.domain_licurl
domain_licurl = tyto.domain_licurl

View File

@ -512,6 +512,7 @@ def exiting(nbr, value, out):
'26' : ':? %sDeactivated%s "%s" in domain conf'%(CY, CS, value),
'27' : ':? %sDeleted%s %s'%(CY, CS, value),
'28' : ':? %sUnused directory%s: %s'%(CY, CS, value),
'29' : ':? %sEmpty configuration%s %s'%(CY, CS, value),
'255' : ':| Maybe later...'
}