added metas manager files (load, wip, publish)
This commit is contained in:
parent
4de6d51ea3
commit
50baaf14f2
|
@ -38,6 +38,17 @@ def manage_domain(target):
|
||||||
else: logs.out("255", '', True)
|
else: logs.out("255", '', True)
|
||||||
|
|
||||||
|
|
||||||
|
#==============================================#
|
||||||
|
# When an active and complete domain is needed #
|
||||||
|
#----------------------------------------------#
|
||||||
|
def domain_needed():
|
||||||
|
# Check if can process
|
||||||
|
if not db.domain_exists \
|
||||||
|
or db.incomplete_domain \
|
||||||
|
or not db.domain_active:
|
||||||
|
sys.exit(1)
|
||||||
|
|
||||||
|
|
||||||
#=====================#
|
#=====================#
|
||||||
# Create a new domain #
|
# Create a new domain #
|
||||||
#---------------------#
|
#---------------------#
|
||||||
|
@ -502,21 +513,15 @@ def create_domain(target):
|
||||||
#------------------------------#
|
#------------------------------#
|
||||||
def create_sidebar(option):
|
def create_sidebar(option):
|
||||||
# Check if can process
|
# Check if can process
|
||||||
if not db.domain_exists \
|
domain_needed()
|
||||||
or db.incomplete_domain \
|
|
||||||
or not db.domain_active:
|
|
||||||
return
|
|
||||||
|
|
||||||
# Create an empty html file in wip server if not exists
|
# Create an empty html file in wip/www server if not exists
|
||||||
try:
|
if not os.path.exists(db.wip_sidebar):
|
||||||
if not os.path.exists(db.wip_sidebar):
|
tyto.set_file(db.wip_sidebar, 'new', '')
|
||||||
tyto.set_file(db.wip_sidebar, 'new', '')
|
print(' ├ Create empty file: %s'%db.wip_sidebar)
|
||||||
print(' ├ Create empty file: %s'%db.wip_sidebar)
|
if not os.path.exists(db.www_sidebar):
|
||||||
if not os.path.exists(db.www_sidebar):
|
tyto.set_file(db.www_sidebar, 'new', '')
|
||||||
tyto.set_file(db.www_sidebar, 'new', '')
|
print(' ├ Create empty file: %s'%db.www_sidebar)
|
||||||
print(' ├ Create empty file: %s'%db.www_sidebar)
|
|
||||||
except:
|
|
||||||
logs.out("4", db.wip_sidebar, True)
|
|
||||||
|
|
||||||
# Create new file, or ask if exists with option = 'reset'
|
# Create new file, or ask if exists with option = 'reset'
|
||||||
ask = ' ├ Reset sidebar configuration file ? '
|
ask = ' ├ Reset sidebar configuration file ? '
|
||||||
|
@ -575,21 +580,15 @@ def create_sidebar(option):
|
||||||
#-----------------------------#
|
#-----------------------------#
|
||||||
def create_navbar(option):
|
def create_navbar(option):
|
||||||
# Check if can process
|
# Check if can process
|
||||||
if not db.domain_exists \
|
domain_needed()
|
||||||
or db.incomplete_domain \
|
|
||||||
or not db.domain_active:
|
|
||||||
return
|
|
||||||
|
|
||||||
# Create an empty html file in wip server if not exists
|
# Create an empty html file in wip/www server if not exists
|
||||||
try:
|
if not os.path.exists(db.wip_navbar):
|
||||||
if not os.path.exists(db.wip_navbar):
|
tyto.set_file(db.wip_navbar, 'new', '')
|
||||||
tyto.set_file(db.wip_navbar, 'new', '')
|
print(' ├ Create empty file: %s'%db.wip_navbar)
|
||||||
print(' ├ Create empty file: %s'%db.wip_navbar)
|
if not os.path.exists(db.www_navbar):
|
||||||
if not os.path.exists(db.www_navbar):
|
tyto.set_file(db.www_navbar, 'new', '')
|
||||||
tyto.set_file(db.www_navbar, 'new', '')
|
print(' ├ Create empty file: %s'%db.www_navbar)
|
||||||
print(' ├ Create empty file: %s'%db.www_navbar)
|
|
||||||
except:
|
|
||||||
logs.out("4", db.wip_navbar, True)
|
|
||||||
|
|
||||||
# Create new file, or ask if exists
|
# Create new file, or ask if exists
|
||||||
ask = ' ├ Reset navbar configuration file ? '
|
ask = ' ├ Reset navbar configuration file ? '
|
||||||
|
@ -654,3 +653,82 @@ def create_navbar(option):
|
||||||
|
|
||||||
tyto.set_file(db.navbar_load, 'new', nvb_load)
|
tyto.set_file(db.navbar_load, 'new', nvb_load)
|
||||||
print(log)
|
print(log)
|
||||||
|
|
||||||
|
|
||||||
|
#========================#
|
||||||
|
# metas_load source file #
|
||||||
|
#------------------------#
|
||||||
|
def create_metas(option):
|
||||||
|
# Check if can process
|
||||||
|
domain_needed()
|
||||||
|
|
||||||
|
|
||||||
|
# Set metas_load default content
|
||||||
|
#-------------------------------
|
||||||
|
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">'
|
||||||
|
|
||||||
|
metas_srvs = \
|
||||||
|
' <meta name="robots" content="all">\n' + \
|
||||||
|
' <meta name="medium" content="website">\n' + \
|
||||||
|
' <meta name="revisit-after" content="3 days">'
|
||||||
|
|
||||||
|
# Create an empty html file in wip/www server if not exists
|
||||||
|
if not os.path.exists(db.wip_metas):
|
||||||
|
tyto.set_file(db.wip_metas, 'new', metas_srvs)
|
||||||
|
print(' ├ Create empty file: %s'%db.wip_metas)
|
||||||
|
if not os.path.exists(db.www_metas):
|
||||||
|
tyto.set_file(db.www_metas, 'new', metas_srvs)
|
||||||
|
print(' ├ Create empty file: %s'%db.www_metas)
|
||||||
|
|
||||||
|
# Create new file, or ask if exists
|
||||||
|
ask = ' ├ Reset metas configuration file ? '
|
||||||
|
log = ' ├ Create source file: %s'%db.metas_load
|
||||||
|
res = ''
|
||||||
|
if os.path.exists(db.metas_load):
|
||||||
|
try:
|
||||||
|
res = input(ask)
|
||||||
|
except KeyboardInterrupt:
|
||||||
|
print('')
|
||||||
|
logs.out("255", '', True)
|
||||||
|
if not res in ['y', 'Y']: return
|
||||||
|
|
||||||
|
tyto.set_file(db.metas_load, 'new', metas_tags)
|
||||||
|
print(log)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -476,111 +476,26 @@ def create_navbar(option):
|
||||||
# To manage new creation if changes #
|
# To manage new creation if changes #
|
||||||
#--------------------------------------------------------#
|
#--------------------------------------------------------#
|
||||||
def create_user_metas(option):
|
def create_user_metas(option):
|
||||||
if not db.domain_exists: return
|
# Check if can process
|
||||||
|
domain.domain_needed()
|
||||||
|
|
||||||
create_load = False # file in _configs
|
if option == 'wip': target = db.wip_navbar
|
||||||
create_html = False # file in template/
|
elif option == 'www': target = db.www_navbar
|
||||||
|
|
||||||
# Get metas_load hash or create metas db file if not exists
|
|
||||||
#----------------------------------------------------------
|
|
||||||
if os.path.exists(db.metas_load):
|
|
||||||
create_db_load(db.metas_load, db.metas_load_db)
|
|
||||||
|
|
||||||
# Manage option
|
|
||||||
#--------------
|
|
||||||
if not os.path.exists(db.metas_load):
|
|
||||||
create_load = True
|
|
||||||
elif option == 'New':
|
|
||||||
create_load = True
|
|
||||||
create_html = True
|
|
||||||
elif option == 'Create':
|
|
||||||
create_html = True
|
|
||||||
elif option == 'Edit':
|
|
||||||
hash_load_old = tyto.get_filesum(db.metas_load, True)
|
|
||||||
tyto.edit_file(db.metas_load)
|
|
||||||
hash_load_new = tyto.get_filesum(db.metas_load, True)
|
|
||||||
if not hash_load_old == hash_load_new:
|
|
||||||
create_db_load(db.metas_load, db.metas_load_db)
|
|
||||||
create_html = True
|
|
||||||
elif option == 'Force':
|
|
||||||
create_load = True
|
|
||||||
create_html = True
|
|
||||||
|
|
||||||
# Set metas_load default content
|
|
||||||
#-------------------------------
|
|
||||||
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 metas_load file according to option
|
|
||||||
#-------------------------------------------
|
|
||||||
if create_load:
|
|
||||||
ask_load = ' ├ Reset metas configuration file ? '
|
|
||||||
log_load = ' ├ Create file: %s'%db.metas_load
|
|
||||||
res = ''
|
|
||||||
if os.path.exists(db.metas_load):
|
|
||||||
try:
|
|
||||||
res = input(ask_load)
|
|
||||||
except KeyboardInterrupt:
|
|
||||||
print('')
|
|
||||||
logs.out("255", '', True)
|
|
||||||
if not res in ['y', 'Y']: return
|
|
||||||
|
|
||||||
|
|
||||||
tyto.set_file(db.metas_load, True, metas_tags)
|
|
||||||
create_html = True
|
|
||||||
create_db_load(db.metas_load, db.metas_load_db)
|
|
||||||
print(log_load)
|
|
||||||
|
|
||||||
# Create wip metas.html file according to option
|
# Create wip metas.html file according to option
|
||||||
#-----------------------------------------------
|
#-----------------------------------------------
|
||||||
if create_html:
|
ask_html = ' ├ Replace %s ? '%target
|
||||||
ask_html = ' ├ Replace %s ? '%db.wip_metas
|
log_html = ' ├ Create file: %s'%target
|
||||||
log_html = ' ├ Create file: %s'%db.wip_metas
|
user_metas = ''
|
||||||
user_metas = ''
|
metas_used = ('<meta ', '<link ')
|
||||||
metas_used = ('<meta ', '<link ')
|
res = ''
|
||||||
|
if os.path.exists(target):
|
||||||
res = ''
|
try:
|
||||||
if os.path.exists(db.wip_metas):
|
res = input(ask_html)
|
||||||
try:
|
except KeyboardInterrupt:
|
||||||
res = input(ask_html)
|
print('')
|
||||||
except KeyboardInterrupt:
|
logs.out("255", '', True)
|
||||||
print('')
|
if not res in ['y', 'Y']: return
|
||||||
logs.out("255", '', True)
|
|
||||||
if not res in ['y', 'Y']: return
|
|
||||||
|
|
||||||
user_file = open(db.metas_load, 'r').read()
|
user_file = open(db.metas_load, 'r').read()
|
||||||
|
|
||||||
|
@ -589,7 +504,7 @@ def create_user_metas(option):
|
||||||
if user_metas: user_metas = "%s\n %s"%(user_metas, line)
|
if user_metas: user_metas = "%s\n %s"%(user_metas, line)
|
||||||
else: user_metas = ' %s'%line
|
else: user_metas = ' %s'%line
|
||||||
|
|
||||||
tyto.set_file(db.wip_metas, True, user_metas)
|
tyto.set_file(target, True, user_metas)
|
||||||
print(log_html)
|
print(log_html)
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -36,7 +36,8 @@ def manage_publish(target):
|
||||||
if target in args.pass_targets:
|
if target in args.pass_targets:
|
||||||
do = {
|
do = {
|
||||||
'sidebar' : html.create_sidebar,
|
'sidebar' : html.create_sidebar,
|
||||||
'navbar' : html.create_navbar
|
'navbar' : html.create_navbar,
|
||||||
|
'metas' : html.create_user_metas
|
||||||
}
|
}
|
||||||
|
|
||||||
do[target]('www')
|
do[target]('www')
|
||||||
|
|
|
@ -196,7 +196,7 @@ def set_file(path, new, text):
|
||||||
file.write(text + '\n')
|
file.write(text + '\n')
|
||||||
file.close()
|
file.close()
|
||||||
except:
|
except:
|
||||||
logs.out("4", db.domain_conf, True)
|
logs.out("4", path, True)
|
||||||
|
|
||||||
|
|
||||||
#==========================#
|
#==========================#
|
||||||
|
|
|
@ -37,7 +37,8 @@ def manage_wip(target):
|
||||||
if target in args.pass_targets:
|
if target in args.pass_targets:
|
||||||
do = {
|
do = {
|
||||||
'sidebar' : html.create_sidebar,
|
'sidebar' : html.create_sidebar,
|
||||||
'navbar' : html.create_navbar
|
'navbar' : html.create_navbar,
|
||||||
|
'metas' : html.create_user_metas
|
||||||
}
|
}
|
||||||
|
|
||||||
do[target]('wip')
|
do[target]('wip')
|
||||||
|
|
Loading…
Reference in New Issue