diff --git a/CHANGELOG.md b/CHANGELOG.md index 8697067..755ab48 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,9 @@ Tyto - Littérateur # CURRENTLY IN DEV ! +## [1.9.24] +- new list process (HTML prepared at 'check') + ## [1.9.23] - new quote process (HTML prepared at 'check') diff --git a/README.md b/README.md index 75e361f..f4a0d0e 100644 --- a/README.md +++ b/README.md @@ -8,11 +8,11 @@ tyto ``` ## ToDo next (working on) +- added lists to post database (prepared wip) + +## Working on - 'check' action processes -- - wip quotes -- - support for words tags (bolds...) -- - support lists, anchors -- - thinking about creating an auto top article menu from titles -- - stats for article words +- thinking about creating an auto top article menu from titles +- stats for article words - Translate logs in english ! diff --git a/src/usr/bin/tyto b/src/usr/bin/tyto index 9940ac8..c3fef68 100755 --- a/src/usr/bin/tyto +++ b/src/usr/bin/tyto @@ -1,6 +1,6 @@ #!/usr/bin/env python3 -# Version: 1.9.23 -# Updated: 2023-10-14 1697274575 +# Version: 1.9.24 +# Updated: 2023-10-14 1697296197 # Tyto - Littérateur # Copyright (C) 2023 Cyrille Louarn @@ -19,7 +19,7 @@ # along with this program. If not, see . #---------------------------------------------------------------------- -# XMPP: echolib (im@echolib.re) +# XMPP: echolib > im@echolib.re # # Description: Main binary to execute. # Import modules and start checking/using arguments diff --git a/src/var/lib/tyto/program/__pycache__/args.cpython-311.pyc b/src/var/lib/tyto/program/__pycache__/args.cpython-311.pyc index 553053a..34c0cfd 100644 Binary files a/src/var/lib/tyto/program/__pycache__/args.cpython-311.pyc and b/src/var/lib/tyto/program/__pycache__/args.cpython-311.pyc differ diff --git a/src/var/lib/tyto/program/__pycache__/check.cpython-311.pyc b/src/var/lib/tyto/program/__pycache__/check.cpython-311.pyc index dbce621..5fd6979 100644 Binary files a/src/var/lib/tyto/program/__pycache__/check.cpython-311.pyc and b/src/var/lib/tyto/program/__pycache__/check.cpython-311.pyc differ diff --git a/src/var/lib/tyto/program/__pycache__/debug.cpython-311.pyc b/src/var/lib/tyto/program/__pycache__/debug.cpython-311.pyc index c1b80bb..1110be4 100644 Binary files a/src/var/lib/tyto/program/__pycache__/debug.cpython-311.pyc and b/src/var/lib/tyto/program/__pycache__/debug.cpython-311.pyc differ diff --git a/src/var/lib/tyto/program/__pycache__/domain.cpython-311.pyc b/src/var/lib/tyto/program/__pycache__/domain.cpython-311.pyc index f6bf54b..2401256 100644 Binary files a/src/var/lib/tyto/program/__pycache__/domain.cpython-311.pyc and b/src/var/lib/tyto/program/__pycache__/domain.cpython-311.pyc differ diff --git a/src/var/lib/tyto/program/__pycache__/forms.cpython-311.pyc b/src/var/lib/tyto/program/__pycache__/forms.cpython-311.pyc index 9ef207c..a581213 100644 Binary files a/src/var/lib/tyto/program/__pycache__/forms.cpython-311.pyc and b/src/var/lib/tyto/program/__pycache__/forms.cpython-311.pyc differ diff --git a/src/var/lib/tyto/program/__pycache__/help.cpython-311.pyc b/src/var/lib/tyto/program/__pycache__/help.cpython-311.pyc index 5090c9a..ff52e8a 100644 Binary files a/src/var/lib/tyto/program/__pycache__/help.cpython-311.pyc and b/src/var/lib/tyto/program/__pycache__/help.cpython-311.pyc differ diff --git a/src/var/lib/tyto/program/__pycache__/langs.cpython-311.pyc b/src/var/lib/tyto/program/__pycache__/langs.cpython-311.pyc index 6403d4d..ee7fa5b 100644 Binary files a/src/var/lib/tyto/program/__pycache__/langs.cpython-311.pyc and b/src/var/lib/tyto/program/__pycache__/langs.cpython-311.pyc differ diff --git a/src/var/lib/tyto/program/__pycache__/new.cpython-311.pyc b/src/var/lib/tyto/program/__pycache__/new.cpython-311.pyc index b01872f..7a26788 100644 Binary files a/src/var/lib/tyto/program/__pycache__/new.cpython-311.pyc and b/src/var/lib/tyto/program/__pycache__/new.cpython-311.pyc differ 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 d954315..e4d963c 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__/show.cpython-311.pyc b/src/var/lib/tyto/program/__pycache__/show.cpython-311.pyc index bb27122..5be388b 100644 Binary files a/src/var/lib/tyto/program/__pycache__/show.cpython-311.pyc and b/src/var/lib/tyto/program/__pycache__/show.cpython-311.pyc differ 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 6db0642..92ea0a9 100644 Binary files a/src/var/lib/tyto/program/__pycache__/tools.cpython-311.pyc and b/src/var/lib/tyto/program/__pycache__/tools.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 aa85f8a..33f994e 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__/userset.cpython-311.pyc b/src/var/lib/tyto/program/__pycache__/userset.cpython-311.pyc index 058e4c4..08a9d41 100644 Binary files a/src/var/lib/tyto/program/__pycache__/userset.cpython-311.pyc and b/src/var/lib/tyto/program/__pycache__/userset.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 af9f6f0..131c6cf 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/args.py b/src/var/lib/tyto/program/args.py index e5e1884..d257aec 100644 --- a/src/var/lib/tyto/program/args.py +++ b/src/var/lib/tyto/program/args.py @@ -17,7 +17,7 @@ # along with this program. If not, see . #---------------------------------------------------------------------- -# XMPP: echolib (im@echolib.re) +# XMPP: echolib > im@echolib.re # # Description: Manage arguments from command line # File: /var/lib/tyto/program/args.py diff --git a/src/var/lib/tyto/program/check.py b/src/var/lib/tyto/program/check.py index 175f827..0cb6573 100644 --- a/src/var/lib/tyto/program/check.py +++ b/src/var/lib/tyto/program/check.py @@ -17,7 +17,7 @@ # along with this program. If not, see . #---------------------------------------------------------------------- -# XMPP: echolib (im@echolib.re) +# XMPP: echolib > im@echolib.re # # Description: Mainly to check article, but also domain and more # File: /var/lib/tyto/program/check.py @@ -115,25 +115,35 @@ def valid(target): # Text article # ============ # Process bcodes and icodes first to protect their contents - post.error == 0 and sl_ptags(post.ptags[0]) or tools.exit(targets, post.error) - post.error == 0 and icodes() or tools.exit(targets, post.error) + post.error == 0 and sl_ptags(post.ptags[0]) \ + or tools.exit(targets, post.error) + post.error == 0 and icodes() \ + or tools.exit(targets, post.error) # ============= # Head contents # ============= # One Line targs in head_contents - post.error == 0 and ol_tags() or tools.exit(targets, post.error) + post.error == 0 and ol_tags() \ + or tools.exit(targets, post.error) # Multiple and optional Tags on 3 linges - post.error == 0 and ml_tags() or tools.exit(targets, post.error) + post.error == 0 and ml_tags() \ + or tools.exit(targets, post.error) # ============ # Text article # ============ # Single tags - post.error == 0 and sl_stags() or tools.exit(targets, post.error) + post.error == 0 and sl_stags() \ + or tools.exit(targets, post.error) # Quotes - post.error == 0 and sl_ptags(post.ptags[1]) or tools.exit(targets, post.error) + post.error == 0 and sl_ptags(post.ptags[1]) \ + or tools.exit(targets, post.error) + + # Lists + post.error == 0 and sl_ptags(post.ptags[3]) \ + or tools.exit(targets, post.error) return True @@ -496,6 +506,7 @@ def sl_ptags(markers): convert = { "bcodes" : wip.bcode, "quotes" : wip.quote, + "lists" : wip.list, } index0 = index1 = -1 @@ -815,6 +826,7 @@ def cf_update_values(): post.cf_set("STATS_TEXTS", "bcodes", str(post.ptags_stats["bcodes"])) post.cf_set("STATS_TEXTS", "bcodes_lines", str(post.stats_bcodes_lines)) post.cf_set("STATS_TEXTS", "quotes", str(post.ptags_stats["quotes"])) + post.cf_set("STATS_TEXTS", "lists", str(post.ptags_stats["lists"])) # Founds from header tags post.cf_set("STATS_TEXTS", "links", str(post.stats_text_links)) post.cf_set("STATS_TEXTS", "files", str(post.stats_text_files)) diff --git a/src/var/lib/tyto/program/debug.py b/src/var/lib/tyto/program/debug.py index 79af455..48ef622 100644 --- a/src/var/lib/tyto/program/debug.py +++ b/src/var/lib/tyto/program/debug.py @@ -17,7 +17,7 @@ # along with this program. If not, see . #---------------------------------------------------------------------- -# XMPP: echolib (im@echolib.re) +# XMPP: echolib > im@echolib.re # # Description: Add more logs when debug is set in command line # File: /var/lib/tyto/program/debug.py diff --git a/src/var/lib/tyto/program/domain.py b/src/var/lib/tyto/program/domain.py index 4ea381d..ba17c42 100644 --- a/src/var/lib/tyto/program/domain.py +++ b/src/var/lib/tyto/program/domain.py @@ -17,7 +17,7 @@ # along with this program. If not, see . #---------------------------------------------------------------------- -# XMPP: echolib (im@echolib.re) +# XMPP: echolib > im@echolib.re # # Description: Manage configuration domain(s) # File: /var/lib/tyto/program/domain.py diff --git a/src/var/lib/tyto/program/forms.py b/src/var/lib/tyto/program/forms.py index 09df2fb..3f2cbff 100644 --- a/src/var/lib/tyto/program/forms.py +++ b/src/var/lib/tyto/program/forms.py @@ -17,7 +17,7 @@ # along with this program. If not, see . #---------------------------------------------------------------------- -# XMPP: echolib (im@echolib.re) +# XMPP: echolib > im@echolib.re # # Description: Forms (edit, create domain, questions...) # File: /var/lib/tyto/program/form.py diff --git a/src/var/lib/tyto/program/help.py b/src/var/lib/tyto/program/help.py index d29a830..5974fc9 100644 --- a/src/var/lib/tyto/program/help.py +++ b/src/var/lib/tyto/program/help.py @@ -17,7 +17,7 @@ # along with this program. If not, see . #---------------------------------------------------------------------- -# XMPP: echolib (im@echolib.re) +# XMPP: echolib > im@echolib.re # # Description: Show help commands # File: /var/lib/tyto/program/help.py diff --git a/src/var/lib/tyto/program/langs.py b/src/var/lib/tyto/program/langs.py index be4b326..636b9b4 100644 --- a/src/var/lib/tyto/program/langs.py +++ b/src/var/lib/tyto/program/langs.py @@ -17,7 +17,7 @@ # along with this program. If not, see . #---------------------------------------------------------------------- -# XMPP: echolib (im@echolib.re) +# XMPP: echolib > im@echolib.re # # Description: Load lang logs file according to system language # Load lang site file according to domain configuration diff --git a/src/var/lib/tyto/program/new.py b/src/var/lib/tyto/program/new.py index d8b6141..d3aace2 100644 --- a/src/var/lib/tyto/program/new.py +++ b/src/var/lib/tyto/program/new.py @@ -17,7 +17,7 @@ # along with this program. If not, see . #---------------------------------------------------------------------- -# XMPP: echolib (im@echolib.re) +# XMPP: echolib > im@echolib.re # # Description: When user wants to create something new # File: /var/lib/tyto/program/new.py diff --git a/src/var/lib/tyto/program/post.py b/src/var/lib/tyto/program/post.py index 08452bc..686e5a2 100644 --- a/src/var/lib/tyto/program/post.py +++ b/src/var/lib/tyto/program/post.py @@ -17,7 +17,7 @@ # along with this program. If not, see . #---------------------------------------------------------------------- -# XMPP: echolib (im@echolib.re) +# XMPP: echolib > im@echolib.re # # Description: About post (from target) database, uri... # File: /var/lib/tyto/program/new.py @@ -317,7 +317,7 @@ ptags = ( ("{{", "}}", "bcodes"), ("[[", "]]", "quotes"), ("((", "))", "parags", '

