This commit is contained in:
Cyrille L 2023-11-13 18:04:12 +01:00
parent b622ff8b24
commit cfb564eb23
20 changed files with 152 additions and 68 deletions

View File

@ -10,6 +10,13 @@ Tyto - Littérateur
# CURRENTLY IN DEV (in devel branch) ! # CURRENTLY IN DEV (in devel branch) !
## [1.9.38]
- Moved: HTML footer in div site_container
- fix: main title in HTML page h1
- Fill Article HTML metas datas
- Working on files copies to wip server with "wip" command
- - some changes in post DB and check process
## [1.9.37] ## [1.9.37]
- Preparing full HTML Page - Preparing full HTML Page
- Some fixes - Some fixes

View File

@ -236,22 +236,24 @@ _code:codetest
# Placer le logo de l'article # Placer le logo de l'article
_image:logo _image:logo
# Marqueur avec options # les options du marqueur:
# ! Les images dans cet exemple sont affichées à la suite
# Placer "|", ou mettez une image dans un paragraphe "((...))"
# ou appliquer un style css de type display:block
# les options des marqueurs:
# - c=CLASS < Sinon la classe est celle du domaine # - c=CLASS < Sinon la classe est celle du domaine
# - w=WIDTH < longueur (si pas d'unité : défaut "px") # - w=WIDTH < longueur (si pas d'unité : défaut "px")
# - h=HEIGHT < Comme w= # - h=HEIGHT < Comme w=
# - f=Ma légende sous l'image (ajoute <figure><figcaption>) # - f=Ma légende sous l'image (ajoute <figure><figcaption>)
# - - Recommandé d'utiliser cette option en dernier # - - Recommandé d'utiliser cette option en dernier
# ! Les images dans cet exemple sont affichées horizontalement
# Placer "|", ou mettez chaque image dans un paragraphe "((...))"
# ou définir un style css de type display:block pour les afficher verticalement
(( ((
_image:mypic _image:mypic
_image:mypic c=MYCSS _image:mypic c=MYCSS
_image:mypic c=PIC w=60em h=30% f=echolib sur une chaise
)) ))
# Une image avec légende (<figure>) (jamais dans un paragraphe)
_image:mypic c=PIC w=60em h=30% f=echolib sur une chaise
``` ```
## Output HTML ## Output HTML
@ -311,7 +313,7 @@ _image:logo
<!-- Quote --> <!-- Quote -->
<!-- A great quote here ! --> <!-- A great quote here ! -->
<p class="tyto"> mycite <p class="mycite">
Here, i am Here, i am
</p> </p>
</time> </time>
@ -361,10 +363,10 @@ Here, i am
</footer> </footer>
</code> </code>
<h3 class="tyto">Les images</h3> <h3 class="tyto">Les images</h3>
<a href="logo.png" class="post_logo image" title="tests d'un article"><img src="logo.png" class="post_logo" alt="tests d'un article" title="tests d'un article"></a> <a href="logo.png" class="post_logo image" title="tests d'un article"><img src="logo.png" class="post_logo" alt="tests d'un article" title="tests d'un article" /></a>
<p class="tyto"> <p class="tyto">
<a href="/images/hello.png" class="tyto image" title="Text Alt"><img src="/images/hello.png" class="tyto" alt="Text Alt" title="Text Alt"></a> <a href="/images/hello.png" class="tyto image" title="Text Alt"><img src="/images/hello.png" class="tyto" alt="Text Alt" title="Text Alt" /></a>
<a href="/images/hello.png" class="MYCSS image" title="Text Alt"><img src="/images/hello.png" class="MYCSS" alt="Text Alt" title="Text Alt"></a> <a href="/images/hello.png" class="MYCSS image" title="Text Alt"><img src="/images/hello.png" class="MYCSS" alt="Text Alt" title="Text Alt" /></a>
<a href="/images/hello.png" class="PIC image" title="Text Alt"><figure class="PIC"><img src="/images/hello.png" class="PIC" alt="Text Alt" title="Text Alt" style="width:60em;height:30%;"><figcaption class="PIC">echolib sur une chaise</figcaption></a>
</p> </p>
<a href="/images/hello.png" class="PIC image" title="Text Alt"><figure class="PIC"><img src="/images/hello.png" class="PIC" alt="Text Alt" title="Text Alt" style="width:60em;height:30%;" /><figcaption class="PIC">echolib sur une chaise</figcaption></figure></a>
``` ```

2
debian/control vendored
View File

@ -1,5 +1,5 @@
Package: tyto Package: tyto
Version: 1.9.37 Version: 1.9.38
Section: custom Section: custom
Priority: optional Priority: optional
Architecture: all Architecture: all

