Updated code. Publish works but needs tests

This commit is contained in:
Cyrille L 2023-04-03 18:48:24 +02:00
parent 29ee8cc704
commit 6f67fd1d01
14 changed files with 554 additions and 343 deletions

View File

@ -114,6 +114,7 @@ def check_process(target):
global post_bottom, article_bottom global post_bottom, article_bottom
global date_wip, hash_wip, date_www, hash_www, post_bottom global date_wip, hash_wip, date_www, hash_www, post_bottom
global post_err global post_err
date_wip = hash_wip = date_www = hash_www = '' date_wip = hash_wip = date_www = hash_www = ''
post_err = False post_err = False
@ -348,7 +349,7 @@ def check_needed_tags(post_header):
# Check if unused needed tags # Check if unused needed tags
for tag in tyto.needed_header_tags: for tag in tyto.needed_header_tags:
if not globals()[tag]: if not globals()[tag]:
logs.out("17", '%s:'%tag, False) logs.out("38", '%s:'%tag, False)
post_err = True post_err = True
# Check date format # Check date format
@ -372,7 +373,9 @@ def check_date(date):
bool(datetime.strptime(date, fmt_article)) bool(datetime.strptime(date, fmt_article))
except ValueError: except ValueError:
post_err = True post_err = True
logs.out("3", 'date: "%s" (YYYY-MM-DD) > %s'%(date, db.uri_file), False) logs.out("3", 'date: "%s" (YYYY-MM-DD) > %s'%(
date, db.uri_file
), False)
# Create date_check (epoch) from article's Date + now TIME # Create date_check (epoch) from article's Date + now TIME
if not post_err: if not post_err:
@ -385,7 +388,6 @@ def check_date(date):
if dom.lang_site == 'fr': if dom.lang_site == 'fr':
date = date.rsplit('-') date = date.rsplit('-')
date_tr = date[2] + '/' + date[1] + '/' + date[0] date_tr = date[2] + '/' + date[1] + '/' + date[0]
print("> Convert date in FR >", date_tr)
#===========================================# #===========================================#
@ -393,13 +395,13 @@ def check_date(date):
# Multiple settings for each on 3 lines # # Multiple settings for each on 3 lines #
#-------------------------------------------# #-------------------------------------------#
def check_opt_tags(post_header): def check_opt_tags(post_header):
global stat_links, stat_images, stat_files, stat_raws global stat_links, stat_images, stat_files, stat_raws, stat_codes
global stat_snpics, snpic_url, stat_abbrs, post_abbrs global stat_snpics, snpic_url, stat_abbrs, post_abbrs
global opt_tags_post_name global opt_tags_post_name
global files_post global files_post
# Statistics # Statistics
stat_links = stat_images = stat_files = stat_raws = 0 stat_links = stat_images = stat_files = stat_raws = stat_codes = 0
stat_snpics = post_abbrs = stat_abbrs = 0 stat_snpics = post_abbrs = stat_abbrs = 0
files_post = (()) files_post = (())
@ -413,6 +415,7 @@ def check_opt_tags(post_header):
'image' : "_image:%s", 'image' : "_image:%s",
'file' : "__%s", 'file' : "__%s",
'raw' : "_raw:%s", 'raw' : "_raw:%s",
'code' : '_code:%s',
'abbr' : "(%s)" 'abbr' : "(%s)"
} }
@ -481,6 +484,8 @@ def check_3lines(tag, ln, line):
elif l == 2: data_log = "Alt-Text" elif l == 2: data_log = "Alt-Text"
ln += 1 ln += 1
data = ''
try: try:
# ln - 1 as string post_header starts with 0 # ln - 1 as string post_header starts with 0
data = post_header.rsplit('\n')[ln - 1].lstrip() data = post_header.rsplit('\n')[ln - 1].lstrip()
@ -488,7 +493,7 @@ def check_3lines(tag, ln, line):
except: except:
data = '' data = ''
if not data: if not data and not l == 2 and not tag == 'raw':
logs.out("2", 'L=%s. "%s" (%s:) > %s'%( logs.out("2", 'L=%s. "%s" (%s:) > %s'%(
ln, data_log, tag, db.uri_file ln, data_log, tag, db.uri_file
), False) ), False)
@ -502,6 +507,7 @@ def check_3lines(tag, ln, line):
return return
globals()[db_tag] = globals()[db_tag] + ((web_uri),) globals()[db_tag] = globals()[db_tag] + ((web_uri),)
files_post = files_post + (('%s'%web_uri),) files_post = files_post + (('%s'%web_uri),)
else: else:
if post_err: if post_err:
return return
@ -525,14 +531,19 @@ def isin(term, post_file):
def check_file_uri(filetype, filename, ln): def check_file_uri(filetype, filename, ln):
global post_err, err, web_uri global post_err, err, web_uri
filetypes = ('file', 'raw', 'code')
# Set file uri from filename # Set file uri from filename
# (@ = images/, / = articles/, else = post_dir) # (@ = images/ or files/
# / = articles/
# Else in post_dir
if filename.startswith('@'): if filename.startswith('@'):
if filetype == 'image' or filetype == "snpic": if filetype in filetypes:
fileuri = dom.images_d + filename[1: len(filename)]
elif filetype == 'file' or filetype == 'raw':
fileuri = dom.files_d + filename[1: len(filename)] fileuri = dom.files_d + filename[1: len(filename)]
elif filetype == 'image' or filetype == "snpic":
fileuri = dom.images_d + filename[1: len(filename)]
else: else:
post_dir = db.uri_file.split("/")[-1] post_dir = db.uri_file.split("/")[-1]
post_dir = db.uri_file.rsplit(post_dir)[0] post_dir = db.uri_file.rsplit(post_dir)[0]
@ -702,6 +713,18 @@ def check_content(post_bottom):
post_err = True post_err = True
# Legacy HTML not paired error
for tag in tyto.leg_html_tags:
leg1 = post_bottom.count(tag[0])
leg2 = post_bottom.count(tag[1])
if leg1 != leg2:
logs.out("8", '"%s" + "%s" > %s'%(
tag[0], tag[1], db.uri_file
), False)
post_err = True
# Template Tags (warning for not paired symbols) # Template Tags (warning for not paired symbols)
#----------------------------------------------- #-----------------------------------------------
for tag in tyto.tpl_tags: for tag in tyto.tpl_tags:
@ -778,12 +801,19 @@ def create_database():
datas_tag, i, globals()['file_%s'%i] datas_tag, i, globals()['file_%s'%i]
) )
if stat_codes > 0:
for i in range(1, stat_codes + 1):
datas_tag = '%s\ncode_%s = %s'%(
datas_tag, i, globals()['code_%s'%i]
)
if stat_raws > 0: if stat_raws > 0:
for i in range(1, stat_raws + 1): for i in range(1, stat_raws + 1):
datas_tag = '%s\nraw_%s = %s'%( datas_tag = '%s\nraw_%s = %s'%(
datas_tag, i, globals()['raw_%s'%i] datas_tag, i, globals()['raw_%s'%i]
) )
opt_tags = '' opt_tags = ''
if datas_tag: if datas_tag:
opt_tags = \ opt_tags = \
@ -801,6 +831,7 @@ def create_database():
'uniq_links = %d\n'%stat_links + \ 'uniq_links = %d\n'%stat_links + \
'uniq_images = %d\n'%stat_images + \ 'uniq_images = %d\n'%stat_images + \
'uniq_files = %d\n'%stat_files + \ 'uniq_files = %d\n'%stat_files + \
'uniq_codes = %d\n'%stat_codes + \
'uniq_raws = %d\n'%stat_raws + \ 'uniq_raws = %d\n'%stat_raws + \
'\n# Statistics from post content\n' + \ '\n# Statistics from post content\n' + \
'post_coms = %d\n'%nbr_coms + \ 'post_coms = %d\n'%nbr_coms + \