', "

"), - ("<<", ">>", "lists" ), + ("<<", ">>", "lists", "=", "+"), ) ptags_stats = { @@ -380,6 +380,8 @@ ini_template = """[DOMAIN] [QUOTES] +[LISTS] + [RAWS] [CODES] diff --git a/src/var/lib/tyto/program/show.py b/src/var/lib/tyto/program/show.py index ee3f698..d7ff1da 100644 --- a/src/var/lib/tyto/program/show.py +++ b/src/var/lib/tyto/program/show.py @@ -17,7 +17,7 @@ # along with this program. If not, see . #---------------------------------------------------------------------- -# XMPP: echolib (im@echolib.re) +# XMPP: echolib > im@echolib.re # # Description: When user wants to see something # File: /var/lib/tyto/program/show.py diff --git a/src/var/lib/tyto/program/tools.py b/src/var/lib/tyto/program/tools.py index b5edb51..3e54974 100644 --- a/src/var/lib/tyto/program/tools.py +++ b/src/var/lib/tyto/program/tools.py @@ -17,7 +17,7 @@ # along with this program. If not, see . #---------------------------------------------------------------------- -# XMPP: echolib (im@echolib.re) +# XMPP: echolib > im@echolib.re # # Description: Tools used by Tyto - Littérateur # File: /var/lib/tyto/program/tools.py diff --git a/src/var/lib/tyto/program/tyto.py b/src/var/lib/tyto/program/tyto.py index 0046ff9..08ce0c5 100644 --- a/src/var/lib/tyto/program/tyto.py +++ b/src/var/lib/tyto/program/tyto.py @@ -17,7 +17,7 @@ # along with this program. If not, see . #---------------------------------------------------------------------- -# XMPP: echolib (im@echolib.re) +# XMPP: echolib > im@echolib.re # # Description: Templates, settings, values # File: /var/lib/tyto/program/tyto.py diff --git a/src/var/lib/tyto/program/userset.py b/src/var/lib/tyto/program/userset.py index e08b000..ede333d 100644 --- a/src/var/lib/tyto/program/userset.py +++ b/src/var/lib/tyto/program/userset.py @@ -17,7 +17,7 @@ # along with this program. If not, see . #---------------------------------------------------------------------- -# XMPP: echolib (im@echolib.re) +# XMPP: echolib > im@echolib.re # # Description: When user wants to set something (mainly in domain) # File: /var/lib/tyto/program/set.py diff --git a/src/var/lib/tyto/program/wip.py b/src/var/lib/tyto/program/wip.py index c8bfb0c..71b13fc 100644 --- a/src/var/lib/tyto/program/wip.py +++ b/src/var/lib/tyto/program/wip.py @@ -2,6 +2,7 @@ # Tyto - Littérateur # Copyright (C) 2023 Cyrille Louarn +# Copyright (C) 2023 Adrien Bourmault # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -17,9 +18,11 @@ # along with this program. If not, see . #---------------------------------------------------------------------- -# XMPP: echolib (im@echolib.re) +# XMPP: echolib > im@echolib.re +# XMPP: neox > neox@a-lec.org # # Description: Convert texts to HTML +# Create HTML page with 'wip' command # File: /var/lib/tyto/program/wip.py #---------------------------------------------------------------------- @@ -34,6 +37,7 @@ import tyto, tools, post, domain + #=========================================================# # Prepared HTML datas in post Database at 'check' process #==================== # Return new string to be converted to one line base64 # @@ -158,11 +162,129 @@ def quote(lines): footer ) - print(html_quote) + #print(html_quote) return html_quote +#===================# +# Create HTML list # +# convert raw lines # +#-------------------# +def list(lines): + lines = lines.rsplit("\n") + + list_raw = "" + + for ln, line in enumerate(lines): + line = line.lstrip() + + # Open Marker (Unused in HTML). Get user CSS class + if ln == 0: + css = tools.get_css(line, post.ptags[3][0]) + continue + + # Closed marker (Unused in HTML) + elif ln == len(lines) - 1: + continue + + if list_raw: list_raw = "%s\n%s"%(list_raw, line) + else: list_raw = line + + # Final HTML list with css class + list_html = convert_list(list_raw, post.ptags[3][3], post.ptags[3][4]) + list_html = list_html.replace(">", ' class="%s">'%css, 1) + list_html = list_html.replace("
  • ", '
  • \n", "\n"] + OPENING = ["ERROR", "
      \n", "
        \n"] + + rank_stack = [] + rank = 0 + cur_rank = 0 + state = 0 + old_state = 0 + work_str = "" + + for i in range(len(items)): + rank = cur_rank + descriptor = items[i].split(" ")[0] + text = items[i][items[i].find(" "):].lstrip() + cur_rank = len(descriptor) + + if "=" in descriptor: + state = UL + elif "+" in descriptor: + state = OL + else: + raise(Exception) + + # rank up + if cur_rank > rank: + for i in range(cur_rank - rank): + work_str += " "*(rank+i) + OPENING[state] + rank_stack.append(state) + + # rank down + elif cur_rank < rank: + for i in range(rank - cur_rank): + work_str += " "*(rank-i-1) + CLOSING[rank_stack.pop()] + + work_str += " "*cur_rank + '
      1. ' + text + "
      2. \n" + + for i in range(cur_rank): + work_str += " "*(cur_rank-i-1) + CLOSING[rank_stack.pop()] + + return work_str + + +#=========================# +# WIP process #==================================================== +# Convert article to HTML # +# Create new file # +#-------------------------# + #============================# # code # # Used by check module that #