[1.9.30] - 'wip' about all HTML markers done

This commit is contained in:
Cyrille L 2023-11-02 15:32:13 +01:00
parent 84abcb5e92
commit d7242c6452
17 changed files with 274 additions and 17 deletions

View File

@ -10,6 +10,10 @@ Tyto - Littérateur
# CURRENTLY IN DEV (in devel branch) !
## [1.9.30]
- 'wip' process
- - About all markers done !
## [1.9.29]
- Translations
- - added for logs (english)

158
README.md
View File

@ -6,13 +6,15 @@ This program can ve tested but not at all usable. Lots of work to do...
# Get commands list help
tyto
```
# Create new domain
- create a domain directory, line www.domain.tld
- Go to this directory
- type `tyto new domain`
## ToDo next (working on)
- added lists to post database (prepared wip)
## Working on
- 'wip' action processes
- - images module
- Create HTML full page from article
## ToDo
- thinking about creating an auto top article menu from titles
@ -43,13 +45,14 @@ date: 2023-10-27
# 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
logo: logo.png
# Données multiples sur 3 lignes
# [TAG]: Nom
# LIEN
# Text alternatif
# Reprendre dans l'article : __cliquer sur ce lien
link: cliquer sur ce Lien
https://
Text alternatif
@ -58,21 +61,29 @@ link: Réservez ici
https://
Billets
# Reprendre dans l'article : --télécharger ce fichier
file: télécharger ce fichier
@/PDFs/hello.pdf
Un PDF !
# Reprendre dans l'article : _code:codetest
code: codetest
@RAWS/test.py
Exemple d'un code Python
# Reprendre dans l'article : _image:mypic
image: mypic
@hello.png
Text Alt
# 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
# Reprendre dans l'article : ;;css
abbr: css
Cascading Stylesheet
CSS
@ -215,4 +226,141 @@ abbr: css
#2 Un block code depuis un fichier
_code:codetest
# Afficher une image (1 tag par ligne)
# ------------------------------------
#2 Les images
# Placer le logo de l'article
_image:logo
# Marqueur avec options
# ! Les images dans cet exemple sont affichées à la suite
# Placer "|", ou mettez une image dans un paragraphe "((...))"
# ou appliquer un style css de type display:block
# les options des marqueurs:
# - c=CLASS < Sinon la classe est celle du domaine
# - w=WIDTH < longueur (si pas d'unité : défaut "px")
# - h=HEIGHT < Comme w=
# - f=Ma légende sous l'image (ajoute <figure><figcaption>)
# - - Recommandé d'utiliser cette option en dernier
((
_image:mypic
_image:mypic c=MYCSS
_image:mypic c=PIC w=60em h=30% f=echolib sur une chaise
))
```
## Output HTML
```
<!-- Article Text: [tests d'un article] -->
<!-- Commentaire -->
<a id="uniq1" class="anchor_target"></a>
<a id="top" class="anchor_target"></a>
<a class="tyto anchor_link" href="#uniq1">Go to uniq1 anchor</a>
<hr class="tyto">
<h2 class="tyto">Titre en h2</h2>
<p class="mypar">
Un long paragraphe...
<br class="brcss">
Il faut <a href="https://" class="tyto link" title="Text alternatif">cliquer sur ce Lien</a>, <a href="https://" class="tyto link" title="Billets">Réservez ici</a> et <a href="/files/PDFs/hello.pdf" class="tyto file" title="Un PDF !">télécharger ce fichier</a>
ou encore faire une <abbr class="tyto" title="Cascading Stylesheet">CSS</abbr> pour du beau rendu <abbr class="tyto" title="HuperText Markup Langage">HTML</abbr>
<p class="tyto">
Un <em class="tyto">court</em> paragraphe de <cite class="tyto">1984</cite> pour de <del class="tyto">vrai</del> <b class="tyto">faux en gras</b>
Il faut le <u class="tyto">souligner</u> et <strong class="tyto">Très Gras</strong>
</p>
<code class="tyto icode">&lt;ol&gt;, &lt;ul&gt;</code>
<code class="tyto icode">{_Afficher un icode brut_}</code>
</p>
<h3 class="tyto">Block Code</h3>
<code class="python bcode">
<p class="bcode"><span class="ln bcode">1</span><span class="line bcode"># Un commentaire et du code</span></p>
<p class="bcode"><span class="ln bcode">2</span><span class="line bcode">def hello(world):</span></p>
<p class="bcode"><span class="ln bcode">3</span><span class="line bcode"> world and print(world) or print(&quot;NoMore&quot;)</span></p>
</code>
<h3 class="tyto">Marqueurs de mots</h3>
<p class="tyto">
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.
<code class="tyto bcode">
<p class="bcode"><span class="ln bcode">1</span><span class="line bcode">*_Très Gras_* &gt; &lt;strong&gt;</span></p>
<p class="bcode"><span class="ln bcode">2</span><span class="line bcode">+_En Gras_+ &gt; &lt;b&gt;</span></p>
<p class="bcode"><span class="ln bcode">3</span><span class="line bcode">[_Citer un texte_] &gt; &lt;q&gt;</span></p>
<p class="bcode"><span class="ln bcode">4</span><span class="line bcode">:_Citer une référence_: &gt; &lt;cite&gt;</span></p>
<p class="bcode"><span class="ln bcode">5</span><span class="line bcode">~_Texte barré_~ &gt; &lt;del&gt;</span></p>
<p class="bcode"><span class="ln bcode">6</span><span class="line bcode">._Text souligné_. &gt; &lt;u&gt;</span></p>
<p class="bcode"><span class="ln bcode">7</span><span class="line bcode">/_En italique_/ &gt; &lt;em&gt;</span></p>
<p class="bcode"><span class="ln bcode">8</span><span class="line bcode">;_En italique_; &gt; &lt;i&gt;</span></p>
<p class="bcode"><span class="ln bcode">9</span><span class="line bcode"></span></p>
<p class="bcode"><span class="ln bcode">10</span><span class="line bcode"># Marques multiples, ajouter &quot;&&quot;</span></p>
<p class="bcode"><span class="ln bcode">11</span><span class="line bcode">*_&._Très gras et souligné_.&_*</span></p>
</code>
</p>
<h3 class="tyto">Citation</h3>
<div class="mydiv">
<blockquote class="mycite" cite="https://..." lang="en" title="-- Someone - A History (2023-10-13)">
<time datetime="2023-10-13">
<!-- Quote -->
<!-- A great quote here ! -->
<p class="tyto"> mycite
Here, i am
</p>
</time>
<footer class="quote">
<p class="quote"><a class="tyto quote" href="https://..." target="_blank">-- Someone - <cite class="quote"> - A History</cite> (2023-10-13)</a></p>
</footer>
</blockquote>
</div>
<h3 class="tyto">Une liste mixée <code class="tyto icode">&lt;ol&gt;, &lt;ul&gt;</code></h3>
<p class="tyto">
<ol class="mylist">
<li class="mylist">numeric o: item 1</li>
<ol>
<li class="mylist">numeric ol sub-Item 1</li>
<ol>
<li class="mylist">numeric ol sub-sub-item 1</li>
<ul>
<li class="mylist">ul item <a class="tyto anchor_link" href="#top">Go to Top</a></li>
<li class="mylist">ul item <a class="tyto anchor_link" href="#top">Another anchor</a></li>
</ul>
</ol>
</ol>
</ol>
</p>
<h3 class="tyto">Un block code depuis un fichier</h3>
<code class="tyto bcode">
<!-- Exemple d'un code Python -->
<p class="bcode"><span class="ln bcode">1</span><span class="line bcode">#================================#</span></p>
<p class="bcode"><span class="ln bcode">2</span><span class="line bcode"># Searching options in arguments #</span></p>
<p class="bcode"><span class="ln bcode">3</span><span class="line bcode">#--------------------------------#</span></p>
<p class="bcode"><span class="ln bcode">4</span><span class="line bcode">def get_options():</span></p>
<p class="bcode"><span class="ln bcode">5</span><span class="line bcode"> global dlogs, force, erron</span></p>
<p class="bcode"><span class="ln bcode">6</span><span class="line bcode"> </span></p>
<p class="bcode"><span class="ln bcode">7</span><span class="line bcode"> dlogs = force = erron = False</span></p>
<p class="bcode"><span class="ln bcode">8</span><span class="line bcode"> for arg in range(1, len(sys.argv)):</span></p>
<p class="bcode"><span class="ln bcode">9</span><span class="line bcode"> dlogs = sys.argv[arg] in tyto.debug_options</span></p>
<p class="bcode"><span class="ln bcode">10</span><span class="line bcode"> force = sys.argv[arg] in tyto.force_options</span></p>
<p class="bcode"><span class="ln bcode">11</span><span class="line bcode"> erron = sys.argv[arg] in tyto.debug_errors</span></p>
<p class="bcode"><span class="ln bcode">12</span><span class="line bcode"> </span></p>
<p class="bcode"><span class="ln bcode">13</span><span class="line bcode"> print(&quot;&lt;li&gt;my &apos;cafe !&lt;/li&gt;&quot;)</span></p>
<p class="bcode"><span class="ln bcode">14</span><span class="line bcode"></span></p>
<footer class="bcode">
<p class="bcode">
<a class="bcode" href="/files/RAWS/test.py" title="Exemple d'un code Python">Source</a>
</p>
</footer>
</code>
<h3 class="tyto">Les images</h3>
<a href="logo.png" class="post_logo image" title="tests d'un article"><img src="logo.png" class="post_logo" alt="tests d'un article" title="tests d'un article"></a>
<p class="tyto">
<a href="/images/hello.png" class="tyto image" title="Text Alt"><img src="/images/hello.png" class="tyto" alt="Text Alt" title="Text Alt"></a>
<a href="/images/hello.png" class="MYCSS image" title="Text Alt"><img src="/images/hello.png" class="MYCSS" alt="Text Alt" title="Text Alt"></a>
<a href="/images/hello.png" class="PIC image" title="Text Alt"><figure class="PIC"><img src="/images/hello.png" class="PIC" alt="Text Alt" title="Text Alt" style="width:60em;height:30%;"><figcaption class="PIC">echolib sur une chaise</figcaption></a>
</p>
```