View File

@ -135,7 +135,7 @@ def create_main_page(target, article_bottom):
post_html_code = '' post_html_code = ''
if dom.article_code: if dom.article_code:
post_html_code = \ post_html_code = \
' <span id="article_code"> ' + \ ' <span id="article_code"> \n' + \
' <a id="article_code_link"\n' + \ ' <a id="article_code_link"\n' + \
' href="./%s"\n'%os.path.basename(db.short_src) + \ ' href="./%s"\n'%os.path.basename(db.short_src) + \
' title="%s">{%s}</a></span> \n'%( ' title="%s">{%s}</a></span> \n'%(
@ -157,7 +157,6 @@ def create_main_page(target, article_bottom):
' <div id="site_logo">\n' + \ ' <div id="site_logo">\n' + \
' %s\n'%logo_html + \ ' %s\n'%logo_html + \
' </div>\n' + \ ' </div>\n' + \
'\n' + \
' <div id="site_infos">\n' + \ ' <div id="site_infos">\n' + \
' <a href="/"\n' + \ ' <a href="/"\n' + \
' title="%s"\n'%(langs.site.home) + \ ' title="%s"\n'%(langs.site.home) + \
@ -173,14 +172,15 @@ def create_main_page(target, article_bottom):
' <section id="article_infos">\n' + \ ' <section id="article_infos">\n' + \
' <p>\n' + \ ' <p>\n' + \
' <span id="article_title"\n' + \ ' <span id="article_title"\n' + \
' title="%s %s %s %s %s">%s</span>\n'%( ' title="[%s] %s %s %s %s">%s</span>\n'%(
title, langs.site.w_written, db.date, langs.site.by, db.title, langs.site.w_written, db.date, langs.site.by,
db.author, db.author,
langs.site.article langs.site.article
) + \ ) + \
'%s'%post_html_code + \ '%s'%post_html_code + \
' <span>%s</span> \n'%langs.site.written_by + \
' <span id="article_author">%s</span>. \n'%(db.author) + \
'%s\n'%time_html_pub + \ '%s\n'%time_html_pub + \
' <span id="article_author">%s</span>\n'%db.author + \
' </p>\n' + \ ' </p>\n' + \
' </section>\n' + \ ' </section>\n' + \
'%s\n'%article_bottom + \ '%s\n'%article_bottom + \
@ -198,18 +198,25 @@ def create_main_page(target, article_bottom):
#--------------------------------------------# #--------------------------------------------#
def create_html_time_meta(process): def create_html_time_meta(process):
# Need to reload the DB to get last time updated # Need to reload the DB to get last time updated
exec(open(db.config).read(), globals()) importlib.reload(db)
global time_html_pub, meta_pub, date_raw global time_html_pub, meta_pub, date_raw
if process == 'wip': if process == 'wip':
date_raw = date_wip # <time datetime= / meta search_date try:
date_pub = date_wip.rsplit(' ')[0] date_raw = db.date_wip # <time datetime= / meta search_date
time_pub = date_wip.rsplit(' ')[1] date_pub = db.date_wip.rsplit(' ')[0]
time_pub = db.date_wip.rsplit(' ')[1]
except:
logs.out("23", '"date_wip = ?" > %s'%db.uri_file, True)
elif process == 'publish': elif process == 'publish':
date_raw = date_www # <time datetime= try:
date_pub = date_www.rsplit(' ')[0] date_raw = db.date_www # <time datetime=
time_pub = date_www.rsplit(' ')[1] date_pub = db.date_www.rsplit(' ')[0]
time_pub = db.date_www.rsplit(' ')[1]
except:
logs.out("23", '"date_www = ?" > %s'%db.uri_file, True)
if dom.lang_site == 'fr': if dom.lang_site == 'fr':
date_new = date_pub.rsplit('-') date_new = date_pub.rsplit('-')
@ -217,19 +224,19 @@ def create_html_time_meta(process):
# in <article> > section info : line with new date # in <article> > section info : line with new date
time_html_pub = \ time_html_pub = \
' <!--TYTOPUB-->\n' + \ '<!--Tyto_Published-->\n' + \
' <time datetime="%s">\n'%date_raw + \ ' <time datetime="%s">\n'%date_raw + \
' <span id="article_pub"\n' + \ ' <span id="article_pub"\n' + \
' title="%s %s %s">%s %s (%s)</span>\n'%( ' title="[%s] %s %s (%s)">%s %s</span>\n'%(
title, langs.site.w_published, date_pub, db.title, langs.site.w_published, date_pub, time_pub,
langs.site.published, date_pub, time_pub langs.site.published, date_pub
) + \ ) + \
' </time> %s\n'%langs.site.by + \ ' </time>\n' + \
' <!--/TYTOPUB-->' '<!--/Tyto_Published-->'
# meta search_date= # meta search_date=
meta_pub = \ meta_pub = \
' <meta name="search_date" content="%s" />\n'%( '<!--Tyto_Meta--> <meta name="search_date" content="%s" />\n'%(
date_raw.rsplit(' ')[0] date_raw.rsplit(' ')[0]
) )

View File

@ -1,11 +1,27 @@
#!/usr/bin/env python3 #!/usr/bin/env python3
# Name: Tyto - Littérateur # Tyto - Littérateur
# Type: logs tools #
# Description: Show logs and statuses, exit if needed # Copyright (C) 2023 Cyrille Louarn <echolib+tyto@a-lec.org>
# file: logs.py #
# Folder: /var/lib/tyto/program/ # This program is free software: you can redistribute it and/or modify
# By echolib (XMPP: im@echolib.re) # it under the terms of the GNU Affero General Public License
# License: GNU AFFERO GENERAL PUBLIC LICENSE Version 3, 19 November 2007 # as published by the Free Software Foundation, either version 3 of the
# License, or of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
#----------------------------------------------------------------------
# XMPP: echolib (im@echolib.re)
#
# Description: Show logs messages, exit with nbr
# File: /var/lib/tyto/program/logs.py
#----------------------------------------------------------------------
#------------ #------------
# funny stats # funny stats
@ -68,6 +84,7 @@ def out(nbr, value, out):
'35' : ' ╞═ %s%s%s %s'%(CG, langs.log.add, CS, value), '35' : ' ╞═ %s%s%s %s'%(CG, langs.log.add, CS, value),
'36' : '%s %s'%(langs.log.file_e, value), '36' : '%s %s'%(langs.log.file_e, value),
'37' : '%s %s'%(langs.log.dir_e, value), '37' : '%s %s'%(langs.log.dir_e, value),
'38' : '%s%s%s "%s ?"'%(CR, langs.log.unused_t, CS, value),
'40' : '%s%s%s > "%s"'%(CY, langs.log.dom_ina, CS, value), '40' : '%s%s%s > "%s"'%(CY, langs.log.dom_ina, CS, value),
'41' : '%s%s%s > "%s"'%(CR, langs.log.dom_inc, CS, value), '41' : '%s%s%s > "%s"'%(CR, langs.log.dom_inc, CS, value),
'42' : '%s%s%s > "%s"'%(CG, langs.log.dom_act, CS, value), '42' : '%s%s%s > "%s"'%(CG, langs.log.dom_act, CS, value),

View File

@ -1,11 +1,27 @@
#!/usr/bin/env python3 #!/usr/bin/env python3
# Name: Tyto - Littérateur # Tyto - Littérateur
# Type: Command arguments 'new' manager #
# Description: manage all 'new' from command action argument # Copyright (C) 2023 Cyrille Louarn <echolib+tyto@a-lec.org>
# file: new.py #
# Folder: /var/lib/tyto/program/ # This program is free software: you can redistribute it and/or modify
# By echolib (XMPP: im@echolib.re) # it under the terms of the GNU Affero General Public License
# License: GNU AFFERO GENERAL PUBLIC LICENSE Version 3, 19 November 2007 # as published by the Free Software Foundation, either version 3 of the
# License, or of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
#----------------------------------------------------------------------
# XMPP: echolib (im@echolib.re)
#
# Description: Create something new (domain, sidebar...)
# File: /var/lib/tyto/program/new.py
#----------------------------------------------------------------------
#------------ #------------
# funny stats # funny stats

View File

@ -1,11 +1,27 @@
#!/usr/bin/env python3 #!/usr/bin/env python3
# Name: Tyto - Littérateur # Tyto - Littérateur
# Type: Create HTML files in www/ #
# Description: Copy files and replace publish line in article # Copyright (C) 2023 Cyrille Louarn <echolib+tyto@a-lec.org>
# file: publish.py #
# Folder: /var/lib/tyto/program/ # This program is free software: you can redistribute it and/or modify
# By echolib (XMPP: im@echolib.re) # it under the terms of the GNU Affero General Public License
# License: GNU AFFERO GENERAL PUBLIC LICENSE Version 3, 19 November 2007 # as published by the Free Software Foundation, either version 3 of the
# License, or of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
#----------------------------------------------------------------------
# XMPP: echolib (im@echolib.re)
#
# Description: Publish on www server
# File: /var/lib/tyto/program/publish.py
#----------------------------------------------------------------------
#------------ #------------
# funny stats # funny stats
@ -19,15 +35,14 @@
import os, sys, shutil, importlib import os, sys, shutil, importlib
from pathlib import Path from pathlib import Path
import logs, args, dom, db, wip, html, tyto, form, stats, rss
import logs, args, dom, html, tyto, form, stats, rss
#==============================# #==============================#
# Manage action, get post db # # Manage action, get post db #
# check if publish can be done # # check if publish can be done #
#------------------------------# #------------------------------#
def manage_publish(target): def manage_publish(target):
domain.domain_needed dom.valid()
# Target is footer, sidebar, navbar, metas # Target is footer, sidebar, navbar, metas
# template: create/copy template/ files # template: create/copy template/ files
@ -51,16 +66,15 @@ def manage_publish(target):
# Database must exists... # Database must exists...
if not target: logs.out("5", '', True) if not target: logs.out("5", '', True)
if not db.post_exists: sys.exit(1) if not db.post: logs.out("1", db.uri_file, True)
if not db.db_exists: logs.out("25", db.uri_file, True) if not db.exists: logs.out("25", db.uri_file, True)
# Publish in www server an article # Publish in www server an article
check_to_publish('one') check_to_publish('one')
publish_article() publish_article()
# Create new ATOM/RSS file # Create new ATOM/RSS file
rss.create_feed() #rss.create_feed()
#===============# #===============#
@ -68,42 +82,60 @@ def manage_publish(target):
#---------------# #---------------#
def publish_article(): def publish_article():
# Copy wip page to www page # Copy wip page to www page
os.makedirs('%s%s'%(db.srv_www, db.direc_src), exist_ok=True) os.makedirs('%s%s'%(dom.srv_www, db.direc_src), exist_ok=True)
shutil.copy2(db.post_wip, db.post_www) logs.out("33", '%s%s'%(dom.srv_www, db.direc_src), False)
logs.out("33", db.post_www, False)
# Replace in DB hash_wip and date_wip
tyto.replace_in_db(db.config, 'www', db.hash_post)
# Copy needed files (Also create sub-folders) # Copy needed files (Also create sub-folders)
tyto.files_to_srv('www') tyto.files_to_srv('www')
# Replace in DB hash_wip and date_wip
tyto.replace_in_db(db.post_db, 'www', db.hash_post)
# Replace publish HTML line # Replace publish HTML line
replace_line_pub() replace_lines_pub()
#=================================================# #=================================================#
# Replace line in article containing publish date # # Replace line in article containing publish date #
#-------------------------------------------------# #-------------------------------------------------#
def replace_line_pub(): def replace_lines_pub():
# Load config html.create_html_time_meta('publish')
importlib.reload(db) print(html.time_html_pub)
html.create_html_infos_section('publish') in_pub = False
time_wip_pub = ''
newfile = ''
wip_html_post = open(db.post_wip, 'r').read() wip_html_post = open(db.post_wip, 'r').read()
www_html_post = wip_html_post
for line in wip_html_post.rsplit('\n'): for line in wip_html_post.rsplit('\n'):
if line.startswith('%s<p><span id="article_title"'%(8 * ' ')): if line.startswith('<!--Tyto_Published-->'):
line = html.post_pub in_pub = True
if line.startswith('%s<meta name="search_date"'%(4 * ' ')): time_wip_pub = line
line = html.meta_pub continue
if not newfile: newfile = line elif line.startswith('<!--/Tyto_Published-->'):
else: newfile = '%s\n%s'%(newfile, line) time_wip_pub = '%s\n%s'%(time_wip_pub, line)
in_pub = False
print('> time_wip_pub')
print(time_wip_pub)
break
tyto.set_file(db.post_www, 'new', newfile) elif line.startswith('<!--Tyto_Meta-->'):
logs.out("34", '(HTML date: %s): %s'%(db.date_www, db.post_www), False) time_wip_meta = line
continue
if in_pub:
time_wip_pub = '%s\n%s'%(time_wip_pub, line)
www_html_post = www_html_post.replace(time_wip_pub,
html.time_html_pub
)
www_html_post = www_html_post.replace(time_wip_meta, html.meta_pub)
#print(www_html_post)
tyto.set_file(db.post_www, 'new', www_html_post)
logs.out("32", db.post_www, False)
#================================# #================================#

View File

@ -19,7 +19,6 @@
import os import os
from pathlib import Path from pathlib import Path
import logs, dom, db, tyto import logs, dom, db, tyto

View File

@ -55,7 +55,7 @@ def read_lines(f, alone):
print(' ├─%s─┐'%(sp_max * '')) print(' ├─%s─┐'%(sp_max * ''))
for ln, line in enumerate(datas.rsplit('\n'), 1): for ln, line in enumerate(datas.rsplit('\n'), 1):
sp = sp_max - len(str(ln)) sp = sp_max - len(str(ln))
print(' %s %s%s'%(ln, int(sp) * " ", line)) print('%s %s %s'%(int(sp) * " ", ln, line))
# Ends for show. False should be for form # Ends for show. False should be for form
if alone: decor = '' if alone: decor = ''

View File

@ -1,11 +1,27 @@
#!/usr/bin/env python3 #!/usr/bin/env python3
# Name: Tyto - Littérateur # Tyto - Littérateur
# Type: DBs tools #
# Description: Show DBs status # Copyright (C) 2023 Cyrille Louarn <echolib+tyto@a-lec.org>
# file: status.py #
# Folder: /var/lib/tyto/program/ # This program is free software: you can redistribute it and/or modify
# By echolib (XMPP: im@echolib.re) # it under the terms of the GNU Affero General Public License
# License: GNU AFFERO GENERAL PUBLIC LICENSE Version 3, 19 November 2007 # as published by the Free Software Foundation, either version 3 of the
# License, or of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
#----------------------------------------------------------------------
# XMPP: echolib (im@echolib.re)
#
# Description: Show statuses for domain
# File: /var/lib/tyto/program/status.py
#----------------------------------------------------------------------
#------------ #------------
# funny stats # funny stats

View File

@ -33,7 +33,7 @@
#********************************************************************** #**********************************************************************
import os, sys, subprocess, locale, base64, datetime, shutil import os, sys, re, subprocess, locale, base64, datetime, shutil
from hashlib import blake2b from hashlib import blake2b
import args, dom, logs import args, dom, logs
@ -62,6 +62,7 @@ opt_header_tags = \
'file', 'file',
'abbr', 'abbr',
'raw', 'raw',
'code',
'snpic' 'snpic'
) )
@ -75,7 +76,8 @@ opt_tags_check_uri = \
( (
'image', 'image',
'file', 'file',
'raw' 'raw',
'code'
) )
# Set all tags used in article's header # Set all tags used in article's header
@ -90,6 +92,7 @@ headers = \
'image:', 'image:',
'file:', 'file:',
'abbr:', 'abbr:',
'code:',
'raw:', 'raw:',
'#', '#',
'snpic:', 'snpic:',
@ -134,7 +137,8 @@ words_tags[11][0], words_tags[11][1], # quotes
words_tags[12][0], words_tags[12][1], # bcodes words_tags[12][0], words_tags[12][1], # bcodes
words_tags[13][0], words_tags[13][1], # lists words_tags[13][0], words_tags[13][1], # lists
single_tags[0][0], single_tags[1][0], # New line, anchor single_tags[0][0], single_tags[1][0], # New line, anchor
'_%s:'%opt_header_tags[1], '_%s:'%opt_header_tags[4] # _image:, _raw: '_%s:'%opt_header_tags[1], '_%s:'%opt_header_tags[4], # _image:, _raw:
'_%s:'%opt_header_tags[5] # _code
) )
# warning symbols (Check if paired) # warning symbols (Check if paired)
@ -144,7 +148,17 @@ tpl_tags = [
('[', ']'), ('[', ']'),
('{', '}'), ('{', '}'),
('«', '»'), ('«', '»'),
('<!--', '-->') ]
# When including HTML in article, check some paired tags
#-------------------------------------------------------
leg_html_tags = [
('<!--', '-->'),
('<div', '</div>'),
('<ul', '</ul>'),
('<li', '</li>'),
('<p', '</p>'),
('<span','</span>'),
] ]
@ -167,7 +181,7 @@ quote_tags = [
] ]
# Tags to check in header in content _TAG # Tags to check in header in content _TAG
head_tags = ("image:", "raw:") head_tags = ("image:", "raw:", "code;")
# Stats for icodes, bcodes, quotes # Stats for icodes, bcodes, quotes
nbr_icodes = 0 nbr_icodes = 0
@ -208,15 +222,6 @@ def nowdate():
return(now.strftime('%Y-%m-%d %H:%M:%S')) return(now.strftime('%Y-%m-%d %H:%M:%S'))
#=======================================#
# Convert date DD/MM/YYYY to YYYY-MM-DD #
#---------------------------------------#
def set_en_date(date):
if db.domain_lang.lower() == 'fr':
udate = date.rsplit('/')
return('%s-%s-%s'%(udate[2], udate[1], udate[0]))
#======================# #======================#
# Open and edit a file # # Open and edit a file #
#----------------------# #----------------------#
@ -258,14 +263,16 @@ def set_file(path, new, text):
#--------------------------# #--------------------------#
def get_css(line): def get_css(line):
# Use this default, if not in conf # Use this default, if not in conf
try: set_css = domain_css css = 'tyto'
except: domain_css = 'tyto'
try: css = dom.css
except: pass
# Get CSS from line # Get CSS from line
try: set_css = line.rsplit(' ')[1] try: css = re.search (r'(?<=' ') +([^ -.]*)', line).group(1)
except: set_css = domain_css except: pass
return set_css return css
#=============================================# #=============================================#

