This commit is contained in:
Cyrille L 2023-11-10 02:56:50 +01:00
parent 238b886bea
commit 119ba6e25f
19 changed files with 271 additions and 109 deletions

View File

@ -10,6 +10,16 @@ Tyto - Littérateur
# CURRENTLY IN DEV (in devel branch) ! # CURRENTLY IN DEV (in devel branch) !
## [1.9.35]
- Working on creating modules
- - Todo last: metas
- check
- - target: domain, wip, www to check directories and files
- - - domain: create .raw modules and wip modules (.html)
- wip
- - html values are now in wip.py
- fixes and more...
## [1.9.34] ## [1.9.34]
- Working on creating modules - Working on creating modules
- - fixes typos codes - - fixes typos codes

View File

@ -7,15 +7,18 @@ This program can ve tested but not at all usable. Lots of work to do...
tyto tyto
``` ```
# Create new domain # Create new domain
- create a domain directory, line www.domain.tld - create a domain directory, like www.domain.tld
- Go to this directory - Go to this directory
- type `tyto new domain` - type `tyto new domain`
- type `tyto check domain`
- create in new directory domain ".../articles/", an article (see tuto below)
- type `check myfile.tyto` (or use "wip" instead of check)
## Working on ## Working on
- 'wip' action processes - 'wip' action processes
- Create HTML full page from article - Create HTML full page from article
- Create/Manage modules (header, navbar, sidebar, footer) - Create/Manage modules (metas, header, navbar, sidebar, footer)
## ToDo ## ToDo
- thinking about creating an auto top article menu from titles - thinking about creating an auto top article menu from titles

2
debian/control vendored
View File

@ -1,5 +1,5 @@
Package: tyto Package: tyto
Version: 1.9.33 Version: 1.9.35
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.34 # Version: 1.9.35
# Updated: 2023-10-18 1697613100 # Updated: 2023-10-18 1697613100
# Tyto - Littérateur # Tyto - Littérateur

View File

@ -64,6 +64,39 @@ def manage(action, target):
# target is not "all" # target is not "all"
ready() ready()
target.endswith(".tyto") and is_article(target) target.endswith(".tyto") and is_article(target)
target == "domain" and wrk_domain()
target in ("wip", "www") and srv_domain(target)
#==========================================#
# Check some things used by current domain #
#------------------------------------------#
def wrk_domain():
wrk_template_files()
wip.get_modules("wip")
if post.error != 0:
sys.exit(post.error)
#==========================================================#
# Warn if unused registred file in wrk template/ directory #
#----------------------------------------------------------#
def wrk_template_files():
for key, uri in domain.cf.items("USER_TEMPLATE_FILES"):
if not os.path.exists(uri):
debug.out(5, key, uri, True, 1, False)
#==================================#
# Check wip and www dirs and files #
#----------------------------------#
def srv_domain(target):
for section in ("%s_DIRS"%target.upper(), "%s_FILES"%target.upper()):
if section.endswith("DIRS"): err = 6
else: err = 5
for key, uri in domain.cf.items(section):
if not os.path.exists(uri):
debug.out(err, key, uri, True, 1, False)
#================================# #================================#

View File