View File

@ -1,5 +1,5 @@
#!/usr/bin/env python3 #!/usr/bin/env python3
# Version: 1.9.37 # Version: 1.9.38
# Updated: 2023-11-11 1699742831 # Updated: 2023-11-11 1699742831
# Tyto - Littérateur # Tyto - Littérateur

View File

@ -314,6 +314,7 @@ def ol_tags():
if not post.logo[1]: if not post.logo[1]:
src_uri = "%stemplate/%s"%(domain.www_url, domain.logo) src_uri = "%stemplate/%s"%(domain.www_url, domain.logo)
post.logo = (post.logo[0], src_uri) post.logo = (post.logo[0], src_uri)
post.cf_set("HEADERS", "logo", src_uri) post.cf_set("HEADERS", "logo", src_uri)
return True return True
@ -589,7 +590,7 @@ def is_value2_file_exists(ln, tag, val2):
# Add file to [SOURCE_FILES] post database # Add file to [SOURCE_FILES] post database
stats_total_files += 1 stats_total_files += 1
post.cf_set("SOURCE_FILES", "file_%s"%stats_total_files, src_uri) post.cf_set("SOURCE_FILES", "file_%s"%stats_total_files, value2_uri)
post.cf_set("STATS_FILE", "files", str(stats_total_files)) post.cf_set("STATS_FILE", "files", str(stats_total_files))
return True return True
@ -1120,11 +1121,14 @@ def cf_update_values(part):
web_target = web_target[:-10] web_target = web_target[:-10]
if not web_target.startswith("/"): if not web_target.startswith("/"):
web_target = "/" + web_target web_target = "/" + web_target
post.cf_set("FILE", "id", post.uri_id)
post.cf_set("FILE", "uri", post.uri) # Create HTML local sub uri
post.cf_set("FILE", "db", post.cf_uri) post.cf_set("FILE", "id", post.uri_id)
post.cf_set("FILE", "target", post.wrk_target) post.cf_set("FILE", "uri", post.uri)
post.cf_set("FILE", "web", web_target) post.cf_set("FILE", "db", post.cf_uri)
post.cf_set("FILE", "target", post.wrk_target)
post.cf_set("FILE", "web", web_target)
post.cf.set("FILE", "sub_uri", post.wrk_target.count('/') * "../" or "./")
# [WIP] # [WIP]
# ----- # -----

View File

@ -48,11 +48,9 @@ import langs, args
#-----------------------------------# #-----------------------------------#
def out(nbr, var, val, show, color, stop): def out(nbr, var, val, show, color, stop):
args.get_options() args.get_options()
if not show:
# Show only warn and error logs
show = args.dlogs or args.erron and color > 0
if not show: logit = show or args.erron and color > 0 or args.dlogs
if not logit:
return nbr return nbr
# COlors # COlors

View File

@ -83,7 +83,7 @@ def is_article(target):
wrk_target = uri.rsplit(domain.wrk_articles)[1] wrk_target = uri.rsplit(domain.wrk_articles)[1]
# Set web target, replace last .tyto with .html # Set web target, replace last .tyto with .html
web_target= wrk_target[:-4] + "html" web_target = wrk_target[:-4] + "html"
# Load Database, get and compare values # Load Database, get and compare values
cf_load() cf_load()
@ -248,12 +248,16 @@ def cf_datas():
www_uri = cf_get("WWW", "uri", False) www_uri = cf_get("WWW", "uri", False)
www_static = cf_get("WWW", "static", True) www_static = cf_get("WWW", "static", True)
global set_title, set_about, set_date, set_author global set_title, set_about, set_date, set_tags, set_author
set_title = cf.get("HEADERS", "title") set_title = cf_get("HEADERS", "title", False)
set_about = cf.get("HEADERS", "about") set_about = cf_get("HEADERS", "about", False)
set_date = cf.get("HEADERS", "date") set_date = cf_get("HEADERS", "date", False)
set_tags = cf.get("HEADERS", "tags") set_tags = cf_get("HEADERS", "tags", False)
set_author = cf.get("HEADERS", "authors") set_author = cf_get("HEADERS", "authors", False)
global sub_uri, www_logo
sub_uri = cf_get("FILE", "sub_uri", False)
www_logo = cf_get("HEADERS", "logo", False)
#===============================# #===============================#

View File

