From 7b38db9f37ffab585fdfe5be0404b0e9f427bd24 Mon Sep 17 00:00:00 2001
From: Cyrille L
Date: Wed, 23 Nov 2022 17:22:29 +0100
Subject: [PATCH] html: HTML page build
---
src/var/lib/tyto/program/domain.py | 34 ++++++++++---
src/var/lib/tyto/program/html.py | 79 ++++++++++++++++++++++++++++--
src/var/lib/tyto/program/wip.py | 4 +-
3 files changed, 104 insertions(+), 13 deletions(-)
diff --git a/src/var/lib/tyto/program/domain.py b/src/var/lib/tyto/program/domain.py
index 48256ba..02366fe 100644
--- a/src/var/lib/tyto/program/domain.py
+++ b/src/var/lib/tyto/program/domain.py
@@ -259,10 +259,8 @@ def domain_form():
domain_articles = '%s/articles/'%curr_dir
domain_images = '%simages/'%domain_articles
domain_files = '%sfiles/'%domain_articles
-
- # 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)
+ domain_url = '%s%s'%(domain_protocol, domain_name)
+
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
diff --git a/src/var/lib/tyto/program/html.py b/src/var/lib/tyto/program/html.py
index cd73b9d..207eff0 100644
--- a/src/var/lib/tyto/program/html.py
+++ b/src/var/lib/tyto/program/html.py
@@ -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():
'\n'
# Article (in section, including aside)
- articles = '\n' + \
+ articles = '\n' + \
' \n'%(
post_ID, domain.domain_css
) + \
@@ -101,7 +101,64 @@ def html_main_page():
' - \n' + \
' %s\n'%post_date + \
'
\n' + \
- ' '
+ ' \n'
+
+
+ # Aside after article
+ #--------------------
+ asides = ''
+
+ # Footer, and of page
+ #--------------------
+ tytogen = 'https://git.a-lec.org/echolib/tyto-litterateur'
+ footers = ''
# 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\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'%(page, 6*' ')
+
+ # Add footer in page
+ #-------------------
+ for footer in footers.rsplit('\n'):
+ page = '%s\n%s%s'%(page, 4*' ', footer)
+
print(page)
diff --git a/src/var/lib/tyto/program/wip.py b/src/var/lib/tyto/program/wip.py
index 5886ee0..f962030 100644
--- a/src/var/lib/tyto/program/wip.py
+++ b/src/var/lib/tyto/program/wip.py
@@ -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