2
debian/control vendored
View File

@ -1,5 +1,5 @@
Package: tyto
Version: 1.9.29
Version: 1.9.30
Section: custom
Priority: optional
Architecture: all

View File

@ -1,5 +1,5 @@
#!/usr/bin/env python3
# Version: 1.9.29
# Version: 1.9.30
# Updated: 2023-10-18 1697613100
# Tyto - Littérateur

View File

@ -459,8 +459,8 @@ def ml_tag_values(ln, tag, stats):
post.stats_text_images += post.text_contents.count(tyto_value)
post.cf_set("STATS_TEXTS", "images", str(post.stats_text_images))
html_value = tyto.image_link%(
value2, "%%s image", "%%s",
value3, value3, "%%s"
value2, "%%s image", value3,
"%%s", value2, "%%s", value3, value3, "%%s", "%%s"
)
# raw: (content file converted to base64)
@ -893,8 +893,9 @@ def sl_stags():
"IMAGES",
"html_%s"%(post.ml_tags_stats["image:"] + 1),
tyto.image_link%(
post.logo[1], "post_logo image", "%%s",
post.title[1], post.title[1], "%%s"
post.logo[1], "%%s image", post.title[1],
"%%s", post.logo[1], "%%s", post.title[1], post.title[1],
"%%s", "%%s"
)
)

