diff --git a/CHANGELOG.md b/CHANGELOG.md index d07dd24..f55a244 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,14 @@ Tyto - Littérateur - Changelog: https://git.a-lec.org/echolib/tyto-litterateur/-/blob/master/CHANGELOG.md - License: https://git.a-lec.org/echolib/tyto-litterateur/-/blob/master/LICENSE +## [0.10.0] +- Add full static page option (--static) only with wip +- Add
markers: `<<`, `>>` +- Add new container
in footer +- Better status display for article +- fix lang setting +- fix for less warnings in HTML validity + ## [0.9.1] - wip: tabulation when using `
` - wip: inline quote markers `@_myquote_@` diff --git a/README.md b/README.md index 50bf72d..4838990 100644 --- a/README.md +++ b/README.md @@ -54,30 +54,31 @@ abbr: abbrev # Les titres HTML vont de 1 à 6. # Utiliser #N, où N est entre 1 et 6. # Si du contenu existe entre les titres, une
est ajoutée -# Astuce: on commence en général par #2 dans l'article +# Astuce: on commence en général par #2 dans l'article le titre du site +# étant en #1 # Source -#1 Titre 1 +#2 Titre 1 Contenu 1 -#2 Titre 2 +#3 Titre 2 -#3 Titre 3 +#4 Titre 3 contenu 2 -#4 Titre 4 +#5 Titre 4 +``` -# HTML -

Titre 1

-
-Contenu 1 -
-

Titre 2

-

Titre 3

-
-contenu 2 -
-

Titre 4

