diff --git a/CHANGELOG.md b/CHANGELOG.md index 5bab16f..4f6b1e4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,13 @@ Tyto - Littérateur # CURRENTLY IN DEV (in devel branch) ! +## [1.9.34] +- Working on creating modules +- - fixes typos codes +- - header, navbar, sidebar = ok +- - toto footer contents and testing things +- - Manage modules with an ini db file to avoid creating HTML updated modules + ## [1.9.33] - Working on creating modules (header, navbar, sidebar, header) - - Added working header module diff --git a/src/usr/bin/tyto b/src/usr/bin/tyto index 1c0911b..2d28505 100755 --- a/src/usr/bin/tyto +++ b/src/usr/bin/tyto @@ -1,5 +1,5 @@ #!/usr/bin/env python3 -# Version: 1.9.33 +# Version: 1.9.34 # Updated: 2023-10-18 1697613100 # Tyto - Littérateur diff --git a/src/var/lib/tyto/program/__pycache__/post.cpython-311.pyc b/src/var/lib/tyto/program/__pycache__/post.cpython-311.pyc index ea6f09a..60ace83 100644 Binary files a/src/var/lib/tyto/program/__pycache__/post.cpython-311.pyc and b/src/var/lib/tyto/program/__pycache__/post.cpython-311.pyc differ diff --git a/src/var/lib/tyto/program/__pycache__/tyto.cpython-311.pyc b/src/var/lib/tyto/program/__pycache__/tyto.cpython-311.pyc index c5e5e2a..67d1412 100644 Binary files a/src/var/lib/tyto/program/__pycache__/tyto.cpython-311.pyc and b/src/var/lib/tyto/program/__pycache__/tyto.cpython-311.pyc differ diff --git a/src/var/lib/tyto/program/__pycache__/wip.cpython-311.pyc b/src/var/lib/tyto/program/__pycache__/wip.cpython-311.pyc index 2863a3a..20bf17d 100644 Binary files a/src/var/lib/tyto/program/__pycache__/wip.cpython-311.pyc and b/src/var/lib/tyto/program/__pycache__/wip.cpython-311.pyc differ diff --git a/src/var/lib/tyto/program/post.py b/src/var/lib/tyto/program/post.py index 70ab4f9..88ad2b1 100644 --- a/src/var/lib/tyto/program/post.py +++ b/src/var/lib/tyto/program/post.py @@ -157,40 +157,49 @@ def cf_load(): #======================================# # Load another post configuration file # #--------------------------------------# -def tmp_load(wrk_post, db_id): +def tmp_load(wrk_post, wrk_post_uri): global error - db_tmp_uri = os.path.join(domain.wrk_db, db_id) - post_tmp_uri = os.path.join(domain.wrk_articles, wrk_post) + db_uri = os.path.join( + domain.wrk_db, + tools.get_filesum(wrk_post_uri, False) + ".ini" + ) - if not os.path.exists(db_tmp_uri): + if not os.path.exists(db_uri): error = \ - debug.out(5, wrk_post, db_tmp_uri, True, 2, False) + debug.out(5, wrk_post, db_uri, True, 2, False) return False global tmp_cf tmp_cf = "" tmp_cf = configparser.ConfigParser() - tmp_cf.read(tmp_uri) + tmp_cf.read(db_uri) - if tmp_cf.get("CHECK", "errors"): + if tmp_cf.getboolean("CHECK", "errors"): error = \ - debug.out(10, "True", db_tmp_uri, True, 2, False) + debug.out(10, "True", db_uri, True, 2, False) return False - global tmp_title, tmp_about + global tmp_title, tmp_about, tmp_logo try: tmp_title = tmp_cf.get("HEADERS", "title") except: error = \ - debug.out(51, "title:", post_tmp_uri, True, 2, False) + debug.out(51, "title:", wrk_post_uri, True, 2, False) return False try: tmp_about = tmp_cf.get("HEADERS", "about") except: error = \ - debug.out(51, "about:", post_tmp_uri, True, 2, False) + debug.out(51, "about:", wrk_post_uri, True, 2, False) + return False + + try: + tmp_logo = tmp_cf.get("HEADERS", "logo") + except: + error = \ + debug.out(51, "logo:", wrk_post_uri, True, 2, False) return False return True diff --git a/src/var/lib/tyto/program/tyto.py b/src/var/lib/tyto/program/tyto.py index 9802265..0046ee5 100644 --- a/src/var/lib/tyto/program/tyto.py +++ b/src/var/lib/tyto/program/tyto.py @@ -161,14 +161,19 @@ module_header = """ """ -module_navbar = """ +module_navbar = """ """ -module_aside = """ +module_sidebar = """ + """ module_footer = """ diff --git a/src/var/lib/tyto/program/wip.py b/src/var/lib/tyto/program/wip.py index 52a5b39..8caefd8 100644 --- a/src/var/lib/tyto/program/wip.py +++ b/src/var/lib/tyto/program/wip.py @@ -35,7 +35,7 @@ # file program : #-------------------------- -import sys, os +import sys, os, configparser import args, debug, tyto, tools, post, domain, check, langs @@ -105,6 +105,11 @@ def convert(target): for key, directory in domain.cf.items("WIP_DIRS"): tools.create_dirs(directory) + # Warn if unused registred file in wrk template/ directory + 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 # navbar, sidebar, header, footer if not get_modules("wip"): @@ -591,6 +596,27 @@ def convert_list(markdown_str, mark_b, mark_c): #=========# # Modules #==================================================================== #---------# +#==================================# +# Create modules ini database file # +# return False if: # +# - datas changed # +# - not created # +#----------------------------------# +def modules_db(): + global db_mods_uri, mods_cf + + db_mods_uri = os.path.join(domain.wrk_mods, ".modules.ini") + + if not os.path.exists(db_mods_uri): + tools.create_file(db_mods_uri, ini_mods) + + mods_cf = configparser.ConfigParser() + mods_cf.read(db_mods_uri) + + + + + #============================================# # Check / Create modules files (.raw + .html # # process: "wip" or "www" # @@ -599,40 +625,10 @@ def convert_list(markdown_str, mark_b, mark_c): # - header # # - footer # #--------------------------------------------# -def get_modules(srv): +def get_modules(srv): global modules # Modules settings - """ - raws_uris = { - "header" : domain.wrk_header, - "navbar" : domain.wrk_navbar, - "sidebar" : domain.wrk_sidebar, - "footer" : domain.wrk_footer - } - raws_sets = \ - { - "header" : tyto.module_header%( - "/template/%s"%domain.logo, domain.about, - "/template/%s"%domain.logo, domain.about, domain.about, - domain.title, - domain.about - ), - "navbar" : langs.logs.navbar_header%( - domain.title, domain.wrk_articles, - domain.wrk_navbar, - domain.wip_navbar, - domain.www_navbar - ), - "sidebar" : langs.logs.sidebar_header%( - domain.title, domain.wrk_articles, - domain.wrk_sidebar, - domain.wip_sidebar, - domain.www_sidebar - ), - "footer" : tyto.module_footer, - } - """ modules = \ { "header" : { @@ -680,16 +676,43 @@ def get_modules(srv): }, } + # Avois creating again module if files are same + modules_db() + mods_cf_write = False + # Manage modules # Create raw files, and set html "srv" file for mod in modules: + create_html_module = False + # Create user raw files modules in modules/ directory - os.path.exists( modules[mod]["wrk"]) or \ - tools.create_file(modules[mod]["wrk"], modules[mod]["raw"]) - - # Create HTML file in srv (wip or www) - if not modules[mod]["set"](srv): - return False + if os.path.exists(modules[mod]["wrk"]): + cur_raw_id = tools.get_filesum(modules[mod]["wrk"], True) + mod_raw_id = mods_cf.get(mod.upper(), "raw") + if cur_raw_id != mod_raw_id: + mods_cf.set(mod.upper(), "raw", cur_raw_id) + mods_cf_write = True + create_html_module = True + + else: + tools.create_file(modules[mod]["wrk"], modules[mod]["raw"]) + mods_cf.set(mod.upper(), "raw", cur_raw_id) + mods_cf_write = True + create_html_module = True + + # Unused module HTML file + if not os.path.exists(modules[mod][srv]): + create_html_module = True + + # Create HTML module if needed (raw updated, or unused html file) + if create_html_module: + print(">> HTML", mod) + if not modules[mod]["set"](srv): + return False + + if mods_cf_write: + with open(db_mods_uri, "w") as f: + mods_cf.write(f) return True @@ -700,7 +723,7 @@ def get_modules(srv): # Copy other lines # # modules/tyto_header.raw has default contents # #------------------------------------------------# -def header_html_create(srv): +def header_html_create(srv): with open(domain.wrk_header, "r") as f: header_raw = f.read().rsplit("\n") header_html = "" @@ -737,11 +760,11 @@ def navbar_check(srv): return True #=================================================# +# navbar is True in domain configuration file # # Create HTML li lists from tyto_navbar.raw datas # #-------------------------------------------------# def navbar_html_create(srv): - items = False - + items = False html_indexes = { "wip" : domain.wip, "www" : domain.www @@ -749,19 +772,23 @@ def navbar_html_create(srv): with open(domain.wrk_navbar, "r") as f: navbar_raw = f.read().rsplit("\n") - navbar_html = "" + navbar_html = "" + html_line = '