@ -33,8 +33,8 @@
#-------------------------- #--------------------------
from hashlib import blake2b from hashlib import blake2b
import sys, os, configparser, datetime, time, base64 import sys, os, configparser, datetime, time, base64, shutil
import args, debug, domain, post import args, langs, debug, domain, post
#=========================================# #=========================================#
@ -123,18 +123,35 @@ def create_dirs(path):
#----------------------------# #----------------------------#
def create_file(file_path, contents): def create_file(file_path, contents):
up = bool(os.path.exists(file_path)) up = bool(os.path.exists(file_path))
try: try:
with open(file_path, "w") as f: with open(file_path, "w") as f:
f.write(contents) f.write(contents)
except: except:
# Exit at error # Exit if not created
debug.out(7, "False", file_path, True, 2, True) debug.out(7, "False", file_path, True, 2, True)
# log "update" or "new" # log "update" or "new"
file_name = os.path.basename(file_path) file_name = os.path.basename(file_path)
if up: debug.out(207, file_name, file_path, False, 0, False) if up: debug.out(207, file_name, file_path, False, 0, False)
else: debug.out(206, file_name, file_path, False, 0, False) else: debug.out(206, file_name, file_path, True, 0, False)
#============#
# Copy files #
#------------#
def copy_files(src, dst):
# Copy file, check if dst exists
up = bool(os.path.exists(dst))
try:
shutil.copy2(src, dst, follow_symlinks=False)
except:
debug.out(7, langs.logs.copy, dst, True, 2, False)
return
# log "update" or "new"
file_name = os.path.basename(src)
if up: debug.out(207, file_name, dst, False, 0, False)
else: debug.out(206, file_name, dst, True, 0, False)
#===========================================# #===========================================#
@ -142,8 +159,7 @@ def create_file(file_path, contents):
#-------------------------------------------# #-------------------------------------------#
def update_ini_file(file_path, section, key, val): def update_ini_file(file_path, section, key, val):
# Exit if no file # Exit if no file
if not os.path.exists(file_path): os.path.exists(file_path) or debug.out(5, "False", file_path, True, 2, True)
debug.out(5, "False", file_path, True, 2, True)
# Load ini file # Load ini file
config = configparser.ConfigParser() config = configparser.ConfigParser()

View File

@ -107,7 +107,7 @@ code_line = '<p class="bcode">' + \
'</p>' '</p>'
image_link = '<a href="%s" class="%s" title="%s">' + \ image_link = '<a href="%s" class="%s" title="%s">' + \
'%s<img src="%s" class="%s" alt="%s" title="%s"%s>' + \ '%s<img src="%s" class="%s" alt="%s" title="%s"%s />' + \
'%s</a>' '%s</a>'
a_link = '<a href="%s" class="%s" title="%s">%s</a>' a_link = '<a href="%s" class="%s" title="%s">%s</a>'

View File