+### Balise div +``` +<< CSS +(( +1er paragraphes dans une balise div class="CSS" +)) +(( +2e paragraphes dans une balise div class="CSS" +)) +>> ``` ### Paragraphes @@ -111,17 +112,10 @@ def hello_world(): # Source de l'ancre cible. "id" est son identité -> id -# HTML - - # Source de l'ancre d'appel # Définir l'identité cible et le texte du lien -(( >_id:Retourner au point d'ancre id_< -)) -# HTML -Retourner au point d'ancre id ``` ### Retour à la ligne HTML @@ -135,18 +129,20 @@ def hello_world(): ### Lien vers URL ``` +# Placer "_" devant le Nom du lien Voir ce _Nom du lien # Ouverture même fenêtre Voir ce _Nom du lien+ # ouverture nouvelle fenêtre ``` ### Lien vers fichier ``` +# Placer "__" devant le Nom du lien Voir ce __Nom du lien # Ouverture même fenêtre Voir ce __Nom du lien+ # ouverture nouvelle fenêtre ``` Note: -Vous pouvez avoir un Nom identique pour les marqueur `file:` et `link:` +Vous pouvez avoir un Nom identique pour les marqueurs `file:` et `link:` ### Gras, Strong, italique... @@ -154,9 +150,9 @@ Vous pouvez avoir un Nom identique pour les marqueur `file:` et `link:` *_très gras_* # +_gras léger_+ # /_en italique_/ # -[_en italique_] # +:_en italique_: # ~_texte barré_~ # -:_Citation rapide_: # +@_Citation rapide_@ # %_Classe personnalisée_% >>> ._Souligné_. # {_Code_} # @@ -207,7 +203,7 @@ optionnels `_xxx:`. Pour la date, utilisez le FORMAT INTERNATIONAL # Source: citation complète [[ CSS_TEST _cite: echolib -_date: 2022-12-28 +_date: 2022-12-28 (format AAAA ou AAAA-MM ou AAAA-MM-JJ) _lang: fr _link: https://tyto.echolib.re _book: Référence @@ -215,29 +211,10 @@ _book: Référence Pfff, vraiment ! )) ]] - -# HTML -
-
- -
-
- echolib - Reference (2022-12-28) -
-
```` ``` # Source: citation basique [[ Une citation simple, et sans paragraphe ]] - -# HTML -
- Une citation simple, et sans paragraphe -
``` diff --git a/debian/control b/debian/control index 962e249..59ae9da 100644 --- a/debian/control +++ b/debian/control @@ -1,5 +1,5 @@ Package: tyto -Version: 0.9.0 +Version: 0.10.0 Section: custom Priority: optional Architecture: all diff --git a/src/usr/bin/tyto b/src/usr/bin/tyto index 39b0751..c6c2314 100755 --- a/src/usr/bin/tyto +++ b/src/usr/bin/tyto @@ -1,5 +1,5 @@ #!/usr/bin/env python3 -# Version: 0.9.1 +# Version: 0.10.0 # Tyto - Littérateur # # Copyright (C) 2023 Cyrille Louarn diff --git a/src/var/lib/tyto/help/styles.css b/src/var/lib/tyto/help/styles.css index 31ccc5c..2dacdf7 100644 --- a/src/var/lib/tyto/help/styles.css +++ b/src/var/lib/tyto/help/styles.css @@ -37,7 +37,7 @@ p#site_about { nav#site_menu { } -ul#site_menu_items { +menu#site_menu_items { } li.site_menu_item { @@ -121,7 +121,7 @@ p.bcode { } /* section for author and date */ -section#article_infos { +div#article_infos { } span#article_author { } @@ -157,6 +157,11 @@ p.sidebar_item_about { */ footer#footer_page { } + +/* container for footer_infos + footer_references */ +div#footer_container { +} + /* Block*/ div#footer_infos { } @@ -164,6 +169,7 @@ h1#footer_site_title { } p#footer_about { } + /* Block */ div#footer_references { } @@ -173,6 +179,7 @@ li.footer_item { } a.footer_item_link { } + /* Block */ div#footer_credits { } diff --git a/src/var/lib/tyto/program/args.py b/src/var/lib/tyto/program/args.py index 102b140..656df18 100644 --- a/src/var/lib/tyto/program/args.py +++ b/src/var/lib/tyto/program/args.py @@ -60,10 +60,12 @@ actions = \ 'publish' ) -pass_actions = ( - 'new' - - ) +option = \ +( +'--static', +) + +pass_actions = ('new') # Actions that needs to check for article's database pass_db = \ @@ -104,24 +106,26 @@ pass_status = \ multi_chk = ('added', 'again', 'updated') +''' action = '' target = '' -noaction = False +option = '' +''' + # action #------- try: action = sys.argv[1] -except: noaction = True +except: action = '' # With no argument, show help -if noaction: +if not action: infos.tyto(target) sys.exit(0) # Unused argument [action] -act_err = False -if not action in actions: - act_err = True +if action in actions: act_err = False +else: act_err = True # target @@ -130,6 +134,10 @@ try: target = sys.argv[2] except: target = '' +# option +try: option = sys.argv[3] +except: option = '' + # Set action and target for binary def set_action(): return(action) diff --git a/src/var/lib/tyto/program/check.py b/src/var/lib/tyto/program/check.py index 8ce9dac..c8ff824 100644 --- a/src/var/lib/tyto/program/check.py +++ b/src/var/lib/tyto/program/check.py @@ -878,39 +878,67 @@ def check_content(post_bottom): ), False) +#==============================================# +# Check if articles in servers are static Page # +#----------------------------------------------# +def check_static_posts(): + global wip_static, www_static + wip_static = www_static = 'False' + + srv_posts = \ + [ + (srv_post_wip_uri, 'wip_static'), + (srv_post_www_uri, 'www_static') + ] + + for srv_post, static in srv_posts: + post_datas = open(srv_post, "r").read() + if not re.findall( + tyto.tags_html_mods[dom.wip_metas_f], + post_datas + ): + globals()[static] = "True" + + #===============================# # Create new article's database # #------------------------------&co-# def create_database(): + # Check if article is in servers + check_static_posts() + + # Post Configurations #-------------------- database = \ - '# Post Configurations\n' + \ - 'post_id = "%s"\n'%db.uri_id + \ - 'post_src = "%s"\n'%db.uri_file + \ - 'post_wip = "%s"\n'%srv_post_wip_uri + \ - 'post_www = "%s"\n'%srv_post_www_uri + \ - '\n' + \ - 'direc_src = "%s"\n'%direc_src + \ - 'short_src = "%s"\n'%src_post_short_uri + \ - 'short_srv = "%s"\n'%srv_post_short_uri + \ - 'sub_uri = "%s"\n'%sub_uri + \ - 'http_wip = "%s"\n'%http_wip + \ - 'http_www = "%s"\n'%http_www + \ - '\n' + \ - 'date_chk = "%s"\n'%tyto.nowdate() + \ - 'hash_chk = "%s"\n'%db.hash_post + \ - 'date_wip = "%s"\n'%date_wip + \ - 'hash_wip = "%s"\n'%hash_wip + \ - 'date_www = "%s"\n'%date_www + \ - 'hash_www = "%s"\n'%hash_www + \ - '\n# Needed tags configurations\n' + \ + '# Writer configurations\n' + \ 'title = "%s"\n'%title + \ 'about = "%s"\n'%about + \ 'author = "%s"\n'%author + \ 'meta_tags = "%s"\n'%tags + \ 'date = "%s"\n'%date_tr + \ 'snpic = "%s"\n'%snpic_url + \ + '\n# Post Configurations\n' + \ + 'post_id = "%s"\n'%db.uri_id + \ + 'post_src = "%s"\n'%db.uri_file + \ + 'direc_src = "%s"\n'%direc_src + \ + 'short_src = "%s"\n'%src_post_short_uri + \ + 'short_srv = "%s"\n'%srv_post_short_uri + \ + 'sub_uri = "%s"\n'%sub_uri + \ + 'date_chk = "%s"\n'%tyto.nowdate() + \ + 'hash_chk = "%s"\n'%db.hash_post + \ + '\n# wip configuration\n' + \ + 'post_wip = "%s"\n'%srv_post_wip_uri + \ + 'http_wip = "%s"\n'%http_wip + \ + 'static_wip = %s\n'%wip_static + \ + 'date_wip = "%s"\n'%date_wip + \ + 'hash_wip = "%s"\n'%hash_wip + \ + '\n# www configuration\n' + \ + 'post_www = "%s"\n'%srv_post_www_uri + \ + 'http_www = "%s"\n'%http_www + \ + 'static_www = %s\n'%www_static + \ + 'date_www = "%s"\n'%date_www + \ + 'hash_www = "%s"\n'%hash_www + \ '\n# Used files\n' + \ 'uris = %s'%str(files_post) diff --git a/src/var/lib/tyto/program/db.py b/src/var/lib/tyto/program/db.py index 5cac1b1..a488d9d 100644 --- a/src/var/lib/tyto/program/db.py +++ b/src/var/lib/tyto/program/db.py @@ -83,7 +83,9 @@ if args.target \ 'post_id', 'post_src', 'post_wip', + 'static_wip', 'post_www', + 'static_www', 'direc_src', 'short_src', 'short_srv', diff --git a/src/var/lib/tyto/program/dom.py b/src/var/lib/tyto/program/dom.py index 21b8eec..df5182d 100644 --- a/src/var/lib/tyto/program/dom.py +++ b/src/var/lib/tyto/program/dom.py @@ -267,6 +267,27 @@ if not hole: "footer" : footers, "template": templates, } + + templates_wip = { + eval(str('wip_logo_f')), + eval(str('wip_css_f')), + eval(str('wip_navbar_f')), + eval(str('wip_sidebar_f')), + eval(str('wip_metas_f')), + eval(str('wip_footer_f')), + eval(str('wip_stats_f')), + } + + templates_www = { + eval(str('www_logo_f')), + eval(str('www_css_f')), + eval(str('www_navbar_f')), + eval(str('www_sidebar_f')), + eval(str('www_metas_f')), + eval(str('www_footer_f')), + eval(str('www_stats_f')), + eval(str('www_rss_f')) + } #====================================# # Check if domain is ready and ready # diff --git a/src/var/lib/tyto/program/form.py b/src/var/lib/tyto/program/form.py index 6316e1d..b11665e 100644 --- a/src/var/lib/tyto/program/form.py +++ b/src/var/lib/tyto/program/form.py @@ -760,10 +760,10 @@ def create_metas(option): '# \n' + \ - '\n' + \ - '\n' + \ - '' + '\n' + \ + '\n' + \ + '\n' + \ + '' tyto.set_file(dom.metas_f, 'New', metas_tags) @@ -966,11 +966,11 @@ def create_footer(option): footer_laws_links = '' if footer_laws: footer_laws_links = \ - ' \n' + ' \n' # Set default content for # navbar config file @@ -1000,41 +1000,43 @@ def create_footer(option): footer = \ '%s\n'%footer_lang%(tyto.Tyto, dom.footer_f) + \ '
\n' + \ - ' \n' + \ + '
\n' + \ '\n' + \ - ' \n' + \ '
\n' + \ ' \n' + \ ' \n' + \ - '\n' + \ - '\n' + \ + tyto.tags_html_mods[dom.wip_navbar_f] + '\n' + \ '
\n' + \ '

