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):
|
if not os.makedirs(folder, exist_ok=True):
|
||||||
print(' │ Exists directory: %s'%folder)
|
print(' │ Exists directory: %s'%folder)
|
||||||
|
|
||||||
# Create tyto.sidebar and metas.html
|
# Create in _configs files
|
||||||
|
# Force will ask to create in template
|
||||||
print(' │')
|
print(' │')
|
||||||
create_sidebar(option)
|
#create_sidebar(option)
|
||||||
html.manage_configs('sidebar', '-n')
|
#html.manage_configs('sidebar', 'Force')
|
||||||
create_navbar(option)
|
#html.manage_configs('navbar', 'Force')
|
||||||
html.manage_configs('navbar', '-n')
|
#html.manage_configs('metas', 'Force')
|
||||||
create_metas_file(option)
|
html.manage_configs('footer', 'Force')
|
||||||
html.manage_configs('metas', '-n')
|
|
||||||
html.create_footer(option)
|
|
||||||
html.manage_configs('footer', '-n')
|
|
||||||
|
|
||||||
print(' │')
|
print(' │')
|
||||||
print(' ├──────────────────────────────────────┐')
|
print(' ├──────────────────────────────────────┐')
|
||||||
|
|
|
@ -41,8 +41,8 @@ navbar_file = '%snavbar.html'%srv_wip_tpl
|
||||||
def manage_configs(target, option):
|
def manage_configs(target, option):
|
||||||
|
|
||||||
args1 = ('metas', 'sidebar', 'footer', 'navbar')
|
args1 = ('metas', 'sidebar', 'footer', 'navbar')
|
||||||
args2 = ('-n', '-e', '-R')
|
args2 = ('-n', '-e', '-F', )
|
||||||
opts = ('New', 'Edit', 'Remove')
|
opts = ('New', 'Edit', 'Force')
|
||||||
|
|
||||||
if target in args1: sys.argv[1] = target
|
if target in args1: sys.argv[1] = target
|
||||||
elif target and not option: option = target
|
elif target and not option: option = target
|
||||||
|
@ -51,15 +51,15 @@ def manage_configs(target, option):
|
||||||
tyto.exiting('11', '%s'%str(args2), True)
|
tyto.exiting('11', '%s'%str(args2), True)
|
||||||
|
|
||||||
# Getting default file
|
# 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
|
domain_relme
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
# Set all raw HTML metas
|
# Set all raw HTML metas
|
||||||
#-----------------------
|
#-----------------------
|
||||||
global metas
|
global metas
|
||||||
metas = ' <meta charset="UTF-8" />\n' + \
|
metas = \
|
||||||
' <meta name="viewport" content="%s" />\n'%scale + \
|
' <meta charset="UTF-8" />\n' + \
|
||||||
' <meta name=”url” content=”%s” />\n'%domain_url + \
|
' <meta name="viewport" content="%s" />\n'%scale + \
|
||||||
' <meta name="language" content="%s" />\n'%domain_lang + \
|
' <meta name=”url” content=”%s” />\n'%domain_url + \
|
||||||
' <meta name="reply-to" content="%s" />\n'%domain_mail + \
|
' <meta name="language" content="%s" />\n'%domain_lang + \
|
||||||
' <meta name="copyright" content="%s" />\n'%domain_license + \
|
' <meta name="reply-to" content="%s" />\n'%domain_mail + \
|
||||||
' <meta name="generator" content="%s" />\n'%Tyto + \
|
' <meta name="copyright" content="%s" />\n'%domain_license + \
|
||||||
' <meta name="title" content="%s" />\n'%title + \
|
' <meta name="generator" content="%s" />\n'%Tyto + \
|
||||||
' <meta name="author" content="%s" />\n'%author + \
|
' <meta name="title" content="%s" />\n'%title + \
|
||||||
' <meta name="description" content="%s" />\n'%about + \
|
' <meta name="author" content="%s" />\n'%author + \
|
||||||
' <meta name="keywords" content="%s" />\n'%all_tags + \
|
' <meta name="description" content="%s" />\n'%about + \
|
||||||
' <meta name="search_date" content="%s" />\n'%en_date + \
|
' <meta name="keywords" content="%s" />\n'%all_tags + \
|
||||||
' <link rel="canonical" href="%s" />\n'%post_url + \
|
' <meta name="search_date" content="%s" />\n'%en_date + \
|
||||||
' <link rel="alternate" %s />\n'%(rss_ref) + \
|
' <link rel="canonical" href="%s" />\n'%post_url + \
|
||||||
' <link rel="stylesheet" %s /\n'%css_ref + \
|
' <link rel="alternate" %s />\n'%(rss_ref) + \
|
||||||
' <link rel="shortcut icon" %s />'%icon_ref + \
|
' <link rel="stylesheet" %s /\n'%css_ref + \
|
||||||
' <!-- Open Graph data -->\n' + \
|
' <link rel="shortcut icon" %s />'%icon_ref + \
|
||||||
' <meta property="og:site_name" content="%s" />\n'%domain_title + \
|
' <!-- Open Graph data -->\n' + \
|
||||||
' <meta property="og:title" content="%s" />\n'%title + \
|
' <meta property="og:site_name" content="%s" />\n'%domain_title + \
|
||||||
' <meta property="og:type" content="article" />\n' + \
|
' <meta property="og:title" content="%s" />\n'%title + \
|
||||||
' <meta property="og:url" content="%s" />\n'%post_url + \
|
' <meta property="og:type" content="article" />\n' + \
|
||||||
' <meta property="og:description" content="Description Here" />\n' + \
|
' <meta property="og:url" content="%s" />\n'%post_url + \
|
||||||
' <meta property="og:image" content="" />\n' + \
|
' <meta property="og:description" content="%s" />\n'%about + \
|
||||||
'%s'%relme + \
|
' <meta property="og:image" content="" />\n' + \
|
||||||
'\n<!--# include virtual="/template/metas.html"-->\n' + \
|
'%s'%relme + \
|
||||||
' <title>%s</title>'%title
|
'\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 #
|
# Create main HTML Page #
|
||||||
#-----------------------#
|
#-----------------------#
|
||||||
main_page = '<!Doctype html>\n' + \
|
main_page = \
|
||||||
'<html lang="%s">\n'%domain_lang + \
|
'<!Doctype html>\n' + \
|
||||||
' <head>\n' + \
|
'<html lang="%s">\n'%domain_lang + \
|
||||||
'%s\n'%metas + \
|
' <head>\n' + \
|
||||||
' </head>\n\n' + \
|
'%s\n'%metas + \
|
||||||
' <body>\n' + \
|
' </head>\n\n' + \
|
||||||
' <header id="header_page">\n' + \
|
' <body>\n' + \
|
||||||
' <div id="site_logo">\n' + \
|
' <header id="header_page">\n' + \
|
||||||
' %s\n'%logo_html + \
|
' <div id="site_logo">\n' + \
|
||||||
' </div>\n' + \
|
' %s\n'%logo_html + \
|
||||||
'\n' + \
|
' </div>\n' + \
|
||||||
' <div id="site_infos">\n' + \
|
'\n' + \
|
||||||
' <a href="/"\n' + \
|
' <div id="site_infos">\n' + \
|
||||||
' title="%s"\n'%(tyto.trans[1][tyto.n]) + \
|
' <a href="/"\n' + \
|
||||||
' id="site_link">\n' + \
|
' title="%s"\n'%(tyto.trans[1][tyto.n]) + \
|
||||||
' <h1 id="site_title">%s</h1>\n'%domain_title + \
|
' id="site_link">\n' + \
|
||||||
' </a>\n' + \
|
' <h1 id="site_title">%s</h1>\n'%domain_title + \
|
||||||
' <p id="site_about">%s</p>\n'%domain_about + \
|
' </a>\n' + \
|
||||||
' </div>\n' + \
|
' <p id="site_about">%s</p>\n'%domain_about + \
|
||||||
'<!--# include virtual="/template/navbar.html"-->\n' + \
|
' </div>\n' + \
|
||||||
' </header>\n' + \
|
'<!--# include virtual="/template/navbar.html"-->\n' + \
|
||||||
'\n' + \
|
' </header>\n' + \
|
||||||
' <article id="article_main">\n' + \
|
'\n' + \
|
||||||
'%s\n'%article_bottom + \
|
' <article id="article_main">\n' + \
|
||||||
' </article>\n' + \
|
'%s\n'%article_bottom + \
|
||||||
'\n' + \
|
' </article>\n' + \
|
||||||
'<!--# include virtual="/template/footer.html"-->\n' + \
|
'\n' + \
|
||||||
' </body>\n' + \
|
'<!--# include virtual="/template/footer.html"-->\n' + \
|
||||||
'</html>'
|
' </body>\n' + \
|
||||||
|
'</html>'
|
||||||
|
|
||||||
footer_file = '%sfooter.html'%srv_wip_tpl
|
footer_file = '%sfooter.html'%srv_wip_tpl
|
||||||
if not os.path.exists(footer_file):
|
if not os.path.exists(footer_file):
|
||||||
|
@ -244,9 +244,9 @@ def create_navbar(option, target):
|
||||||
tyto.set_file(navbar_file, 'new', menu_html)
|
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):
|
def create_user_metas(option):
|
||||||
domain.create_metas_file("-i") # Ensure config file exists
|
domain.create_metas_file("-i") # Ensure config file exists
|
||||||
|
|
||||||
|
@ -279,49 +279,89 @@ def create_footer(option):
|
||||||
domain_licurl = "/"
|
domain_licurl = "/"
|
||||||
|
|
||||||
# Default footer contents
|
# Default footer contents
|
||||||
footer = '<footer id="footer_page">\n' + \
|
footer = \
|
||||||
' <div id="footer_infos">\n' + \
|
'<!-- Default <footer> generated by %s -->\n'%Tyto + \
|
||||||
' <a href="/"\n' + \
|
'<footer id="footer_page">\n' + \
|
||||||
' title="%s"\n'%(tyto.trans[1][tyto.n]) + \
|
' <div id="footer_infos">\n' + \
|
||||||
' id="footer_title_link">\n' + \
|
' <a href="/"\n' + \
|
||||||
' <h1 id="footer_site_title">%s</h1>\n'%(
|
' title="%s"\n'%(tyto.trans[1][tyto.n]) + \
|
||||||
domain_title) + \
|
' id="footer_title_link">\n' + \
|
||||||
' </a>\n' + \
|
' <h1 id="footer_site_title">%s</h1>\n'%(domain_title) + \
|
||||||
' <p id="footer_site_about">%s</p>\n'%(
|
' </a>\n' + \
|
||||||
domain_about) + \
|
' <p id="footer_site_about">%s</p>\n'%(domain_about) + \
|
||||||
' </div>\n' + \
|
' </div>\n' + \
|
||||||
'\n' + \
|
'\n' + \
|
||||||
' <div id="footer_references">\n' + \
|
' <div id="footer_references">\n' + \
|
||||||
' <ul> id="footer_items"\n' + \
|
' <ul> id="footer_items"\n' + \
|
||||||
' <li id="fotter_item">\n' + \
|
' <li id="fotter_item">\n' + \
|
||||||
' <a href="%s"\n'%domain_licurl + \
|
' <a href="%s"\n'%domain_licurl + \
|
||||||
' title="%s %s %s"\n'%(
|
' title="%s %s %s"\n'%(
|
||||||
tyto.trans[2][tyto.n],
|
tyto.trans[2][tyto.n],
|
||||||
domain_sep, domain_title) + \
|
domain_sep, domain_title) + \
|
||||||
' id="footer_item_link">%s</a>\n'%(
|
' id="footer_item_link">%s</a>\n'%(
|
||||||
domain_license) + \
|
domain_license) + \
|
||||||
' </li>\n' + \
|
' </li>\n' + \
|
||||||
' <li id="fotter_item">\n' + \
|
' <li id="fotter_item">\n' + \
|
||||||
' <a href="%s"\n'%Tytoweb + \
|
' <a href="%s"\n'%Tytoweb + \
|
||||||
' title="%s"\n'%Tytowti + \
|
' title="%s"\n'%Tytowti + \
|
||||||
' id="footer_item_link">%s</a> %s\n'%(Tyto, Tytosrc) + \
|
' id="footer_item_link">%s</a> %s\n'%(Tyto, Tytosrc) + \
|
||||||
' </li>\n' + \
|
' </li>\n' + \
|
||||||
' </ul>\n' + \
|
' </ul>\n' + \
|
||||||
' </div>\n' + \
|
' </div>\n' + \
|
||||||
'</footer>\n'
|
'</footer>'
|
||||||
|
|
||||||
|
|
||||||
# Create new file, or ask if exists
|
# Create new file, or ask if exists
|
||||||
ask = ' ├ Use default footer.html ? '
|
ask_load = ' ├ Use default _configs/tyto.footer.html ? '
|
||||||
log = ' ├ Create file: %s'%footer_load
|
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 os.path.exists(footer_load):
|
||||||
if option == '-i': return
|
if option == 'New':
|
||||||
res = input(ask)
|
create_load = False
|
||||||
if not res in ['y', 'Y']: return
|
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' + \
|
' <li id="fotter_item">\n' + \
|
||||||
|
@ -332,26 +372,3 @@ def create_footer(option):
|
||||||
Copyright © 2021-2022
|
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