[1.9.29] - 'wip' process. See changelog
This commit is contained in:
parent
b6730f2f77
commit
84abcb5e92
21
CHANGELOG.md
21
CHANGELOG.md
|
@ -1,13 +1,26 @@
|
|||
# Changelog
|
||||
|
||||
Tyto - Littérateur
|
||||
- Repository:
|
||||
- Issues:
|
||||
- Repository: https://forge.a-lec.org/echolib/tyto-litterateur/
|
||||
- Issues: https://forge.a-lec.org/echolib/tyto-litterateur/issues
|
||||
- Changelog:
|
||||
- License:
|
||||
- Documentation:
|
||||
- Documentation: https://forge.a-lec.org/echolib/tyto-litterateur/src/branch/master/LICENSE
|
||||
- Development: https://forge.a-lec.org/echolib/tyto-litterateur/src/branch/devel
|
||||
|
||||
# CURRENTLY IN DEV !
|
||||
# CURRENTLY IN DEV (in devel branch) !
|
||||
|
||||
## [1.9.29]
|
||||
- Translations
|
||||
- - added for logs (english)
|
||||
- - updated french logs
|
||||
- wip (working on...)
|
||||
- - added modules conversions (source to HTML)
|
||||
- check
|
||||
- - some fixes and updated code
|
||||
- tools
|
||||
- - check css content
|
||||
- readme : updated article example with comments
|
||||
|
||||
## [1.9.28]
|
||||
- readme
|
||||
|
|
105
README.md
105
README.md
|
@ -11,17 +11,23 @@ tyto
|
|||
- added lists to post database (prepared wip)
|
||||
|
||||
## Working on
|
||||
- 'check' action processes
|
||||
- thinking about creating an auto top article menu from titles
|
||||
- stats for article words
|
||||
- Translate logs in english !
|
||||
- 'wip' action processes
|
||||
- - images module
|
||||
|
||||
## Exemple d'article
|
||||
## ToDo
|
||||
- thinking about creating an auto top article menu from titles
|
||||
- create full HTML page
|
||||
- sitemaps
|
||||
- RSS
|
||||
- 'publish' process
|
||||
|
||||
## Exemple d'article .tyto commenté
|
||||
```
|
||||
#================================================#
|
||||
# Entete de l'article #
|
||||
# Fin de l'entête avec au moins 5 tirets "-----" #
|
||||
# Toute ligne de commentaire "# ..." est ignorée #
|
||||
# ! Recommandé de ne pas utiliser le signe "_" #
|
||||
#================================================#
|
||||
|
||||
# Pour ne pas inclure cet article dans les sitemaps :
|
||||
|
@ -34,7 +40,16 @@ tags: Tyto, tuto,
|
|||
author: echolib
|
||||
date: 2023-10-27
|
||||
|
||||
# Données multiple sur 3 lignes
|
||||
# Données unique sur UNE ligne optionnelle
|
||||
# Si non définit, le logo du domaine est utilisé
|
||||
# Ne sera affiché qu'avec _image:logo
|
||||
logo: post-logo.png
|
||||
|
||||
# Données multiples sur 3 lignes
|
||||
# [TAG]: Nom
|
||||
# LIEN
|
||||
# Text alternatif
|
||||
|
||||
link: cliquer sur ce Lien
|
||||
https://
|
||||
Text alternatif
|
||||
|
@ -47,66 +62,121 @@ file: télécharger ce fichier
|
|||
@/PDFs/hello.pdf
|
||||
Un PDF !
|
||||
|
||||
code: codetest
|
||||
@RAWS/test.py
|
||||
Exemple d'un code Python
|
||||
|
||||
# Les abréviations :
|
||||
# 2eme ligne: Texte alternatif
|
||||
# 3ème ligne: valeur affichée dans l'article à la place du Nom
|
||||
abbr: HTML
|
||||
HuperText Markup Langage
|
||||
HTML
|
||||
|
||||
abbr: css
|
||||
Cascading Stylesheet
|
||||
CSS
|
||||
|
||||
-----
|
||||
|
||||
#=====================================================================#
|
||||
# Contenu de l'article #
|
||||
# Les classe optionnelles non renseignées deviennent celle du domaine #
|
||||
# /!\ Tout code HTML sera interprêté par le navigateur sauf si placé #
|
||||
# entre les marqueurs de block-code ou icode #
|
||||
#=====================================================================#
|
||||
|
||||
# La ligne suivante est un commentaire HTML "<!-- Commentaire -->"
|
||||
# ----------------------------------------------------------------
|
||||
;; Commentaire
|
||||
|
||||
# Ceci est une ancre avec l'ID uniq1 (ID unique)
|
||||
# ----------------------------------------------
|
||||
-> uniq1
|
||||
-> top
|
||||
|
||||
# Créer un lien vers l'ancre "uniq1"
|
||||
# ----------------------------------
|
||||
>_uniq1: Go to uniq1 anchor_<
|
||||
|
||||
# Ceci est une ligne <hr> ayant pour classe hrcss
|
||||
# -----------------------------------------------
|
||||
-- hrcss
|
||||
|
||||
# Les Titres de l'article de #1 à #5 (<h2> à <h6>)
|
||||
# ------------------------------------------------
|
||||
#1 Titre en h2
|
||||
|
||||
# Contenu dans un paragraphe ayant pour classe "mypar"
|
||||
# Contenu dans un paragraphe entre (( ... )) ayant pour classe "mypar"
|
||||
# --------------------------------------------------------------------
|
||||
(( mypar
|
||||
Un long paragraphe...
|
||||
|
||||
# Retour à la ligne avec un <br /> de classe brcss
|
||||
# (les retours à la ligne vides ne sont pas pris en compte)
|
||||
# ---------------------------------------------------------
|
||||
| brcss
|
||||
|
||||
# Reprise du Nom pour les liens de link: et file:
|
||||
# Reprise des abréviations
|
||||
Il faut __cliquer sur ce Lien, __Réservez ici et --télécharger ce fichier
|
||||
ou encore faire une ::CSS pour du beau rendu ::HTML
|
||||
ou encore faire une ::css pour du beau rendu ::HTML
|
||||
|
||||
# Un paragraphe dans le paragraphe ayant pour classe, celle du domaine
|
||||
# --------------------------------------------------------------------
|
||||
((
|
||||
Un /_court_/ paragraphe de :_1984_: pour de ~_vrai_~ +_faux en gras_+
|
||||
Il faut le ._souligner_. et *_Très Gras_*
|
||||
))
|
||||
|
||||
# Créer un icode (utiliser la balise <code>)
|
||||
# /!\ ! Doit être sur une ligne
|
||||
# Créer un icode (utilise la balise <code> HTML)
|
||||
# /!\ ! Doit être sur une même ligne
|
||||
# ----------------------------------------------
|
||||
{_<ol>, <ul>_}
|
||||
|
||||
{_{_Afficher un icode brut_}_}
|
||||
))
|
||||
|
||||
|
||||
#2 Un exemple de block code ayant pour classe python
|
||||
# Un exemple de block code ayant pour classe python
|
||||
# Tout contenu entre les marqueurs "{{" et "}}" est conservé
|
||||
# ----------------------------------------------------------
|
||||
#2 Block Code
|
||||
{{ python
|
||||
# Un commentaire et du code
|
||||
def hello(world):
|
||||
world and print(world) or print("NoMore")
|
||||
}}
|
||||
|
||||
#2 Citation
|
||||
|
||||
# Écrire en gras, italique...
|
||||
# ---------------------------
|
||||
#2 Marqueurs de mots
|
||||
((
|
||||
Même si, il est possible d'écrire directement des balises (HTML), Tyto
|
||||
propose de les simplifier, en entourant les mots avec des marqueurs. La
|
||||
classe CSS du domaine est utilisée pour chaque marqueur.
|
||||
|
||||
{{
|
||||
*_Très Gras_* > <strong>
|
||||
+_En Gras_+ > <b>
|
||||
[_Citer un texte_] > <q>
|
||||
:_Citer une référence_: > <cite>
|
||||
~_Texte barré_~ > <del>
|
||||
._Text souligné_. > <u>
|
||||
/_En italique_/ > <em>
|
||||
;_En italique_; > <i>
|
||||
|
||||
# Marques multiples, ajouter "&"
|
||||
*_&._Très gras et souligné_.&_*
|
||||
}}
|
||||
))
|
||||
|
||||
|
||||
# Dans un block div [[ ... ]] (classe CSS mydiv),
|
||||
# La citation entre [" ... "] (classe CSS mycite)
|
||||
# est placée dans un paragraphe (classe CSS mycite)
|
||||
# ! Tout commentaire "# ..." dans la citation sera affiché...
|
||||
# -----------------------------------------------------------
|
||||
#2 Citation
|
||||
[[ mydiv
|
||||
[" mycite
|
||||
;; A great quote here !
|
||||
|
@ -127,6 +197,7 @@ file: télécharger ce fichier
|
|||
# dans un paragraphe (classe du domaine)
|
||||
# "+" pour ol, "=" pour ul
|
||||
# Ajouter toujours un signe pour un sous-item ou /!\ au changement de signe
|
||||
# -------------------------------------------------------------------------
|
||||
#2 Une liste mixée {_<ol>, <ul>_}
|
||||
((
|
||||
<: mylist
|
||||
|
@ -138,4 +209,10 @@ file: télécharger ce fichier
|
|||
:>
|
||||
))
|
||||
|
||||
# Afficher un block code avec le contenu d'un fichier
|
||||
# Il doit avoir été configuré dans l'entête
|
||||
# -----------------------------------------
|
||||
#2 Un block code depuis un fichier
|
||||
_code:codetest
|
||||
|
||||
```
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
Package: tyto
|
||||
Version: 1.0.0
|
||||
Version: 1.9.29
|
||||
Section: custom
|
||||
Priority: optional
|
||||
Architecture: all
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
#!/usr/bin/env python3
|
||||
# Version: 1.9.28
|
||||
# Version: 1.9.29
|
||||
# Updated: 2023-10-18 1697613100
|
||||
# Tyto - Littérateur
|
||||
|
||||
|
|
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.
|
@ -33,7 +33,7 @@
|
|||
#--------------------------
|
||||
|
||||
import sys
|
||||
import langs, tyto, debug, help, new, check, userset, show
|
||||
import langs, tyto, debug, help, new, check, userset, show, wip
|
||||
|
||||
|
||||
#==================#
|
||||
|
@ -100,6 +100,7 @@ def start_process():
|
|||
"start" : userset.manage,
|
||||
"stop" : userset.manage,
|
||||
"show" : show.manage,
|
||||
"wip" : wip.manage,
|
||||
}
|
||||
|
||||
do[action](action, target)
|
||||
|
|
|
@ -77,16 +77,14 @@ def is_article(target):
|
|||
|
||||
# When all is OK
|
||||
# Will create post database, but now, show some values
|
||||
print("Final texts string")
|
||||
|
||||
for ln, line in enumerate(texts, post.head_lines + 1):
|
||||
print(">", ln, line)
|
||||
"""
|
||||
print("Final texts string:")
|
||||
print('\n'.join(texts))
|
||||
"""
|
||||
|
||||
print()
|
||||
|
||||
# Write to post database
|
||||
cf_update_values("after")
|
||||
|
||||
|
||||
|
||||
#===========================================#
|
||||
# Check full article contents (head + text) #
|
||||
|
@ -394,8 +392,9 @@ def ml_tag_values(ln, tag, stats):
|
|||
return False
|
||||
|
||||
# value1 must not starts or contains:o
|
||||
elif value1.startswith("_"):
|
||||
post.error = debug.out(56, "%s) '_...'"%(ln+1), post.uri, True, 2, False)
|
||||
elif "_" in value1:
|
||||
post.error = \
|
||||
debug.out(56, '%s) "_" : "%s"'%(ln+1, value1), post.uri, True, 2, False)
|
||||
return False
|
||||
|
||||
# Specific for image: logo name is reserved
|
||||
|
@ -442,7 +441,7 @@ def ml_tag_values(ln, tag, stats):
|
|||
post.stats_text_links += post.text_contents.count(tyto_value)
|
||||
post.cf_set("STATS_TEXTS", "links", str(post.stats_text_links))
|
||||
html_value = tyto.a_link%(
|
||||
value2, "%s link"%css, "%%s", value3, value1
|
||||
value2, "%s link"%css, value3, value1
|
||||
)
|
||||
|
||||
# file:
|
||||
|
@ -451,7 +450,7 @@ def ml_tag_values(ln, tag, stats):
|
|||
post.stats_text_files += post.text_contents.count(tyto_value)
|
||||
post.cf_set("STATS_TEXTS", "files", str(post.stats_text_files))
|
||||
html_value = tyto.a_link%(
|
||||
value2, "%s file"%css, "%%s", value3, value1
|
||||
value2, "%s file"%css, value3, value1
|
||||
)
|
||||
|
||||
# image:
|
||||
|
@ -487,7 +486,14 @@ def ml_tag_values(ln, tag, stats):
|
|||
line = tyto.code_line%(ln, line)
|
||||
htmlbcode = "%s\n%s"%(htmlbcode, line)
|
||||
|
||||
html_value = tyto.code_bcode%(css, htmlbcode)
|
||||
footer_code = '\n<footer class="bcode">\n' + \
|
||||
'<p class="bcode">\n' + \
|
||||
'<a class="bcode" href="%s" title="%s">%s</a>\n'%(
|
||||
value2, value3, "Source"
|
||||
) + \
|
||||
'</p>\n' + \
|
||||
'</footer>'
|
||||
html_value = tyto.code_bcode%(css, htmlbcode, footer_code)
|
||||
html_value = tools.b64_convert("encode", html_value)
|
||||
|
||||
# abbr:
|
||||
|
@ -587,7 +593,8 @@ def sl_ptags(markers):
|
|||
if index0 >= 0 :
|
||||
content = "%s\n%s"%(content, line)
|
||||
if markers[2] == "bcodes":
|
||||
texts[ln - 1 - post.head_lines] = ""
|
||||
if index1 != index0:
|
||||
texts[ln - 1 - post.head_lines] = ""
|
||||
|
||||
# Opened mark
|
||||
if line.lstrip().startswith(markers[0]):
|
||||
|
@ -601,9 +608,11 @@ def sl_ptags(markers):
|
|||
), post.uri, True, 2, False)
|
||||
return False
|
||||
continue
|
||||
|
||||
csstest = tools.get_css(line, markers[0], ln)
|
||||
if post.error > 0:
|
||||
return
|
||||
|
||||
index0 = line.index(markers[0][0])
|
||||
tag_ln = ln
|
||||
content = line
|
||||
|
@ -612,12 +621,14 @@ def sl_ptags(markers):
|
|||
|
||||
# Closed mark
|
||||
if line.lstrip().startswith(markers[1]):
|
||||
# But not opened
|
||||
if index0 < 0:
|
||||
post.error = \
|
||||
debug.out(53, '%s) %s: %s...'%(
|
||||
ln, markers[2], markers[0]
|
||||
), post.uri, True, 2, False)
|
||||
return False
|
||||
|
||||
index1 = line.index(markers[1][0])
|
||||
# at same position as opened
|
||||
if index1 == index0:
|
||||
|
@ -633,6 +644,10 @@ def sl_ptags(markers):
|
|||
if markers[2] in ("parags", "divs"):
|
||||
continue
|
||||
|
||||
elif markers[2] == "bcodes":
|
||||
texts[ln - 1 - post.head_lines] = \
|
||||
"%s_%s"%(markers[2][:-1], post.ptags_stats[markers[2]])
|
||||
|
||||
# Set keys, values to post database
|
||||
post.cf_set(
|
||||
markers[2].upper(),
|
||||
|
@ -726,59 +741,65 @@ def icodes():
|
|||
|
||||
if markers[0][0] in line:
|
||||
# Double mark first
|
||||
line = line.replace(markers[0][0], markers[0][4])
|
||||
line = line.replace(markers[0][1], markers[0][5])
|
||||
line = line.replace(markers[0][0], markers[0][4])
|
||||
line = line.replace(markers[0][1], markers[0][5])
|
||||
icodes = re.findall('%s(.*?)%s'%(markers[0][4], markers[0][5]), line)
|
||||
|
||||
for icode in icodes:
|
||||
stats_text_icodes += 1
|
||||
icleg = markers[0][0] + icode + markers[0][1]
|
||||
icnew = markers[0][4] + \
|
||||
tools.convert_html_signs(icode) + \
|
||||
markers[0][5]
|
||||
icrep = markers[0][4] + \
|
||||
icode + \
|
||||
markers[0][5]
|
||||
line = line.replace(icrep, "")
|
||||
line = line.replace(icrep, "icode_%s"%stats_text_icodes)
|
||||
|
||||
# Set HTML [ICODES] to post database
|
||||
html_val = icnew.replace(markers[0][4], markers[0][2]%css)
|
||||
html_val = html_val.replace(markers[0][5], markers[0][3])
|
||||
html_val = tools.b64_convert("encode", html_val)
|
||||
post.cf_set(
|
||||
"ICODES",
|
||||
"icode_%s"%stats_text_icodes,
|
||||
markers[0][0] + icode + markers[0][1]
|
||||
icleg
|
||||
)
|
||||
post.cf_set(
|
||||
"ICODES",
|
||||
"html_%s"%stats_text_icodes,
|
||||
html_val.replace(markers[0][5], markers[0][3])
|
||||
html_val
|
||||
)
|
||||
|
||||
# Single mark
|
||||
line = line.replace(markers[1][0], markers[1][4])
|
||||
line = line.replace(markers[1][1], markers[1][5])
|
||||
line = line.replace(markers[1][0], markers[1][4])
|
||||
line = line.replace(markers[1][1], markers[1][5])
|
||||
icodes = re.findall('%s(.*?)%s'%(markers[1][4], markers[1][5]), line)
|
||||
|
||||
for icode in icodes:
|
||||
stats_text_icodes += 1
|
||||
icleg = markers[1][0] + icode + markers[1][1]
|
||||
icnew = markers[1][4] + \
|
||||
tools.convert_html_signs(icode) + \
|
||||
markers[1][5]
|
||||
icrep = markers[1][4] + \
|
||||
icode + \
|
||||
markers[1][5]
|
||||
line = line.replace(icrep, "")
|
||||
line = line.replace(icrep, "icode_%s"%stats_text_icodes)
|
||||
|
||||
# Set HTML [ICODES] to post database
|
||||
html_val = icnew.replace(markers[1][4], markers[1][2]%css)
|
||||
html_val = html_val.replace(markers[1][5], markers[1][3])
|
||||
html_val = tools.b64_convert("encode", html_val)
|
||||
post.cf_set(
|
||||
"ICODES",
|
||||
"icode_%s"%stats_text_icodes,
|
||||
markers[1][0] + icode + markers[1][1]
|
||||
icleg
|
||||
)
|
||||
post.cf_set(
|
||||
"ICODES",
|
||||
"html_%s"%stats_text_icodes,
|
||||
html_val.replace(markers[1][5], markers[1][3])
|
||||
html_val
|
||||
)
|
||||
|
||||
texts[ln - 1 - post.head_lines] = line
|
||||
|
@ -850,7 +871,7 @@ def sl_stags():
|
|||
real_com = line.lstrip()[3:]
|
||||
post.cf_set(
|
||||
"COMMENTS",
|
||||
"comm_%s"%stats_html_coms,
|
||||
"comment_%s"%stats_html_coms,
|
||||
line.lstrip()
|
||||
)
|
||||
post.cf_set(
|
||||
|
@ -1098,8 +1119,13 @@ def cf_update_values(part):
|
|||
stats_tyto_all_coms > 0 and \
|
||||
post.cf_set("STATS_FILE", "tyto_coms", str(stats_tyto_all_coms))
|
||||
|
||||
# Add base64 new article TEXTS
|
||||
post.cf_set("TEXTS", "post", tools.b64_convert("encode", '\n'.join(texts)))
|
||||
|
||||
# ============================
|
||||
# Write new values in database
|
||||
# ============================
|
||||
post.cf_write()
|
||||
|
||||
# Show done message
|
||||
debug.out(254, "[%s]"%post.title[1], post.uri, True, 0, False)
|
||||
|
|
|
@ -84,6 +84,7 @@ def out(nbr, var, val, show, color, stop):
|
|||
7 : langs.logs.err_cr_file,
|
||||
8 : langs.logs.err_lang,
|
||||
9 : langs.logs.err_ini_file,
|
||||
10 : langs.logs.err_post_global,
|
||||
20 : langs.logs.err_bad_uri,
|
||||
21 : langs.logs.err_post_sep,
|
||||
22 : langs.logs.err_post_head,
|
||||
|
@ -114,6 +115,7 @@ def out(nbr, var, val, show, color, stop):
|
|||
208 : langs.logs.website_lang,
|
||||
209 : langs.logs.domain_on,
|
||||
210 : langs.logs.post_chk_yet,
|
||||
254 : langs.logs.post_chk_ready,
|
||||
255 : langs.logs.later,
|
||||
}
|
||||
|
||||
|
|
|
@ -122,12 +122,6 @@ def is_tyto_format():
|
|||
if not separator:
|
||||
error = debug.out(21, sep, uri, True, 2, False)
|
||||
return False
|
||||
|
||||
print("===")
|
||||
print(head_contents)
|
||||
print("===")
|
||||
print(text_contents)
|
||||
print("===")
|
||||
|
||||
if not head_contents:
|
||||
error = debug.out(22, "?", uri, True, 2, False)
|
||||
|
@ -209,20 +203,22 @@ def cf_datas():
|
|||
def compare_datas():
|
||||
global do_chk, do_wip
|
||||
|
||||
# check can be done ?
|
||||
do_chk = False
|
||||
|
||||
if chk_errors:
|
||||
if chk_errors or \
|
||||
chk_static != domain.static or \
|
||||
args.force == True:
|
||||
do_chk = True
|
||||
do_wip = False
|
||||
|
||||
if chk_static != domain.static:
|
||||
do_chk = True
|
||||
|
||||
if args.force:
|
||||
do_chk = do_wip = True
|
||||
|
||||
else:
|
||||
do_chk = tools.compare_values(wrk_id, chk_hash)
|
||||
|
||||
|
||||
# wip can be done
|
||||
do_wip = False
|
||||
if wip_static != domain.static or \
|
||||
args.force:
|
||||
do_wip = True
|
||||
else:
|
||||
do_wip = tools.compare_values(chk_hash, wip_hash)
|
||||
|
||||
|
||||
|
@ -388,13 +384,13 @@ html_titles = {
|
|||
"#5" : '<h6 class="%s">%s</h6>',
|
||||
}
|
||||
|
||||
html_brline = ("|", '<br class="%s%s">')
|
||||
html_hrline = ("--", '<hr class="%s%s">')
|
||||
html_brline = ("|", '<br class="%s">')
|
||||
html_hrline = ("--", '<hr class="%s">')
|
||||
text_comments = (";;", "<!--")
|
||||
anchor_target = ("->", '<a id="%s" class="anchor_target"></a>')
|
||||
anchor_link = (">_", "_<")
|
||||
anchor_set = (">_%s_<", '<a class="%s anchor_link" href="#%s">%s</a>')
|
||||
quote_metas = ("cite:", "date:", "book:", "lang:", "link:")
|
||||
quote_metas = ("cite:", "date:", "book:", "lang:", "link:")
|
||||
|
||||
# Words tags
|
||||
words_tags = (
|
||||
|
@ -408,6 +404,8 @@ words_tags = (
|
|||
(";_", "_;", "italics", '<i class="%s">', '</i>'),
|
||||
)
|
||||
|
||||
words_ml_tag = "&"
|
||||
|
||||
# Specifics convertion
|
||||
words_markers = \
|
||||
(
|
||||
|
@ -425,6 +423,8 @@ ini_template = """[DOMAIN]
|
|||
|
||||
[HEADERS]
|
||||
|
||||
[TEXTS]
|
||||
|
||||
[CHECK]
|
||||
|
||||
[WIP]
|
||||
|
|
|
@ -34,9 +34,7 @@
|
|||
|
||||
from hashlib import blake2b
|
||||
import sys, os, configparser, datetime, time, base64
|
||||
import debug, domain, post
|
||||
|
||||
import post
|
||||
import args, debug, domain, post
|
||||
|
||||
|
||||
#=========================================#
|
||||
|
@ -211,9 +209,9 @@ def get_css(line, mark, ln):
|
|||
css = css or domain.css
|
||||
|
||||
# Tyto use _abc as markers
|
||||
if css.startswith("_"):
|
||||
if "_" in css:
|
||||
post.error = \
|
||||
debug.out(56, '%s) CSS: "%s"'%(ln, css), post.uri, True, 2, False)
|
||||
debug.out(56, '%s) (CSS) "_" : "%s"'%(ln, css), post.uri, True, 2, False)
|
||||
return "NameError"
|
||||
|
||||
return css
|
||||
|
@ -223,12 +221,17 @@ def get_css(line, mark, ln):
|
|||
# Compare 2 values #
|
||||
# used for hashes and more... #
|
||||
# return True if not same values #
|
||||
# ex: do_wip = True #
|
||||
# ex: do_chk = True #
|
||||
# (as chk_hash and wip_hash are different) #
|
||||
#------------------------------------------#
|
||||
def compare_values(val1, val2):
|
||||
if val1 != val2:
|
||||
return True
|
||||
# Mainly for check comparison values
|
||||
if args.action == "check":
|
||||
if val1 != val2:
|
||||
return True
|
||||
|
||||
# Others, like wip, publish
|
||||
else:
|
||||
if val1 == val2: return True
|
||||
|
||||
return False
|
||||
|
||||
|
|
|
@ -98,7 +98,7 @@ notarget = ("./", "../")
|
|||
# HTML #=======================================================================
|
||||
#======#
|
||||
code_bcode = """<code class="%s bcode">
|
||||
%s
|
||||
%s%s
|
||||
</code>"""
|
||||
|
||||
code_line = '<p class="bcode">' + \
|
||||
|
@ -107,7 +107,7 @@ code_line = '<p class="bcode">' + \
|
|||
'</p>'
|
||||
|
||||
image_link = '<a href="%s" class="%s" target="%s" alt="%s" title="%s">%s</a>'
|
||||
a_link = '<a href="%s" class="%s" target="%s" title="%s">%s</a>'
|
||||
a_link = '<a href="%s" class="%s" title="%s">%s</a>'
|
||||
|
||||
quote = """<blockquote class="%s"%s%s%s>%s
|
||||
%s%s
|
||||
|
|
|
@ -35,7 +35,209 @@
|
|||
# file program :
|
||||
#--------------------------
|
||||
|
||||
import tyto, tools, post, domain
|
||||
import sys
|
||||
import args, debug, tyto, tools, post, domain
|
||||
|
||||
|
||||
#=====================================#
|
||||
# Check domain #
|
||||
# Load domain configuration file #
|
||||
# Update it if needed, and set values #
|
||||
# Load website lang #
|
||||
# Domain must be activated #
|
||||
#-------------------------------------#
|
||||
def ready():
|
||||
domain.cf_update_values(False)
|
||||
domain.ready()
|
||||
|
||||
|
||||
#=========================================#
|
||||
# Manage argument from command line "wip" #
|
||||
# Domain must be valid to proceed #
|
||||
# Create user work domain directories #
|
||||
#-----------------------------------------#
|
||||
def manage(action, target):
|
||||
# target is "all"
|
||||
if args.targets:
|
||||
multiple_targets()
|
||||
return
|
||||
|
||||
# target is not "all"
|
||||
ready()
|
||||
target.endswith(".tyto") and is_article(target)
|
||||
|
||||
|
||||
#===========================================#
|
||||
# Create a loop to get all .tyto articles #
|
||||
#-------------------------------------------#
|
||||
def multiple_targets():
|
||||
ready()
|
||||
post.find_tyto_article()
|
||||
|
||||
|
||||
#================================#
|
||||
# Check article(S) #
|
||||
# Also used with multiple (loop) #
|
||||
#--------------------------------#
|
||||
def is_article(target):
|
||||
if not convert(target) or post.error != 0:
|
||||
if targets: return
|
||||
else: sys.exit(post.error)
|
||||
|
||||
print("> wip:", target)
|
||||
print(html_post)
|
||||
|
||||
|
||||
#===========================================#
|
||||
# Check full article contents (head + text) #
|
||||
# In error case, exit or return if targetS #
|
||||
#-------------------------------------------#
|
||||
def convert(target):
|
||||
global targets, raw_post
|
||||
targets = args.targets
|
||||
|
||||
# Target is a tyto article format
|
||||
if not post.is_article(target):
|
||||
return False
|
||||
|
||||
# Article has errors
|
||||
if post.chk_errors:
|
||||
post.error = debug.out(10, "'check'", post.uri, True, 2, False)
|
||||
return False
|
||||
|
||||
# Get raw post from database
|
||||
raw_post = tools.b64_convert("decode", post.cf.get("TEXTS", "post"))
|
||||
|
||||
# words_tags
|
||||
clean_post()
|
||||
value_replace("QUOTES", True, True)
|
||||
value_replace("LISTS", True, True)
|
||||
value_replace("ANCHORS", False, False)
|
||||
value_replace("TITLES", False, False)
|
||||
value_replace("LINKS", False, False)
|
||||
value_replace("FILES", False, False)
|
||||
|
||||
words_tags()
|
||||
sl_tags()
|
||||
|
||||
value_replace("COMMENTS", False, False)
|
||||
value_replace("ABBRS", False, False)
|
||||
|
||||
value_replace("ICODES", False, True)
|
||||
value_replace("BCODES", False, True)
|
||||
value_replace("CODES", False, True)
|
||||
|
||||
return True
|
||||
|
||||
|
||||
#==========================================================#
|
||||
# Generic function that replace source text with HTML text #
|
||||
#----------------------------------------------------------#
|
||||
def text_replace(src, html):
|
||||
global html_post
|
||||
|
||||
html_post = html_post.replace(src, html)
|
||||
|
||||
|
||||
#==========================================#
|
||||
# Generic function that: #
|
||||
# - get key_X, html_X in post DB #
|
||||
# - replace key_X with html_X in html_post #
|
||||
# srv_b64 : True to decode base64 source #
|
||||
# tgt_b64 : True to decode base64 target # #
|
||||
#------------------------------------------#
|
||||
def value_replace(section, src_b64, tgt_b64):
|
||||
for key, val in post.cf.items(section):
|
||||
if key.startswith("html_"):
|
||||
continue
|
||||
|
||||
if section == "BCODES" or section == "ICODES":
|
||||
val = key
|
||||
|
||||
# val is base64 string
|
||||
if src_b64:
|
||||
val = tools.b64_convert("decode", val)
|
||||
|
||||
# Get target value by replacing key with html
|
||||
html_key = key.replace(section.lower()[:-1], "html")
|
||||
html_val = post.cf.get(section, html_key)
|
||||
|
||||
# target val is base64 string
|
||||
if tgt_b64:
|
||||
html_val = tools.b64_convert("decode", html_val)
|
||||
|
||||
# Replace in html_post src value with html_value
|
||||
text_replace(val, html_val)
|
||||
|
||||
|
||||
#========================================#
|
||||
# Clean article texts #
|
||||
# (remove empty lines and tyto comments) #
|
||||
#----------------------------------------#
|
||||
def clean_post():
|
||||
global html_post
|
||||
html_post = "<!-- Article Text: [%s] -->"%post.cf.get("HEADERS", "title")
|
||||
|
||||
for line in raw_post.rsplit("\n"):
|
||||
# Line is empty
|
||||
if not line or line == " ":
|
||||
continue
|
||||
|
||||
# Line is a tyto comment or tyto title
|
||||
if line.lstrip().startswith("#") and \
|
||||
not line.lstrip().startswith(post.tyto_titles):
|
||||
continue
|
||||
|
||||
html_post = "%s\n%s"%(html_post, line)
|
||||
|
||||
|
||||
#============================#
|
||||
# Convert words tags to HTML #
|
||||
#----------------------------#
|
||||
def words_tags():
|
||||
for tags in post.words_tags:
|
||||
text_replace(tags[0], tags[3]%domain.css) # Opened tag
|
||||
text_replace(tags[1], tags[4]) # closed tag
|
||||
text_replace(">%s<"%post.words_ml_tag, "><") # multiple tags for words
|
||||
|
||||
|
||||
#=========================#
|
||||
# Convert Start line tags #
|
||||
# anchors, paragraphs... #
|
||||
#-------------------------#
|
||||
def sl_tags():
|
||||
for line in html_post.rsplit("\n"):
|
||||
css = ""
|
||||
|
||||
# Paragraphs
|
||||
if line.lstrip().startswith(post.ptags[2][0]):
|
||||
css = tools.get_css(line, post.ptags[2][0], "?")
|
||||
text_replace(line, post.ptags[2][3]%css)
|
||||
elif line.lstrip().startswith(post.ptags[2][1]):
|
||||
text_replace(line, post.ptags[2][4])
|
||||
|
||||
# DIVs
|
||||
if line.lstrip().startswith(post.ptags[4][0]):
|
||||
css = tools.get_css(line, post.ptags[4][0], "?")
|
||||
text_replace(line, post.ptags[4][3]%css)
|
||||
elif line.lstrip().startswith(post.ptags[4][1]):
|
||||
text_replace(line, post.ptags[4][4])
|
||||
|
||||
# <br>
|
||||
elif line.lstrip().startswith(post.html_brline[0]):
|
||||
css = tools.get_css(line, post.html_brline[0][0], "?")
|
||||
text_replace(line, post.html_brline[1]%css)
|
||||
|
||||
# <hr>
|
||||
elif line.lstrip().startswith(post.html_hrline[0]):
|
||||
css = tools.get_css(line, post.html_hrline[0][0], "?")
|
||||
text_replace(line, post.html_hrline[1]%css)
|
||||
|
||||
|
||||
# Anchors
|
||||
elif line.lstrip().startswith(post.anchor_target[0]):
|
||||
css = tools.get_css(line, post.anchor_target[0], "?")
|
||||
text_replace(line, post.anchor_target[1]%css)
|
||||
|
||||
|
||||
#=========================================================#
|
||||
|
@ -69,7 +271,7 @@ def bcode(lines, ln):
|
|||
if not html_bcode: html_bcode = line
|
||||
else: html_bcode = "%s\n%s"%(html_bcode, line)
|
||||
|
||||
html_bcode = tyto.code_bcode%(css, html_bcode)
|
||||
html_bcode = tyto.code_bcode%(css, html_bcode, "")
|
||||
|
||||
post.cf_set("STATS_TEXTS", "bcodes_lines", str(post.stats_bcodes_lines))
|
||||
|
||||
|
@ -170,8 +372,6 @@ def quote(lines, ln):
|
|||
footer
|
||||
)
|
||||
|
||||
#print(html_quote)
|
||||
|
||||
return html_quote
|
||||
|
||||
|
||||
|
@ -287,21 +487,7 @@ def convert_list(markdown_str, mark_b, mark_c):
|
|||
return work_str
|
||||
|
||||
|
||||
#=========================#
|
||||
# WIP process #====================================================
|
||||
# Convert article to HTML #
|
||||
# Create new file #
|
||||
#-------------------------#
|
||||
|
||||
#============================#
|
||||
# code #
|
||||
# Used by check module that #
|
||||
# convert file lines to HTML #
|
||||
#----------------------------#
|
||||
def code(lines):
|
||||
print("soon...")
|
||||
|
||||
|
||||
"""
|
||||
#
|
||||
# Not Yet done, soon...
|
||||
#
|
||||
|
@ -312,3 +498,4 @@ def paragraphs():
|
|||
html_quote = "%s\n%s"%(html_quote, post.ptags[2][3]%p_css)
|
||||
elif line.startswith(post.ptags[2][1]):
|
||||
html_quote = "%s\n%s"%(html_quote, post.ptags[2][4])
|
||||
"""
|
||||
|
|
Binary file not shown.
|
@ -33,6 +33,66 @@
|
|||
# Réponses valides (! NON sensible à la case : oui = OUI, Oui...)
|
||||
ok = ("yes", "y")
|
||||
|
||||
# Form
|
||||
q = " ?"
|
||||
configure_domain = "Configure domain"
|
||||
domain_title = "Domain title"
|
||||
domain_date = "Creation date"
|
||||
domain_about = "Domain description"
|
||||
domain_mail = "Admin mail"
|
||||
domain_tags = "Domain tags [1,2,3]"
|
||||
domain_lang = "Website lang"
|
||||
domain_srv = "Server URI"
|
||||
|
||||
# Misc
|
||||
anchor_title = "Anchor title"
|
||||
|
||||
# logs for debug
|
||||
#---------------
|
||||
# Errors
|
||||
err_arg = "Argument error"
|
||||
err_hole = "Current directory error"
|
||||
err_date = "Date error"
|
||||
err_lang = "Lang error"
|
||||
err_dir = "Directory error"
|
||||
err_no_dir = "Directory unused"
|
||||
err_cd = "Directory not created"
|
||||
err_no_file = "File unused"
|
||||
err_cr_file = "File not created"
|
||||
err_bad_uri = "URI error"
|
||||
err_post_sep = "Separator unused"
|
||||
err_post_head = "Header is empty"
|
||||
err_post_empty = "Article is empty"
|
||||
err_ini_file = "Configuration error"
|
||||
err_post_data = "Data unused"
|
||||
err_post_title = "Title error"
|
||||
err_post_paired = "Markers not paired"
|
||||
err_post_in_tag = "Markers without contents"
|
||||
err_post_datatag= "Data reserved"
|
||||
err_post_id_yet = "ID used yet"
|
||||
err_post_global = "Article Error"
|
||||
|
||||
# Warnings
|
||||
warn_no_dom = "Domain not configured"
|
||||
domain_off = "Domain deactivated"
|
||||
reset_dom = "RESET domain"
|
||||
|
||||
# infos
|
||||
load_file = "File loaded"
|
||||
lang_logs_sys = "Logs lang"
|
||||
website_lang = "Website lang"
|
||||
domains_no = "Domain not found"
|
||||
domain_found = "Domain exists"
|
||||
domain_on = "Domain activated"
|
||||
domain_created = "Domain updated yet"
|
||||
domain_updated = "Domain updated"
|
||||
domain_new = "Domain created"
|
||||
created_dir = "Directory created"
|
||||
created_file = "File created"
|
||||
updated_file = "File Updated"
|
||||
post_chk_yet = "Article checked yet"
|
||||
post_chk_ready = "Article checked"
|
||||
later = "Maybe later..."
|
||||
|
||||
#
|
||||
# Show HELP
|
||||
|
@ -44,6 +104,7 @@ tyto [action] [target] [options]
|
|||
set : set website lang, domain values (title, server...)
|
||||
start : activate domain (default "no" when created)
|
||||
stop : deactivate domain
|
||||
show : [domains]
|
||||
check :
|
||||
wip :
|
||||
publish :
|
||||
|
|
|
@ -40,7 +40,7 @@ domain_title = "Titre du domaine"
|
|||
domain_date = "Date de création"
|
||||
domain_about = "Description du domaine"
|
||||
domain_mail = "Courriel de l'administration"
|
||||
domain_tags = "Mots-clés génériques [1,2,3]"
|
||||
domain_tags = "Mots-clés du domaine [1,2,3]"
|
||||
domain_lang = "Langue du site web"
|
||||
domain_srv = "URI du serveur"
|
||||
|
||||
|
@ -70,6 +70,7 @@ err_post_paired = "Marqueurs non apairés"
|
|||
err_post_in_tag = "Marqueurs sans contenu"
|
||||
err_post_datatag= "Donnée réservée"
|
||||
err_post_id_yet = "Identité déjà utilisée"
|
||||
err_post_global = "Article erronné"
|
||||
|
||||
# Warnings
|
||||
warn_no_dom = "Domaine non configuré"
|
||||
|
@ -77,7 +78,7 @@ domain_off = "Domaine désactivé"
|
|||
reset_dom = "RÉINITIALISE le domaine"
|
||||
|
||||
# infos
|
||||
load_file = "Chargement du fichier"
|
||||
load_file = "Fichier chargé"
|
||||
lang_logs_sys = "Langue des logs"
|
||||
website_lang = "Langue du site web"
|
||||
domains_no = "Aucun domaine trouvé"
|
||||
|
@ -90,10 +91,9 @@ created_dir = "Dossier créé"
|
|||
created_file = "Fichier créé"
|
||||
updated_file = "Fichier mis à jour"
|
||||
post_chk_yet = "Article déjà vérifié"
|
||||
post_chk_ready = "Article vérifié"
|
||||
later = "Peut-être plus tard..."
|
||||
|
||||
|
||||
|
||||
#
|
||||
# Show HELP
|
||||
#
|
||||
|
|
Loading…
Reference in New Issue