html: use template file else defaut
This commit is contained in:
parent
f2d1f341dd
commit
3e3885edf6
|
@ -222,7 +222,7 @@ def html_main_page(wip_html):
|
||||||
' </div>\n' + \
|
' </div>\n' + \
|
||||||
'</footer>'
|
'</footer>'
|
||||||
|
|
||||||
|
|
||||||
# Create file if not exists
|
# Create file if not exists
|
||||||
#--------------------------
|
#--------------------------
|
||||||
files_tpl = [
|
files_tpl = [
|
||||||
|
@ -230,6 +230,7 @@ def html_main_page(wip_html):
|
||||||
[ '%sheader.html'%domain.srv_wip_template, headers ],
|
[ '%sheader.html'%domain.srv_wip_template, headers ],
|
||||||
[ '%sfooter.html'%domain.srv_wip_template, footers ],
|
[ '%sfooter.html'%domain.srv_wip_template, footers ],
|
||||||
]
|
]
|
||||||
|
|
||||||
for file_tpl in files_tpl:
|
for file_tpl in files_tpl:
|
||||||
if not os.path.exists(file_tpl[0]):
|
if not os.path.exists(file_tpl[0]):
|
||||||
datas = open(file_tpl[0], 'w')
|
datas = open(file_tpl[0], 'w')
|
||||||
|
@ -238,31 +239,50 @@ def html_main_page(wip_html):
|
||||||
msg_log = 'Create default file: %s'%file_tpl[0]
|
msg_log = 'Create default file: %s'%file_tpl[0]
|
||||||
log.append_f(check.post_logs, msg_log, 0)
|
log.append_f(check.post_logs, msg_log, 0)
|
||||||
|
|
||||||
|
#------------------#
|
||||||
# Create full page
|
# Create full page #
|
||||||
#-----------------
|
#------------------#
|
||||||
page = '<!DOCTYPE html>\n' + \
|
page = '<!DOCTYPE html>\n' + \
|
||||||
' <html lang="%s">\n'%domain.domain_lang + \
|
' <html lang="%s">\n'%domain.domain_lang + \
|
||||||
' <head>'
|
' <head>'
|
||||||
|
|
||||||
# Add tab metas in page
|
# Add tab metas in page
|
||||||
for meta in metas.rsplit('\n'):
|
#----------------------
|
||||||
page = '%s\n%s%s'%(page, 6*' ', meta)
|
if os.path.exists(files_tpl[0][0]):
|
||||||
|
metas_datas = open(files_tpl[0][0], 'r').read()
|
||||||
|
for meta_line in metas_datas.rsplit('\n'):
|
||||||
|
page = '%s\n%s%s'%(page, 6*' ', meta_line)
|
||||||
|
else:
|
||||||
|
# No file: use this default
|
||||||
|
for meta in metas.rsplit('\n'):
|
||||||
|
page = '%s\n%s%s'%(page, 6*' ', meta)
|
||||||
|
msg_log = 'Use default metas in page. Unused file: %s'%files_tpl[0][0]
|
||||||
|
log.append_f(check.post_logs, msg_log, 0)
|
||||||
|
|
||||||
page = '%s\n%s</head>\n'%(page, 4*' ') + \
|
page = '%s\n%s</head>\n'%(page, 4*' ') + \
|
||||||
'\n%s<body id="%s" class="%s">'%(
|
'\n%s<body id="%s" class="%s">'%(
|
||||||
4*' ', post_ID, domain.domain_css
|
4*' ', post_ID, domain.domain_css
|
||||||
)
|
)
|
||||||
|
|
||||||
# Add tab header in page
|
# Add tab header in page
|
||||||
for header in headers.rsplit('\n'):
|
#-----------------------
|
||||||
page = '%s\n%s%s'%(page, 6*' ', header)
|
if os.path.exists(files_tpl[1][0]):
|
||||||
|
headers_datas = open(files_tpl[1][0], 'r').read()
|
||||||
|
for header_line in headers_datas.rsplit('\n'):
|
||||||
|
page = '%s\n%s%s'%(page, 6*' ', header_line)
|
||||||
|
else:
|
||||||
|
# No file: use this default
|
||||||
|
for header in headers.rsplit('\n'):
|
||||||
|
page = '%s\n%s%s'%(page, 6*' ', header)
|
||||||
|
msg_log = 'Use default header in page. Unused file: %s'%files_tpl[1][0]
|
||||||
|
log.append_f(check.post_logs, msg_log, 0)
|
||||||
|
|
||||||
# Add tab article in page
|
# Add tab article in page
|
||||||
for article in articles.rsplit('\n'):
|
for article in articles.rsplit('\n'):
|
||||||
page = '%s\n%s%s'%(page, 6*' ', article)
|
page = '%s\n%s%s'%(page, 6*' ', article)
|
||||||
|
|
||||||
# Add post from wip.html
|
# Add post from wip.html
|
||||||
|
#-----------------------
|
||||||
for line in wip_html:
|
for line in wip_html:
|
||||||
page = '%s\n%s%s'%(page, 4*' ', line)
|
page = '%s\n%s%s'%(page, 4*' ', line)
|
||||||
page = '%s\n%s</article>\n'%(page, 8*' ')
|
page = '%s\n%s</article>\n'%(page, 8*' ')
|
||||||
|
@ -275,8 +295,16 @@ def html_main_page(wip_html):
|
||||||
|
|
||||||
# Add footer in page
|
# Add footer in page
|
||||||
#-------------------
|
#-------------------
|
||||||
for footer in footers.rsplit('\n'):
|
if os.path.exists(files_tpl[2][0]):
|
||||||
page = '%s\n%s%s'%(page, 4*' ', footer)
|
footers_datas = open(files_tpl[2][0], 'r').read()
|
||||||
|
for footer_line in footers_datas.rsplit('\n'):
|
||||||
|
page = '%s\n%s%s'%(page, 4*' ', footer_line)
|
||||||
|
else:
|
||||||
|
# No file: use this default
|
||||||
|
for footer in footers.rsplit('\n'):
|
||||||
|
page = '%s\n%s%s'%(page, 4*' ', footer)
|
||||||
|
msg_log = 'Use default footer in page. Unused file: %s'%files_tpl[2][0]
|
||||||
|
log.append_f(check.post_logs, msg_log, 0)
|
||||||
|
|
||||||
print(page)
|
print(page)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue