This commit is contained in:
Cyrille L 2023-11-12 03:00:17 +01:00
parent d1bed4c17b
commit b622ff8b24
13 changed files with 114 additions and 18 deletions

View File

@ -10,6 +10,12 @@ Tyto - Littérateur
# CURRENTLY IN DEV (in devel branch) !
## [1.9.37]
- Preparing full HTML Page
- Some fixes
- Added web target (without index.html) in section "FILE" in post DB
- Added article footer contents
## [1.9.36]
- fix translations modules
- added metas module

2
debian/control vendored
View File

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

View File

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

View File

@ -1114,25 +1114,31 @@ def cf_update_values(part):
post.cf_set("CHECK", "static", str(domain.static))
post.cf_set("CHECK", "hash", post.wrk_id)
# [FILE]
# [FILE]
web_target = post.wrk_target[:-4] + "html"
if web_target.endswith("index.html"):
web_target = web_target[:-10]
if not web_target.startswith("/"):
web_target = "/" + web_target
post.cf_set("FILE", "id", post.uri_id)
post.cf_set("FILE", "uri", post.uri)
post.cf_set("FILE", "db", post.cf_uri)
post.cf_set("FILE", "target", post.wrk_target)
post.cf_set("FILE", "web", web_target)
# [WIP]
# -----
post.cf_set("WIP", "hash", post.wip_hash)
post.cf_set("WIP", "date", post.wip_date)
post.cf_set("WIP", "web", "%s%s"%(domain.wip_url, post.wrk_target))
post.cf_set("WIP", "uri", "%s%s"%(domain.wip, post.wrk_target))
post.cf_set("WIP", "web", "%s%s"%(domain.wip_url, post.web_target))
post.cf_set("WIP", "uri", "%s%s"%(domain.wip, post.web_target))
# [WWW]
# -----
post.cf_set("WWW", "hash", post.www_hash)
post.cf_set("WWW", "date", post.www_date)
post.cf_set("WWW", "web", "%s%s"%(domain.www_url, post.wrk_target))
post.cf_set("WWW", "uri", "%s%s"%(domain.www, post.wrk_target))
post.cf_set("WWW", "web", "%s%s"%(domain.www_url, post.web_target))
post.cf_set("WWW", "uri", "%s%s"%(domain.www, post.web_target))
# Stats (these, cause i want them first)
post.cf_set("STATS_FILE", "lines", str(post.lines))

View File

@ -71,7 +71,7 @@ def is_article(target):
if not is_tyto_format():
return False
global uri_id, wrk_id, cf_uri, wrk_target
global uri_id, wrk_id, cf_uri, wrk_target, web_target
# Set post ID from...
uri_id = tools.get_filesum(uri, False) # ...URI
wrk_id = tools.get_filesum(uri, True) # ...CONTENTS
@ -82,6 +82,9 @@ def is_article(target):
# Set target from articles/
wrk_target = uri.rsplit(domain.wrk_articles)[1]
# Set web target, replace last .tyto with .html
web_target= wrk_target[:-4] + "html"
# Load Database, get and compare values
cf_load()
cf_datas()
@ -130,10 +133,10 @@ def is_tyto_format():
if not text_contents:
error = debug.out(23, "?", uri, True, 2, False)
return False
lines = len(contents.splitlines())
head_lines = len(head_contents.splitlines()) + 1 # Count with sep line
text_lines = len(text_contents.splitlines())
lines = head_lines + text_lines
return True
@ -245,6 +248,13 @@ def cf_datas():
www_uri = cf_get("WWW", "uri", False)
www_static = cf_get("WWW", "static", True)
global set_title, set_about, set_date, set_author
set_title = cf.get("HEADERS", "title")
set_about = cf.get("HEADERS", "about")
set_date = cf.get("HEADERS", "date")
set_tags = cf.get("HEADERS", "tags")
set_author = cf.get("HEADERS", "authors")
#===============================#
# Do some datas comparisons #
@ -372,7 +382,7 @@ nositemap = "! NoSitemap" # Article will not be included in sitemap
# One Line needed
sep = "-----" # Splitter between header and article texts
# Will replace "Fals" with data value
# Will replace "False" with data value (check process)
title = ("title:", False)
about = ("about:", False)
date = ("date:", False)