View File

@ -76,7 +76,7 @@ def manage(target):
logs.out("1", db.uri_file, True) logs.out("1", db.uri_file, True)
elif not db.exists: elif not db.exists:
logs.out("28", '%s %s'%(args.action, args.target), True) logs.out("25", db.uri_file, True)
elif db.old_chk: elif db.old_chk:
logs.out("9", db.uri_file, True) logs.out("9", db.uri_file, True)
@ -159,10 +159,12 @@ def wip_article(target):
wip_abbrs() # Convert abbr wip_abbrs() # Convert abbr
wip_images() # Images_%i from headers in DB wip_images() # Images_%i from headers in DB
wip_titles() # Convert #N, remove empty line, add divs wip_titles() # Convert #N, remove empty line, add divs
wip_lists() # convert ul/ol lists
wip_quotes() # Quotes. Decode base64 Q64 and convert to HTML wip_quotes() # Quotes. Decode base64 Q64 and convert to HTML
wip_icodes() # inline_codes. Decode base64 icode and replace wip_icodes() # inline_codes. Decode base64 icode and replace
wip_filecode(target) # Read file and convert to HTML
wip_bcodes() # Block-codes. Decode B64 and convert to HTML wip_bcodes() # Block-codes. Decode B64 and convert to HTML
wip_raws(target) # Read file and convert to HTML wip_fileraws(target) # Read file and add raw content
wip_tabs() # make HTML tabulations wip_tabs() # make HTML tabulations
# Replace in DB hash_wip and date_wip # Replace in DB hash_wip and date_wip
@ -206,21 +208,28 @@ def file_to_string(post_file):
else: post_header = '%s\n%s'%(post_header, line) else: post_header = '%s\n%s'%(post_header, line)
#===============================================================#
# Simple function to replace source text to HTML in post_bottom #
#---------------------------------------------------------------#
def replace_in_post(src, html):
global post_bottom
post_bottom = post_bottom.replace(src, html)
#=============================# #=============================#
# Convert tags (br /, anchor) # # Convert tags (br /, anchor) #
#-----------------------------# #-----------------------------#
def wip_single_tags(): def wip_single_tags():
global post_bottom
# <br /> from "|" # <br /> from "|"
post_bottom = post_bottom.replace(tyto.single_tags[0][0], replace_in_post(tyto.single_tags[0][0],
tyto.single_tags[0][1] tyto.single_tags[0][1]
) )
# Anchor source
for line in post_bottom.rsplit('\n'): for line in post_bottom.rsplit('\n'):
if line.startswith(tyto.single_tags[1][0]): if line.startswith(tyto.single_tags[1][0]):
set_css = tyto.get_css(line) set_css = tyto.get_css(line)
post_bottom = post_bottom.replace(line, replace_in_post(line,
tyto.single_tags[1][1]%set_css tyto.single_tags[1][1]%set_css
) )
@ -230,8 +239,6 @@ def wip_single_tags():
# Convert Paragraphs # # Convert Paragraphs #
#----------------------------------# #----------------------------------#
def wip_words_tags(): def wip_words_tags():
global post_bottom
# Strongs, italics... # Strongs, italics...
# (Stop after 8 tags) # (Stop after 8 tags)
# For anchor (0), must do it differently # For anchor (0), must do it differently
@ -240,14 +247,22 @@ def wip_words_tags():
if m == 0: if m == 0:
m += 1 m += 1
# Close anchor (generic) # Close anchor (generic)
post_bottom = post_bottom.replace(tag[1], tag[3]) replace_in_post(tag[1],
tag[3]
)
continue continue
elif m > 8: break
elif m > 8:
break
# Open tag # Open tag
post_bottom = post_bottom.replace(tag[0], tag[2]) replace_in_post(tag[0],
tag[2]
)
# Close tag # Close tag
post_bottom = post_bottom.replace(tag[1], tag[3]) replace_in_post(tag[1],
tag[3]
)
m += 1 m += 1
@ -257,21 +272,21 @@ def wip_words_tags():
if db.post_paragraphs > 0: if db.post_paragraphs > 0:
if line.startswith(tyto.words_tags[10][0]): if line.startswith(tyto.words_tags[10][0]):
set_css = tyto.get_css(line) set_css = tyto.get_css(line)
post_bottom = post_bottom.replace(post_bottom.rsplit('\n')[ln], replace_in_post(post_bottom.rsplit('\n')[ln],
tyto.words_tags[10][2]%set_css tyto.words_tags[10][2]%set_css
) )
# Close tag # Close paragraph tag
elif line.startswith(tyto.words_tags[10][1]): elif line.startswith(tyto.words_tags[10][1]):
post_bottom = post_bottom.replace(line, replace_in_post(line,
tyto.words_tags[10][3] tyto.words_tags[10][3]
) )
# Open anchors # Open anchors link
if db.post_anchors == 0: continue if db.post_anchors == 0: continue
anchor_links = re.findall(r'>_(.+?):', line) anchor_links = re.findall(r'>_(.+?):', line)
for item in anchor_links: for item in anchor_links:
anchor_id = '%s%s:'%(tyto.words_tags[0][0], item) anchor_id = '%s%s:'%(tyto.words_tags[0][0], item)
post_bottom = post_bottom.replace(anchor_id, replace_in_post(anchor_id,
tyto.words_tags[0][2]%item tyto.words_tags[0][2]%item
) )
@ -282,10 +297,6 @@ def wip_words_tags():
# - link_%i # # - link_%i #
# from marker to HTML # # from marker to HTML #
#------------------------# #------------------------#
def wip_link_convert(marker, html):
global post_bottom
post_bottom = post_bottom.replace(marker, html)
def wip_links(): def wip_links():
if db.uniq_files == 0 and db.uniq_links == 0: return if db.uniq_files == 0 and db.uniq_links == 0: return
@ -306,8 +317,8 @@ def wip_links():
link_css, link_anc, link_title, "%s", link_name link_css, link_anc, link_title, "%s", link_name
) )
wip_link_convert(eval(link)[0]+'+', link_set%link_tb) replace_in_post(eval(link)[0]+'+', link_set%link_tb)
wip_link_convert(eval(link)[0], link_set%link_ts) replace_in_post(eval(link)[0], link_set%link_ts)
# Convert simple links # Convert simple links
@ -323,8 +334,8 @@ def wip_links():
link_css, link_anc, link_title, "%s", link_name link_css, link_anc, link_title, "%s", link_name
) )
wip_link_convert(eval(link)[0]+'+', link_set%link_tb) replace_in_post(eval(link)[0]+'+', link_set%link_tb)
wip_link_convert(eval(link)[0], link_set%link_ts) replace_in_post(eval(link)[0], link_set%link_ts)
#===============# #===============#
@ -333,11 +344,9 @@ def wip_links():
def wip_abbrs(): def wip_abbrs():
if db.uniq_abbrs == 0: return if db.uniq_abbrs == 0: return
global post_bottom
for i in range(1, db.uniq_abbrs + 1): for i in range(1, db.uniq_abbrs + 1):
abbr = 'db.abbr_%s'%i abbr = 'db.abbr_%s'%i
post_bottom = post_bottom.replace(eval(abbr)[0], replace_in_post(eval(abbr)[0],
eval(abbr)[1] eval(abbr)[1]
) )
@ -358,7 +367,6 @@ def get_wh_image(value):
def wip_images(): def wip_images():
if db.uniq_images == 0: return if db.uniq_images == 0: return
global post_bottom
image_link = '<a class="%s" href="%s">%s</a>' image_link = '<a class="%s" href="%s">%s</a>'
image_show = '<img class="%s" src="%s" alt="%s" title="%s"%s />' image_show = '<img class="%s" src="%s" alt="%s" title="%s"%s />'
@ -424,7 +432,7 @@ def wip_images():
# Set HTML to replace line number # Set HTML to replace line number
image_html = image_tgt%image_src image_html = image_tgt%image_src
post_bottom = post_bottom.replace(post_bottom.rsplit('\n')[ln], replace_in_post(post_bottom.rsplit('\n')[ln],
image_html image_html
) )
@ -444,7 +452,6 @@ def quote_params(qline):
def wip_quotes() : def wip_quotes() :
if db.post_quotes == 0: return if db.post_quotes == 0: return
global post_bottom
global author, link, lang, book, date global author, link, lang, book, date
for ln, line in enumerate(post_bottom.rsplit('\n')): for ln, line in enumerate(post_bottom.rsplit('\n')):
@ -480,8 +487,8 @@ def wip_quotes() :
else: tab_c = tab_c + 2 else: tab_c = tab_c + 2
# Replace opened paragrph with html line # Replace opened paragrph with html line
qline_html = '%s%s'%(tab_p * ' ', qline_html = '%s%s'%(
tyto.words_tags[10][2]%par_css tab_p * ' ', tyto.words_tags[10][2]%par_css
) )
# Add line to quote_html # Add line to quote_html
@ -505,10 +512,14 @@ def wip_quotes() :
continue continue
# Add other lines # Add other lines
if quote_html: quote_html = '%s\n%s%s'%( if quote_html:
quote_html = '%s\n%s%s'%(
quote_html, int(tab_c) * ' ', qline quote_html, int(tab_c) * ' ', qline
) )
else: quote_html = '%s%s'%(tab_c * ' ', qline) else:
quote_html = '%s%s'%(
tab_c * ' ', qline
)
# New quote set, then, repare datas # New quote set, then, repare datas
if link: cite = ' cite="%s"'%(link) if link: cite = ' cite="%s"'%(link)
@ -540,9 +551,7 @@ def wip_quotes() :
figc = '<span class="figc">%s</span>'%auth_html figc = '<span class="figc">%s</span>'%auth_html
else: else:
if book and date: title_html = ' title="%s (%s)"'%( if book and date: title_html = ' title="%s (%s)"'%(book, date)
book, date
)
elif book: title_html = ' title="%s"'%(book) elif book: title_html = ' title="%s"'%(book)
elif date: title_html = ' title="(%s)"'%(date) elif date: title_html = ' title="(%s)"'%(date)
@ -554,7 +563,8 @@ def wip_quotes() :
# Create HTML Quote with datas # Create HTML Quote with datas
if author: if author:
quote_html = '<figure class="%s">\n'%set_css + \ quote_html = \
'<figure class="%s">\n'%set_css + \
' <blockquote class="%s"%s%s%s>\n'%( ' <blockquote class="%s"%s%s%s>\n'%(
set_css, lang, cite, title_html set_css, lang, cite, title_html
) + \ ) + \
@ -567,7 +577,8 @@ def wip_quotes() :
' </figcaption>\n' + \ ' </figcaption>\n' + \
'</figure>' '</figure>'
else: else:
quote_html ='<blockquote class="%s"%s%s%s>\n'%( quote_html = \
'<blockquote class="%s"%s%s%s>\n'%(
set_css, lang, cite, title_html set_css, lang, cite, title_html
) + \ ) + \
time_html_o + \ time_html_o + \
@ -576,7 +587,7 @@ def wip_quotes() :
'</blockquote>' '</blockquote>'
# Replace line with final HTML Quote # Replace line with final HTML Quote
post_bottom = post_bottom.replace('Q64.%s.Q64'%line, replace_in_post('Q64.%s.Q64'%line,
quote_html quote_html
) )
@ -588,13 +599,13 @@ def wip_quotes() :
def wip_icodes(): def wip_icodes():
if db.post_icodes == 0: return if db.post_icodes == 0: return
global post_bottom
matches = re.findall(r'I64.(.*?).I64', post_bottom) matches = re.findall(r'I64.(.*?).I64', post_bottom)
for match in matches: for match in matches:
rep_icode = 'I64.' + match + '.I64' rep_icode = 'I64.' + match + '.I64'
src_icode = tyto.b64("Decode", match, 'I64.', '.I64') src_icode = tyto.b64("Decode", match, 'I64.', '.I64')
post_bottom = post_bottom.replace(rep_icode, src_icode) replace_in_post(rep_icode,
src_icode
)
#==================================================# #==================================================#
@ -604,8 +615,6 @@ def wip_icodes():
def wip_bcodes(): def wip_bcodes():
if db.post_bcodes == 0: return if db.post_bcodes == 0: return
global post_bottom
matches = re.findall(r'B64.(.*?).B64', post_bottom) matches = re.findall(r'B64.(.*?).B64', post_bottom)
for match in matches: for match in matches:
rep_bcode = 'B64.' + match + '.B64' rep_bcode = 'B64.' + match + '.B64'
@ -616,19 +625,26 @@ def wip_bcodes():
# CSS + opened marker # CSS + opened marker
if line.startswith(tyto.words_tags[12][0]): if line.startswith(tyto.words_tags[12][0]):
set_css = tyto.get_css(line) set_css = tyto.get_css(line)
html_bcode = '<pre class="%s">\n'%set_css + \ html_bcode = \
'<pre class="%s">\n'%set_css + \
' <code class="bcode">' ' <code class="bcode">'
# closed marker # closed marker
elif line.startswith(tyto.words_tags[12][1]): elif line.startswith(tyto.words_tags[12][1]):
html_bcode = '%s\n </code>\n'%html_bcode + \ html_bcode = \
'%s\n </code>\n'%html_bcode + \
'</pre>' '</pre>'
# Block-code content per line # Block-code content per line
else: else:
html_bcode = '%s\n <span class="bcode">%s</span>'%(html_bcode, html_bcode = \
line '%s\n <span class="bcode">%s</span>'%(
html_bcode, line
) )
post_bottom = post_bottom.replace(rep_bcode, html_bcode) replace_in_post(rep_bcode,
html_bcode
)
#========================================# #========================================#
@ -639,6 +655,7 @@ def wip_titles():
if db.post_titles == 0: return if db.post_titles == 0: return
global post_bottom global post_bottom
article_temp = post_bottom article_temp = post_bottom
article_tmp2 = '' # Construct article, without empty lines article_tmp2 = '' # Construct article, without empty lines
@ -669,8 +686,9 @@ def wip_titles():
if article_tmp2.rsplit('\n')[ln + 1].startswith('<h'): if article_tmp2.rsplit('\n')[ln + 1].startswith('<h'):
continue continue
else: else:
article_temp = article_temp.replace( article_temp = \
line, '%s\n<div class="title_%s">'%(line, hx) article_temp.replace(line,
'%s\n<div class="title_%s">'%(line, hx)
) )
continue continue
else: else:
@ -684,8 +702,9 @@ def wip_titles():
except: continue except: continue
if line.startswith('<h') and indiv: if line.startswith('<h') and indiv:
article_temp = article_temp.replace( article_temp = \
line, '</div>\n%s'%line article_temp.replace(line,
'</div>\n%s'%line
) )
indiv = False indiv = False
@ -703,106 +722,90 @@ def wip_titles():
#==============================================# #==============================================#
# Convert raw file to HTML with <pre> + <code> # # Convert raw file to HTML with <pre> + <code> #
#----------------------------------------------# #----------------------------------------------#
def wip_raws(target): def wip_filecode(target):
if db.uniq_raws == 0: return if db.uniq_codes == 0: return
global post_bottom for i in range(1, db.uniq_codes + 1):
code = 'db.code_%s'%i
for i in range(1, db.uniq_raws + 1): code_file = open('%s%s'%(dom.articles_d, eval(code)[1])).read()
raw = 'db.raw_%s'%i code_html = '<pre class="%s" title="%s">\n'%(
raw_file = open( dom.css, eval(code)[2]
'%s%s'%(
db.domain_articles, eval(raw)[1]
)
).read()
raw_html = '<pre class="%s" title="%s">\n'%(
db.domain_css, eval(raw)[2]
) + \ ) + \
' <code class="bcode">' ' <code class="bcode">'
for line in raw_file.rsplit('\n'):
raw_html = '%s\n <span class="bcode">%s</span>'%( for line in code_file.rsplit('\n'):
raw_html, line code_html = '%s\n <span class="bcode">%s</span>'%(
code_html, line
) )
raw_html = '%s\n </code>\n</pre>'%(raw_html) code_html = '%s\n </code>\n</pre>'%(code_html)
post_bottom = post_bottom.replace(eval(raw)[0], replace_in_post(eval(code)[0],
raw_html code_html
) )
#=======================# #==============================#
# Make HTML tabulations # # Search lines for list marker #
#-----------------------# #------------------------------#
def wip_tabs(): def wip_lists():
if not db.post_lists > 0: return
global post_bottom global post_bottom
article_temp = ''
tab = tab_start = 6 # From <article> tag
indiv = False
tabs_hX = { content_list = ''
'1' : '6', in_list = False
'2' : '8',
'3' : '10',
'4' : '12',
'5' : '14',
'6' : '16'
}
for line in post_bottom.rsplit('\n'): for line in post_bottom.rsplit('\n'):
# Titles # Open list
if line.startswith('<h'): if line.startswith(tyto.words_tags[13][0]):
get_tab = line[2] css = tyto.get_css(line)
tab = tabs_hX[get_tab] in_list = True
if not article_temp: content_list = line
article_temp = '%s%s'%(int(tab) * ' ', line)
else:
article_temp = '%s\n%s%s'%(article_temp, int(tab) * ' ', line)
continue continue
# div # Close list
if line.startswith('<div'): elif line.startswith(tyto.words_tags[13][1]):
tab = int(tab) + 2 in_list = False
indiv = True content_list = '%s\n%s'%(content_list, line)
article_temp = '%s\n%s%s'%(article_temp, int(tab) * ' ', line) html_list = convert_list(
tab = int(tab) + 2 content_list
continue ).replace('<ul>',
elif line.startswith('</div>'): '<ul class="%s">'%css, 1
tab = int(tab) - 2 ).replace('<li>',
article_temp = '%s\n%s%s'%(article_temp, int(tab) * ' ', line) '<li class="%s">'%css
indiv = False ) + '</ul>'
replace_in_post(content_list, html_list)
if in_list:
content_list = '%s\n%s'%(content_list, line)
else:
continue continue
# Other contents
else:
if not article_temp:
article_temp = '%s%s'%(int(tab) * ' ', line)
else:
article_temp = '%s\n%s%s'%(article_temp, int(tab) * ' ', line)
post_bottom = article_temp #===================================#
# Convert list with markers to HTML #
#=================================#
# Convert list in markers to HTML #
# Def from neox <- Thx a lot # # Def from neox <- Thx a lot #
#---------------------------------# # (Did little few updates) #
#-----------------------------------#
def convert_list(markdown_str): def convert_list(markdown_str):
# First step : reshape lines # First step : reshape lines
items = [] items = []
inside_item = 0 inside_item = 0
index = -1 index = -1
# Cut string with \n's # Cut string with \n's
strlist = markdown_slangs.site.split("\n") strlist = markdown_str.split("\n")
# Find items # Find items
for i in range(len(strlist)): for i in range(len(strlist)):
if "-(" in strlist[i] or "-)" in strlist[i]: if tyto.words_tags[13][0] in strlist[i] or \
tyto.words_tags[13][1] in strlist[i]:
continue continue
if strlist[i][0] != "=" and strlist[i][0] != "+": # = and +
if strlist[i][0] != tyto.markers_lists[1] and \
strlist[i][0] != tyto.markers_lists[0]:
if inside_item != 1: if inside_item != 1:
inside_item = 1 inside_item = 1
else: else:
@ -813,10 +816,9 @@ def convert_list(markdown_str):
index += 1 index += 1
if inside_item == 1: if inside_item == 1:
items[index] = '%s '%items[index] # Add one space
items[index] += strlist[i].lstrip() items[index] += strlist[i].lstrip()
#print("[{}] index {}, inside_item {}, curstr {}\n".format(i, index, inside_item, strlist[i]))
# Second step : parsing # Second step : parsing
UL = 1 UL = 1
OL = 2 OL = 2
@ -831,11 +833,13 @@ def convert_list(markdown_str):
work_str = "" work_str = ""
for i in range(len(items)): for i in range(len(items)):
if "-(" in items[i] or "-)" in items[i]: if tyto.words_tags[13][0] in items[i] or \
tyto.words_tags[13][1] in items[i]:
continue continue
rank = cur_rank rank = cur_rank
descriptor = items[i].split(" ")[0] descriptor = items[i].split(" ")[0]
text = items[i][items[i].find(" "):] text = items[i][items[i].find(" "):].lstrip()
cur_rank = len(descriptor) cur_rank = len(descriptor)
if "=" in descriptor: if "=" in descriptor:
@ -860,15 +864,93 @@ def convert_list(markdown_str):
work_str += " "*cur_rank + CLOSING[rank_stack.pop()] work_str += " "*cur_rank + CLOSING[rank_stack.pop()]
work_str += " "*cur_rank + '<li>' + text + "</li>\n"
work_str += " "*cur_rank + "<li>" + text + "</li>\n"
print("[{}] rank_stack {}, state {}, old_state {}, rank {}, cur_rank {}, text {}\n".format(
i, rank_stack, state, old_state, rank, cur_rank, text))
work_str += " "*(cur_rank-1) + CLOSING[rank_stack.pop()] work_str += " "*(cur_rank-1) + CLOSING[rank_stack.pop()]
return(work_str) return work_str
#print(convert_list(str_exemple)) #=======================================#
# Replace tag with contents of raw file #
#---------------------------------------#
def wip_fileraws(target):
for i in range(1, db.uniq_raws + 1):
raw = 'db.raw_%s'%i
raw_file = open('%s%s'%(dom.articles_d, eval(raw)[1])).read()
if eval(raw)[2]:
raw_alt = ' # %s'%eval(raw)[2]
raw_inc = '<!--Tyto_Include file%s-->'%raw_alt
for line in raw_file.rsplit('\n'):
if not line:
continue
raw_inc = '%s\n%s'%(raw_inc, line)
raw_inc = '%s\n<!--/Tyto_Include file%s-->'%(raw_inc, raw_alt)
replace_in_post(eval(raw)[0],
raw_inc
)
#=======================#
# Make HTML tabulations #
#-----------------------#
def wip_tabs():
global post_bottom
article_temp = ''
tab = tab_start = 6 # From <article> tag
indiv = False
tabs_hX = {
'1' : '6',
'2' : '8',
'3' : '10',
'4' : '12',
'5' : '14',
'6' : '16'
}
cs = 0
for line in post_bottom.rsplit('\n'):
# Titles
if line.startswith('<!'):
if cs != 1:
cs += 1
article_temp = '%s\n%s%s'%(article_temp, int(tab) * ' ', line)
tab = int(tab) - 2
continue
elif line.startswith('<h'):
get_tab = line[2]
tab = tabs_hX[get_tab]
if not article_temp:
article_temp = '%s%s'%(int(tab) * ' ', line)
else:
article_temp = '%s\n%s%s'%(article_temp, int(tab) * ' ', line)
continue
# div
elif line.startswith('<div'):
tab = int(tab) + 2
indiv = True
article_temp = '%s\n%s%s'%(article_temp, int(tab) * ' ', line)
tab = int(tab) + 2
continue
elif line.startswith('</div>'):
tab = int(tab) - 2
article_temp = '%s\n%s%s'%(article_temp, int(tab) * ' ', line)
indiv = False
continue
# Other contents
else:
if not article_temp:
article_temp = '%s%s'%(int(tab) * ' ', line)
else:
article_temp = '%s\n%s%s'%(article_temp, int(tab) * ' ', line)
post_bottom = article_temp

