html: HTML page build

This commit is contained in:
Cyrille L 2022-11-23 17:22:29 +01:00
parent 9d8d54d5d4
commit 7b38db9f37
3 changed files with 104 additions and 13 deletions

View File

@ -259,10 +259,8 @@ def domain_form():
domain_articles = '%s/articles/'%curr_dir
domain_images = '%simages/'%domain_articles
domain_files = '%sfiles/'%domain_articles
domain_url = '%s%s'%(domain_protocol, domain_name)
# Add settings from domain name before starting form
append_f(temp_domain,'domain_name = "%s"'%domain_name)
append_f(temp_domain,'domain_protocol = "%s"'%domain_protocol)
append_f(temp_domain,'domain_conf = "%s"'%conf_domain)
append_f(temp_domain,'domain_db = "%s"'%domain_db)
append_f(temp_domain,'domain_logs = "%s"'%domain_logs)
@ -282,10 +280,8 @@ def domain_form():
# Local server Directory
# ----------------------
global srv
try:
srv
except:
srv = '/var/www'
try: srv
except: srv = '/var/www'
set_srv = input(' ├ Local server directory (%s) ? '%srv)
if not set_srv and not srv:
@ -306,6 +302,7 @@ def domain_form():
srv_www_files = '%s/%s/www/files/'%(srv,domain_name)
srv_www_images = '%s/%s/www/images/'%(srv,domain_name)
srv_www_template = '%s/%s/www/template/'%(srv,domain_name)
# Write settings to temp_omain
append_f(temp_domain,'\n# Server directories')
append_f(temp_domain,'srv = "%s"'%srv)
@ -337,6 +334,9 @@ def domain_form():
domain_title = domain_title.replace('"','\\"')
append_f(temp_domain,'\n# Domain datas for web pages')
append_f(temp_domain,'domain_name = "%s"'%domain_name)
append_f(temp_domain,'domain_protocol = "%s"'%domain_protocol)
append_f(temp_domain,'domain_url = "%s"'%domain_url)
append_f(temp_domain,'domain_title = "%s"'%domain_title)
# Separator Pages Titles (default '-')
@ -457,6 +457,24 @@ def domain_form():
append_f(temp_domain,'domain_license = "%s"'%domain_license)
# Copyright URL
#--------------
global domain_lic_url
try:
domain_lic_url
show_license = domain_lic_url[:14] + '...'
except:
domain_lic_url = ''
set_lic_url = input(' ├ Copyright URL (%s) ? '%show_license)
if not set_lic_url and not domain_lic_url:
exiting('form', 2, '\n:< Copyright URL is required.')
elif set_lic_url:
set_lic_url: domain_lic_url = set_lic_url
append_f(temp_domain,'domain_lic_url = "%s"'%domain_lic_url)
# Sidebar Title
# -------------
global sidebar_title

View File

@ -18,7 +18,7 @@
#**********************************************************************
import check, log, domain
def html_main_page():
def html_main_page(wip_html):
# Source DB variables
post_db = exec(open(check.curr_post_db).read(),globals())
@ -91,7 +91,7 @@ def html_main_page():
'</header>\n'
# Article (in section, including aside)
articles = '<section id="wrapper">\n' + \
articles = '<section id="page-wrapper">\n' + \
' <article id="article_%s" class="%s">\n'%(
post_ID, domain.domain_css
) + \
@ -101,7 +101,64 @@ def html_main_page():
' <span id="sep"> - </span>\n' + \
' <span id="date">%s</span>\n'%post_date + \
' </p>\n' + \
' </div>'
' </div>\n'
# Aside after article
#--------------------
asides = '<aside id="sidebar">\n' + \
' <div id="sidebar-wrapper" role="navigation">\n' + \
' <nav id="latest-posts">\n' + \
' <h1 id="sidebar-title">%s</h1>\n'%domain.domain_sdb_title + \
' <ul id="list-posts"\n' + \
' aria-label="$domain_sidebar_title">\n' + \
' <!--# include virtual="/template/sidebar.html" -->\n' + \
' </ul>\n' + \
' </nav>\n' + \
' </div>\n' + \
'</aside>'
# Footer, and of page
#--------------------
tytogen = 'https://git.a-lec.org/echolib/tyto-litterateur'
footers = '<footer id="footer">\n' + \
' <h1 id="footer-title">%s</h1>\n'%domain.domain_title + \
' <div id="footer-infos">\n' + \
' <p id="site-about">%s<p>\n'%domain.domain_about + \
' </div>\n' + \
' <div id="footer-about">\n' + \
' <ul class="site-list">\n' + \
' <li class="site-list">URL:\n' + \
' <a class="site_url"\n' + \
' href="/">\n' + \
' title="%s">%s</a>\n'%(
domain.domain_title, domain.domain_url
) + \
' </li>\n' + \
' <li class="site-list">License: \n' + \
' <a href="mailto:%s"\n'%domain.domain_mail +\
' title="Contact %s">%s</a>\n'%(
domain.domain_title, domain.domain_mail
) + \
' </li>\n' + \
' <li class="site-list">Copyright: \n' + \
' <a href="%s"\n'%domain.domain_lic_url +\
' title="License informations">%s</a>\n'%(
domain.domain_license
) + \
' </li>\n' + \
' <li class="site-list"><abbr title="Really Simple Syndication">RSS/<abbr>: \n' + \
' <a href="/rss.xml"\n' +\
' title="Syndication %s">/rss.xml</a>\n'%domain.domain_title + \
' </li>\n' + \
' <li class="site-list">Generator: \n' + \
' <a href="%s"\n' +\
' type="application/rss+xml"\n' + \
' title="Website generated by Tyto - Littérateur">Tyto - Littérateur</a>\n' + \
' </li>\n' + \
' </ul>\n' + \
' </div>\n' + \
'</footer>'
# Create full page
#-----------------
@ -124,5 +181,21 @@ def html_main_page():
for article in articles.rsplit('\n'):
page = '%s\n%s%s'%(page, 6*' ', article)
# Add post from wip.html
for line in wip_html:
page = '%s\n%s%s'%(page, 4*' ', line)
page = '%s\n%s</article>\n'%(page, 8*' ')
# Add latest-posts in page
#-------------------------
for aside in asides.rsplit('\n'):
page = '%s\n%s%s'%(page, 8*' ', aside)
page = '%s\n%s</section>'%(page, 6*' ')
# Add footer in page
#-------------------
for footer in footers.rsplit('\n'):
page = '%s\n%s%s'%(page, 4*' ', footer)
print(page)

View File

@ -117,7 +117,7 @@ def manage_wip(file_post, Force):
tab_article(wip_html.rsplit('\n'))
# Create full page
html.html_main_page()
html.html_main_page(wip_html.rsplit('\n'))
@ -783,4 +783,4 @@ def tab_article(article):
if wip_tmp: wip_tmp = '%s\n%s%s'%(wip_tmp, int(tab)*' ', line)
else : wip_tmp = '%s%s'%(int(tab)*' ', line)
print(wip_tmp)
wip_html = wip_tmp