View File

@ -76,7 +76,9 @@ def multiple_targets():
#================================#
# Check article(S) #
# Check article(s) #
# - Convert tags #
# - Create full page #
# Also used with multiple (loop) #
#--------------------------------#
def is_article(target):
@ -84,10 +86,39 @@ def is_article(target):
if targets: return
else: sys.exit(post.error)
# Create full page
page_html_create()
print("\n> wip:", target)
print(html_post)
#=======================#
# Create full page HTML #
#-----------------------#
def page_html_create():
page_html = \
page_tpl%(
post.set_title, domain.title,
domain.lang,
nginx_mods%("metas"),
metas_post,
nginx_mods%("header"),
nginx_mods%("navbar"),
post.cf.get("WWW", "web"),
langs.site.permalink, langs.logs.pp, post.set_title, post.cf.get("WWW", "web"),
post.set_title, post.set_author, domain.title,
html_post,
footer_post,
nginx_mods%("sidebar"),
nginx_mods%("footer")
)
print()
print(page_html)
#===========================================#
# Check full article contents (head + text) #
# In error case, exit or return if targetS #
@ -146,6 +177,7 @@ def convert(target):
value_replace("BCODES", False, True)
value_replace("CODES", False, True)
footer_post_create()
return True
@ -590,6 +622,29 @@ def convert_list(markdown_str, mark_b, mark_c):
return work_str
#===========================================#
# Create contents in <footer> for <article> #
#-------------------------------------------#
def footer_post_create():
global footer_post
link_post_code = ""
if domain.article_code:
link_post_code = \
' <a id="post_code" title="%s%s %s - %s" href="/%s">[%s]</a>'%(
langs.site.source_code, langs.logs.pp, post.set_title, domain.title,
post.cf.get("FILE", "target"),
langs.site.source_code
)
footer_post = \
page_time%tools.nowdate() + '\n' + \
'<p id="post_metas">%s, %s%s</p>\n'%(
post.set_date, post.set_author, link_post_code
) + \
'</time>'
#=========#
# Modules #====================================================================
#---------#
@ -1174,11 +1229,14 @@ module_footer = """<!-- Website footer-->
</footer>
"""
page_tpl = """<!-- %s -->
<!Doctype html>
nginx_mods = '<!--# include virtual="/template/%s.html"-->'
page_tpl = """<!-- %s - %s -->
<!DocType html>
<html lang="%s">
<head>
%s
%s
</head>
<body>
<div id="site_container">
@ -1187,11 +1245,13 @@ page_tpl = """<!-- %s -->
%s
<!-- div contains <article> and <aside> -->
<!-- main contains <article> and <aside> -->
<main id="site_article_aside">
<article id="site_article">
<header id="site_article_header">
<h1 id="site_article_title">%s</h1>
<h1 id="site_article_title">
<a id="main_title" href="%s" title="%s%s %s - [%s]">%s (%s) - %s</a>
</h1>
</header>
%s
<footer id="site_article_footer">
@ -1199,8 +1259,13 @@ page_tpl = """<!-- %s -->
</footer>
</article>
%s
</main> <!-- site_article_aside -->
</main>
</div> <!-- #site_container -->
%s
</body>
</html>"""
page_time = '<!-- pagetime --><time datetime="%s">'

View File

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

View File

@ -32,6 +32,8 @@
sidebar_title = "Featured posts"
sitemap = "sitemap"
source_code = "Source code"
permalink = "Permalink"
license = "License"
license_title = "Website %s of"%license

View File

@ -32,6 +32,8 @@
sidebar_title = "Articles recommandés"
sitemap = "Plan du site"
source_code = "Code source"
permalink = "Permalien"
license = "Licence"
license_title = "%s du site web de"%license