This commit is contained in:
Cyrille L 2023-04-16 16:42:31 +02:00
parent 1113b2da9f
commit 4df098260a
21 changed files with 335 additions and 212 deletions

View File

@ -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 <div> markers: `<<`, `>>`
- Add new container <div> in footer
- Better status display for article
- fix lang setting
- fix for less warnings in HTML validity
## [0.9.1]
- wip: tabulation when using `<hr />`
- wip: inline quote markers `@_myquote_@`

View File

@ -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 <div> 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
<h1 class="title_1">Titre 1</h1>
<div class="content_title">
Contenu 1
</div>
<h2 class="title_2">Titre 2</h2>
<h3 class="title_3">Titre 3</h3>
<div class="content_title">
contenu 2
</div>
<h4 class="title_4">Titre 4</h4>
### 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
<a href="id2"></a>
# Source de l'ancre d'appel
# Définir l'identité cible et le texte du lien
((
>_id:Retourner au point d'ancre id_<
))
# HTML
<a class="anchor" href="#id">Retourner au point d'ancre id</a>
```
### 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_* # <strong>
+_gras léger_+ # <b>
/_en italique_/ # <em>
[_en italique_] # <i>
:_en italique_: # <i>
~_texte barré_~ # <del>
:_Citation rapide_: # <cite>
@_Citation rapide_@ # <cite>
%_Classe personnalisée_% >>> <span class="custom">
._Souligné_. # <u>
{_Code_} # <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
<figure class="CSS_TEST">
<blockquote class="CSS_TEST" lang="fr" cite="https://tyto.echolib.re" title="echolib - Reference (2022-12-28)">
<time datetime="2022-12-28">
<p class="tyto">
Pfff, vraiment !
</p>
</time>
</blockquote>
<figcaption class="CSS_TEST">
<a class="figc" href="https://tyto.echolib.re">echolib - Reference (2022-12-28)</a>
</figcaption>
</figure>
````
```
# Source: citation basique
[[
Une citation simple, et sans paragraphe
]]
# HTML
<blockquote class="tyto">
Une citation simple, et sans paragraphe
</blockquote>
```

2
debian/control vendored
View File

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

View File

@ -1,5 +1,5 @@
#!/usr/bin/env python3
# Version: 0.9.1
# Version: 0.10.0
# Tyto - Littérateur
#
# Copyright (C) 2023 Cyrille Louarn <echolib+tyto@a-lec.org>

View File

@ -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 {
}

View File

@ -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)

View File

@ -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)

View File

@ -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',

View File

@ -268,6 +268,27 @@ if not hole:
"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 #
#------------------------------------#

View File

@ -760,10 +760,10 @@ def create_metas(option):
'# <meta property="og:description" ...\n' + \
'# <meta property="og:image" ...\n' + \
'# %s\n\n'%(15 * "-") + \
'<meta charset="UTF-8" />\n' + \
'<meta name="robots" content="all" />\n' + \
'<meta name="medium" content="website" />\n' + \
'<meta name="revisit-after" content="3 days" />'
'<meta charset="UTF-8">\n' + \
'<meta name="robots" content="all">\n' + \
'<meta name="medium" content="website">\n' + \
'<meta name="revisit-after" content="3 days">'
tyto.set_file(dom.metas_f, 'New', metas_tags)
@ -1000,6 +1000,7 @@ def create_footer(option):
footer = \
'%s\n'%footer_lang%(tyto.Tyto, dom.footer_f) + \
'<footer id="footer_page">\n' + \
' <div id="footer_container"> \n' + \
' <div id="footer_infos">\n' + \
' <h1 id="footer_site_title"\n' + \
' title="%s %s">%s %s\n'%(
@ -1036,6 +1037,7 @@ def create_footer(option):
' </li>\n' + \
' </ul>\n' + \
' </div>\n' + \
' </div>\n' + \
' <div id="footer_credits">\n' + \
' <p class="footer_copyright">Copyright%s © %s %s</p>\n'%(
langs.site.pp, footer_date, dom.title

View File

@ -84,29 +84,29 @@ def create_metas_page():
#-----------------------
global metas
metas = \
'<!--# include virtual="/template/metas.html"-->\n' + \
' <meta name="viewport" content="%s" />\n'%scale + \
' <meta name=”url” content=”%s />\n'%dom.www_url + \
' <meta name="language" content="%s" />\n'%dom.lang_site + \
' <meta name="reply-to" content="%s" />\n'%dom.mail + \
' <meta name="copyright" content="%s" />\n'%dom.license + \
' <meta name="generator" content="%s" />\n'%tyto.Tyto + \
' <meta name="title" content="%s" />\n'%db.title + \
' <meta name="author" content="%s" />\n'%db.author + \
' <meta name="description" content="%s" />\n'%db.about + \
' <meta name="keywords" content="%s" />\n'%all_tags + \
tyto.tags_html_mods[dom.wip_metas_f] + '\n' + \
' <meta name="viewport" content="%s">\n'%scale + \
' <meta name=”url” content=”%s>\n'%dom.www_url + \
' <meta name="language" content="%s">\n'%dom.lang_site + \
' <meta name="reply-to" content="%s">\n'%dom.mail + \
' <meta name="copyright" content="%s">\n'%dom.license + \
' <meta name="generator" content="%s">\n'%tyto.Tyto + \
' <meta name="title" content="%s">\n'%db.title + \
' <meta name="author" content="%s">\n'%db.author + \
' <meta name="description" content="%s">\n'%db.about + \
' <meta name="keywords" content="%s">\n'%all_tags + \
'%s'%meta_pub + \
' <link rel="canonical" href="%s" />\n'%db.http_www + \
' <link rel="alternate" %s />\n'%(rss_ref) + \
' <link rel="stylesheet" %s />\n'%css_ref + \
' <link rel="shortcut icon" %s />\n'%icon_ref + \
' <link rel="canonical" href="%s">\n'%db.http_www + \
' <link rel="alternate" %s>\n'%(rss_ref) + \
' <link rel="stylesheet" %s>\n'%css_ref + \
' <link rel="shortcut icon" %s>\n'%icon_ref + \
' <!-- Open Graph data -->\n' + \
' <meta property="og:site_name" content="%s" />\n'%dom.title + \
' <meta property="og:title" content="%s" />\n'%db.title + \
' <meta property="og:type" content="article" />\n' + \
' <meta property="og:url" content="%s" />\n'%db.http_www + \
' <meta property="og:description" content="%s" />\n'%db.about + \
' <meta property="og:image" content="%s" />\n'%db.snpic + \
' <meta property="og:site_name" content="%s">\n'%dom.title + \
' <meta property="og:title" content="%s">\n'%db.title + \
' <meta property="og:type" content="article">\n' + \
' <meta property="og:url" content="%s">\n'%db.http_www + \
' <meta property="og:description" content="%s">\n'%db.about + \
' <meta property="og:image" content="%s">\n'%db.snpic + \
'%s'%relme + \
' <title>%s %s %s</title>'%(db.title, dom.sep, dom.title)
@ -129,7 +129,7 @@ def create_main_page(target, article_bottom):
10 * " ", db.sub_uri, dom.logo
) + \
'%salt="logo: %s"\n'%(15 * " ", dom.title) + \
'%sid="site_logo_image" />\n'%(15 * " ") + \
'%sid="site_logo_image">\n'%(15 * " ") + \
'%s</a>'%(8 * " ")
post_html_code = ''
@ -166,8 +166,7 @@ def create_main_page(target, article_bottom):
' <p id="site_about">%s</p>\n'%dom.about + \
' </div>\n' + \
' </header>\n' + \
'<!--# include virtual="/template/navbar.html"-->\n' + \
'\n' + \
tyto.tags_html_mods[dom.wip_navbar_f] + '\n' + \
' <article id="article_main">\n' + \
' <h1 id="main_title"\n' + \
' title="[%s] %s %s %s %s">%s</h1>\n'%(
@ -176,7 +175,7 @@ def create_main_page(target, article_bottom):
db.title,
) + \
'%s\n'%article_bottom + \
' <section id="article_infos">\n' + \
' <div id="article_infos">\n' + \
' <p>\n' + \
' <span id="article_author"\n' + \
' title="%s %s [%s]">%s</span>, %s\n'%(
@ -186,11 +185,11 @@ def create_main_page(target, article_bottom):
'%s\n'%time_html_pub + \
'%s'%post_html_code + \
' </p>\n' + \
' </section>\n' + \
' </div>\n' + \
' </article>\n' + \
'\n' + \
'<!--# include virtual="/template/sidebar.html"-->\n' + \
'<!--# include virtual="/template/footer.html"-->\n' + \
tyto.tags_html_mods[dom.wip_sidebar_f] + '\n' + \
tyto.tags_html_mods[dom.wip_footer_f] + '\n' + \
' </body>\n' + \
'</html>'
@ -239,7 +238,7 @@ def create_html_time_meta(process):
# meta search_date=
meta_pub = \
'<!--Tyto_Meta--> <meta name="search_date" content="%s" />\n'%(
'<!--Tyto_Meta--> <meta name="search_date" content="%s">\n'%(
date_raw.rsplit(' ')[0]
)
@ -305,7 +304,7 @@ def create_navbar(option):
# Set first HTML line
menu_html = \
'%s<nav id="site_menu">\n'%(4 * ' ') + \
'%s<ul id="site_menu_items">'%(6 * ' ')
'%s<menu id="site_menu_items">'%(6 * ' ')
navbar_lines = open(dom.navbar_f, 'r').read()
@ -382,7 +381,7 @@ def create_navbar(option):
# Create ending HTML file
else:
menu_html = '\n%s\n%s</ul>\n%s</nav>\n'%(menu_html, 8 * ' ', 6 * ' ')
menu_html = '\n%s\n%s</menu>\n%s</nav>\n'%(menu_html, 6 * ' ', 4 * ' ')
tyto.set_file(target, 'New', menu_html)

View File

@ -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)

View File

@ -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
}

View File

@ -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')

View File

@ -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
#----------------------------------------------------------------------
@ -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

View File

@ -118,14 +118,15 @@ words_tags = [
('((', '))', '<p class="%s">', '</p>', 'paragraphs', 't'),
('[[', ']]', '[[', ']]', 'quotes', 't'),
('{{', '}}', '{{', '}}', 'bcodes', 't'),
('-(', '-)', '-(', '-)', 'lists', 't')
('-(', '-)', '-(', '-)', 'lists', 't'),
('<<', '>>', '<div class="%s">', '</div>', 'div', 't')
]
# Tags that do not need to be paired
#-----------------------------------
single_tags = [
('|', '<br class="%s" />'), # New Line
('->', '<a class="anchor_target" id="%s"></a>') # Anchors
('->', '<a class="anchor_target" id="%s"></a>'), # 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 : '<!--# include virtual="/template/navbar.html"-->',
dom.wip_sidebar_f : '<!--# include virtual="/template/sidebar.html"-->',
dom.wip_metas_f : '<!--# include virtual="/template/metas.html"-->',
dom.wip_footer_f : '<!--# include virtual="/template/footer.html"-->'
}
# 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)
#===================================#

View File

@ -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():
'<img class="%s"\n' + \
' src="%s"\n' + \
' alt="%s"\n' + \
' title="%s"%s />'
' title="%s"%s>'
# Check each line
for ln, line in enumerate(post_bottom.rsplit('\n')):

View File

@ -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"

View File

@ -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"

View File

@ -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"

View File

@ -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"