indev: changed code for managing tyto.metas.html and metas.html
This commit is contained in:
parent
9adb8ec8c8
commit
47592b6108
|
@ -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(' │')
|
||||
|
@ -444,61 +444,6 @@ def create_domain(target, option):
|
|||
print(' └──────────────────────────────────────┘')
|
||||
|
||||
|
||||
#========================================#
|
||||
# Create metas.html with default content #
|
||||
#----------------------------------------#
|
||||
def create_metas_file(option):
|
||||
metas_load = tyto.metas_load
|
||||
metas_tags = '<!-- Custom HTML metas for all pages\n' + \
|
||||
'# You can add/edit HTML tags\n' + \
|
||||
'# ! Only <meta > and <link > lines are used !\n' + \
|
||||
'# After editing, use "tyto metas -n"\n' + \
|
||||
'# (You should not copy this file to template)' + \
|
||||
'\n' + \
|
||||
'# Already set metas with values:\n' + \
|
||||
'# <meta charset="UTF-8">\n' + \
|
||||
'# <meta name="viewport" ...>\n' + \
|
||||
'# <meta name=”url” ...>\n' + \
|
||||
'# <meta name="language" ...>\n' + \
|
||||
'# <meta name="reply-to" ...>\n' + \
|
||||
'# <meta name="copyright" ...>\n' + \
|
||||
'# <meta name="generator" ...>\n' + \
|
||||
'# <meta name="title" ...>\n' + \
|
||||
'# <meta name="author" ...>\n' + \
|
||||
'# <meta name="description" ...>\n' + \
|
||||
'# <meta name="keywords" ...>\n' + \
|
||||
'# <meta name="search_date" ...>\n' + \
|
||||
'# <link rel="canonical" ..." />\n' + \
|
||||
'# <link rel="alternate" ..." /> # RSS\n' + \
|
||||
'# <link rel="stylesheet" ... />\n' + \
|
||||
'# <link rel="shortcut icon" ... />\n' + \
|
||||
'# <link rel="me" ... > # if profile url in config\n' + \
|
||||
'# Open Graph data\n' + \
|
||||
'# <meta property="og:site_name" ... />\n' + \
|
||||
'# <meta property="og:title" ... />\n' + \
|
||||
'# <meta property="og:type" ... />\n' + \
|
||||
'# <meta property="og:url" ... />\n' + \
|
||||
'# <meta property="og:description" ... />\n' + \
|
||||
'# <meta property="og:image" ... />\n' + \
|
||||
'-->\n' + \
|
||||
'<meta name="robots" content="all">\n' + \
|
||||
'<meta name="medium" content="website">\n' + \
|
||||
'<meta name="revisit-after" content="3 days">'
|
||||
|
||||
|
||||
# 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 #
|
||||
#------------------------------#
|
||||
|
|
|
@ -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 = '<a href="/"\n' + \
|
||||
|
@ -151,8 +164,6 @@ def create_main_page(target, article_bottom):
|
|||
'%sid="site_logo_image">\n'%(15 * " ") + \
|
||||
'%s</a>'%(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):
|
|||
' </body>\n' + \
|
||||
'</html>'
|
||||
|
||||
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 = \
|
||||
'<!-- Custom HTML metas for all pages\n' + \
|
||||
'# You can add/edit HTML tags\n' + \
|
||||
'# ! Only <meta > and <link > lines are used !\n' + \
|
||||
'# After editing, use "tyto metas -n"\n' + \
|
||||
'# (You should not copy this file to template)' + \
|
||||
'\n' + \
|
||||
'# Already set metas with values:\n' + \
|
||||
'# <meta charset="UTF-8">\n' + \
|
||||
'# <meta name="viewport" ...>\n' + \
|
||||
'# <meta name=”url” ...>\n' + \
|
||||
'# <meta name="language" ...>\n' + \
|
||||
'# <meta name="reply-to" ...>\n' + \
|
||||
'# <meta name="copyright" ...>\n' + \
|
||||
'# <meta name="generator" ...>\n' + \
|
||||
'# <meta name="title" ...>\n' + \
|
||||
'# <meta name="author" ...>\n' + \
|
||||
'# <meta name="description" ...>\n' + \
|
||||
'# <meta name="keywords" ...>\n' + \
|
||||
'# <meta name="search_date" ...>\n' + \
|
||||
'# <link rel="canonical" ..." />\n' + \
|
||||
'# <link rel="alternate" ..." /> # RSS\n' + \
|
||||
'# <link rel="stylesheet" ... />\n' + \
|
||||
'# <link rel="shortcut icon" ... />\n' + \
|
||||
'# <link rel="me" ... > # if profile url in config\n' + \
|
||||
'# Open Graph data\n' + \
|
||||
'# <meta property="og:site_name" ... />\n' + \
|
||||
'# <meta property="og:title" ... />\n' + \
|
||||
'# <meta property="og:type" ... />\n' + \
|
||||
'# <meta property="og:url" ... />\n' + \
|
||||
'# <meta property="og:description" ... />\n' + \
|
||||
'# <meta property="og:image" ... />\n' + \
|
||||
'-->\n' + \
|
||||
'<meta name="robots" content="all">\n' + \
|
||||
'<meta name="medium" content="website">\n' + \
|
||||
'<meta name="revisit-after" content="3 days">'
|
||||
|
||||
# Create new file, or ask if exists
|
||||
ask_load = ' ├ Use default _configs/tyto.metas.html ? '
|
||||
log_load = ' ├ Create file: %s'%metas_load
|
||||
create_load = True
|
||||
|
||||
metas_html = '%smetas.html'%srv_wip_tpl
|
||||
ask_html = ' ├ Replace template/metas.html ' + \
|
||||
'from _configs/tyto.metas.html ? '
|
||||
log_html = ' ├ Create file: %s'%metas_html
|
||||
create_html = True
|
||||
|
||||
user_metas = ''
|
||||
metas_used = ('<meta ', '<link ')
|
||||
log = ' ├ Create file: %s'%metas_html
|
||||
|
||||
try:
|
||||
# Auto create if not tyto.metas.html in _configs
|
||||
# Pass if exists, user not wants, option is 'New' (only footer.html)
|
||||
res = ''
|
||||
if os.path.exists(metas_load):
|
||||
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(metas_load, 'new', metas_tags)
|
||||
print(log_load)
|
||||
|
||||
# Auto create if not metas.html in template/
|
||||
# Create if option is 'New'
|
||||
res = ''
|
||||
if os.path.exists(metas_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(metas_load, 'r').read()
|
||||
|
||||
for line in user_file.rsplit('\n'):
|
||||
|
@ -263,9 +339,7 @@ def create_user_metas(option):
|
|||
if user_metas: user_metas = "%s\n %s"%(user_metas, line)
|
||||
else: user_metas = ' %s'%line
|
||||
tyto.set_file(metas_html, 'new', user_metas)
|
||||
print(log)
|
||||
except:
|
||||
tyto.exiting("24", '(metas file): %s'%metas_load, False)
|
||||
print(log_html)
|
||||
|
||||
|
||||
#=========================================#
|
||||
|
|
Loading…
Reference in New Issue