working on publish template command #6
This commit is contained in:
parent
71efba587e
commit
8b33b675c9
|
@ -220,6 +220,7 @@ def create_sidebar(option):
|
||||||
|
|
||||||
if option == 'wip': target = db.wip_sidebar
|
if option == 'wip': target = db.wip_sidebar
|
||||||
elif option == 'www': target = db.www_sidebar
|
elif option == 'www': target = db.www_sidebar
|
||||||
|
elif option == 'pub': target = db.www_sidebar
|
||||||
|
|
||||||
# If content in sidebar, go True
|
# If content in sidebar, go True
|
||||||
sidebar_new = False
|
sidebar_new = False
|
||||||
|
@ -330,7 +331,7 @@ def create_sidebar(option):
|
||||||
ask_html = ' ├ Replace %s ? '%target
|
ask_html = ' ├ Replace %s ? '%target
|
||||||
res = ''
|
res = ''
|
||||||
|
|
||||||
if os.path.exists(target):
|
if not option == 'pub' and os.path.exists(target):
|
||||||
res = input(ask_html)
|
res = input(ask_html)
|
||||||
if not res in ['y', 'Y']:
|
if not res in ['y', 'Y']:
|
||||||
logs.out("255", '', True)
|
logs.out("255", '', True)
|
||||||
|
@ -354,6 +355,7 @@ def create_navbar(option):
|
||||||
|
|
||||||
if option == 'wip': target = db.wip_navbar
|
if option == 'wip': target = db.wip_navbar
|
||||||
elif option == 'www': target = db.www_navbar
|
elif option == 'www': target = db.www_navbar
|
||||||
|
elif option == 'pub': target = db.www_navbar
|
||||||
|
|
||||||
# If content in sidebar, go True
|
# If content in sidebar, go True
|
||||||
navbar_new = False
|
navbar_new = False
|
||||||
|
@ -436,7 +438,7 @@ def create_navbar(option):
|
||||||
ask_html = ' ├ Replace %s ? '%target
|
ask_html = ' ├ Replace %s ? '%target
|
||||||
res = ''
|
res = ''
|
||||||
|
|
||||||
if os.path.exists(target):
|
if not option == 'pub' and os.path.exists(target):
|
||||||
try:
|
try:
|
||||||
res = input(ask_html)
|
res = input(ask_html)
|
||||||
except KeyboardInterrupt:
|
except KeyboardInterrupt:
|
||||||
|
@ -462,6 +464,7 @@ def create_user_metas(option):
|
||||||
|
|
||||||
if option == 'wip': target = db.wip_metas
|
if option == 'wip': target = db.wip_metas
|
||||||
elif option == 'www': target = db.www_metas
|
elif option == 'www': target = db.www_metas
|
||||||
|
elif option == 'pub': target = db.www_metas
|
||||||
|
|
||||||
# Create wip metas.html file according to option
|
# Create wip metas.html file according to option
|
||||||
#-----------------------------------------------
|
#-----------------------------------------------
|
||||||
|
@ -471,7 +474,7 @@ def create_user_metas(option):
|
||||||
metas_used = ('<meta ', '<link ')
|
metas_used = ('<meta ', '<link ')
|
||||||
res = ''
|
res = ''
|
||||||
|
|
||||||
if os.path.exists(target):
|
if not option == 'pub' and os.path.exists(target):
|
||||||
try:
|
try:
|
||||||
res = input(ask_html)
|
res = input(ask_html)
|
||||||
except KeyboardInterrupt:
|
except KeyboardInterrupt:
|
||||||
|
@ -499,12 +502,13 @@ def create_user_footer(option):
|
||||||
|
|
||||||
if option == 'wip': target = db.wip_footer
|
if option == 'wip': target = db.wip_footer
|
||||||
elif option == 'www': target = db.www_footer
|
elif option == 'www': target = db.www_footer
|
||||||
|
elif option == 'pub': target = db.www_footer
|
||||||
|
|
||||||
ask_load = ' ├ Replace HTML footer: %s ? '%target
|
ask_load = ' ├ Replace HTML footer: %s ? '%target
|
||||||
log_load = ' ├ Create file: %s'%target
|
log_load = ' ├ Create file: %s'%target
|
||||||
res = ''
|
res = ''
|
||||||
|
|
||||||
if os.path.exists(target):
|
if not option == 'pub' and os.path.exists(target):
|
||||||
try:
|
try:
|
||||||
res = input(ask_load)
|
res = input(ask_load)
|
||||||
except KeyboardInterrupt:
|
except KeyboardInterrupt:
|
||||||
|
|
|
@ -124,7 +124,7 @@ def create_template(option):
|
||||||
print( \
|
print( \
|
||||||
'! Note:\n',
|
'! Note:\n',
|
||||||
' - footer, sidebar, metas, navbar\n',
|
' - footer, sidebar, metas, navbar\n',
|
||||||
' will be generated from configuration files\n',
|
' will be generated and REPLACED from configuration files\n',
|
||||||
' in %s\n'%db.navbars_dir,
|
' in %s\n'%db.navbars_dir,
|
||||||
' - ALL other files will be copied\n',
|
' - ALL other files will be copied\n',
|
||||||
' from %s\n'%db.srv_wip_tpl,
|
' from %s\n'%db.srv_wip_tpl,
|
||||||
|
@ -142,12 +142,6 @@ def create_template(option):
|
||||||
if not res in ['y', 'Y']:
|
if not res in ['y', 'Y']:
|
||||||
logs.out("255", '', True)
|
logs.out("255", '', True)
|
||||||
|
|
||||||
# Create new file from _configs/ files
|
|
||||||
html.create_sidebar('www')
|
|
||||||
html.create_navbar('www')
|
|
||||||
html.create_user_metas('www')
|
|
||||||
html.create_user_footer('www')
|
|
||||||
|
|
||||||
# Copy all file in wip server template, except "nofiles"
|
# Copy all file in wip server template, except "nofiles"
|
||||||
nofiles = (
|
nofiles = (
|
||||||
'footer.html',
|
'footer.html',
|
||||||
|
@ -163,12 +157,18 @@ def create_template(option):
|
||||||
item_src = '%s%s'%(db.srv_wip_tpl, item)
|
item_src = '%s%s'%(db.srv_wip_tpl, item)
|
||||||
item_dst = '%s%s'%(db.srv_www_tpl, item)
|
item_dst = '%s%s'%(db.srv_www_tpl, item)
|
||||||
if os.path.isdir(item_src):
|
if os.path.isdir(item_src):
|
||||||
shutil.copytree(item_src, item_dst)
|
shutil.copytree(item_src, item_dst, dirs_exist_ok=True)
|
||||||
print(' ├ Create dir :', item_dst)
|
print(' ├ Create dir :', item_dst)
|
||||||
else:
|
else:
|
||||||
shutil.copy2(item_src, item_dst)
|
shutil.copy2(item_src, item_dst)
|
||||||
print(' ├ Create file:', item_dst)
|
print(' ├ Create file:', item_dst)
|
||||||
|
|
||||||
|
# Create new file from _configs/ files
|
||||||
|
html.create_sidebar('pub')
|
||||||
|
html.create_navbar('pub')
|
||||||
|
html.create_user_metas('pub')
|
||||||
|
html.create_user_footer('pub')
|
||||||
|
|
||||||
|
|
||||||
#================================#
|
#================================#
|
||||||
# Publish template in www server #
|
# Publish template in www server #
|
||||||
|
|
Loading…
Reference in New Issue