html: in-dev template files

This commit is contained in:
Cyrille L 2022-11-24 00:11:35 +01:00
parent b3781b17d0
commit b565238eea
3 changed files with 44 additions and 13 deletions

View File

@ -58,12 +58,11 @@ def post_IDs(file_post):
# Check if file exists or exit
global post_uri
post_uri = '%s%s'%(domain.domain_articles, file_post)
if not os.path.exists(post_uri):
print(':< Unused file: %s'%post_uri)
sys.exit(1)
global post_url
# Set HTML file from file_post
file_html = file_post.replace('.tyto','.html')
if file_html.endswith('index.html'):
@ -295,7 +294,7 @@ def post_to_strings(post_uri):
file_string = open(post_uri,'r').read()
if not '-----' in file_string:
msg_log = 'Unused separator "-----" (header,post)'
log.append_f(post_logs,msg_log,1)
log.append_f(post_logs, msg_log, 1)
sys.exit(0)
# From Separator...

View File

@ -16,7 +16,7 @@
#----------------------------------------------------------------------
#**********************************************************************
import re
import re, os
import check, log, domain
trans = [
@ -42,7 +42,6 @@ def translations():
else : fl = 1
#========================#
# Create FULL HTML5 Page #
# includes wip.html #
@ -51,9 +50,6 @@ def html_main_page(wip_html):
# Source DB variables
post_db = exec(open(check.curr_post_db).read(),globals())
# Set some terms from lang domain
translations()
# Metas in HTML page
#-------------------
scale = 'width=device-width, initial-scale=1.0'
@ -61,12 +57,33 @@ def html_main_page(wip_html):
title = '%s %s %s'%(post_title, domain.sep_titles, domain.domain_title)
tags = '%s,%s'%(domain.domain_tags, post_tags)
icon = '/template/favicon.png'
logo = '/template/%s'%domain.domain_logo
f_css = '/template/styles.css'
f_rss = '/rss.xml'
i_rss = 'RSS 2.0, %s %s %s'%(
domain.domain_title, domain.sep_titles, domain.domain_name
)
# If no logo
if not domain.domain_logo:
msg_log = 'Unregistred logo in configuration domain'
log.append_f(check.post_logs, msg_log, 1)
# Check here for template files
files_uri = (
'%s%s'%(domain.srv_wip, f_rss[1:len(f_rss)]),
'%s%s'%(domain.srv_wip, icon[1:len(icon)]),
'%s%s'%(domain.srv_wip, f_css[1:len(f_css)]),
'%s%s'%(domain.srv_wip, logo[1:len(logo)])
)
for file_uri in files_uri:
if not os.path.exists(file_uri):
msg_log = 'Unused template file: %s'%file_uri
log.append_f(check.post_logs, msg_log, 1)
# Set some terms from lang domain
translations()
# External URL in metas (if exists)
if domain.domain_exturl:
relme = '<link rel="me" type="text/html" href="%s">\n'%(
@ -96,13 +113,14 @@ def html_main_page(wip_html):
'%s'%relme + \
'<title>%s</title>'%title
# header in HTML page
#--------------------
headers = '<header class="%s">\n'%domain.domain_css + \
' <div id="logo-header">\n' + \
' <a id="logo-link" href="/">\n' + \
' <img id="%s_logo"\n'%domain.domain_css + \
' src="/template/%s"\n'%domain.domain_logo + \
' src="%s"\n'%logo + \
' alt="Logo: %s"\n'%domain.domain_title + \
' title="Logo: %s" />\n'%domain.domain_title + \
' </a>\n' + \
@ -196,6 +214,21 @@ def html_main_page(wip_html):
' </div>\n' + \
'</footer>'
# Create file if not exists
files_tpl = [
[ '%smetas.html'%domain.srv_wip_template, metas ],
[ '%sheader.html'%domain.srv_wip_template, headers ],
[ '%sfooter.html'%domain.srv_wip_template, footers ],
]
for file_tpl in files_tpl:
if not os.path.exists(file_tpl[0]):
datas = open(file_tpl[0], 'w')
datas.write(file_tpl[1])
datas.close()
msg_log = 'Create default file: %s'%file_tpl[0]
log.append_f(check.post_logs, msg_log, 0)
# Create full page
#-----------------
page = '<!DOCTYPE html>\n' + \
@ -233,5 +266,5 @@ def html_main_page(wip_html):
for footer in footers.rsplit('\n'):
page = '%s\n%s%s'%(page, 4*' ', footer)
print(page)
#print(page)

View File

@ -113,14 +113,13 @@ def manage_wip(file_post, Force):
#print('> Article HTML:')
#print(wip_html)
print('> Article with Tabs:')
#print('> Article with Tabs:')
tab_article(wip_html.rsplit('\n'))
# Create full page
html.html_main_page(wip_html.rsplit('\n'))
#============================#
# HTML CONVERTERS #
# wip_tmp: new replacedlines #