@ -197,8 +197,11 @@ def cf_set(section, key, default):
# Optional key # Optional key
elif not default: elif not default:
if not val: return default if not val:
else: default = val cf.set(section, key, default)
return default
else:
default = val
# Force set default value # Force set default value
if val != default: if val != default:
@ -234,17 +237,18 @@ def cf_update_values(write):
tags = cf_set("DOMAIN", "tags", "tags") tags = cf_set("DOMAIN", "tags", "tags")
license = cf_set("DOMAIN", "lincese", "") license = cf_set("DOMAIN", "lincese", "")
if not license: if not license:
license = cf_set("DOMAIN", "lincese", "gfdl-1.3") license = cf_set("DOMAIN", "license", "gfdl-1.3")
license_url = cf_set("DOMAIN", "lincese_url", license_url = cf_set("DOMAIN", "license_url",
"https://www.gnu.org/licenses/fdl-1.3.txt") "https://www.gnu.org/licenses/fdl-1.3.txt")
elif not license == "gfdl-1.3": elif not license == "gfdl-1.3" and \
license_url = cf_set("DOMAIN", "lincese_url","") license_url == "https://www.gnu.org/licenses/fdl-1.3.txt":
license_url = cf_set("DOMAIN", "license_url", "")
# Optional # [WEBSITE_FOOTER]
global legals_url, terms_url, statuses_url global legals_url, terms_url, bylaws_url
legals_url = cf_set("DOMAIN", "legals_url", "") legals_url = cf_set("WEBSITE_FOOTER", "legals_url", "")
terms_url = cf_set("DOMAIN", "terms_url", "") terms_url = cf_set("WEBSITE_FOOTER", "terms_url", "")
statuses_url = cf_set("DOMAIN", "statuses_url", "") bylaws_url = cf_set("WEBSITE_FOOTER", "bylaws_url", "")
# [SERVER] # [SERVER]
@ -613,9 +617,6 @@ tags =
mail = mail =
license = gfdl-1.3 license = gfdl-1.3
license_url = https://www.gnu.org/licenses/fdl-1.3.txt license_url = https://www.gnu.org/licenses/fdl-1.3.txt
legals_url =
terms_url =
statuses_url =
[WEBSITE] [WEBSITE]
www_url = www_url =
@ -627,6 +628,11 @@ article_code = yes
static = no static = no
navbar = yes navbar = yes
[WEBSITE_FOOTER]
legals_url =
terms_url =
bylaws_url =
[WEBSITE_MODULES] [WEBSITE_MODULES]
navbar = yes navbar = yes
sidebar_title = sidebar_title =

View File