@ -35,7 +35,7 @@
# file program : # file program :
#-------------------------- #--------------------------
import sys, os, configparser import sys, os, configparser, shutil
import args, debug, tyto, tools, post, domain, check, langs import args, debug, tyto, tools, post, domain, check, langs
@ -89,34 +89,86 @@ def is_article(target):
# Create full page # Create full page
page_html_create() page_html_create()
print("\n> wip:", target) # Copy article files
print(html_post) create_files()
#print()
#print(html_post)
#=======================# #=======================#
# Create full page HTML # # Create full page HTML #
#-----------------------# #-----------------------#
def page_html_create(): def page_html_create():
global page_html
page_html = \ page_html = \
page_tpl%( page_tpl%(
post.set_title, domain.title, post.set_title, domain.title,
domain.lang, domain.lang,
nginx_mods%("metas"), nginx_mods%("metas"),
metas_post, metas_post%(
domain.www_url,
domain.lang,
domain.mail,
domain.license,
post.set_title,
post.set_author,
post.set_about,
post.set_tags,
post.cf.get("WWW", "web"),
post.sub_uri, domain.styles,
os.path.splitext(domain.favicon)[1][1:], post.sub_uri, domain.favicon,
domain.www_url, domain.rss, domain.title,
domain.title,
post.set_title,
post.cf.get("WWW", "web"),
post.set_about,
post.www_logo,
datepub,
post.set_title, post.set_author, domain.sep, domain.title
),
nginx_mods%("header"), nginx_mods%("header"),
nginx_mods%("navbar"), nginx_mods%("navbar"),
post.cf.get("WWW", "web"), post.cf.get("WWW", "web"),
langs.site.permalink, langs.logs.pp, post.set_title, post.cf.get("WWW", "web"), langs.site.permalink, langs.logs.pp, post.cf.get("WWW", "web"),
post.set_title, post.set_author, domain.title, post.set_title,
html_post, html_post,
footer_post, footer_post,
nginx_mods%("sidebar"), nginx_mods%("sidebar"),
nginx_mods%("footer") nginx_mods%("footer")
) )
print()
print(page_html)
#========================================#
# Create and copy files for this article #
#----------------------------------------#
def create_files():
# Copy files used by article
for key, src_uri in post.cf.items("SOURCE_FILES"):
dst_uri = src_uri.replace(domain.wrk_articles, domain.wip)
wip_dirs = dst_uri.rsplit(os.path.basename(src_uri))[0] or domain.wip
tools.create_dirs(wip_dirs)
tools.copy_files(src_uri, dst_uri)
# Create source post wip dirs and html file
wip_dirs = \
post.wip_uri.rsplit(os.path.basename(post.wip_uri))[0] or domain.wip
tools.create_dirs(wip_dirs)
tools.create_file(post.wip_uri, page_html)
# Copy domain work template directory
shutil.copytree(domain.wrk_tpl,
domain.wip_tpl,
dirs_exist_ok=True)
# Copy source file if article_code is True in domain config
if domain.article_code:
tools.copy_files(post.uri,
os.path.join(domain.wip, post.wrk_target)
)
#===========================================# #===========================================#
@ -124,13 +176,15 @@ def page_html_create():
# In error case, exit or return if targetS # # In error case, exit or return if targetS #
#-------------------------------------------# #-------------------------------------------#
def convert(target): def convert(target):
global targets, raw_post global targets, raw_post, datepub
targets = args.targets targets = args.targets
# Target is a tyto article format # Target is a tyto article format
if not post.is_article(target): if not post.is_article(target):
return False return False
datepub = tools.nowdate()
# Check/create wip server directories # Check/create wip server directories
# Exit on error ! # Exit on error !
for key, directory in domain.cf.items("WIP_DIRS"): for key, directory in domain.cf.items("WIP_DIRS"):
@ -358,7 +412,9 @@ def images():
# <figure is set # <figure is set
if figure: if figure:
figcap_o = '<figure class="%s">'%css figcap_o = '<figure class="%s">'%css
figcap_c = '<figcaption class="%s">%s</figcaption>'%(css, figure) figcap_c = '<figcaption class="%s">%s</figcaption></figure>'%(
css, figure
)
# Width + height: # Width + height:
if width and height: if width and height:
@ -638,7 +694,7 @@ def footer_post_create():
) )
footer_post = \ footer_post = \
page_time%tools.nowdate() + '\n' + \ page_time%datepub + '\n' + \
'<p id="post_metas">%s, %s%s</p>\n'%( '<p id="post_metas">%s, %s%s</p>\n'%(
post.set_date, post.set_author, link_post_code post.set_date, post.set_author, link_post_code
) + \ ) + \
@ -903,11 +959,9 @@ def navbar_html_create(srv):
html_index_srv_uri = os.path.join(html_indexes[srv], folder) html_index_srv_uri = os.path.join(html_indexes[srv], folder)
html_index_srv_uri = os.path.join(html_index_srv_uri, "index.html") html_index_srv_uri = os.path.join(html_index_srv_uri, "index.html")
if not os.path.exists(html_index_srv_uri): if not os.path.exists(html_index_srv_uri):
post.error = \
debug.out(5, 'Navbar. %s) "%s"'%( debug.out(5, 'Navbar. %s) "%s"'%(
ln, html_index_srv_uri.rsplit(domain.srv_name)[1] ln, html_index_srv_uri.rsplit(domain.srv_name)[1]
), domain.wrk_navbar, True, 2, False) ), domain.wrk_navbar, True, 1, False)
return False
# Load post configuration file in tmp module # Load post configuration file in tmp module
# return if unused or post errors # return if unused or post errors
@ -1011,13 +1065,11 @@ def sidebar_html_create(srv):
wrk_post[:-4] + "html" wrk_post[:-4] + "html"
) )
# Unused HTML post # Unused index.html in srv
if not os.path.exists(srv_post_uri): if not os.path.exists(srv_post_uri):
post.error = \
debug.out(5, "Sidebar. %s) %s"%( debug.out(5, "Sidebar. %s) %s"%(
ln, wrk_post ln, wrk_post
), srv_post_uri, True, 2, False) ), srv_post_uri, True, 1, False)
return False
# Load post configuration file in tmp module # Load post configuration file in tmp module
# return if unused or post errors # return if unused or post errors
@ -1048,7 +1100,6 @@ def sidebar_html_create(srv):
debug.out(9, 'Sidebar', domain.wrk_sidebar, True, 2, False) debug.out(9, 'Sidebar', domain.wrk_sidebar, True, 2, False)
return False return False
tools.create_file(modules["sidebar"][srv], module_sidebar%sidebar_html) tools.create_file(modules["sidebar"][srv], module_sidebar%sidebar_html)
return True return True
@ -1094,7 +1145,7 @@ def fill_footer_raw():
) )
# Create copyright line # Create copyright line
cur_date = tools.nowdate().rsplit("-")[0] cur_date = datepub.rsplit("-")[0]
dom_date = domain.date.rsplit("-")[0] dom_date = domain.date.rsplit("-")[0]
if cur_date != dom_date: dates = "%s-%s"%(dom_date, cur_date) if cur_date != dom_date: dates = "%s-%s"%(dom_date, cur_date)
else: dates = cur_date else: dates = cur_date
@ -1167,7 +1218,7 @@ metas_post = """<!-- Metas/links from domain and article -->
<link rel="canonical" href="%s"> <link rel="canonical" href="%s">
<link rel="stylesheet" href="%stemplate/%s"> <link rel="stylesheet" href="%stemplate/%s">
<link rel="shortcut icon" type="image/%s" href="%stemplate/%s"> <link rel="shortcut icon" type="image/%s" href="%stemplate/%s">
<link rel="alternate" type="application/rss+xml" href="%s/%s" title="RSS 2.0 (%s)"> <link rel="alternate" type="application/rss+xml" href="%s%s" title="RSS 2.0 %s">
<!-- Open Graph data --> <!-- Open Graph data -->
<meta property="og:site_name" content="%s"> <meta property="og:site_name" content="%s">
@ -1175,7 +1226,7 @@ metas_post = """<!-- Metas/links from domain and article -->
<meta property="og:type" content="article"> <meta property="og:type" content="article">
<meta property="og:url" content="%s"> <meta property="og:url" content="%s">
<meta property="og:description" content="%s"> <meta property="og:description" content="%s">
<meta property="og:image" content="%s">%s <meta property="og:image" content="%s">
<!-- Publication date and title --> <!-- Publication date and title -->
<meta itemprop="datePublished" content="%s" id="date"> <meta itemprop="datePublished" content="%s" id="date">
@ -1250,7 +1301,7 @@ page_tpl = """<!-- %s - %s -->
<article id="site_article"> <article id="site_article">
<header id="site_article_header"> <header id="site_article_header">
<h1 id="site_article_title"> <h1 id="site_article_title">
<a id="main_title" href="%s" title="%s%s %s - [%s]">%s (%s) - %s</a> <a id="main_title" href="%s" title="%s%s %s">%s</a>
</h1> </h1>
</header> </header>
%s %s
@ -1261,10 +1312,10 @@ page_tpl = """<!-- %s - %s -->
%s %s
</main> </main>
</div> <!-- #site_container -->
%s %s
</div> <!-- #site_container -->
</body> </body>
</html>""" </html>"""

