indev: changed code for managing tyto.footer.html and footer.html
This commit is contained in:
parent
73546b5966
commit
9adb8ec8c8
|
@ -429,16 +429,14 @@ def create_domain(target, option):
|
|||
if not os.makedirs(folder, exist_ok=True):
|
||||
print(' │ Exists directory: %s'%folder)
|
||||
|
||||
# Create tyto.sidebar and metas.html
|
||||
# Create in _configs files
|
||||
# Force will ask to create in template
|
||||
print(' │')
|
||||
create_sidebar(option)
|
||||
html.manage_configs('sidebar', '-n')
|
||||
create_navbar(option)
|
||||
html.manage_configs('navbar', '-n')
|
||||
create_metas_file(option)
|
||||
html.manage_configs('metas', '-n')
|
||||
html.create_footer(option)
|
||||
html.manage_configs('footer', '-n')
|
||||
#create_sidebar(option)
|
||||
#html.manage_configs('sidebar', 'Force')
|
||||
#html.manage_configs('navbar', 'Force')
|
||||
#html.manage_configs('metas', 'Force')
|
||||
html.manage_configs('footer', 'Force')
|
||||
|
||||
print(' │')
|
||||
print(' ├──────────────────────────────────────┐')
|
||||
|
|
|
@ -41,8 +41,8 @@ navbar_file = '%snavbar.html'%srv_wip_tpl
|
|||
def manage_configs(target, option):
|
||||
|
||||
args1 = ('metas', 'sidebar', 'footer', 'navbar')
|
||||
args2 = ('-n', '-e', '-R')
|
||||
opts = ('New', 'Edit', 'Remove')
|
||||
args2 = ('-n', '-e', '-F', )
|
||||
opts = ('New', 'Edit', 'Force')
|
||||
|
||||
if target in args1: sys.argv[1] = target
|
||||
elif target and not option: option = target
|
||||
|
@ -51,15 +51,15 @@ def manage_configs(target, option):
|
|||
tyto.exiting('11', '%s'%str(args2), True)
|
||||
|
||||
# Getting default file
|
||||
if option == 'New':
|
||||
actions = {
|
||||
'sidebar' : domain.create_sidebar,
|
||||
'navbar' : domain.create_navbar,
|
||||
'metas' : create_user_metas,
|
||||
'footer' : html.create_footer
|
||||
}
|
||||
|
||||
actions[sys.argv[1]](option)
|
||||
actions = {
|
||||
'sidebar' : domain.create_sidebar,
|
||||
'navbar' : domain.create_navbar,
|
||||
'metas' : create_user_metas,
|
||||
'footer' : create_footer
|
||||
}
|
||||
|
||||
actions[sys.argv[1]](option)
|
||||
|
||||
|
||||
#==========================#
|
||||
|
@ -101,37 +101,36 @@ def create_metas_page():
|
|||
domain_relme
|
||||
)
|
||||
|
||||
|
||||
# Set all raw HTML metas
|
||||
#-----------------------
|
||||
global metas
|
||||
metas = ' <meta charset="UTF-8" />\n' + \
|
||||
' <meta name="viewport" content="%s" />\n'%scale + \
|
||||
' <meta name=”url” content=”%s” />\n'%domain_url + \
|
||||
' <meta name="language" content="%s" />\n'%domain_lang + \
|
||||
' <meta name="reply-to" content="%s" />\n'%domain_mail + \
|
||||
' <meta name="copyright" content="%s" />\n'%domain_license + \
|
||||
' <meta name="generator" content="%s" />\n'%Tyto + \
|
||||
' <meta name="title" content="%s" />\n'%title + \
|
||||
' <meta name="author" content="%s" />\n'%author + \
|
||||
' <meta name="description" content="%s" />\n'%about + \
|
||||
' <meta name="keywords" content="%s" />\n'%all_tags + \
|
||||
' <meta name="search_date" content="%s" />\n'%en_date + \
|
||||
' <link rel="canonical" href="%s" />\n'%post_url + \
|
||||
' <link rel="alternate" %s />\n'%(rss_ref) + \
|
||||
' <link rel="stylesheet" %s /\n'%css_ref + \
|
||||
' <link rel="shortcut icon" %s />'%icon_ref + \
|
||||
' <!-- Open Graph data -->\n' + \
|
||||
' <meta property="og:site_name" content="%s" />\n'%domain_title + \
|
||||
' <meta property="og:title" content="%s" />\n'%title + \
|
||||
' <meta property="og:type" content="article" />\n' + \
|
||||
' <meta property="og:url" content="%s" />\n'%post_url + \
|
||||
' <meta property="og:description" content="Description Here" />\n' + \
|
||||
' <meta property="og:image" content="" />\n' + \
|
||||
'%s'%relme + \
|
||||
'\n<!--# include virtual="/template/metas.html"-->\n' + \
|
||||
' <title>%s</title>'%title
|
||||
|
||||
metas = \
|
||||
' <meta charset="UTF-8" />\n' + \
|
||||
' <meta name="viewport" content="%s" />\n'%scale + \
|
||||
' <meta name=”url” content=”%s” />\n'%domain_url + \
|
||||
' <meta name="language" content="%s" />\n'%domain_lang + \
|
||||
' <meta name="reply-to" content="%s" />\n'%domain_mail + \
|
||||
' <meta name="copyright" content="%s" />\n'%domain_license + \
|
||||
' <meta name="generator" content="%s" />\n'%Tyto + \
|
||||
' <meta name="title" content="%s" />\n'%title + \
|
||||
' <meta name="author" content="%s" />\n'%author + \
|
||||
' <meta name="description" content="%s" />\n'%about + \
|
||||
' <meta name="keywords" content="%s" />\n'%all_tags + \
|
||||
' <meta name="search_date" content="%s" />\n'%en_date + \
|
||||
' <link rel="canonical" href="%s" />\n'%post_url + \
|
||||
' <link rel="alternate" %s />\n'%(rss_ref) + \
|
||||
' <link rel="stylesheet" %s /\n'%css_ref + \
|
||||
' <link rel="shortcut icon" %s />'%icon_ref + \
|
||||
' <!-- Open Graph data -->\n' + \
|
||||
' <meta property="og:site_name" content="%s" />\n'%domain_title + \
|
||||
' <meta property="og:title" content="%s" />\n'%title + \
|
||||
' <meta property="og:type" content="article" />\n' + \
|
||||
' <meta property="og:url" content="%s" />\n'%post_url + \
|
||||
' <meta property="og:description" content="%s" />\n'%about + \
|
||||
' <meta property="og:image" content="" />\n' + \
|
||||
'%s'%relme + \
|
||||
'\n<!--# include virtual="/template/metas.html"-->\n' + \
|
||||
' <title>%s</title>'%title
|
||||
|
||||
|
||||
#=======================================#
|
||||
|
@ -158,35 +157,36 @@ def create_main_page(target, article_bottom):
|
|||
#-----------------------#
|
||||
# Create main HTML Page #
|
||||
#-----------------------#
|
||||
main_page = '<!Doctype html>\n' + \
|
||||
'<html lang="%s">\n'%domain_lang + \
|
||||
' <head>\n' + \
|
||||
'%s\n'%metas + \
|
||||
' </head>\n\n' + \
|
||||
' <body>\n' + \
|
||||
' <header id="header_page">\n' + \
|
||||
' <div id="site_logo">\n' + \
|
||||
' %s\n'%logo_html + \
|
||||
' </div>\n' + \
|
||||
'\n' + \
|
||||
' <div id="site_infos">\n' + \
|
||||
' <a href="/"\n' + \
|
||||
' title="%s"\n'%(tyto.trans[1][tyto.n]) + \
|
||||
' id="site_link">\n' + \
|
||||
' <h1 id="site_title">%s</h1>\n'%domain_title + \
|
||||
' </a>\n' + \
|
||||
' <p id="site_about">%s</p>\n'%domain_about + \
|
||||
' </div>\n' + \
|
||||
'<!--# include virtual="/template/navbar.html"-->\n' + \
|
||||
' </header>\n' + \
|
||||
'\n' + \
|
||||
' <article id="article_main">\n' + \
|
||||
'%s\n'%article_bottom + \
|
||||
' </article>\n' + \
|
||||
'\n' + \
|
||||
'<!--# include virtual="/template/footer.html"-->\n' + \
|
||||
' </body>\n' + \
|
||||
'</html>'
|
||||
main_page = \
|
||||
'<!Doctype html>\n' + \
|
||||
'<html lang="%s">\n'%domain_lang + \
|
||||
' <head>\n' + \
|
||||
'%s\n'%metas + \
|
||||
' </head>\n\n' + \
|
||||
' <body>\n' + \
|
||||
' <header id="header_page">\n' + \
|
||||
' <div id="site_logo">\n' + \
|
||||
' %s\n'%logo_html + \
|
||||
' </div>\n' + \
|
||||
'\n' + \
|
||||
' <div id="site_infos">\n' + \
|
||||
' <a href="/"\n' + \
|
||||
' title="%s"\n'%(tyto.trans[1][tyto.n]) + \
|
||||
' id="site_link">\n' + \
|
||||
' <h1 id="site_title">%s</h1>\n'%domain_title + \
|
||||
' </a>\n' + \
|
||||
' <p id="site_about">%s</p>\n'%domain_about + \
|
||||
' </div>\n' + \
|
||||
'<!--# include virtual="/template/navbar.html"-->\n' + \
|
||||
' </header>\n' + \
|
||||
'\n' + \
|
||||
' <article id="article_main">\n' + \
|
||||
'%s\n'%article_bottom + \
|
||||
' </article>\n' + \
|
||||
'\n' + \
|
||||
'<!--# include virtual="/template/footer.html"-->\n' + \
|
||||
' </body>\n' + \
|
||||
'</html>'
|
||||
|
||||
footer_file = '%sfooter.html'%srv_wip_tpl
|
||||
if not os.path.exists(footer_file):
|
||||
|
@ -244,9 +244,9 @@ def create_navbar(option, target):
|
|||
tyto.set_file(navbar_file, 'new', menu_html)
|
||||
|
||||
|
||||
#
|
||||
# Create metas.html from tyto.metas.html
|
||||
#
|
||||
#========================================#
|
||||
# Create metas.html from tyto.metas.html #
|
||||
#----------------------------------------#
|
||||
def create_user_metas(option):
|
||||
domain.create_metas_file("-i") # Ensure config file exists
|
||||
|
||||
|
@ -279,49 +279,89 @@ def create_footer(option):
|
|||
domain_licurl = "/"
|
||||
|
||||
# Default footer contents
|
||||
footer = '<footer id="footer_page">\n' + \
|
||||
' <div id="footer_infos">\n' + \
|
||||
' <a href="/"\n' + \
|
||||
' title="%s"\n'%(tyto.trans[1][tyto.n]) + \
|
||||
' id="footer_title_link">\n' + \
|
||||
' <h1 id="footer_site_title">%s</h1>\n'%(
|
||||
domain_title) + \
|
||||
' </a>\n' + \
|
||||
' <p id="footer_site_about">%s</p>\n'%(
|
||||
domain_about) + \
|
||||
' </div>\n' + \
|
||||
'\n' + \
|
||||
' <div id="footer_references">\n' + \
|
||||
' <ul> id="footer_items"\n' + \
|
||||
' <li id="fotter_item">\n' + \
|
||||
' <a href="%s"\n'%domain_licurl + \
|
||||
' title="%s %s %s"\n'%(
|
||||
tyto.trans[2][tyto.n],
|
||||
domain_sep, domain_title) + \
|
||||
' id="footer_item_link">%s</a>\n'%(
|
||||
domain_license) + \
|
||||
' </li>\n' + \
|
||||
' <li id="fotter_item">\n' + \
|
||||
' <a href="%s"\n'%Tytoweb + \
|
||||
' title="%s"\n'%Tytowti + \
|
||||
' id="footer_item_link">%s</a> %s\n'%(Tyto, Tytosrc) + \
|
||||
' </li>\n' + \
|
||||
' </ul>\n' + \
|
||||
' </div>\n' + \
|
||||
'</footer>\n'
|
||||
footer = \
|
||||
'<!-- Default <footer> generated by %s -->\n'%Tyto + \
|
||||
'<footer id="footer_page">\n' + \
|
||||
' <div id="footer_infos">\n' + \
|
||||
' <a href="/"\n' + \
|
||||
' title="%s"\n'%(tyto.trans[1][tyto.n]) + \
|
||||
' id="footer_title_link">\n' + \
|
||||
' <h1 id="footer_site_title">%s</h1>\n'%(domain_title) + \
|
||||
' </a>\n' + \
|
||||
' <p id="footer_site_about">%s</p>\n'%(domain_about) + \
|
||||
' </div>\n' + \
|
||||
'\n' + \
|
||||
' <div id="footer_references">\n' + \
|
||||
' <ul> id="footer_items"\n' + \
|
||||
' <li id="fotter_item">\n' + \
|
||||
' <a href="%s"\n'%domain_licurl + \
|
||||
' title="%s %s %s"\n'%(
|
||||
tyto.trans[2][tyto.n],
|
||||
domain_sep, domain_title) + \
|
||||
' id="footer_item_link">%s</a>\n'%(
|
||||
domain_license) + \
|
||||
' </li>\n' + \
|
||||
' <li id="fotter_item">\n' + \
|
||||
' <a href="%s"\n'%Tytoweb + \
|
||||
' title="%s"\n'%Tytowti + \
|
||||
' id="footer_item_link">%s</a> %s\n'%(Tyto, Tytosrc) + \
|
||||
' </li>\n' + \
|
||||
' </ul>\n' + \
|
||||
' </div>\n' + \
|
||||
'</footer>'
|
||||
|
||||
|
||||
# Create new file, or ask if exists
|
||||
ask = ' ├ Use default footer.html ? '
|
||||
log = ' ├ Create file: %s'%footer_load
|
||||
ask_load = ' ├ Use default _configs/tyto.footer.html ? '
|
||||
log_load = ' ├ Create file: %s'%footer_load
|
||||
create_load = True
|
||||
|
||||
footer_html = '%sfooter.html'%srv_wip_tpl
|
||||
ask_html = ' ├ Replace template/footer.html ' + \
|
||||
'from _configs/tyto.footer.html ? '
|
||||
log_html = ' ├ Create file: %s'%footer_html
|
||||
create_html = True
|
||||
user_footer = ''
|
||||
|
||||
|
||||
# Auto create if not tyto.footer.html in _configs
|
||||
# Pass if exists, user not wants, option is 'New' (only footer.html)
|
||||
res = ''
|
||||
if os.path.exists(footer_load):
|
||||
if option == '-i': return
|
||||
res = input(ask)
|
||||
if not res in ['y', 'Y']: return
|
||||
if option == 'New':
|
||||
create_load = False
|
||||
else:
|
||||
res = input(ask_load)
|
||||
if not res in ['y', 'Y']: create_load = False
|
||||
|
||||
if create_load:
|
||||
tyto.set_file(footer_load, 'new', footer)
|
||||
print(log_load)
|
||||
|
||||
|
||||
# Auto create if not footer.html in template/
|
||||
# Create if option is 'New'
|
||||
res = ''
|
||||
if os.path.exists(footer_html):
|
||||
if option == 'New':
|
||||
create_html = True
|
||||
else:
|
||||
res = input(ask_html)
|
||||
if not res in ['y', 'Y']: create_html = False
|
||||
|
||||
if create_html:
|
||||
user_file = open(footer_load, 'r').read()
|
||||
|
||||
for line in user_file.rsplit('\n'):
|
||||
if not line: continue
|
||||
if user_footer: user_footer = "%s\n %s"%(user_footer, line)
|
||||
else: user_footer = ' %s'%line
|
||||
|
||||
tyto.set_file(footer_html, 'new', user_footer)
|
||||
print(log_html)
|
||||
|
||||
|
||||
|
||||
tyto.set_file(footer_load, 'new', footer)
|
||||
print(log)
|
||||
|
||||
'''
|
||||
' <li id="fotter_item">\n' + \
|
||||
|
@ -332,26 +372,3 @@ def create_footer(option):
|
|||
Copyright © 2021-2022
|
||||
|
||||
'''
|
||||
|
||||
#
|
||||
# Create footer.html from tyto.footer.html
|
||||
#
|
||||
def create_user_footer(option):
|
||||
create_footer("-i") # Ensure config file exists
|
||||
|
||||
footer_html = '%sfooter.html'%srv_wip_tpl
|
||||
user_footer = ''
|
||||
noline = ('<!--')
|
||||
log = ' ├ Create file: %s'%footer_html
|
||||
|
||||
try:
|
||||
user_file = open(footer_load, 'r').read()
|
||||
|
||||
for line in user_file.rsplit('\n'):
|
||||
if line.startswith(noline): continue
|
||||
if user_metas: user_metas = "%s\n %s"%(user_metas, line)
|
||||
else: user_metas = ' %s'%line
|
||||
tyto.set_file(footer_html, 'new', user_footer)
|
||||
print(log)
|
||||
except:
|
||||
tyto.exiting("24", '(metas file): %s'%footer_load, False)
|
||||
|
|
Loading…
Reference in New Issue