bug when new or updating domain configuration file
This commit is contained in:
parent
45cdecd7a5
commit
beecb0ee5e
|
@ -7,6 +7,9 @@ Tyto - Littérateur
|
|||
- License:
|
||||
- Documentation:
|
||||
|
||||
## [1.9.7]
|
||||
- new process to check and update configuration file (bug at write some values)
|
||||
|
||||
## [1.9.6]
|
||||
- Better management to create/update domain
|
||||
|
||||
|
|
|
@ -8,7 +8,7 @@ tyto
|
|||
```
|
||||
|
||||
## ToDo next (working on)
|
||||
- Manage domain configuration file values
|
||||
- check action
|
||||
- target post exists and compatible
|
||||
- create template post database
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
#!/usr/bin/env python3
|
||||
# Version: 1.9.6
|
||||
# Updated: 2023-09-26 1695738690
|
||||
# Version: 1.9.7
|
||||
# Updated: 2023-09-27 1695799605
|
||||
# Tyto - Littérateur
|
||||
|
||||
# Copyright (C) 2023 Cyrille Louarn <echolib+tyto@a-lec.org>
|
||||
|
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
@ -43,7 +43,8 @@ import domain, langs, debug, post, tools
|
|||
#-------------------------------------------#
|
||||
def manage(action, target):
|
||||
# Load domain configuration (update it if needed), check if valid
|
||||
domain.cf_valid() or debug.out(105, domain.name, domain.cf_uri, True, 1, True)
|
||||
#domain.cf_valid() or debug.out(105, domain.name, domain.cf_uri, True, 1, True)
|
||||
domain.cf_update_values(False)
|
||||
target.endswith(".tyto") and post.is_article(target)
|
||||
|
||||
langs.load_website_lang()
|
||||
|
|
|
@ -57,12 +57,6 @@ def cf_load():
|
|||
cf = configparser.ConfigParser()
|
||||
cf.read(cf_uri)
|
||||
|
||||
# Set some needed global values
|
||||
global articles_dir, db_dir
|
||||
|
||||
articles_dir = cf.get("USER_DIRS", "articles")
|
||||
db_dir = cf.get("USER_DIRS", "database")
|
||||
|
||||
|
||||
#=====================================#
|
||||
# Load User Domain Configuration file #
|
||||
|
@ -154,7 +148,7 @@ def cf_create():
|
|||
forms.ask_domain_shortname(name)
|
||||
|
||||
# Create default files
|
||||
tools.create_file(cf_uri, tyto.ini_domain)
|
||||
tools.create_file(cf_uri, tyto.ini_domain%name)
|
||||
tools.create_dirs(ult_dir)
|
||||
tools.create_file(ult_cf_uri, tyto.ini_domain_user)
|
||||
|
||||
|
@ -177,7 +171,7 @@ def cf_create():
|
|||
forms.ask_domain_server(True)
|
||||
|
||||
# Update Domain Configuration file
|
||||
cf_update_values()
|
||||
cf_update_values(True)
|
||||
|
||||
|
||||
#===========================================#
|
||||
|
@ -185,168 +179,334 @@ def cf_create():
|
|||
# Ask for some values if empty #
|
||||
# Ensure to set correct values #
|
||||
#-------------------------------------------#
|
||||
def cf_update_values():
|
||||
# Prepare Domain Configuration File keys values
|
||||
#-----------------------------------------------
|
||||
def cf_update_values(write):
|
||||
global cf
|
||||
# Load Domain Configuration file
|
||||
cf = ""
|
||||
cf_load()
|
||||
|
||||
if cf.get("DOMAIN", "name") != name:
|
||||
cf.set("DOMAIN", "name", name)
|
||||
debug.out(204, "[DOMAIN] name", name, False, 0, False)
|
||||
write = True
|
||||
|
||||
# Server
|
||||
srv = cf.get("SERVER", "root") or \
|
||||
cf.set("SERVER", "root", forms.ask_domain_server(False))
|
||||
# [SERVER]
|
||||
global srv
|
||||
srv = cf.get("SERVER", "root")
|
||||
if not tools.dir_exists(srv, False):
|
||||
srv = forms.ask_domain_server(False)
|
||||
cf.set("SERVER", "root", srv)
|
||||
debug.out(204, "[SERVER] root", srv, False, 0, False)
|
||||
write = True
|
||||
|
||||
global srv_name
|
||||
srv_name = os.path.join(srv, name + "/")
|
||||
print("domain: srv_name", srv_name)
|
||||
if cf.get("SERVER", "domain") != srv_name:
|
||||
cf.set("SERVER", "domain", srv_name)
|
||||
debug.out(204, "[SERVER] domain", srv_name, False, 0, False)
|
||||
write = True
|
||||
|
||||
global srv_wip
|
||||
srv_wip = os.path.join(srv_name, "wip/")
|
||||
if cf.get("SERVER", "wip") != srv_wip:
|
||||
cf.set("SERVER", "wip", srv_wip)
|
||||
debug.out(204, "[SERVER] wip", srv_wip, False, 0, False)
|
||||
write = True
|
||||
|
||||
# Title
|
||||
cf.get("DOMAIN", "title") or \
|
||||
cf.set("DOMAIN", "title", forms.ask_domain_title(False))
|
||||
global srv_wip_tpl
|
||||
srv_wip_tpl = os.path.join(srv_wip, "template/")
|
||||
if cf.get("WIP_DIRS", "template") != srv_wip_tpl:
|
||||
cf.set("WIP_DIRS", "template", srv_wip_tpl)
|
||||
debug.out(204, "[WIP_DIRS] template", srv_wip_tpl, False, 0, False)
|
||||
write = True
|
||||
|
||||
global srv_wip_images
|
||||
srv_wip_images = os.path.join(srv_wip, "images/")
|
||||
if cf.get("WIP_DIRS", "images") != srv_wip_images:
|
||||
cf.set("WIP_DIRS", "images", srv_wip_images)
|
||||
debug.out(204, "[WIP_DIRS] images", srv_wip_images, False, 0, False)
|
||||
write = True
|
||||
|
||||
global srv_wip_files
|
||||
srv_wip_files = os.path.join(srv_wip, "files/")
|
||||
if cf.get("WIP_DIRS", "files") != srv_wip_files:
|
||||
cf.set("WIP_DIRS", "files", srv_wip_files)
|
||||
debug.out(204, "[WIP_DIRS] files", srv_wip_files, False, 0, False)
|
||||
write = True
|
||||
|
||||
global srv_www
|
||||
srv_www = os.path.join(srv_name, "www/")
|
||||
if cf.get("SERVER", "www") != srv_www:
|
||||
cf.set("SERVER", "www", srv_www)
|
||||
debug.out(204, "[SERVER] www", srv_www, False, 0, False)
|
||||
write = True
|
||||
|
||||
global srv_www_tpl
|
||||
srv_www_tpl = os.path.join(srv_www, "template/")
|
||||
if cf.get("WWW_DIRS", "template") != srv_www_tpl:
|
||||
cf.set("WWW_DIRS", "template", srv_www_tpl)
|
||||
debug.out(204, "[WWW_DIRS] template", srv_www_tpl, False, 0, False)
|
||||
write = True
|
||||
|
||||
# Date
|
||||
cf.get("DOMAIN", "date") or \
|
||||
cf.set("DOMAIN", "date", forms.ask_domain_date(False))
|
||||
global srv_www_images
|
||||
srv_www_images = os.path.join(srv_www, "images/")
|
||||
if cf.get("WWW_DIRS", "images") != srv_www_images:
|
||||
cf.set("WWW_DIRS", "images", srv_www_images)
|
||||
debug.out(204, "[WWW_DIRS] images", srv_www_images, False, 0, False)
|
||||
write = True
|
||||
|
||||
global srv_www_files
|
||||
srv_www_files = os.path.join(srv_www, "files/")
|
||||
if cf.get("WWW_DIRS", "files") != srv_www_files:
|
||||
cf.set("WWW_DIRS", "files", srv_www_files)
|
||||
debug.out(204, "[WWW_DIRS] files", srv_www_files, False, 0, False)
|
||||
write = True
|
||||
|
||||
|
||||
# About
|
||||
cf.get("DOMAIN", "about") or \
|
||||
cf.set("DOMAIN", "about", forms.ask_domain_about(False))
|
||||
# [DOMAIN]
|
||||
# ========
|
||||
try: cf.getboolean("DOMAIN", "activated")
|
||||
except:
|
||||
cf.set("DOMAIN", "activated", "no")
|
||||
debug.out(204, "[DOMAIN] activated", "no", False, 0, False)
|
||||
write = True
|
||||
|
||||
# mail
|
||||
cf.get("DOMAIN", "mail") or \
|
||||
cf.set("DOMAIN", "mail", forms.ask_domain_mail(False))
|
||||
global title
|
||||
title = cf.get("DOMAIN", "title")
|
||||
if not title:
|
||||
cf.set("DOMAIN", "title", forms.ask_domain_title(False))
|
||||
write = True
|
||||
|
||||
# tags
|
||||
cf.get("DOMAIN", "tags") or \
|
||||
cf.set("DOMAIN", "tags", forms.ask_domain_tags(False))
|
||||
global date
|
||||
date = cf.get("DOMAIN", "date")
|
||||
if not date:
|
||||
cf.set("DOMAIN", "date", forms.ask_domain_date(False))
|
||||
write = True
|
||||
|
||||
global about
|
||||
about = cf.get("DOMAIN", "about")
|
||||
if not about:
|
||||
cf.set("DOMAIN", "about", forms.ask_domain_about(False))
|
||||
write = True
|
||||
|
||||
global mail
|
||||
mail = cf.get("DOMAIN", "mail")
|
||||
if not mail:
|
||||
cf.set("DOMAIN", "mail", forms.ask_domain_mail(False))
|
||||
write = True
|
||||
|
||||
global tags
|
||||
tags = cf.get("DOMAIN", "tags")
|
||||
if not tags:
|
||||
cf.set("DOMAIN", "tags", forms.ask_domain_tags(False))
|
||||
write = True
|
||||
|
||||
global license, license_url
|
||||
license = cf.get("DOMAIN", "license")
|
||||
if not license:
|
||||
cf.set("DOMAIN", "license", "gfdl-1.3")
|
||||
write = True
|
||||
license_url = cf.get("DOMAIN", "license_url")
|
||||
if license == "gfdl-1.3" and \
|
||||
not license_url == "https://www.gnu.org/licenses/fdl-1.3.txt":
|
||||
cf.set("DOMAIN", "license_url", "https://www.gnu.org/licenses/fdl-1.3.txt")
|
||||
write = True
|
||||
|
||||
# [WEBSITE]
|
||||
# =========
|
||||
global www_url, wip_url
|
||||
www_url = cf.get("WEBSITE", "www_url")
|
||||
if not www_url:
|
||||
cf.set("WEBSITE", "www_url", "https://%s/"%name)
|
||||
write = True
|
||||
|
||||
wip_url = cf.get("WEBSITE", "wip_url")
|
||||
if not wip_url:
|
||||
cf.set("WEBSITE", "wip_url", create_wip_url())
|
||||
write = True
|
||||
|
||||
global lang
|
||||
lang = cf.get("WEBSITE", "lang")
|
||||
if not lang:
|
||||
cf.set("WEBSITE", "lang", forms.ask_domain_lang(False))
|
||||
write = True
|
||||
elif not langs.translation_exists("website", lang, False):
|
||||
lang = langs.get_sys_lang()
|
||||
write = True
|
||||
|
||||
# Lang
|
||||
cf.get("WEBSITE", "lang") or \
|
||||
cf.set("WEBSITE", "date", forms.ask_domain_lang(False))
|
||||
langs.load_website_lang()
|
||||
|
||||
# Set URIs from srv uri
|
||||
srv_dom = os.path.join(srv, name + "/")
|
||||
srv_wip = os.path.join(srv_dom, "wip/")
|
||||
srv_www = os.path.join(srv_dom, "www/")
|
||||
|
||||
# Set booleans if invalid values
|
||||
try: cf.getboolean("DOMAIN", "activated")
|
||||
except: cf.set("DOMAIN", "activated", "no")
|
||||
global css
|
||||
css = cf.get("WEBSITE", "css")
|
||||
if not css:
|
||||
cf.set("WEBSITE", "css", "tyto")
|
||||
|
||||
global sep
|
||||
sep = cf.get("WEBSITE", "separator")
|
||||
if not sep or len(sep) > 2:
|
||||
cf.set("WEBSITE", "separator", "|")
|
||||
write = True
|
||||
|
||||
global article_code, static
|
||||
try: cf.getboolean("WEBSITE", "article_code")
|
||||
except: cf.set("WEBSITE", "article_code", "yes")
|
||||
except: cf.set("WEBSITE", "article_code", "yes") ; write = True
|
||||
try: cf.getboolean("WEBSITE", "static")
|
||||
except: cf.set("WEBSITE", "static", "no")
|
||||
except: cf.set("WEBSITE", "static", "no") ; write = True
|
||||
|
||||
# [WEBSITE_MODULES]
|
||||
global navbar
|
||||
try: cf.getboolean("WEBSITE_MODULES", "navbar")
|
||||
except: cf.set("WEBSITE_MODULES", "navbar", "yes") ; write = True
|
||||
|
||||
global sidebar_title
|
||||
sidebar_title = cf.get("WEBSITE_MODULES", "sidebar_title")
|
||||
if not sidebar_title:
|
||||
cf.set("WEBSITE_MODULES", "sidebar_title", langs.site.sidebar_title)
|
||||
write = True
|
||||
|
||||
global sidebar_items
|
||||
sidebar_items = cf.get("WEBSITE_MODULES", "sidebar_items")
|
||||
if not sidebar_items.isdigit():
|
||||
cf.set("WEBSITE_MODULES", "sidebar_items", "0")
|
||||
write = True
|
||||
|
||||
try: cf.getboolean("WEBSITE_MODULES", "sitemaps")
|
||||
except: cf.set("WEBSITE_MODULES", "sitemaps", "yes")
|
||||
except: cf.set("WEBSITE_MODULES", "sitemaps", "yes") ; write = True
|
||||
|
||||
# Set template filenames to default if none
|
||||
favicon = cf.get("TEMPLATE_FILENAMES", "favicon") or "favicon.png"
|
||||
logo = cf.get("TEMPLATE_FILENAMES", "logo") or "logo.png"
|
||||
styles = cf.get("TEMPLATE_FILENAMES", "styles") or "styles.css"
|
||||
rss = cf.get("TEMPLATE_FILENAMES", "rss") or "rss.xml"
|
||||
stats = cf.get("TEMPLATE_FILENAMES", "stats") or "stats.ini"
|
||||
global rss_items
|
||||
rss_items = cf.get("WEBSITE_MODULES", "rss_items")
|
||||
if not rss_items.isdigit():
|
||||
cf.set("WEBSITE_MODULES", "rss_items", "0")
|
||||
write = True
|
||||
|
||||
# TEMPLATE_FILES
|
||||
# ==============
|
||||
favicon = cf.get("TEMPLATE_FILENAMES", "favicon")
|
||||
if not favicon:
|
||||
favicon = "favicon.png"
|
||||
cf.set("TEMPLATE_FILENAMES", "favicon", favicon)
|
||||
write = True
|
||||
usr_favicon = os.path.join(cf_usr_tpl, favicon)
|
||||
if cf.get("USER_TEMPLATE_FILES", "favicon") != usr_favicon:
|
||||
cf.set("USER_TEMPLATE_FILES", "favicon", usr_favicon)
|
||||
write = True
|
||||
wip_favicon = os.path.join(srv_wip_tpl, favicon)
|
||||
if cf.get("WIP_FILES", "favicon") != wip_favicon:
|
||||
cf.set("WIP_FILES", "favicon", wip_favicon)
|
||||
write = True
|
||||
www_favicon = os.path.join(srv_www_tpl, favicon)
|
||||
if cf.get("WWW_FILES", "favicon") != www_favicon:
|
||||
cf.set("WWW_FILES", "favicon", www_favicon)
|
||||
write = True
|
||||
|
||||
logo = cf.get("TEMPLATE_FILENAMES", "logo")
|
||||
if not logo:
|
||||
logo = "logo.png"
|
||||
cf.set("TEMPLATE_FILENAMES", "logo", logo)
|
||||
write = True
|
||||
usr_logo = os.path.join(cf_usr_tpl, logo)
|
||||
if cf.get("USER_TEMPLATE_FILES", "logo") != usr_logo:
|
||||
cf.set("USER_TEMPLATE_FILES", "logo", usr_logo)
|
||||
write = True
|
||||
wip_logo = os.path.join(srv_wip_tpl, logo)
|
||||
if cf.get("WIP_FILES", "logo") != wip_logo:
|
||||
cf.set("WIP_FILES", "logo", wip_logo)
|
||||
write = True
|
||||
www_logo = os.path.join(srv_www_tpl, logo)
|
||||
if cf.get("WWW_FILES", "logo") != www_logo:
|
||||
cf.set("WWW_FILES", "logo", www_logo)
|
||||
write = True
|
||||
|
||||
styles = cf.get("TEMPLATE_FILENAMES", "styles")
|
||||
if not styles:
|
||||
styles = "styles.css"
|
||||
cf.set("TEMPLATE_FILENAMES", "styles", styles)
|
||||
write = True
|
||||
usr_styles = os.path.join(cf_usr_tpl, styles)
|
||||
if cf.get("USER_TEMPLATE_FILES", "styles") != usr_styles:
|
||||
cf.set("USER_TEMPLATE_FILES", "styles", usr_styles)
|
||||
write = True
|
||||
wip_styles = os.path.join(srv_wip_tpl, styles)
|
||||
if cf.get("WIP_FILES", "styles") != wip_styles:
|
||||
cf.set("WIP_FILES", "styles", wip_styles)
|
||||
write = True
|
||||
www_styles = os.path.join(srv_www_tpl, styles)
|
||||
if cf.get("WWW_FILES", "styles") != www_styles:
|
||||
cf.set("WWW_FILES", "styles", www_styles)
|
||||
write = True
|
||||
|
||||
rss = cf.get("TEMPLATE_FILENAMES", "rss")
|
||||
if not rss:
|
||||
rss = "rss.xml"
|
||||
cf.set("TEMPLATE_FILENAMES", "rss", rss)
|
||||
write = True
|
||||
wip_rss = os.path.join(srv_wip_tpl, rss)
|
||||
if cf.get("WIP_FILES", "rss") != wip_rss:
|
||||
cf.set("WIP_FILES", "rss", wip_rss)
|
||||
write = True
|
||||
www_rss = os.path.join(srv_www_tpl, rss)
|
||||
if cf.get("WWW_FILES", "rss") != www_rss:
|
||||
cf.set("WWW_FILES", "rss", www_rss)
|
||||
write = True
|
||||
|
||||
stats = cf.get("TEMPLATE_FILENAMES", "stats")
|
||||
if not stats:
|
||||
stats = "tyto_stats.ini"
|
||||
cf.set("TEMPLATE_FILENAMES", "stats", stats)
|
||||
write = True
|
||||
wip_stats = os.path.join(srv_wip_tpl, stats)
|
||||
if cf.get("WIP_FILES", "stats") != wip_stats:
|
||||
cf.set("WIP_FILES", "stats", wip_stats)
|
||||
write = True
|
||||
www_stats = os.path.join(srv_www_tpl, stats)
|
||||
if cf.get("WWW_FILES", "stats") != www_stats:
|
||||
cf.set("WWW_FILES", "stats", www_stats)
|
||||
write = True
|
||||
|
||||
# https URLs (www + wip)
|
||||
cf.get("WEBSITE", "www_url") or \
|
||||
cf.set("WEBSITE", "www_url", "https://%s/"%name)
|
||||
cf.get("WEBSITE", "wip_url") or \
|
||||
cf.set("WEBSITE", "wip_url", create_wip_url())
|
||||
# [USER_DIRS]
|
||||
# ===========
|
||||
if cf.get("USER_DIRS", "root") != cf_dir:
|
||||
cf.set("USER_DIRS", "root", cf_dir)
|
||||
write = True
|
||||
if cf.get("USER_DIRS", "articles") != cf_usr_articles:
|
||||
cf.set("USER_DIRS", "articles", cf_usr_articles)
|
||||
write = True
|
||||
if cf.get("USER_DIRS", "images") != cf_usr_images:
|
||||
cf.set("USER_DIRS", "images", cf_usr_images)
|
||||
write = True
|
||||
if cf.get("USER_DIRS", "files") != cf_usr_files:
|
||||
cf.set("USER_DIRS", "files", cf_usr_files)
|
||||
write = True
|
||||
if cf.get("USER_DIRS", "template") != cf_usr_tpl:
|
||||
cf.set("USER_DIRS", "template", cf_usr_tpl)
|
||||
write = True
|
||||
if cf.get("USER_DIRS", "modules") != cf_usr_mods:
|
||||
cf.set("USER_DIRS", "modules", cf_usr_mods)
|
||||
write = True
|
||||
if cf.get("USER_DIRS", "database") != cf_usr_db:
|
||||
cf.set("USER_DIRS", "database", cf_usr_db)
|
||||
write = True
|
||||
|
||||
usr_mods = os.path.join(cf_dir, "modules/")
|
||||
usr_tpl = os.path.join(cf_dir, "template/")
|
||||
usr_favicon = os.path.join(usr_tpl, favicon)
|
||||
usr_logo = os.path.join(usr_tpl, logo)
|
||||
usr_styles = os.path.join(usr_tpl, styles)
|
||||
# [TYTO]
|
||||
# ======
|
||||
if cf.get("TYTO", "domain_hash") != cf_id:
|
||||
cf.set("TYTO", "domain_hash", cf_id)
|
||||
write = True
|
||||
if cf.get("TYTO", "domain_conf") != cf_uri:
|
||||
cf.set("TYTO", "domain_conf", cf_uri)
|
||||
write = True
|
||||
if cf.get("TYTO", "domain_user") != ult_cf_uri:
|
||||
cf.set("TYTO", "domain_user", ult_cf_uri)
|
||||
write = True
|
||||
|
||||
wip_tpl = srv_wip + "template/"
|
||||
wip_favicon = os.path.join(wip_tpl, favicon)
|
||||
wip_logo = os.path.join(wip_tpl, logo)
|
||||
wip_styles = os.path.join(wip_tpl, styles)
|
||||
wip_rss = os.path.join(wip_tpl, rss)
|
||||
wip_stats = os.path.join(wip_tpl, stats)
|
||||
|
||||
www_tpl = srv_www + "template/"
|
||||
www_favicon = os.path.join(www_tpl, favicon)
|
||||
www_logo = os.path.join(www_tpl, logo)
|
||||
www_styles = os.path.join(www_tpl, styles)
|
||||
www_rss = os.path.join(www_tpl, rss)
|
||||
www_stats = os.path.join(www_tpl, stats)
|
||||
|
||||
|
||||
# Update Domain Configuration File
|
||||
#---------------------------------
|
||||
cf.set("DOMAIN", "name", name)
|
||||
cf.set("TYTO", "domain_hash", tools.get_filesum(cf_uri, False))
|
||||
cf.set("TYTO", "domain_conf", cf_uri)
|
||||
cf.set("TYTO", "domain_user", ult_cf_uri)
|
||||
|
||||
# USER
|
||||
cf.set("USER_DIRS", "root", cf_dir)
|
||||
cf.set("USER_DIRS", "articles", cf_dir + "articles/")
|
||||
cf.set("USER_DIRS", "images", cf_dir + "images/")
|
||||
cf.set("USER_DIRS", "files", cf_dir + "files/")
|
||||
cf.set("USER_DIRS", "modules", usr_mods)
|
||||
cf.set("USER_DIRS", "database", cf_dir + ".db/")
|
||||
cf.set("USER_DIRS", "template", usr_tpl)
|
||||
|
||||
cf.set("USER_MODULES_FILES", "metas", usr_mods + "tyto_metas.raw")
|
||||
cf.set("USER_MODULES_FILES", "header", usr_mods + "tyto_header.raw")
|
||||
cf.set("USER_MODULES_FILES", "navbar", usr_mods + "tyto_navbar.raw")
|
||||
cf.set("USER_MODULES_FILES", "sidebar", usr_mods + "tyto_sidebar.raw")
|
||||
cf.set("USER_MODULES_FILES", "footer", usr_mods + "tyto_footer.raw")
|
||||
|
||||
cf.set("USER_TEMPLATE_FILES", "favicon", usr_favicon)
|
||||
cf.set("USER_TEMPLATE_FILES", "logo", usr_logo)
|
||||
cf.set("USER_TEMPLATE_FILES", "styles", usr_styles)
|
||||
|
||||
# WEBSITE
|
||||
cf.get("WEBSITE_MODULES", "sidebar_title") or \
|
||||
cf.set("WEBSITE_MODULES", "sidebar_title", langs.site.sidebar_title)
|
||||
cf.get("WEBSITE_MODULES", "sidebar_items").isdigit() or \
|
||||
cf.set("WEBSITE_MODULES", "sidebar_items", "0")
|
||||
cf.get("WEBSITE_MODULES", "rss_items").isdigit() or \
|
||||
cf.set("WEBSITE_MODULES", "rss_items", "0")
|
||||
|
||||
cf.set("TEMPLATE_FILENAMES", "favicon", favicon)
|
||||
cf.set("TEMPLATE_FILENAMES", "logo", logo)
|
||||
cf.set("TEMPLATE_FILENAMES", "styles", styles)
|
||||
cf.set("TEMPLATE_FILENAMES", "rss", rss)
|
||||
cf.set("TEMPLATE_FILENAMES", "stats", stats)
|
||||
|
||||
# SERVER
|
||||
cf.set("SERVER", "root", srv)
|
||||
cf.set("SERVER", "domain", srv_dom)
|
||||
|
||||
# WIP
|
||||
cf.set("WIP_DIRS", "root", srv_wip)
|
||||
cf.set("WIP_DIRS", "images", srv_wip + "images/")
|
||||
cf.set("WIP_DIRS", "files", srv_wip + "files/")
|
||||
cf.set("WIP_DIRS", "template", wip_tpl)
|
||||
cf.set("WIP_FILES", "favicon", wip_favicon)
|
||||
cf.set("WIP_FILES", "logo", wip_logo)
|
||||
cf.set("WIP_FILES", "styles", wip_styles)
|
||||
cf.set("WIP_FILES", "rss", wip_rss)
|
||||
cf.set("WIP_FILES", "stats", wip_stats)
|
||||
cf.set("WIP_FILES", "metas", wip_tpl + "metas.html")
|
||||
cf.set("WIP_FILES", "header", wip_tpl + "header.html")
|
||||
cf.set("WIP_FILES", "navbar", wip_tpl + "navbar.html")
|
||||
cf.set("WIP_FILES", "sidebar", wip_tpl + "sidebar.html")
|
||||
cf.set("WIP_FILES", "footer", wip_tpl + "footer.html")
|
||||
|
||||
|
||||
# WWW
|
||||
cf.set("WWW_DIRS", "root", srv_www)
|
||||
cf.set("WWW_DIRS", "images", srv_www + "images/")
|
||||
cf.set("WWW_DIRS", "files", srv_www + "files/")
|
||||
cf.set("WWW_DIRS", "template", www_tpl)
|
||||
cf.set("WWW_FILES", "favicon", www_favicon)
|
||||
cf.set("WWW_FILES", "logo", www_logo)
|
||||
cf.set("WWW_FILES", "styles", www_styles)
|
||||
cf.set("WWW_FILES", "rss", www_rss)
|
||||
cf.set("WWW_FILES", "stats", www_stats)
|
||||
cf.set("WWW_FILES", "metas", www_tpl + "metas.html")
|
||||
cf.set("WWW_FILES", "header", www_tpl + "header.html")
|
||||
cf.set("WWW_FILES", "navbar", www_tpl + "navbar.html")
|
||||
cf.set("WWW_FILES", "sidebar", www_tpl + "sidebar.html")
|
||||
cf.set("WWW_FILES", "footer", www_tpl + "footer.html")
|
||||
|
||||
with open(cf_uri, "w") as f:
|
||||
cf.write(f)
|
||||
# Write Configuration file
|
||||
# Only if needed or when new domain
|
||||
print("domain: write", write)
|
||||
if write:
|
||||
with open(cf_uri, "w") as f:
|
||||
cf.write(f)
|
||||
|
||||
# Update User local domain configuration file
|
||||
#--------------------------------------------
|
||||
|
@ -377,26 +537,15 @@ def cf_update_values():
|
|||
def cf_valid():
|
||||
global active
|
||||
|
||||
# Check some values in ult_cf
|
||||
cf_load()
|
||||
ult_cf_load()
|
||||
|
||||
if not tools.compare_ini_ft(cf_uri, tyto.ini_domain):
|
||||
return
|
||||
|
||||
# - domain name must be cf_name
|
||||
try: cf_name = cf.get("DOMAIN", "name")
|
||||
except: debug.out(100, name, cf_uri, True, 2, True)
|
||||
if cf_name != name:
|
||||
cf_update_values()
|
||||
|
||||
try: ult_cf_hash = ult_cf.get("DOMAIN", "hash")
|
||||
except: cf_update_values()
|
||||
cf_update_values(False)
|
||||
|
||||
# Check if cf need to be updated
|
||||
ult_cf_load()
|
||||
ult_cf_hash = ult_cf.get("DOMAIN", "hash")
|
||||
now_cf_hash = tools.get_filesum(cf_uri, True)
|
||||
if now_cf_hash != ult_cf_hash:
|
||||
cf_update_values()
|
||||
cf_update_values(False)
|
||||
|
||||
active = is_active()
|
||||
active and create_work_dirs()
|
||||
|
@ -456,7 +605,13 @@ except:
|
|||
# cf: Domain Configuration File #
|
||||
#------------------------------------------#
|
||||
# Domain Configuration directory
|
||||
cf_dir = user_dir.rsplit("articles/")[0]
|
||||
cf_dir = user_dir.rsplit("articles/")[0]
|
||||
cf_usr_articles = os.path.join(cf_dir, "articles/")
|
||||
cf_usr_tpl = os.path.join(cf_dir, "template/")
|
||||
cf_usr_images = os.path.join(cf_dir, "images/")
|
||||
cf_usr_files = os.path.join(cf_dir, "files/")
|
||||
cf_usr_mods = os.path.join(cf_dir, "modules/")
|
||||
cf_usr_db = os.path.join(cf_dir, ".db/")
|
||||
|
||||
# Domain name from current basename directory
|
||||
# Exit if not format at least "abc.tld"
|
||||
|
|
|
@ -107,12 +107,6 @@ def ask_domain_title(update):
|
|||
try: title = domain.cf.get("DOMAIN", "title")
|
||||
except: title = ""
|
||||
|
||||
"""
|
||||
if update:
|
||||
domain.cf_load()
|
||||
title = domain.cf.get("DOMAIN", "title")
|
||||
"""
|
||||
|
||||
q = "> %s (%s)%s "%(langs.logs.domain_title, shorter(title), langs.logs.q)
|
||||
answer = ask(q, False, title)
|
||||
|
||||
|
@ -130,11 +124,7 @@ def ask_domain_title(update):
|
|||
def ask_domain_date(update):
|
||||
try: date = domain.cf.get("DOMAIN", "date")
|
||||
except: date = "YYYY[-MM-DD]"
|
||||
"""
|
||||
if update:
|
||||
domain.cf_load()
|
||||
date = domain.cf.get("DOMAIN", "date")
|
||||
"""
|
||||
|
||||
example = date or "YYYY[-MM-DD]"
|
||||
|
||||
q = "> %s (%s)%s "%(langs.logs.domain_date, example, langs.logs.q)
|
||||
|
@ -170,12 +160,6 @@ def ask_domain_date(update):
|
|||
def ask_domain_about(update):
|
||||
try: about = domain.cf.get("DOMAIN", "about")
|
||||
except: about = ""
|
||||
|
||||
"""
|
||||
if update:
|
||||
domain.cf_load()
|
||||
about = domain.cf.get("DOMAIN", "about")
|
||||
"""
|
||||
|
||||
q = "> %s (%s)%s "%(langs.logs.domain_about, shorter(about), langs.logs.q)
|
||||
answer = ask(q, False, about)
|
||||
|
@ -193,11 +177,6 @@ def ask_domain_about(update):
|
|||
def ask_domain_mail(update):
|
||||
try: mail = domain.cf.get("DOMAIN", "mail")
|
||||
except: mail = ""
|
||||
"""
|
||||
if update:
|
||||
domain.cf_load()
|
||||
mail = domain.cf.get("DOMAIN", "mail")
|
||||
"""
|
||||
|
||||
q = "> %s (%s)%s "%(langs.logs.domain_mail, shorter(mail), langs.logs.q)
|
||||
answer = ask(q, False, mail)
|
||||
|
@ -215,11 +194,6 @@ def ask_domain_mail(update):
|
|||
def ask_domain_tags(update):
|
||||
try: tags = domain.cf.get("DOMAIN", "tags")
|
||||
except: tags = ""
|
||||
"""
|
||||
if update:
|
||||
domain.cf_load()
|
||||
tags = domain.cf.get("DOMAIN", "tags")
|
||||
"""
|
||||
|
||||
q = "> %s (%s)%s "%(langs.logs.domain_tags, shorter(tags), langs.logs.q)
|
||||
answer = ask(q, False, tags)
|
||||
|
@ -241,15 +215,9 @@ def ask_domain_tags(update):
|
|||
# default en if no translation file # > !!!!!!!!!!!!!!!!!!!!!!!!!!!!!! < TODO
|
||||
#-----------------------------------#
|
||||
def ask_domain_lang(update):
|
||||
try:
|
||||
lang = domain.cf.get("WEBSITE", "lang") or langs.get_sys_lang()
|
||||
except:
|
||||
lang = ""
|
||||
"""
|
||||
if update:
|
||||
domain.cf_load()
|
||||
lang = domain.cf.get("WEBSITE", "lang")
|
||||
"""
|
||||
try: lang = domain.cf.get("WEBSITE", "lang") or langs.get_sys_lang()
|
||||
except: lang = ""
|
||||
|
||||
|
||||
q = "> %s (%s)%s "%(langs.logs.domain_lang, lang, langs.logs.q)
|
||||
answer = ask(q, False, lang).lower()
|
||||
|
@ -278,12 +246,8 @@ def ask_domain_server(update):
|
|||
srv = domain.cf.get("SERVER", "root")
|
||||
if not tools.dir_exists(srv, False):
|
||||
srv = ""
|
||||
except: srv = ""
|
||||
"""
|
||||
if update:
|
||||
domain.cf_load()
|
||||
srv = domain.cf.get("SERVER", "root")
|
||||
"""
|
||||
except:
|
||||
srv = ""
|
||||
|
||||
if srv and not tools.dir_exists(srv, False):
|
||||
srv = ""
|
||||
|
|
|
@ -45,17 +45,17 @@ import domain, debug, tools, tyto
|
|||
def is_article(target):
|
||||
# User MUST be in articles/
|
||||
domain.cf_load()
|
||||
(os.getcwd() + "/").startswith(domain.articles_dir) or \
|
||||
debug.out(2, "-> articles/", domain.articles_dir, True, 2, True)
|
||||
(os.getcwd() + "/").startswith(domain.cf_usr_articles) or \
|
||||
debug.out(2, "-> articles/", domain.cf_usr_articles, True, 2, True)
|
||||
|
||||
# Target URI is from legacy directory
|
||||
if target.startswith("./") or target.startswith("../"):
|
||||
# Target URI most be from legacy directory or not begins with
|
||||
if target.startswith(tyto.notarget):
|
||||
debug.out(20, "./, ../", target, True, 2, True)
|
||||
|
||||
# Article exists
|
||||
global uri
|
||||
|
||||
uri = os.path.join(domain.articles_dir, target)
|
||||
uri = os.path.join(domain.cf_usr_articles, target)
|
||||
os.path.exists(uri) or debug.out(5, "False", uri, True, 2, True)
|
||||
|
||||
# Article is a Tyto format and not empty (exit on errors)
|
||||
|
@ -68,7 +68,7 @@ def is_article(target):
|
|||
uri_id = tools.get_filesum(uri, False)
|
||||
|
||||
# Set post configuration file database
|
||||
cf_uri = os.path.join(domain.db_dir, uri_id + ".ini")
|
||||
cf_uri = os.path.join(domain.cf_usr_db, uri_id + ".ini")
|
||||
|
||||
# Load Database
|
||||
db = cf_load() # True or False
|
||||
|
|
|
@ -61,7 +61,7 @@ git_url = "https://git.a-lec.org/echolib/tyto-litterateur"
|
|||
#---------------------------#
|
||||
ini_domain = """[DOMAIN]
|
||||
activated = no
|
||||
name =
|
||||
name = %s
|
||||
title =
|
||||
date =
|
||||
about =
|
||||
|
@ -94,7 +94,7 @@ favicon = favicon.png
|
|||
logo = logo.png
|
||||
styles = styles.css
|
||||
rss = rss.xml
|
||||
stats = stats.ini
|
||||
stats = tyto_stats.ini
|
||||
|
||||
[USER_DIRS]
|
||||
root =
|
||||
|
@ -120,9 +120,10 @@ footer =
|
|||
[SERVER]
|
||||
root = /var/www/
|
||||
domain =
|
||||
wip =
|
||||
www =
|
||||
|
||||
[WIP_DIRS]
|
||||
root =
|
||||
images =
|
||||
files =
|
||||
template =
|
||||
|
@ -140,7 +141,6 @@ sidebar =
|
|||
footer =
|
||||
|
||||
[WWW_DIRS]
|
||||
root =
|
||||
images =
|
||||
files =
|
||||
template =
|
||||
|
@ -231,6 +231,9 @@ web =
|
|||
lines =
|
||||
"""
|
||||
|
||||
# Put here values where posts target cannot begin with
|
||||
notarget = ("./", "../")
|
||||
|
||||
#===================#
|
||||
# Artcicle contents #==========================================================
|
||||
#===================#
|
||||
|
|
Loading…
Reference in New Issue