View File

@ -46,6 +46,7 @@ post_val = "Article is valid"
post_chg = "Article changed: 'check' it first" post_chg = "Article changed: 'check' it first"
sep_inv = "Unused separator in article" sep_inv = "Unused separator in article"
unused_v = "Unused value in article" unused_v = "Unused value in article"
unused_t = "Unused value in header"
unused_p = "Empty article" unused_p = "Empty article"
mark_np = "Not paired marks" mark_np = "Not paired marks"
symb_np = "Not paired symbols" symb_np = "Not paired symbols"

View File

@ -46,6 +46,7 @@ post_val = "Article valide"
post_chg = "Article modifié : commencer par 'check'" post_chg = "Article modifié : commencer par 'check'"
sep_inv = "Séparateur manquant dans l'article" sep_inv = "Séparateur manquant dans l'article"
unused_v = "Valeur manquante dans l'article" unused_v = "Valeur manquante dans l'article"
unused_t = "Valeur manquante dans l'entête"
unused_p = "L'article est vide" unused_p = "L'article est vide"
mark_np = "Marqueurs non jumelés" mark_np = "Marqueurs non jumelés"
symb_np = "Symboles non jumelés" symb_np = "Symboles non jumelés"

View File

@ -29,7 +29,7 @@ footer = 'Footer'
title = 'Title' title = 'Title'
File = 'File' File = 'File'
name = 'Name' name = 'Name'
by = 'par' by = "by"
q = '?' q = '?'
i = '!' i = '!'
pp = ":" pp = ":"
@ -45,7 +45,8 @@ tyto_psrc = "Show this article's source code in Tyto format"
w_written = "was written the" w_written = "was written the"
w_published = "was published the" w_published = "was published the"
written = "written the" written = "written the"
published = "wpublished the" written_by = 'written by'
published = "Published the"
# Sidebar # Sidebar
site_sdb_t = "Featured..." site_sdb_t = "Featured..."

View File

@ -29,7 +29,7 @@ footer = 'Pied de Page'
title = 'Titre' title = 'Titre'
File = 'Fichier' File = 'Fichier'
name = 'Nom' name = 'Nom'
by = 'par' by = "par"
q = ' ?' q = ' ?'
i = ' !' i = ' !'
pp = " :" pp = " :"
@ -45,7 +45,8 @@ tyto_psrc = "Voir le code source au format Tyto de cet article"
w_written = "a été écrit le" w_written = "a été écrit le"
w_published = "a été publié le" w_published = "a été publié le"
written = "écrit le" written = "écrit le"
published = "publié le" written_by = 'écrit par'
published = "Publié le"
# Barre latérale # Barre latérale
site_sdb_t = "À l'affiche..." site_sdb_t = "À l'affiche..."