View File

@ -103,6 +103,7 @@ def out(nbr, var, val, show, color, stop):
103 : langs.logs.website_lang,
104 : langs.logs.domains_no,
105 : langs.logs.domain_off,
106 : langs.logs.warn_post_chk,
# Great (200-255)
200 : langs.logs.load_file,
201 : langs.logs.lang_logs_sys,

View File

@ -201,9 +201,13 @@ def cf_datas():
# Used to do processes (mainly) #
#-------------------------------#
def compare_datas():
global do_chk, do_wip
global do_chk, do_wip, has_changed
# check can be done ?
has_changed = False
if wrk_id != chk_hash:
has_changed = True
do_chk = False
if chk_errors or \
chk_static != domain.static or \

View File

@ -106,10 +106,13 @@ code_line = '<p class="bcode">' + \
'<span class="line bcode">%s</span>' +\
'</p>'
image_link = '<a href="%s" class="%s" target="%s" alt="%s" title="%s">%s</a>'
image_link = '<a href="%s" class="%s" title="%s">' + \
'%s<img src="%s" class="%s" alt="%s" title="%s"%s>' + \
'%s</a>'
a_link = '<a href="%s" class="%s" title="%s">%s</a>'
quote = """<blockquote class="%s"%s%s%s>%s
%s%s
%s
</blockquote>"""