%s

\n'%( @@ -176,7 +175,7 @@ def create_main_page(target, article_bottom): db.title, ) + \ '%s\n'%article_bottom + \ - '
\n' + \ + '
\n' + \ '

\n' + \ ' %s, %s\n'%( @@ -186,11 +185,11 @@ def create_main_page(target, article_bottom): '%s\n'%time_html_pub + \ '%s'%post_html_code + \ '

\n' + \ - '
\n' + \ + '
\n' + \ ' \n' + \ '\n' + \ - '\n' + \ - '\n' + \ + tyto.tags_html_mods[dom.wip_sidebar_f] + '\n' + \ + tyto.tags_html_mods[dom.wip_footer_f] + '\n' + \ ' \n' + \ '' @@ -239,7 +238,7 @@ def create_html_time_meta(process): # meta search_date= meta_pub = \ - ' \n'%( + ' \n'%( date_raw.rsplit(' ')[0] ) @@ -305,7 +304,7 @@ def create_navbar(option): # Set first HTML line menu_html = \ '%s\n'%(menu_html, 8 * ' ', 6 * ' ') + menu_html = '\n%s\n%s\n%s\n'%(menu_html, 6 * ' ', 4 * ' ') tyto.set_file(target, 'New', menu_html) diff --git a/src/var/lib/tyto/program/langs.py b/src/var/lib/tyto/program/langs.py index 2fc4ffa..d0d9afa 100644 --- a/src/var/lib/tyto/program/langs.py +++ b/src/var/lib/tyto/program/langs.py @@ -56,7 +56,7 @@ try: dom.exists lang_logs = dom.lang_logs os.path.exists('%s/logs_%s.py'%(trans_dir, lang_logs)) - log = importlib.import_module('logs_%s'%lang_logse, package=None) + log = importlib.import_module('logs_%s'%lang_logs, package=None) except: log = importlib.import_module('logs_%s'%lang_sys, package=None) diff --git a/src/var/lib/tyto/program/logs.py b/src/var/lib/tyto/program/logs.py index c23549b..3473a0d 100644 --- a/src/var/lib/tyto/program/logs.py +++ b/src/var/lib/tyto/program/logs.py @@ -66,12 +66,12 @@ def out(nbr, value, out): '17' : ' ╞ %s%s%s "%s ?"'%(CR, langs.log.unused_v, CS, value), '18' : ' ╘ %s%s%s > %s'%(CR, langs.log.unused_p, CS, value), '19' : ' ╞ %s%s%s %s'%(CG, langs.log.was_wip, CS, value), - '20' : ' ╞ %s%s%s %s'%(CG, langs.log.was_chk, CS, value), + '20' : ' ╞═ %s%s%s %s'%(CG, langs.log.was_chk, CS, value), '21' : ' ╘ %s%s%s > %s'%(CG, langs.log.post_val, CS, value), '22' : ' ╞ %s%s%s %s'%(CY, langs.log.symb_np, CS, value), '23' : ' ╞ %s%s%s > %s'%(CY, langs.log.db_inv, CS, value), '24' : ' ╞ %s%s%s > %s'%(CY, langs.log.unused_r, CS, value), - '25' : ' ╞ %s%s%s > %s'%(CY, langs.log.nycheck, CS, value), + '25' : ' ╞═ %s%s%s > %s'%(CY, langs.log.nycheck, CS, value), '26' : ' ╞ %s%s%s %s'%(CY, langs.log.nyfile, CS, value), '27' : ' ╞ %s%s%s %s'%(CY, langs.log.snpic_d, CS, value), '28' : ' ╘ %s (%s)'%(langs.log.ntd, value), @@ -96,16 +96,15 @@ def out(nbr, value, out): '51' : ' ╞ %s%s%s > %s'%(CY, langs.log.data_inc, CS, value), '60' : ' │\n ╞ %s'%langs.log.status_r, '61' : ' ╞ %s%s%s > %s'%(CG, langs.log.file_e, CS, value), - '71' : ' ╞═ %s%s%s > %s'%(CY, langs.log.post_nwi, CS, value), - '72' : ' ╞═ %s%s%s > %s'%(CG, langs.log.post_wip, CS, value), - '73' : ' ╞═ %s%s%s > %s'%(CY, langs.log.st_wip_n, CS, value), - '74' : ' ╞═ %s%s%s > %s'%(CY, langs.log.st_wip_o, CS, value), - '81' : ' ╞═ %s%s%s > %s'%(CY, langs.log.post_nww, CS, value), - '82' : ' ╞═ %s%s%s > %s'%(CG, langs.log.post_www, CS, value), - '83' : ' ╞═ %s%s%s > %s'%(CY, langs.log.st_www_n, CS, value), - '84' : ' ╞═ %s%s%s > %s'%(CY, langs.log.st_www_o, CS, value), '85' : ' ╞═ %s%s%s > %s'%(CY, langs.log.was_pub, CS, value), + '91' : ' ╞═ %s%s%s > %s'%(CY, langs.log.post_nfd, CS, value), + '92' : ' ╞═ %s%s%s > %s'%(CG, langs.log.post_yfd, CS, value), '94' : ' ╞═ %s%s%s > %s'%(CY, langs.log.st_chk_o, CS, value), + '95' : ' ╞═ %s%s%s > %s'%(CG, langs.log.status_s, CS, value), + '96' : ' ╞═ %s%s%s > %s'%(CY, langs.log.static_y, CS, value), + '97' : ' ╞═ %s%s%s > %s'%(CG, langs.log.static_n, CS, value), + '98' : ' ╞═ %s%s%s > %s'%(CY, langs.log.status_n, CS, value), + '99' : ' ╞═ %s%s%s > %s'%(CY, langs.log.status_o, CS, value), '255' : ' ╘ %s'%langs.log.laterout } diff --git a/src/var/lib/tyto/program/publish.py b/src/var/lib/tyto/program/publish.py index 8cd3bf1..bc268fc 100644 --- a/src/var/lib/tyto/program/publish.py +++ b/src/var/lib/tyto/program/publish.py @@ -165,7 +165,13 @@ def publish_article(): logs.out("33", '%s%s'%(dom.srv_www, db.direc_src), False) # Replace in DB hash_wip and date_wip - tyto.replace_in_db(db.config, 'www', db.hash_post) + db_values = \ + [ + ("date_www", '"%s"'%db.date_www, '"%s"'%tyto.nowdate()), + ("hash_www", '"%s"'%db.hash_www, '"%s"'%db.hash_post), + ("static_www", '%s'%db.static_www, '%s'%db.static_wip) + ] + tyto.change_in_db(db.config, db_values) # Copy needed files (Also create sub-folders) tyto.files_to_srv('www') diff --git a/src/var/lib/tyto/program/status.py b/src/var/lib/tyto/program/status.py index fdedd8c..c0d5dea 100644 --- a/src/var/lib/tyto/program/status.py +++ b/src/var/lib/tyto/program/status.py @@ -19,7 +19,7 @@ #---------------------------------------------------------------------- # XMPP: echolib (im@echolib.re) # -# Description: Show statuses for domain +# Description: Show statuses for commands, domain, article # File: /var/lib/tyto/program/status.py #---------------------------------------------------------------------- @@ -37,8 +37,8 @@ import args, dom, logs, tyto, form, db def domain(): if dom.hole: logs.out("13", '', True) - elif args.action == 'new': return - elif args.act_err: logs.out("11", args.action, True) + elif args.action == 'new': return + elif args.act_err: logs.out("11", args.action, True) elif not dom.exists: logs.out("10", '', True) elif dom.corrupt: logs.out("39", dom.shortname, True) @@ -76,6 +76,7 @@ def domain(): if not tyto.exists(file_mods): logs.out("1", file_mods, False) + #==============================# # On demand with status action # #------------------------------# @@ -84,6 +85,7 @@ def check(target): if not target: logs.out("5", '[target]', True) + # Domain statuses elif target == "domain": conf_err = False @@ -101,6 +103,7 @@ def check(target): logs.out("31", '', True) return + # target is an article # Unused file elif not db.post: logs.out("1", db.uri_file, True) @@ -115,16 +118,30 @@ def check(target): else: logs.out("20", db.uri_file, False) # wip - if not db.file_wip: logs.out("71", db.post_wip, False) - else: logs.out("72", db.post_wip, False) - if db.no_wip: logs.out("73", db.post_wip, False) - elif db.old_wip: logs.out("74", db.post_wip, False) - + print(' │ [wip]') + if not db.file_wip: + logs.out("91", db.post_wip, False) + else: + logs.out("92", db.post_wip, False) + # wip static + if db.static_wip: logs.out("96", db.post_wip, False) + else: logs.out("97", db.post_wip, False) + if db.no_wip: logs.out("98", db.post_wip, False) + elif db.old_wip: logs.out("99", db.post_wip, False) + else: logs.out("95", db.post_wip, False) + # www - if not db.file_www: logs.out("81", db.post_www, False) - else: logs.out("82", db.post_www, False) - if db.no_www: logs.out("83", db.post_www, False) - elif db.old_www: logs.out("84", db.post_www, False) + print(' │ [www]') + if not db.file_www: + logs.out("91", db.post_www, False) + else: + logs.out("92", db.post_www, False) + # www static + if db.static_www: logs.out("96", db.post_wip, False) + else: logs.out("97", db.post_wip, False) + if db.no_www: logs.out("98", db.post_www, False) + elif db.old_www: logs.out("99", db.post_www, False) + else: logs.out("95", db.post_www, False) return # Article has NO DB diff --git a/src/var/lib/tyto/program/tyto.py b/src/var/lib/tyto/program/tyto.py index f9f35b4..01b4c57 100644 --- a/src/var/lib/tyto/program/tyto.py +++ b/src/var/lib/tyto/program/tyto.py @@ -118,14 +118,15 @@ words_tags = [ ('((', '))', '

