From 461c15c46e04b59e73ef7fe11f99e422ab663957 Mon Sep 17 00:00:00 2001 From: Cyrille LOUARN Date: Tue, 7 Nov 2023 02:06:54 +0100 Subject: [PATCH] [1.9.33] - Working on modules (header Ok, testing navbar) --- CHANGELOG.md | 6 + README.md | 1 + debian/control | 2 +- src/usr/bin/tyto | 2 +- .../program/__pycache__/post.cpython-311.pyc | Bin 11511 -> 12957 bytes .../program/__pycache__/tools.cpython-311.pyc | Bin 7429 -> 7429 bytes .../program/__pycache__/wip.cpython-311.pyc | Bin 25286 -> 28936 bytes src/var/lib/tyto/program/post.py | 42 ++++ src/var/lib/tyto/program/tools.py | 2 +- src/var/lib/tyto/program/wip.py | 228 ++++++++++++++---- .../__pycache__/logs_fr.cpython-311.pyc | Bin 4650 -> 4550 bytes src/var/lib/tyto/translations/logs_en.py | 5 +- src/var/lib/tyto/translations/logs_fr.py | 5 +- 13 files changed, 237 insertions(+), 56 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1945be0..5bab16f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,12 @@ Tyto - Littérateur # CURRENTLY IN DEV (in devel branch) ! +## [1.9.33] +- Working on creating modules (header, navbar, sidebar, header) +- - Added working header module +- - Finishing navbar module... +- - Todo Next: sidebar and footer modules + ## [1.9.32] - Working on creating modules (header, navbar, sidebar, header) diff --git a/README.md b/README.md index b8323d5..3e75292 100644 --- a/README.md +++ b/README.md @@ -15,6 +15,7 @@ tyto ## Working on - 'wip' action processes - Create HTML full page from article +- Create/Manage modules (header, navbar, sidebar, footer) ## ToDo - thinking about creating an auto top article menu from titles diff --git a/debian/control b/debian/control index 0b08938..1104f3e 100644 --- a/debian/control +++ b/debian/control @@ -1,5 +1,5 @@ Package: tyto -Version: 1.9.32 +Version: 1.9.33 Section: custom Priority: optional Architecture: all diff --git a/src/usr/bin/tyto b/src/usr/bin/tyto index 54aaa26..1c0911b 100755 --- a/src/usr/bin/tyto +++ b/src/usr/bin/tyto @@ -1,5 +1,5 @@ #!/usr/bin/env python3 -# Version: 1.9.32 +# Version: 1.9.33 # 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 e417c3e1138ce9735270df12c94913bb170d1925..ea6f09abe173e23f6c3738cdb4617411bdc6dbf9 100644 GIT binary patch delta 2133 zcmbVNUrbw77{C9a<(9Gw{R4#oYq1nI*r3}GqwX5xfsm5uA zM(n^H2JQr2ZQwP)T?SqYyw1S)0`>H>}$$t_W}4jcv%6_Xl7)CS-N z5p{=%S`Q+JcI4Q$jUDT^O5D<)5<(rMG1N)+h5V}DSgG+OR6E2BMQ)2ZAZ9!@gRMFt zW+>h;?=YiQL(q6!#)UNzF?5)?Lq~{*G?5pGmoyXiEm6DAwVFCZ#|S&j`21h+CaZ(n zI!GK$(0S;;|Hf%Q)zxS(@(%54Sy}C@fKhA-_AV^=?AfA=oE8@B#fjSM^=2i(?3ltA zrVz6|l;G~Nup0Vii@D;~qRlX~rA3>t2`0f2j_^ddE5Qorn=Nc2!Z1U`usQB1`e3E3 zeJt54z*+U&dB>vVgtiKn+2*urxxKcaL`t?7N&l{rQeyh2N=&XByoM zRI>YSWnxM2yYDv0;C|ocgUkZEn^w|H%6Dk(`4=tgf6*cwT#$+r6c2uc;^!Zrt$@1N zHyG%9RhLvsqcrw7iLZn%jL`F{UNRVXxj%4fSQq1w_`LeK6GBg=g59l);fd(^_*1Dc zbo&&FUy9lg>piA-7XU8X}XaGF}2uJZ5&`Z#No^L$3`23HjDaGH;dUFKQ7_7t;-vX#n9w(X-hmzq z!VOL_Pb8)?X}j*dvH#ls+i%^vm{D_zKd<;x-4B(jqB~#Tu{xMjdh<$e>ZLWayyX3$ z?Y*{iP0sAen?36cFI28cWtSt%>~dE+l&Q*`TW!ioU3sZ%oo7nqM;2vqbX{UB*3^-Q zvNJC?BqhrP*aix;ZDg^OD<;o?9MBAI}Jx z@Tx5*9nDKejp;?9@}c6q(Q>UN9n6&El!JNYU@DS|Y^-z7>f@FN)AO1B)yCD)oYa$- zdI|}Wg#s5xH#Robh5w)Cd6q}!@hMlQVO49tfR7C|uJiO>-V_pGAHe;S~fQ0$v#E zDZ-QN&(3zP8mrU!7~D;9fkxu0PoU#CC<&!RfX=k$`*AmMnwO?uvi0^`@HCtWR z&a;c!P=l9!M?2Tx7q5f6EBk4K$Xe)0um^k`Jq2U->&72gHm%)sr>i~$enFgwM(4UO zi1Xny)7|u=?11M1$M$KpUSIDb#0x(rivM4<83F%r={^L!-xQCKx)BQd!15?oM6YKr sdOfU6Pat^>LCt>Ne26vw2sS?Hu}bY%->WRhgb6v>f1 z(Vt-Z0-5HYm9rSFhK!1@sePxA%FBa8{C(^#4%AKR@x8c-S0Ko9|7AR{%msL1X>nmW z2-h9AUJJs+@o1pAp5rw(t_K=rtjXL!wJu#{F}MYlWf>8+!qwzs^vZvhbd@nn2pVbL z+Nf_a8wgty&?jJ(7t;mprYLW4C!Inc{d;LsNnD0bpt{rx@LksMs1at%V(1G0kTJAf zD1V0hUztOMc6eJaU=KRTKhjMV?eiZ~dF1ke+zf6*JL)gyFgnxHyoR?;t2IMuY0i3c z&#U@Y{u@FMxoJEax(|~ryxweXRao(TW0L~10z^J0BC)m~D`e4NfV<`a?i#ae{>5S$^?!m11dprowt3{&N|y2$*wU_h diff --git a/src/var/lib/tyto/program/__pycache__/tools.cpython-311.pyc b/src/var/lib/tyto/program/__pycache__/tools.cpython-311.pyc index 61c55d85dac765b10720815ef8b05ae1f7839b74..134902071a8c7d9b5d4fc0fcb22489efa5d38875 100644 GIT binary patch delta 96 zcmZp*YPI5C&dbZi00h~Yo*TJ+xtNMfCr5DwF*xtLzEPLARVVszfTmP?(PF<|pm-gsuAB1fQ#A~PTn rQX~apx=wZzjN$MEGBw$XyeF>`lxOtYd`fUGCz~@!I$(3I^bAG-L~Iu5 diff --git a/src/var/lib/tyto/program/__pycache__/wip.c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~w~J1w zi$};)z!-Lg^@QFZUs+qH)qViuaKnyUSPH5S4-3(7Eja_cHdgUp;v0qqNMRq~9mkX{ zwP?T;lTfr+!HGdZ`Zd1v}Fk~mwm8UV(t)!^15A9$KD9GEbirjRv!vJe$D8!Tf zkcc((cuZIM$GX$~2WLWf1mphO0HfTL%R9Q{eTVxy+YC>2M#wrMh9i>WW{MH2^n_E0fBM|su5mEW&C zS#`Q9b0|YH#3-NpTKU3P%NJ(L7aQe^$JR`h&&nLmmd_j8Fy;0`-_p>7u?J$u<{zIw z7QEo~9k)N|e!xAx&8S*%epc4I%RbEWn5FSrDq$@Ha_co);U?T`e@@+&EA=l?wMn2j&3-%A=e0>pYvQb_y4!&Y8x+J zym+m_Oko309s92zIl5z9H)bq6AIr{InH8E0p=nZRdRr+Pi)eT=A7A5JyGnR*#ZthR zR*CBb`)_0(Fj_?_aFbagK_9R@5*^R-L*|xnoN{Ct0!uC!G6Z9kco4AK9kK5JcpqdJ za(1^SE!bR*kV3c-0ka3Y;Sju5uqvOGMJ&HCXCrnLV6D!)@RDPNRZ=w(1x|DL=d>pQ za{|xvxlKIB7mpUvSn?;u4SaEqn}$C6Uh=8NdgM(*FJFr7X;?I^eYqb}Z1(>GY`DA~ diff --git a/src/var/lib/tyto/program/post.py b/src/var/lib/tyto/program/post.py index 678bd99..70ab4f9 100644 --- a/src/var/lib/tyto/program/post.py +++ b/src/var/lib/tyto/program/post.py @@ -154,6 +154,48 @@ def cf_load(): return True +#======================================# +# Load another post configuration file # +#--------------------------------------# +def tmp_load(wrk_post, db_id): + global error + + db_tmp_uri = os.path.join(domain.wrk_db, db_id) + post_tmp_uri = os.path.join(domain.wrk_articles, wrk_post) + + if not os.path.exists(db_tmp_uri): + error = \ + debug.out(5, wrk_post, db_tmp_uri, True, 2, False) + return False + + global tmp_cf + tmp_cf = "" + tmp_cf = configparser.ConfigParser() + tmp_cf.read(tmp_uri) + + if tmp_cf.get("CHECK", "errors"): + error = \ + debug.out(10, "True", db_tmp_uri, True, 2, False) + return False + + global tmp_title, tmp_about + try: + tmp_title = tmp_cf.get("HEADERS", "title") + except: + error = \ + debug.out(51, "title:", post_tmp_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) + return False + + return True + + #================================# # Return value from section, key # #--------------------------------# diff --git a/src/var/lib/tyto/program/tools.py b/src/var/lib/tyto/program/tools.py index ed7f251..a2ab867 100644 --- a/src/var/lib/tyto/program/tools.py +++ b/src/var/lib/tyto/program/tools.py @@ -115,7 +115,7 @@ def create_dirs(path): debug.out(203, "True", path, False, 0, False) except: # Exit if not created - debug.out(5, "False", path, True, 2, True) + debug.out(6, "False", path, True, 2, True) #============================# diff --git a/src/var/lib/tyto/program/wip.py b/src/var/lib/tyto/program/wip.py index 3425b59..52a5b39 100644 --- a/src/var/lib/tyto/program/wip.py +++ b/src/var/lib/tyto/program/wip.py @@ -100,6 +100,11 @@ def convert(target): if not post.is_article(target): return False + # Check/create wip server directories + # Exit on error ! + for key, directory in domain.cf.items("WIP_DIRS"): + tools.create_dirs(directory) + # Check/Create modules files # navbar, sidebar, header, footer if not get_modules("wip"): @@ -595,14 +600,16 @@ def convert_list(markdown_str, mark_b, mark_c): # - footer # #--------------------------------------------# 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%( @@ -625,56 +632,125 @@ def get_modules(srv): ), "footer" : tyto.module_footer, } + """ + modules = \ + { + "header" : { + "raw" : tyto.module_header%( + "/template/%s"%domain.logo, domain.about, + "/template/%s"%domain.logo, domain.about, domain.about, + domain.title, + domain.about + ), + "wrk" : domain.wrk_header, + "wip" : domain.wip_header, + "www" : domain.www_header, + "set" : header_html_create + }, + "navbar" : { + "raw" : langs.logs.navbar_header%( + domain.title, domain.wrk_articles, + domain.wrk_navbar, + domain.wip_navbar, + domain.www_navbar + ), + "wrk" : domain.wrk_navbar, + "wip" : domain.wip_navbar, + "www" : domain.www_navbar, + "set" : navbar_check + }, + "sidebar" : { + "raw" : langs.logs.sidebar_header%( + domain.title, domain.wrk_articles, + domain.wrk_sidebar, + domain.wip_sidebar, + domain.www_sidebar + ), + "wrk" : domain.wrk_sidebar, + "wip" : domain.wip_sidebar, + "www" : domain.www_sidebar, + "set" : sidebar_check, + }, + "footer" : { + "raw" : tyto.module_footer, + "wrk" : domain.wrk_footer, + "wip" : domain.wip_footer, + "www" : domain.www_footer, + "set" : footer_html_create + }, + } - create_html_mods = { - "header" : navbar_check, - } - - # Create user raw files modules in modules/ directory - for module in raws_uris: - if not os.path.exists(raws_uris[module]): - tools.create_file(raws_uris[module], raws_sets[module]) + # Manage modules + # Create raw files, and set html "srv" file + for mod in modules: + # 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 module from raw files - for module in create_html_mods: - if not create_html_mods[module](srv): + # Create HTML file in srv (wip or www) + if not modules[mod]["set"](srv): return False return True -# -# Navbar Creation # -# +#================================================# +# Create header.html in server (wip/ or www/) # +# Remove empty lines and those starting with "#" # +# Copy other lines # +# modules/tyto_header.raw has default contents # +#------------------------------------------------# +def header_html_create(srv): + with open(domain.wrk_header, "r") as f: + header_raw = f.read().rsplit("\n") + header_html = "" + + for line in header_raw: + if not line or \ + line.isspace() or \ + line.lstrip().startswith("#"): + continue + + if not header_html: header_html = line + else: header_html = "%s\n%s"%(header_html, line) + + tools.create_file(modules["header"][srv], header_html) + return True + + +#========================================================# +# Create navbar.html in server (wip/ or www/) # +# If navbar is deactivated, create one HTML comment line # +# else, create HTML li lists from tyto_navbar.raw datas # +#--------------------------------------------------------# def navbar_check(srv): # navbar is NOT activated in domain configuration file - navbar_contents = "" - if srv == "wip": srv_file = domain.wip_navbar - elif srv == "www": srv_file = domain.www_navbar - + navbar_html = "" if not domain.navbar: - tools.create_file(srv_file, navbar_contents) + tools.create_file(modules["navbar"][srv], navbar_html) return True # Create navbar HTML file in srv, from raw - if not navbar_html_create(srv_file): + if not navbar_html_create(srv): return False return True - -# -# Create navbar HTML file in wip, from raw -# -def navbar_html_create(srv_file): +#=================================================# +# Create HTML li lists from tyto_navbar.raw datas # +#-------------------------------------------------# +def navbar_html_create(srv): items = False + html_indexes = { + "wip" : domain.wip, + "www" : domain.www + } + with open(domain.wrk_navbar, "r") as f: navbar_raw = f.read().rsplit("\n") navbar_html = "" - title = title_html = "" - - + for ln, line in enumerate(navbar_raw, 1): if line.lstrip().startswith("#") or \ not line or \ @@ -682,35 +758,97 @@ def navbar_html_create(srv_file): continue html_line = '' + title_html = "" - # Get folder title (if set) - if line.lstrip().startswith(">"): - title = line.lstrip()[1:].lstrip() - title_html = ' title="%s"'%title - continue + # Get directory name + folder = line.lstrip() + folder_uri = os.path.join(domain.wrk_articles, folder) - # Get directory name and check if exists - folder = line.lstrip() - if not os.path.join(domain.wrk_articles, folder): + # Unused directory in articles/ + if not os.path.exists(folder_uri): post.error = \ debug.out(6, 'Navbar. %s) "%s"'%( ln, folder ), domain.wrk_navbar, True, 2, False) return False + + # Directory exists + # Unused index.tyto in wrk folder + wrk_index = os.path.join(folder, "index.tyto") + wrk_index_uri = os.path.join(folder_uri, "index.tyto") + if not os.path.exists(wrk_index_uri): + post.error = \ + debug.out(5, 'Navbar. %s) "%s"'%( + ln, wrk_index + ), domain.wrk_navbar, True, 2, False) + return False + + # Unused index.html in srv + html_index_srv_uri = os.path.join(html_indexes[srv], folder) + html_index_srv_uri = os.path.join(html_index_srv_uri, "index.html") + if not os.path.exists(html_index_srv_uri): + post.error = \ + debug.out(5, 'Navbar. %s) "%s"'%( + ln, html_index_srv_uri.rsplit(domain.srv_name)[1] + ), domain.wrk_navbar, True, 2, False) + return False + + # Load post configuration file in tmp module + # return if unused or post errors + db_id = tools.get_filesum(wrk_index_uri, False) + ".ini" + if not post.tmp_load(wrk_index, db_id): + return False + + items = True + title_html = ' title="%s - %s"'%(post.tmp_title, post.tmp_about) + + # Format HTML href uri + if not folder.startswith("/"): + folder = "/%s"%folder + if not navbar_html: + navbar_html = html_line%(title_html, folder, folder) else: - items = True - if not folder.startswith("/"): - folder = "/%s"%folder - html_line = html_line%(title_html, folder, folder) - if not navbar_html: navbar_html = html_line - else: navbar_html = "%s\n%s"%(navbar_html, html_line) - title = title_html = "" + navbar_html = "%s\n%s"%( + navbar_html, + html_line%(title_html, folder, folder) + ) if not items: post.error = \ debug.out(9, 'Navbar', domain.wrk_navbar, True, 2, False) return False - tools.create_file(srv_file, tyto.module_navbar%navbar_html) + tools.create_file(modules["navbar"][srv], tyto.module_navbar%navbar_html) return True + + +# +# +# +def sidebar_check(srv): + return True + + +#================================================# +# Create footer.html in server (wip/ or www/) # +# Remove empty lines and those starting with "#" # +# Copy other lines # +# modules/tyto_footer.raw has default contents # +#------------------------------------------------# +def footer_html_create(srv): + with open(domain.wrk_footer, "r") as f: + footer_raw = f.read().rsplit("\n") + footer_html = "" + + for line in footer_raw: + if not line or \ + line.isspace() or \ + line.lstrip().startswith("#"): + continue + + if not footer_html: footer_html = line + else: footer_html = "%s\n%s"%(footer_html, line) + + tools.create_file(modules["footer"][srv], footer_html) + return True diff --git a/src/var/lib/tyto/translations/__pycache__/logs_fr.cpython-311.pyc b/src/var/lib/tyto/translations/__pycache__/logs_fr.cpython-311.pyc index 8c28e398ed030cc6b8f08a7c32a3d450b585420a..ebe583aa6c6a6d3fc6fe9df4b1f4147e89d4acbf 100644 GIT binary patch delta 132 zcmZ3ba!i?bIWI340}$No^h_1o$a{-}J%fpXL77W=@<$G@%@&-cjE;&5F8P@y3d#9- zC8>FtMGB>P3W-G}naMe+3QC!IDXA5DC6y)lN(u!u)`67xzFauOACGSl-?6_o50 zLOer)T#=M0aRCi-tw_x+$Vn{*846SaGOrkDUa>+-YEfS1;T1(dW?p`&T3KoiP!y;r zFSQ&**(n@uP$($MFUSWeRY*=%D9$WN-TaR0Fq^1^AWH-92NMw?mIgi$EV2gr4FDm_ BNA&;z diff --git a/src/var/lib/tyto/translations/logs_en.py b/src/var/lib/tyto/translations/logs_en.py index 9669c82..fe0a87e 100644 --- a/src/var/lib/tyto/translations/logs_en.py +++ b/src/var/lib/tyto/translations/logs_en.py @@ -145,13 +145,10 @@ navbar_header = """# # How to configure this file: # - Add one directory URI per line # - - URI is from domain directory articles/ -# - - Option: -# - - - Add title folder before the directory line "> Directory title" +# ! Must contains an article "index.tyto" ready # Examples: -# > All last news # news ! -# > About this website # about/website #------------------------------------------------------------------------------ """ diff --git a/src/var/lib/tyto/translations/logs_fr.py b/src/var/lib/tyto/translations/logs_fr.py index 3ac88ee..0e2e99c 100644 --- a/src/var/lib/tyto/translations/logs_fr.py +++ b/src/var/lib/tyto/translations/logs_fr.py @@ -145,13 +145,10 @@ navbar_header = """# # Comment configurer ce fichier : # - Ajouter un URI de dossier par ligne # - - URI depuis le dossier articles/ du domaine -# - - Option : -# - - - Ajouter le titre du dossier avant la ligne "> TITRE du dossier" +# ! Doit contenir un article "index.tyto" prêt # Exemples: -# > Toutes les dernières nouvelles # news -# > À propos de ce site # a-propos/website #------------------------------------------------------------------------------ """