View File

@ -84,7 +84,7 @@ def is_article(target):
if targets: return
else: sys.exit(post.error)
print("> wip:", target)
print("\n> wip:", target)
print(html_post)
@ -105,6 +105,10 @@ def convert(target):
post.error = debug.out(10, "'check'", post.uri, True, 2, False)
return False
if post.has_changed and not args.force:
post.error = debug.out(106, "'check'", post.uri, True, 1,False)
return False
# Get raw post from database
raw_post = tools.b64_convert("decode", post.cf.get("TEXTS", "post"))
@ -119,6 +123,7 @@ def convert(target):
words_tags()
sl_tags()
images()
value_replace("COMMENTS", False, False)
value_replace("ABBRS", False, False)
@ -240,6 +245,95 @@ def sl_tags():
text_replace(line, post.anchor_target[1]%css)
#
#
#
def split_size(size):
tup_size= (
''.join(filter(str.isdigit, size)) or "",
''.join(c for c in size if not c.isdigit()) or "px"
)
if not tup_size[0]:
return ""
return tup_size[0] + tup_size[1]
#=============================#
# Convert images tags to HTML #
#-----------------------------#
def images():
global html_post
for key, val in post.cf.items("IMAGES"):
if key.startswith("html"):
continue
# Get target value by replacing key with html
html_key = key.replace("image", "html")
html_val = post.cf.get("IMAGES", html_key)
# Search tag from val in html_post
for ln, line in enumerate(html_post.rsplit("\n")):
if line.lstrip().startswith(val):
css = domain.css
width = height = figure = figcap_o = figcap_c = style = ""
options = line.split()
markers = ('c=', 'w=', 'h=','f=')
# Specific CSS class for _image:logo
if options[0].rsplit(":")[1] == "logo":
css = "post_logo"
for option in options:
# <figure> was activated with f=
if figure and not option.startswith(markers):
figure = "%s %s"%(figure, option)
# CSS (default domain css)
try: css = option.rsplit("c=")[1]
except: pass
# >idth:
try:
width = option.rsplit("w=")[1]
width = split_size(width)
print("wip: size =", width)
except:
pass
# Height
try:
height = option.rsplit("h=")[1]
height = split_size(height)
print("wip: size =", height)
except:
pass
try: figure = option.rsplit("f=")[1]
except: pass
# <figure is set
if figure:
figcap_o = '<figure class="%s">'%css
figcap_c = '<figcaption class="%s">%s</figcaption>'%(css, figure)
# Width + height:
if width and height:
style = ' style="width:%s;height:%s;"'%(width, height)
elif width:
style = ' style="width:%s;"'%width
elif height:
style = ' style="height:%s;"'%height
html_post = \
html_post.replace(
html_post.rsplit("\n")[ln],
html_val%(css, figcap_o, css, style, figcap_c)
)
#=========================================================#
# Prepared HTML datas in post Database at 'check' process #====================
# Return new string to be converted to one line base64 #

View File

@ -76,6 +76,7 @@ err_post_global = "Article Error"
warn_no_dom = "Domain not configured"
domain_off = "Domain deactivated"
reset_dom = "RESET domain"
warn_post_chk = "Article changed"
# infos
load_file = "File loaded"

View File

@ -73,9 +73,10 @@ err_post_id_yet = "Identité déjà utilisée"
err_post_global = "Article erronné"
# Warnings
warn_no_dom = "Domaine non configuré"
domain_off = "Domaine désactivé"
reset_dom = "RÉINITIALISE le domaine"
warn_no_dom = "Domaine non configuré"
domain_off = "Domaine désactivé"
reset_dom = "RÉINITIALISE le domaine"
warn_post_chk = "Article modifié"
# infos
load_file = "Fichier chargé"