', '

', 'paragraphs', 't'), ('[[', ']]', '[[', ']]', 'quotes', 't'), ('{{', '}}', '{{', '}}', 'bcodes', 't'), -('-(', '-)', '-(', '-)', 'lists', 't') +('-(', '-)', '-(', '-)', 'lists', 't'), +('<<', '>>', '
', '
', 'div', 't') ] # Tags that do not need to be paired #----------------------------------- single_tags = [ ('|', '
'), # New Line -('->', '') # Anchors +('->', ''), # Anchors ] # When counting words, do no count line starting with: @@ -182,6 +183,15 @@ quote_tags = [ # Tags to check in header in content _TAG head_tags = ("image:", "raw:", "code;") +# For static modules +tags_html_mods = \ +{ +dom.wip_navbar_f : '', +dom.wip_sidebar_f : '', +dom.wip_metas_f : '', +dom.wip_footer_f : '' +} + # Valid characters for some datas chrs_invalid = \ set('{}[]_()+*=/:%~´') @@ -269,7 +279,7 @@ def set_file(path, new, text): try: file = open(path, opt) - file.write(text + '\n') + file.write(text) file.close() if opt == 'w': logs.out("32", path, False) @@ -474,32 +484,20 @@ def b64(action, content, before, after): # Used for wip and publish # # to replace hash and date when done # #------------------------------------# -def replace_in_db(post_db, process, hash_post): - try: - file_db = open(post_db, "r") - lines = file_db.readlines() - except: - logs.out("1", post_db, True) +def change_in_db(db_file, db_values): + try: post_db = open(db_file, "r").read() + except: logs.out("1", db_file, True) - new_file = '' + for value in db_values: + old_value = re.findall(r'%s\s+=\s+%s'%( + value[0],value[1] + ), post_db + )[0] + new_value = old_value.replace(value[1], value[2]) + if new_value != old_value: + post_db = post_db.replace(old_value, new_value) - for line in lines: - if line.startswith('hash_%s'%process): - line = line.replace(line, 'hash_%s = "%s"'%(process, hash_post)) - new_file = '%s%s\n'%(new_file, line) - elif line.startswith('date_%s'%process): - line = line.replace(line, 'date_%s = "%s"'%(process, nowdate())) - new_file = '%s%s\n'%(new_file, line) - else: - if new_file: new_file = '%s%s'%(new_file, line) - else: new_file = line - - try: - file = open(post_db, 'w') - file.write(new_file) - file.close() - except: - logs.out("1", post_db, True) + set_file(db_file, 'New', post_db) #===================================# diff --git a/src/var/lib/tyto/program/wip.py b/src/var/lib/tyto/program/wip.py index d4cf7b7..42722c6 100644 --- a/src/var/lib/tyto/program/wip.py +++ b/src/var/lib/tyto/program/wip.py @@ -176,11 +176,15 @@ def wip_article(target): wip_tabs() # make HTML tabulations # Replace in DB hash_wip and date_wip - tyto.replace_in_db(db.config, 'wip', db.hash_post) + db_values = \ + [ + ("date_wip", '"%s"'%db.date_wip, '"%s"'%tyto.nowdate()), + ("hash_wip", '"%s"'%db.hash_wip, '"%s"'%db.hash_post) + ] + tyto.change_in_db(db.config, db_values) # Get article DB in html.py html.set_page(db.uri_file, post_bottom) - #print(html.main_page) # Create wip file if os.makedirs('%s%s'%(dom.srv_wip, db.direc_src), exist_ok=True): @@ -190,6 +194,10 @@ def wip_article(target): # Copy needed files (Also create sub-folders) tyto.files_to_srv('wip') + # Making article static (on demand) + if args.option == "--static": + wip_static() + #=================================# # Create string article from file # @@ -215,6 +223,33 @@ def file_to_string(post_file): else: post_header = '%s\n%s'%(post_header, line) +#=========================================# +# Create real static page, by # +# including modules contents in HTML page # +# (optional) on demande with --static +#-----------------------------------------# +def wip_static(): + importlib.reload(db) + if not db.file_wip: + return + + print(' ├─ %s > %s'%(langs.site.wip_in_mod, db.post_wip)) + + wip_html_post = open(db.post_wip, 'r').read() + for module in dom.wip_html_mods: + wip_module = open(module, 'r').read() + wip_html_post = \ + wip_html_post.replace( + tyto.tags_html_mods[module], + wip_module + ) + tyto.set_file(db.post_wip, "New", wip_html_post) + + # Change status in db + db_values = [("static_wip", '%s'%db.static_wip, 'True')] + tyto.change_in_db(db.config, db_values) + + #===============================================================# # Simple function to replace source text to HTML in post_bottom # #---------------------------------------------------------------# @@ -274,8 +309,7 @@ def wip_words_tags(): for ln, line in enumerate(post_bottom.rsplit('\n')): - # Paragraphs - # Open tag + # Paragraphs Open tag if db.paragraphs > 0: if line.startswith(tyto.words_tags[10][0]): set_css = tyto.get_css(line) @@ -287,6 +321,19 @@ def wip_words_tags(): replace_in_post(line, tyto.words_tags[10][3] ) + + # div Open tag + if line.startswith(tyto.words_tags[14][0]): + set_css = tyto.get_css(line) + replace_in_post(post_bottom.rsplit('\n')[ln], + tyto.words_tags[14][2]%set_css + ) + # Close paragraph tag + elif line.startswith(tyto.words_tags[14][1]): + replace_in_post(line, + tyto.words_tags[14][3] + ) + # Open anchors link if db.anchors == 0: continue @@ -392,7 +439,7 @@ def wip_images(): '%s' + ' title="%s"%s>' # Check each line for ln, line in enumerate(post_bottom.rsplit('\n')): diff --git a/src/var/lib/tyto/translations/logs_en.py b/src/var/lib/tyto/translations/logs_en.py index 88a7436..584b4d0 100644 --- a/src/var/lib/tyto/translations/logs_en.py +++ b/src/var/lib/tyto/translations/logs_en.py @@ -53,19 +53,19 @@ post_val = "Article is valid" # wip nywip = "Article not yet wip" was_wip = "Article was 'wip'" -post_nwi = "Article not in 'wip'" -st_wip_n = "Unused 'wip' status" -st_wip_o = "Old 'wip' status" -post_wip = "Article is in 'wip'" # www was_pub = "Article was published" -post_nww = "Article not in 'www'" -st_www_n = "Unused 'www' status" -st_www_o = "Old 'www' status" -post_www = "Article is in 'www'" # Misc +post_nfd = "Page not found" +post_yfd = "Page found" +static_y = "Page is static" +static_n = "Page not static" +status_n = "Status: unused" +status_o = "Status: old" +status_s = "Status: up to date" + check_m = "Check manually" post_chg = "Article changed: 'check' it first" sep_inv = "Unused separator in article" diff --git a/src/var/lib/tyto/translations/logs_fr.py b/src/var/lib/tyto/translations/logs_fr.py index 26a96eb..ec65f5c 100644 --- a/src/var/lib/tyto/translations/logs_fr.py +++ b/src/var/lib/tyto/translations/logs_fr.py @@ -52,19 +52,21 @@ post_val = "Article valide" # Wip nywip = "Article pas encore 'wip'" was_wip = "Article déjà 'wip'" -post_nwi = "Article non présent dans 'wip'" -st_wip_n = "Statut 'wip' Non présent" -st_wip_o = "Statut 'wip' Ancien" -post_wip = "Article présent dans 'wip'" + # www was_pub = "Article déjà publié" -post_nww = "Article non présent dans 'www'" -st_www_n = "Statut 'www' Non présent" -st_www_o = "Statut 'www' Ancien" -post_www = "Article présent dans 'www'" + # Misc +post_nfd = "Page non présente" +post_yfd = "Page présente" +static_y = "Page statique" +status_n = "Statut : non présent" +status_o = "Statut : ancien" +status_s = "Statut : à jour" + +static_n = "Page non statique" check_m = "Vérifier manuellement" post_chg = "Article modifié : commencer par 'check'" sep_inv = "Séparateur manquant dans l'article" diff --git a/src/var/lib/tyto/translations/site_en.py b/src/var/lib/tyto/translations/site_en.py index 92ce345..113d9a6 100644 --- a/src/var/lib/tyto/translations/site_en.py +++ b/src/var/lib/tyto/translations/site_en.py @@ -79,6 +79,7 @@ wip_new = "Create a new HTML page in 'wip' server again" srv_again = "Create again converted HTMl pages in server" srv_added = "Create missing HTML pages in server" srv_updated = "Update HTMl pages in server" +wip_in_mod = "Include static module" # publish publish_a = "Publish again this article" diff --git a/src/var/lib/tyto/translations/site_fr.py b/src/var/lib/tyto/translations/site_fr.py index 78d7ddc..db92258 100644 --- a/src/var/lib/tyto/translations/site_fr.py +++ b/src/var/lib/tyto/translations/site_fr.py @@ -79,6 +79,7 @@ wip_new = "Créer encore une page HTML dans le serveur 'wip'" srv_again = "Créer encore les pages dans le serveur" srv_added = "Créer les pages HTML manquantes dans le serveur" srv_updated = "Mise à jour des pages HTML dans le serveur" +wip_in_mod = "Intégration statique des modules" # publish publish_a = "Publier encore l'article"