[1.9.24] - new list process (HTML prepared at 'check')
This commit is contained in:
parent
8843fd3f76
commit
6d5a75b4bf
|
@ -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')
|
||||
|
||||
|
|
10
README.md
10
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 !
|
||||
|
||||
|
|
|
@ -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 <echolib+tyto@a-lec.org>
|
||||
|
@ -19,7 +19,7 @@
|
|||
# along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
# XMPP: echolib (im@echolib.re)
|
||||
# XMPP: echolib > im@echolib.re
|
||||
#
|
||||
# Description: Main binary to execute.
|
||||
# Import modules and start checking/using arguments
|
||||
|
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
@ -17,7 +17,7 @@
|
|||
# along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
# XMPP: echolib (im@echolib.re)
|
||||
# XMPP: echolib > im@echolib.re
|
||||
#
|
||||
# Description: Manage arguments from command line
|
||||
# File: /var/lib/tyto/program/args.py
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
# along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
# 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))
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
# along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
# 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
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
# along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
# XMPP: echolib (im@echolib.re)
|
||||
# XMPP: echolib > im@echolib.re
|
||||
#
|
||||
# Description: Manage configuration domain(s)
|
||||
# File: /var/lib/tyto/program/domain.py
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
# along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
# XMPP: echolib (im@echolib.re)
|
||||
# XMPP: echolib > im@echolib.re
|
||||
#
|
||||
# Description: Forms (edit, create domain, questions...)
|
||||
# File: /var/lib/tyto/program/form.py
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
# along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
# XMPP: echolib (im@echolib.re)
|
||||
# XMPP: echolib > im@echolib.re
|
||||
#
|
||||
# Description: Show help commands
|
||||
# File: /var/lib/tyto/program/help.py
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
# along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
# 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
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
# along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
# 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
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
# along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
# 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", '<p class="%s">', "</p>"),
|
||||
("<<", ">>", "lists" ),
|
||||
("<<", ">>", "lists", "=", "+"),
|
||||
)
|
||||
|
||||
ptags_stats = {
|
||||
|
@ -380,6 +380,8 @@ ini_template = """[DOMAIN]
|
|||
|
||||
[QUOTES]
|
||||
|
||||
[LISTS]
|
||||
|
||||
[RAWS]
|
||||
|
||||
[CODES]
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
# along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
# XMPP: echolib (im@echolib.re)
|
||||
# XMPP: echolib > im@echolib.re
|
||||
#
|
||||
# Description: When user wants to see something
|
||||
# File: /var/lib/tyto/program/show.py
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
# along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
# XMPP: echolib (im@echolib.re)
|
||||
# XMPP: echolib > im@echolib.re
|
||||
#
|
||||
# Description: Tools used by Tyto - Littérateur
|
||||
# File: /var/lib/tyto/program/tools.py
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
# along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
# XMPP: echolib (im@echolib.re)
|
||||
# XMPP: echolib > im@echolib.re
|
||||
#
|
||||
# Description: Templates, settings, values
|
||||
# File: /var/lib/tyto/program/tyto.py
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
# along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
# 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
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
# Tyto - Littérateur
|
||||
|
||||
# Copyright (C) 2023 Cyrille Louarn <echolib+tyto@a-lec.org>
|
||||
# Copyright (C) 2023 Adrien Bourmault <neox@a-lec.org>
|
||||
|
||||
# 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 <https://www.gnu.org/licenses/>.
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
# 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("<li>", ' <li class="%s>"'%css)
|
||||
|
||||
return list_html
|
||||
|
||||
#====================================================================#
|
||||
# Tool to convert content lists to HTML #
|
||||
# markdown_str: from lists_to_HTML() #
|
||||
# So many THANX neox ! #
|
||||
# (Not sure, i was able to do it and even not in a so beautiful way) #
|
||||
#--------------------------------------------------------------------#
|
||||
def convert_list(markdown_str, mark_b, mark_c):
|
||||
# First step : reshape lines
|
||||
items = []
|
||||
inside_item = 0
|
||||
index = -1
|
||||
|
||||
# Cut string with \n's
|
||||
strlist = markdown_str.split("\n")
|
||||
|
||||
# Find items
|
||||
for i in range(len(strlist)):
|
||||
if strlist[i] == "":
|
||||
continue
|
||||
|
||||
# = and +
|
||||
if strlist[i][0] != mark_b and \
|
||||
strlist[i][0] != mark_c:
|
||||
if inside_item != 1:
|
||||
inside_item = 1
|
||||
else:
|
||||
inside_item = 0
|
||||
|
||||
if inside_item == 0:
|
||||
items.append(strlist[i])
|
||||
index += 1
|
||||
|
||||
if inside_item == 1:
|
||||
items[index] = '%s '%items[index] # Add one space
|
||||
items[index] += strlist[i].lstrip()
|
||||
|
||||
# Second step : parsing
|
||||
UL = 1
|
||||
OL = 2
|
||||
CLOSING = ["ERROR", "</ul>\n", "</ol>\n"]
|
||||
OPENING = ["ERROR", "<ul>\n", "<ol>\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 + '<li>' + text + "</li>\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 #
|
||||
|
|
Loading…
Reference in New Issue