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 # Check if file exists or exit
global post_uri global post_uri
post_uri = '%s%s'%(domain.domain_articles, file_post) post_uri = '%s%s'%(domain.domain_articles, file_post)
if not os.path.exists(post_uri): if not os.path.exists(post_uri):
print(':< Unused file: %s'%post_uri) print(':< Unused file: %s'%post_uri)
sys.exit(1) sys.exit(1)
global post_url
# Set HTML file from file_post # Set HTML file from file_post
file_html = file_post.replace('.tyto','.html') file_html = file_post.replace('.tyto','.html')
if file_html.endswith('index.html'): if file_html.endswith('index.html'):

View File

@ -16,7 +16,7 @@
#---------------------------------------------------------------------- #----------------------------------------------------------------------
#********************************************************************** #**********************************************************************
import re import re, os
import check, log, domain import check, log, domain
trans = [ trans = [
@ -42,7 +42,6 @@ def translations():
else : fl = 1 else : fl = 1
#========================# #========================#
# Create FULL HTML5 Page # # Create FULL HTML5 Page #
# includes wip.html # # includes wip.html #
@ -51,9 +50,6 @@ def html_main_page(wip_html):
# Source DB variables # Source DB variables
post_db = exec(open(check.curr_post_db).read(),globals()) post_db = exec(open(check.curr_post_db).read(),globals())
# Set some terms from lang domain
translations()
# Metas in HTML page # Metas in HTML page
#------------------- #-------------------
scale = 'width=device-width, initial-scale=1.0' 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) title = '%s %s %s'%(post_title, domain.sep_titles, domain.domain_title)
tags = '%s,%s'%(domain.domain_tags, post_tags) tags = '%s,%s'%(domain.domain_tags, post_tags)
icon = '/template/favicon.png' icon = '/template/favicon.png'
logo = '/template/%s'%domain.domain_logo
f_css = '/template/styles.css' f_css = '/template/styles.css'
f_rss = '/rss.xml' f_rss = '/rss.xml'
i_rss = 'RSS 2.0, %s %s %s'%( i_rss = 'RSS 2.0, %s %s %s'%(
domain.domain_title, domain.sep_titles, domain.domain_name 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) # External URL in metas (if exists)
if domain.domain_exturl: if domain.domain_exturl:
relme = '<link rel="me" type="text/html" href="%s">\n'%( relme = '<link rel="me" type="text/html" href="%s">\n'%(
@ -96,13 +113,14 @@ def html_main_page(wip_html):
'%s'%relme + \ '%s'%relme + \
'<title>%s</title>'%title '<title>%s</title>'%title
# header in HTML page # header in HTML page
#-------------------- #--------------------
headers = '<header class="%s">\n'%domain.domain_css + \ headers = '<header class="%s">\n'%domain.domain_css + \
' <div id="logo-header">\n' + \ ' <div id="logo-header">\n' + \
' <a id="logo-link" href="/">\n' + \ ' <a id="logo-link" href="/">\n' + \
' <img id="%s_logo"\n'%domain.domain_css + \ ' <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 + \ ' alt="Logo: %s"\n'%domain.domain_title + \
' title="Logo: %s" />\n'%domain.domain_title + \ ' title="Logo: %s" />\n'%domain.domain_title + \
' </a>\n' + \ ' </a>\n' + \
@ -196,6 +214,21 @@ def html_main_page(wip_html):
' </div>\n' + \ ' </div>\n' + \
'</footer>' '</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 # Create full page
#----------------- #-----------------
page = '<!DOCTYPE html>\n' + \ page = '<!DOCTYPE html>\n' + \
@ -233,5 +266,5 @@ def html_main_page(wip_html):
for footer in footers.rsplit('\n'): for footer in footers.rsplit('\n'):
page = '%s\n%s%s'%(page, 4*' ', footer) 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('> Article HTML:')
#print(wip_html) #print(wip_html)
print('> Article with Tabs:') #print('> Article with Tabs:')
tab_article(wip_html.rsplit('\n')) tab_article(wip_html.rsplit('\n'))
# Create full page # Create full page
html.html_main_page(wip_html.rsplit('\n')) html.html_main_page(wip_html.rsplit('\n'))
#============================# #============================#
# HTML CONVERTERS # # HTML CONVERTERS #
# wip_tmp: new replacedlines # # wip_tmp: new replacedlines #