View File

@ -37,8 +37,7 @@ a.site_menu_link {}
/* div contains <article> and <aside> */ /* div contains <article> and <aside> */
main#site_article_aside {} main#site_article_aside {}
/* in main > <h1> < No id or class */
a#main_title {}
/* ---------------------------------------------------------------------------- /* ----------------------------------------------------------------------------
* Article contents styles * Article contents styles
@ -47,6 +46,7 @@ a#main_title {}
article#site_article {} article#site_article {}
header#site_article_header {} header#site_article_header {}
h1#site_article_title {} h1#site_article_title {}
a#main_title {}
footer#site_article_footer {} footer#site_article_footer {}
/* In <footer> for <article> */ /* In <footer> for <article> */
p#post_metas {} p#post_metas {}

View File

@ -44,6 +44,7 @@ domain_mail = "Admin mail"
domain_tags = "Domain tags [1,2,3]" domain_tags = "Domain tags [1,2,3]"
domain_lang = "Website lang" domain_lang = "Website lang"
domain_srv = "Server URI" domain_srv = "Server URI"
copy = "Copy"
# Misc # Misc
anchor_title = "Anchor title" anchor_title = "Anchor title"

View File

@ -44,6 +44,7 @@ domain_mail = "Courriel de l'administration"
domain_tags = "Mots-clés du domaine [1,2,3]" domain_tags = "Mots-clés du domaine [1,2,3]"
domain_lang = "Langue du site web" domain_lang = "Langue du site web"
domain_srv = "URI du serveur" domain_srv = "URI du serveur"
copy = "Copie"
# Misc # Misc
anchor_title = "Titre de l'ancre" anchor_title = "Titre de l'ancre"