@ -23,7 +23,7 @@
# File: /var/lib/tyto/program/tyto.py # File: /var/lib/tyto/program/tyto.py
#---------------------------------------------------------------------- #----------------------------------------------------------------------
import forms import forms, wip
# #
# Arguments in command line # # Arguments in command line #
@ -116,65 +116,4 @@ quote = """<blockquote class="%s"%s%s%s>%s
%s %s
</blockquote>""" </blockquote>"""
page_tpl = """<!-- %s -->
<!Doctype html>
<html lang="%s">
<head>
%s
</head>
<body>
<div id="site_container">
%s
%s
<!-- div contains <article> and <aside> -->
<div id="site_article_aside">
<article id="site_article">
<header id="site_article_header">
<h1 id="site_article_title">%s</h1>
</header>
%s
<footer id="site_article_footer">
%s
</footer>
</article>
%s
</div> <!-- site_article_aside -->
</div> <!-- #site_container -->
</body>
</html>"""
module_header = """<!-- Header (logo, description) -->
<header id="site_header">
<div id="site_logo">
<a id="site_logo_link" href="%s" title="%s">
<img id="site_logo_image" src="%s" alt="%s" title="%s">
</a>
</div>
<div id="site_infos">
<p id="site_infos_title">%s</p>
<p id="site_infos_text">%s</p>
</div<
</header>"""
module_navbar = """<!-- Website Menu navbar -->
<nav id="site_menu">
<menu id="site_menu_items">
%s
</menu>
</nav>"""
module_sidebar = """<!-- Website Sidebar -->
<aside id="site_sidebar">
<ul id="site_sidebar_items">
%s
</ul>
</aside>
"""
module_footer = """<!-- Website footer-->
"""

View File

@ -105,10 +105,7 @@ def convert(target):
for key, directory in domain.cf.items("WIP_DIRS"): for key, directory in domain.cf.items("WIP_DIRS"):
tools.create_dirs(directory) tools.create_dirs(directory)
# Warn if unused registred file in wrk template/ directory check.wrk_template_files()
for key, uri in domain.cf.items("USER_TEMPLATE_FILES"):
os.path.exists(uri) or \
debug.out(5, key, uri, True, 1, False)
# Check/Create modules files # Check/Create modules files
# navbar, sidebar, header, footer # navbar, sidebar, header, footer
@ -614,9 +611,6 @@ def modules_db():
mods_cf.read(db_mods_uri) mods_cf.read(db_mods_uri)
#============================================# #============================================#
# Check / Create modules files (.raw + .html # # Check / Create modules files (.raw + .html #
# process: "wip" or "www" # # process: "wip" or "www" #
@ -629,10 +623,11 @@ def get_modules(srv):
global modules global modules
# Modules settings # Modules settings
fill_footer_raw()
modules = \ modules = \
{ {
"header" : { "header" : {
"raw" : tyto.module_header%( "raw" : module_header%(
"/template/%s"%domain.logo, domain.about, "/template/%s"%domain.logo, domain.about,
"/template/%s"%domain.logo, domain.about, domain.about, "/template/%s"%domain.logo, domain.about, domain.about,
domain.title, domain.title,
@ -668,7 +663,12 @@ def get_modules(srv):
"set" : sidebar_check, "set" : sidebar_check,
}, },
"footer" : { "footer" : {
"raw" : tyto.module_footer, "raw" : module_footer%(
domain.title,
domain.about,
footer_items,
footer_cpr
),
"wrk" : domain.wrk_footer, "wrk" : domain.wrk_footer,
"wip" : domain.wip_footer, "wip" : domain.wip_footer,
"www" : domain.www_footer, "www" : domain.www_footer,
@ -696,6 +696,7 @@ def get_modules(srv):
else: else:
tools.create_file(modules[mod]["wrk"], modules[mod]["raw"]) tools.create_file(modules[mod]["wrk"], modules[mod]["raw"])
cur_raw_id = tools.get_filesum(modules[mod]["wrk"], True)
mods_cf.set(mod.upper(), "raw", cur_raw_id) mods_cf.set(mod.upper(), "raw", cur_raw_id)
mods_cf_write = True mods_cf_write = True
create_html_module = True create_html_module = True
@ -706,9 +707,10 @@ def get_modules(srv):
# Create HTML module if needed (raw updated, or unused html file) # Create HTML module if needed (raw updated, or unused html file)
if create_html_module: if create_html_module:
print(">> HTML", mod) modules[mod]["set"](srv)
if not modules[mod]["set"](srv):
return False if post.error != 0:
return False
if mods_cf_write: if mods_cf_write:
with open(db_mods_uri, "w") as f: with open(db_mods_uri, "w") as f:
@ -773,8 +775,8 @@ def navbar_html_create(srv):
with open(domain.wrk_navbar, "r") as f: with open(domain.wrk_navbar, "r") as f:
navbar_raw = f.read().rsplit("\n") navbar_raw = f.read().rsplit("\n")
navbar_html = "<!-- Website Menu Directories -->" navbar_html = "<!-- Website Menu Directories -->"
html_line = '<li class="site_menu_item"%s>' + \ html_line = '<li class="site_menu_item"%s>' + \
'<a class="%s site_menu_link" href="%s">%s</a></li>' '<a class="%s site_menu_link" href="%s">%s</a></li>'
for ln, line in enumerate(navbar_raw, 1): for ln, line in enumerate(navbar_raw, 1):
if line.lstrip().startswith("#") or \ if line.lstrip().startswith("#") or \
@ -841,7 +843,7 @@ def navbar_html_create(srv):
debug.out(9, 'Navbar', domain.wrk_navbar, True, 2, False) debug.out(9, 'Navbar', domain.wrk_navbar, True, 2, False)
return False return False
tools.create_file(modules["navbar"][srv], tyto.module_navbar%navbar_html) tools.create_file(modules["navbar"][srv], module_navbar%navbar_html)
return True return True
@ -960,10 +962,58 @@ def sidebar_html_create(srv):
return False return False
tools.create_file(modules["sidebar"][srv], tyto.module_sidebar%sidebar_html) tools.create_file(modules["sidebar"][srv], module_sidebar%sidebar_html)
return True return True
#===============================#
# Get datas and fill footer raw #
#-------------------------------#
def fill_footer_raw():
global footer_items, footer_cpr
# Create list items
footer_items = "<!-- Domain items -->"
item = \
'<li class="site_footer_item">' + \
'<a class="tyto site_footer_item_link" href="%s" title="%s %s">%s</a>'+ \
'</li>'
# Specific to License
if not domain.license: domain.license = "Copyleft"
if not domain.license_url: domain.license_url = "/"
show_license = "%s%s %s"%(langs.site.license, langs.logs.pp, domain.license)
footer_items = "%s\n%s"%(
footer_items,
item%(
domain.license_url,
langs.site.license_title, domain.title,
show_license
)
)
# Loop to [WEBSITE_FOOTER] and make link from key_url
for key, link in domain.cf.items("WEBSITE_FOOTER"):
if link:
keyname = key.rsplit("_url")[0]
footer_items = "%s\n%s"%(
footer_items,
item%(
link,
getattr(langs.site, "%s_title"%keyname), domain.title,
getattr(langs.site, keyname)
)
)
# Create copyright line
cur_date = tools.nowdate().rsplit("-")[0]
dom_date = domain.date.rsplit("-")[0]
if cur_date != dom_date: dates = "%s-%s"%(dom_date, cur_date)
else: dates = cur_date
footer_cpr = 'Copyright © %s %s'%(dates, domain.title)
#================================================# #================================================#
# Create footer.html in server (wip/ or www/) # # Create footer.html in server (wip/ or www/) #
# Remove empty lines and those starting with "#" # # Remove empty lines and those starting with "#" #
@ -991,6 +1041,7 @@ def footer_html_create(srv):
#======# #======#
# MAIN #======================================================================= # MAIN #=======================================================================
#======# #======#
# modules .ini configuration file
ini_mods = """ ini_mods = """
[HEADER] [HEADER]
raw = raw =
@ -1004,3 +1055,83 @@ raw =
[FOOTER] [FOOTER]
raw = raw =
""" """
# HTML templates
module_header = """<!-- Header (logo, description) -->
<header id="site_header">
<div id="site_logo">
<a id="site_logo_link" href="%s" title="%s">
<img id="site_logo_image" src="%s" alt="%s" title="%s">
</a>
</div>
<div id="site_infos">
<p id="site_infos_title">%s</p>
<p id="site_infos_text">%s</p>
</div<
</header>
"""
module_navbar = """<!-- Website Menu navbar -->
<nav id="site_menu" aria-labelledby="navigation-1">
<menu id="site_menu_items">
%s
</menu>
</nav>
"""
module_sidebar = """<!-- Website Sidebar -->
<aside id="site_sidebar">
<nav id="site_sidebar_menu" aria-labelledby="navigation-2">
<ul id="site_sidebar_items">
%s
</ul>
</nav>
</aside>
"""
module_footer = """<!-- Website footer-->
<footer id="site_footer">
<div id="site_footer_infos">
<p id="site_footer_title">%s</p>
<p id="site_footer_about">%s</p>
</div>
<nav id="site_footer_menu" aria-labelledby="navigation-3">
<ul id="site_footer_items">
%s
</ul>
</nav>
<p id="site_footer_copyright">%s</p>
</footer>
"""
page_tpl = """<!-- %s -->
<!Doctype html>
<html lang="%s">
<head>
%s
</head>
<body>
<div id="site_container">
%s
%s
<!-- div 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>
</header>
%s
<footer id="site_article_footer">
%s
</footer>
</article>
%s
</main> <!-- site_article_aside -->
</div> <!-- #site_container -->
</body>
</html>"""

View File

@ -12,7 +12,7 @@ div#site_container {}
/* ---------------------------------------------------------------------------- /* ----------------------------------------------------------------------------
* Header (Logo, Description) * Header (Wensite Logo, Description)
*/ */
header#site_header {} header#site_header {}
/* Website Logo */ /* Website Logo */
@ -26,7 +26,7 @@ p#site_infos_text {}
/* ---------------------------------------------------------------------------- /* ----------------------------------------------------------------------------
* Website Menu navbar * Menu navbar (Website)
*/ */
nav#site_menu {} nav#site_menu {}
menu#site_menu_items {} menu#site_menu_items {}
@ -36,7 +36,7 @@ a.site_menu_link {}
/* div contains <article> and <aside> */ /* div contains <article> and <aside> */
div#site_article_aside {} main#site_article_aside {}
/* ---------------------------------------------------------------------------- /* ----------------------------------------------------------------------------
@ -127,9 +127,10 @@ img.tyto {}
/* ---------------------------------------------------------------------------- /* ----------------------------------------------------------------------------
* Sidebar navigation * Sidebar (Website)
*/ */
aside#site_sidebar {} aside#site_sidebar {}
nav#site_sidebar_menu {}
ul#site_sidebar_items {} ul#site_sidebar_items {}
li.site_sidebar_item {} li.site_sidebar_item {}
/* Around div.site_sidebar_block */ /* Around div.site_sidebar_block */
@ -140,3 +141,18 @@ p.site_sidebar_title {}
footer.site_sidebar_footer {} footer.site_sidebar_footer {}
img.site_sidebar_image {} img.site_sidebar_image {}
p.site_sidebar_about {} p.site_sidebar_about {}
/* ============================================================================
* Footer (Website)
*/
footer#site_footer {}
div#site_footer_infos {}
p#site_footer_title {}
p#site_footer_about {}
nav#site_footer_menu {}
ul#site_footer_items {}
li.site_footer_item {}
/* Also a.tyto */
a.site_footer_item_link {}
p#site_footer_copyright {}

View File

@ -34,7 +34,8 @@
ok = ("yes", "y") ok = ("yes", "y")
# Form # Form
q = " ?" q = "?"
pp = ":"
configure_domain = "Configure domain" configure_domain = "Configure domain"
domain_title = "Domain title" domain_title = "Domain title"
domain_date = "Creation date" domain_date = "Creation date"
@ -106,7 +107,7 @@ tyto [action] [target] [options]
start : activate domain (default "no" when created) start : activate domain (default "no" when created)
stop : deactivate domain stop : deactivate domain
show : [domains] show : [domains]
check : check : [domain, wip, www, [name].tyto]
wip : wip :
publish : publish :
@ -120,6 +121,8 @@ tyto [action] [target] [options]
tags : [set]: domain tags (added to all articles) tags : [set]: domain tags (added to all articles)
lang : lang :
server : [set]: server local URI server : [set]: server local URI
wip : [check] Directories and files
www : [check] Directories and files
[options] ; multi-set [options] ; multi-set
--force, -F : force doing things... --force, -F : force doing things...

View File

@ -35,6 +35,7 @@ ok = ("oui", "o")
# Form # Form
q = " ?" q = " ?"
pp = " :"
configure_domain = "Configurer le domaine" configure_domain = "Configurer le domaine"
domain_title = "Titre du domaine" domain_title = "Titre du domaine"
domain_date = "Date de création" domain_date = "Date de création"
@ -106,7 +107,7 @@ tyto [action] [target] [options]
start : activer le domaine (défaut "no" à la création) start : activer le domaine (défaut "no" à la création)
stop : désactiver le domaine stop : désactiver le domaine
show : [domains] show : [domains]
check : check : [domain, wip, www, [name].tyto]
wip : wip :
publish : publish :
@ -120,6 +121,8 @@ tyto [action] [target] [options]
tags : [set]: étiquettes du domaine (ajoutées aux articles) tags : [set]: étiquettes du domaine (ajoutées aux articles)
lang : lang :
server : [set]: URI du serveur local server : [set]: URI du serveur local
wip : [check] dossiers et fichiers
www : [check] dossiers et fichiers
[options] ; multiples [options] ; multiples
--force, -F : forcer à faire quelque chose... --force, -F : forcer à faire quelque chose...

View File

@ -31,4 +31,13 @@
# Note: python file # Note: python file
sidebar_title = "Featured posts" sidebar_title = "Featured posts"
sitemap = "sitemap" sitemap = "sitemap"
license = "License"
license_title = "Website %s of"%license
legals = "Legal Mentions"
legal_title = "%s of"%legals
terms = "Terms of Service"
terms_title = "%s of"%terms
bylaws = "Bylaws"
bylaws_title = "%s of"%bylaws

View File

@ -28,7 +28,16 @@
# - Copier ce contenu dedans, et traduire les variables # - Copier ce contenu dedans, et traduire les variables
#---------------------------------------------------------------------- #----------------------------------------------------------------------
# Rappel: Fichier au format python # Note: Fichier au format python
sidebar_title = "Articles recommandés" sidebar_title = "Articles recommandés"
sitemap = "Plan du site" sitemap = "Plan du site"
license = "Licence"
license_title = "%s du site web de"%license
legals = "Mentions légales"
legal_title = "%s de"%legals
terms = "C.G.U"
terms_title = "%s de"%terms
bylaws = "Statuts"
bylaws_title = "%s de"%bylaws