+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Affero General Public License
+# 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 .
+
+#----------------------------------------------------------------------
+# XMPP: echolib (im@echolib.re)
+#
+# Description: Publish on www server
+# File: /var/lib/tyto/program/publish.py
+#----------------------------------------------------------------------
#------------
# funny stats
@@ -19,15 +35,14 @@
import os, sys, shutil, importlib
from pathlib import Path
-
-import logs, args, dom, html, tyto, form, stats, rss
+import logs, args, dom, db, wip, html, tyto, form, stats, rss
#==============================#
# Manage action, get post db #
# check if publish can be done #
#------------------------------#
def manage_publish(target):
- domain.domain_needed
+ dom.valid()
# Target is footer, sidebar, navbar, metas
# template: create/copy template/ files
@@ -50,17 +65,16 @@ def manage_publish(target):
return
# Database must exists...
- if not target: logs.out("5", '', True)
- if not db.post_exists: sys.exit(1)
- if not db.db_exists: logs.out("25", db.uri_file, True)
-
+ if not target: logs.out("5", '', True)
+ if not db.post: logs.out("1", db.uri_file, True)
+ if not db.exists: logs.out("25", db.uri_file, True)
# Publish in www server an article
check_to_publish('one')
publish_article()
# Create new ATOM/RSS file
- rss.create_feed()
+ #rss.create_feed()
#===============#
@@ -68,42 +82,60 @@ def manage_publish(target):
#---------------#
def publish_article():
# Copy wip page to www page
- os.makedirs('%s%s'%(db.srv_www, db.direc_src), exist_ok=True)
- shutil.copy2(db.post_wip, db.post_www)
- logs.out("33", db.post_www, False)
-
+ os.makedirs('%s%s'%(dom.srv_www, db.direc_src), exist_ok=True)
+ 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)
+
# Copy needed files (Also create sub-folders)
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_line_pub()
-
+ replace_lines_pub()
+
#=================================================#
# Replace line in article containing publish date #
#-------------------------------------------------#
-def replace_line_pub():
- # Load config
- importlib.reload(db)
+def replace_lines_pub():
+ html.create_html_time_meta('publish')
+ print(html.time_html_pub)
- html.create_html_infos_section('publish')
-
- newfile = ''
+ in_pub = False
+ time_wip_pub = ''
wip_html_post = open(db.post_wip, 'r').read()
+ www_html_post = wip_html_post
+
for line in wip_html_post.rsplit('\n'):
- if line.startswith('%s'):
+ in_pub = True
+ time_wip_pub = line
+ continue
+
+ elif line.startswith(''):
+ time_wip_pub = '%s\n%s'%(time_wip_pub, line)
+ in_pub = False
+ print('> time_wip_pub')
+ print(time_wip_pub)
+ break
+
+ elif line.startswith(''):
+ time_wip_meta = line
+ continue
- if not newfile: newfile = line
- else: newfile = '%s\n%s'%(newfile, line)
+ if in_pub:
+ time_wip_pub = '%s\n%s'%(time_wip_pub, line)
- tyto.set_file(db.post_www, 'new', newfile)
- logs.out("34", '(HTML date: %s): %s'%(db.date_www, db.post_www), False)
+ 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)
#================================#
diff --git a/src/var/lib/tyto/program/rss.py b/src/var/lib/tyto/program/rss.py
index 605e1ae..c8c465c 100644
--- a/src/var/lib/tyto/program/rss.py
+++ b/src/var/lib/tyto/program/rss.py
@@ -19,7 +19,6 @@
import os
from pathlib import Path
-
import logs, dom, db, tyto
diff --git a/src/var/lib/tyto/program/show.py b/src/var/lib/tyto/program/show.py
index d9d1e32..6917467 100644
--- a/src/var/lib/tyto/program/show.py
+++ b/src/var/lib/tyto/program/show.py
@@ -55,7 +55,7 @@ def read_lines(f, alone):
print(' ├─%s─┐'%(sp_max * '─'))
for ln, line in enumerate(datas.rsplit('\n'), 1):
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
if alone: decor = '└'
diff --git a/src/var/lib/tyto/program/status.py b/src/var/lib/tyto/program/status.py
index 0647cc6..2b9f2ea 100644
--- a/src/var/lib/tyto/program/status.py
+++ b/src/var/lib/tyto/program/status.py
@@ -1,11 +1,27 @@
#!/usr/bin/env python3
-# Name: Tyto - Littérateur
-# Type: DBs tools
-# Description: Show DBs status
-# file: status.py
-# Folder: /var/lib/tyto/program/
-# By echolib (XMPP: im@echolib.re)
-# License: GNU AFFERO GENERAL PUBLIC LICENSE Version 3, 19 November 2007
+# Tyto - Littérateur
+#
+# Copyright (C) 2023 Cyrille Louarn
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Affero General Public License
+# 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 .
+
+#----------------------------------------------------------------------
+# XMPP: echolib (im@echolib.re)
+#
+# Description: Show statuses for domain
+# File: /var/lib/tyto/program/status.py
+#----------------------------------------------------------------------
#------------
# funny stats
diff --git a/src/var/lib/tyto/program/tyto.py b/src/var/lib/tyto/program/tyto.py
index c906751..87f8d57 100644
--- a/src/var/lib/tyto/program/tyto.py
+++ b/src/var/lib/tyto/program/tyto.py
@@ -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
import args, dom, logs
@@ -62,6 +62,7 @@ opt_header_tags = \
'file',
'abbr',
'raw',
+'code',
'snpic'
)
@@ -75,7 +76,8 @@ opt_tags_check_uri = \
(
'image',
'file',
-'raw'
+'raw',
+'code'
)
# Set all tags used in article's header
@@ -90,6 +92,7 @@ headers = \
'image:',
'file:',
'abbr:',
+'code:',
'raw:',
'#',
'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[13][0], words_tags[13][1], # lists
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)
@@ -144,7 +148,17 @@ tpl_tags = [
('[', ']'),
('{', '}'),
('«', '»'),
-('')
+]
+
+# When including HTML in article, check some paired tags
+#-------------------------------------------------------
+leg_html_tags = [
+(''),
+(''),
+('
'),
+('- '),
+('
'),
+(''),
]
@@ -167,7 +181,7 @@ quote_tags = [
]
# Tags to check in header in content _TAG
-head_tags = ("image:", "raw:")
+head_tags = ("image:", "raw:", "code;")
# Stats for icodes, bcodes, quotes
nbr_icodes = 0
@@ -208,15 +222,6 @@ def nowdate():
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 #
#----------------------#
@@ -258,14 +263,16 @@ def set_file(path, new, text):
#--------------------------#
def get_css(line):
# Use this default, if not in conf
- try: set_css = domain_css
- except: domain_css = 'tyto'
+ css = 'tyto'
+
+ try: css = dom.css
+ except: pass
# Get CSS from line
- try: set_css = line.rsplit(' ')[1]
- except: set_css = domain_css
-
- return set_css
+ try: css = re.search (r'(?<=' ') +([^ -.]*)', line).group(1)
+ except: pass
+
+ return css
#=============================================#
diff --git a/src/var/lib/tyto/program/wip.py b/src/var/lib/tyto/program/wip.py
index ed11a7c..2b8c201 100644
--- a/src/var/lib/tyto/program/wip.py
+++ b/src/var/lib/tyto/program/wip.py
@@ -76,7 +76,7 @@ def manage(target):
logs.out("1", db.uri_file, True)
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:
logs.out("9", db.uri_file, True)
@@ -153,17 +153,19 @@ def wip_article(target):
# Convert contents from modules
- wip_single_tags() # br /, anchors
- wip_words_tags() # Paragraphs, strongs, italics
- wip_links() # Links_%i from headers in DB
- wip_abbrs() # Convert abbr
- wip_images() # Images_%i from headers in DB
- wip_titles() # Convert #N, remove empty line, add divs
- wip_quotes() # Quotes. Decode base64 Q64 and convert to HTML
- wip_icodes() # inline_codes. Decode base64 icode and replace
- wip_bcodes() # Block-codes. Decode B64 and convert to HTML
- wip_raws(target) # Read file and convert to HTML
- wip_tabs() # make HTML tabulations
+ wip_single_tags() # br /, anchors
+ wip_words_tags() # Paragraphs, strongs, italics
+ wip_links() # Links_%i from headers in DB
+ wip_abbrs() # Convert abbr
+ wip_images() # Images_%i from headers in DB
+ 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_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_fileraws(target) # Read file and add raw content
+ wip_tabs() # make HTML tabulations
# Replace in DB hash_wip and date_wip
tyto.replace_in_db(db.config, 'wip', db.hash_post)
@@ -206,23 +208,30 @@ def file_to_string(post_file):
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) #
#-----------------------------#
def wip_single_tags():
- global post_bottom
-
#
from "|"
- post_bottom = post_bottom.replace(tyto.single_tags[0][0],
- tyto.single_tags[0][1]
- )
+ replace_in_post(tyto.single_tags[0][0],
+ tyto.single_tags[0][1]
+ )
+ # Anchor source
for line in post_bottom.rsplit('\n'):
if line.startswith(tyto.single_tags[1][0]):
set_css = tyto.get_css(line)
- post_bottom = post_bottom.replace(line,
- tyto.single_tags[1][1]%set_css
- )
+ replace_in_post(line,
+ tyto.single_tags[1][1]%set_css
+ )
#==================================#
@@ -230,8 +239,6 @@ def wip_single_tags():
# Convert Paragraphs #
#----------------------------------#
def wip_words_tags():
- global post_bottom
-
# Strongs, italics...
# (Stop after 8 tags)
# For anchor (0), must do it differently
@@ -240,14 +247,22 @@ def wip_words_tags():
if m == 0:
m += 1
# Close anchor (generic)
- post_bottom = post_bottom.replace(tag[1], tag[3])
+ replace_in_post(tag[1],
+ tag[3]
+ )
continue
- elif m > 8: break
+
+ elif m > 8:
+ break
# Open tag
- post_bottom = post_bottom.replace(tag[0], tag[2])
+ replace_in_post(tag[0],
+ tag[2]
+ )
# Close tag
- post_bottom = post_bottom.replace(tag[1], tag[3])
+ replace_in_post(tag[1],
+ tag[3]
+ )
m += 1
@@ -257,23 +272,23 @@ def wip_words_tags():
if db.post_paragraphs > 0:
if line.startswith(tyto.words_tags[10][0]):
set_css = tyto.get_css(line)
- post_bottom = post_bottom.replace(post_bottom.rsplit('\n')[ln],
- tyto.words_tags[10][2]%set_css
- )
- # Close tag
+ replace_in_post(post_bottom.rsplit('\n')[ln],
+ tyto.words_tags[10][2]%set_css
+ )
+ # Close paragraph tag
elif line.startswith(tyto.words_tags[10][1]):
- post_bottom = post_bottom.replace(line,
- tyto.words_tags[10][3]
- )
- # Open anchors
+ replace_in_post(line,
+ tyto.words_tags[10][3]
+ )
+ # Open anchors link
if db.post_anchors == 0: continue
anchor_links = re.findall(r'>_(.+?):', line)
for item in anchor_links:
anchor_id = '%s%s:'%(tyto.words_tags[0][0], item)
- post_bottom = post_bottom.replace(anchor_id,
- tyto.words_tags[0][2]%item
- )
+ replace_in_post(anchor_id,
+ tyto.words_tags[0][2]%item
+ )
#========================#
@@ -281,11 +296,7 @@ def wip_words_tags():
# - file_%i #
# - link_%i #
# from marker to HTML #
-#------------------------#
-def wip_link_convert(marker, html):
- global post_bottom
- post_bottom = post_bottom.replace(marker, html)
-
+#------------------------#
def wip_links():
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
)
- wip_link_convert(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_tb)
+ replace_in_post(eval(link)[0], link_set%link_ts)
# Convert simple links
@@ -323,8 +334,8 @@ def wip_links():
link_css, link_anc, link_title, "%s", link_name
)
- wip_link_convert(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_tb)
+ replace_in_post(eval(link)[0], link_set%link_ts)
#===============#
@@ -333,13 +344,11 @@ def wip_links():
def wip_abbrs():
if db.uniq_abbrs == 0: return
- global post_bottom
-
for i in range(1, db.uniq_abbrs + 1):
abbr = 'db.abbr_%s'%i
- post_bottom = post_bottom.replace(eval(abbr)[0],
- eval(abbr)[1]
- )
+ replace_in_post(eval(abbr)[0],
+ eval(abbr)[1]
+ )
#---------------------------------------#
@@ -358,7 +367,6 @@ def get_wh_image(value):
def wip_images():
if db.uniq_images == 0: return
- global post_bottom
image_link = '%s'
image_show = ''
@@ -424,9 +432,9 @@ def wip_images():
# Set HTML to replace line number
image_html = image_tgt%image_src
- post_bottom = post_bottom.replace(post_bottom.rsplit('\n')[ln],
- image_html
- )
+ replace_in_post(post_bottom.rsplit('\n')[ln],
+ image_html
+ )
#--------------------------------------------#
@@ -443,8 +451,7 @@ def quote_params(qline):
#--------------------------#
def wip_quotes() :
if db.post_quotes == 0: return
-
- global post_bottom
+
global author, link, lang, book, date
for ln, line in enumerate(post_bottom.rsplit('\n')):
@@ -477,12 +484,12 @@ def wip_quotes() :
# Set tabulation for paragraphs and content
if author: tab_p = tab_p + 2 ; tab_c = tab_c + 4
- else: tab_c = tab_c + 2
+ else: tab_c = tab_c + 2
# Replace opened paragrph with html line
- qline_html = '%s%s'%(tab_p * ' ',
- tyto.words_tags[10][2]%par_css
- )
+ qline_html = '%s%s'%(
+ tab_p * ' ', tyto.words_tags[10][2]%par_css
+ )
# Add line to quote_html
if quote_html:
@@ -505,10 +512,14 @@ def wip_quotes() :
continue
# 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
)
- else: quote_html = '%s%s'%(tab_c * ' ', qline)
+ else:
+ quote_html = '%s%s'%(
+ tab_c * ' ', qline
+ )
# New quote set, then, repare datas
if link: cite = ' cite="%s"'%(link)
@@ -540,9 +551,7 @@ def wip_quotes() :
figc = '%s'%auth_html
else:
- if book and date: title_html = ' title="%s (%s)"'%(
- book, date
- )
+ if book and date: title_html = ' title="%s (%s)"'%(book, date)
elif book: title_html = ' title="%s"'%(book)
elif date: title_html = ' title="(%s)"'%(date)
@@ -554,31 +563,33 @@ def wip_quotes() :
# Create HTML Quote with datas
if author:
- quote_html = ''
+ quote_html = \
+ ''
else:
- quote_html ='\n'%(
- set_css, lang, cite, title_html
- ) + \
- time_html_o + \
- '%s\n'%quote_html + \
- time_html_c + \
- '
'
+ quote_html = \
+ '\n'%(
+ set_css, lang, cite, title_html
+ ) + \
+ time_html_o + \
+ '%s\n'%quote_html + \
+ time_html_c + \
+ '
'
# Replace line with final HTML Quote
- post_bottom = post_bottom.replace('Q64.%s.Q64'%line,
- quote_html
- )
+ replace_in_post('Q64.%s.Q64'%line,
+ quote_html
+ )
#==========================#
@@ -588,13 +599,13 @@ def wip_quotes() :
def wip_icodes():
if db.post_icodes == 0: return
- global post_bottom
-
matches = re.findall(r'I64.(.*?).I64', post_bottom)
for match in matches:
rep_icode = 'I64.' + match + '.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():
if db.post_bcodes == 0: return
- global post_bottom
-
matches = re.findall(r'B64.(.*?).B64', post_bottom)
for match in matches:
rep_bcode = 'B64.' + match + '.B64'
@@ -616,19 +625,26 @@ def wip_bcodes():
# CSS + opened marker
if line.startswith(tyto.words_tags[12][0]):
set_css = tyto.get_css(line)
- html_bcode = '\n'%set_css + \
- ' '
+ html_bcode = \
+ '\n'%set_css + \
+ ' '
+
# closed marker
elif line.startswith(tyto.words_tags[12][1]):
- html_bcode = '%s\n
\n'%html_bcode + \
- '
'
+ html_bcode = \
+ '%s\n
\n'%html_bcode + \
+ '
'
+
# Block-code content per line
else:
- html_bcode = '%s\n %s'%(html_bcode,
- line
- )
+ html_bcode = \
+ '%s\n %s'%(
+ 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
global post_bottom
+
article_temp = post_bottom
article_tmp2 = '' # Construct article, without empty lines
@@ -656,7 +673,7 @@ def wip_titles():
for line in article_temp.rsplit('\n'):
if line:
if article_tmp2: article_tmp2 = '%s\n%s'%(article_tmp2, line)
- else: article_tmp2 = line
+ else: article_tmp2 = line
article_temp = article_tmp2
@@ -669,9 +686,10 @@ def wip_titles():
if article_tmp2.rsplit('\n')[ln + 1].startswith(''%(line, hx)
- )
+ article_temp = \
+ article_temp.replace(line,
+ '%s\n'%(line, hx)
+ )
continue
else:
continue
@@ -684,9 +702,10 @@ def wip_titles():
except: continue
if line.startswith('\n%s'%line
- )
+ article_temp = \
+ article_temp.replace(line,
+ '
\n%s'%line
+ )
indiv = False
if article_tmp2.rsplit('\n')[ln + 1].startswith(' +
#
#----------------------------------------------#
-def wip_raws(target):
- if db.uniq_raws == 0: return
+def wip_filecode(target):
+ if db.uniq_codes == 0: return
+
+ for i in range(1, db.uniq_codes + 1):
+ code = 'db.code_%s'%i
+ code_file = open('%s%s'%(dom.articles_d, eval(code)[1])).read()
+ code_html = '\n'%(
+ dom.css, eval(code)[2]
+ ) + \
+ ' '
+
+ for line in code_file.rsplit('\n'):
+ code_html = '%s\n %s'%(
+ code_html, line
+ )
+
+ code_html = '%s\n
\n
'%(code_html)
+ replace_in_post(eval(code)[0],
+ code_html
+ )
+
+
+#==============================#
+# Search lines for list marker #
+#------------------------------#
+def wip_lists():
+ if not db.post_lists > 0: return
global post_bottom
+ content_list = ''
+ in_list = False
+
+ for line in post_bottom.rsplit('\n'):
+ # Open list
+ if line.startswith(tyto.words_tags[13][0]):
+ css = tyto.get_css(line)
+ in_list = True
+ content_list = line
+ continue
+
+ # Close list
+ elif line.startswith(tyto.words_tags[13][1]):
+ in_list = False
+ content_list = '%s\n%s'%(content_list, line)
+ html_list = convert_list(
+ content_list
+ ).replace('',
+ ''%css, 1
+ ).replace('- ',
+ '
- '%css
+ ) + '
'
+ replace_in_post(content_list, html_list)
+
+ if in_list:
+ content_list = '%s\n%s'%(content_list, line)
+
+ else:
+ continue
+
+
+#===================================#
+# Convert list with markers to HTML #
+# Def from neox <- Thx a lot #
+# (Did little few updates) #
+#-----------------------------------#
+def convert_list(markdown_str):
+ # First step : reshape lines
+ items = []
+ inside_item = 0
+ index = -1
+
+ # Cut string with \n's
+ strlist = markdown_str.split("\n")
+
+ # Find items
+ for i in range(len(strlist)):
+ if tyto.words_tags[13][0] in strlist[i] or \
+ tyto.words_tags[13][1] in strlist[i]:
+ continue
+
+ # = and +
+ if strlist[i][0] != tyto.markers_lists[1] and \
+ strlist[i][0] != tyto.markers_lists[0]:
+ if inside_item != 1:
+ inside_item = 1
+ else:
+ inside_item = 0
+
+ if inside_item == 0:
+ items.append(strlist[i])
+ index += 1
+
+ if inside_item == 1:
+ items[index] = '%s '%items[index] # Add one space
+ items[index] += strlist[i].lstrip()
+
+ # Second step : parsing
+ UL = 1
+ OL = 2
+ CLOSING = ["ERROR", "
\n", "\n"]
+ OPENING = ["ERROR", "\n", "\n"]
+
+ rank_stack = []
+ rank = 0
+ cur_rank = 0
+ state = 0
+ old_state = 0
+ work_str = ""
+
+ for i in range(len(items)):
+ if tyto.words_tags[13][0] in items[i] or \
+ tyto.words_tags[13][1] in items[i]:
+ continue
+
+ rank = cur_rank
+ descriptor = items[i].split(" ")[0]
+ text = items[i][items[i].find(" "):].lstrip()
+ cur_rank = len(descriptor)
+
+ if "=" in descriptor:
+ state = UL
+ elif "+" in descriptor:
+ state = OL
+ else:
+ raise(Exception)
+
+ # rank up
+ if cur_rank > rank:
+ for i in range(cur_rank - rank - 1):
+ work_str += " "*(rank+i) + OPENING[rank_stack.append(UL)]
+ rank_stack.append(state)
+
+ work_str += " "*rank + OPENING[state]
+
+ # rank down
+ elif cur_rank < rank:
+ for i in range(rank - cur_rank - 1):
+ work_str += " "*(rank-i-1) + CLOSING[rank_stack.pop()]
+
+ work_str += " "*cur_rank + CLOSING[rank_stack.pop()]
+
+ work_str += " "*cur_rank + '- ' + text + "
\n"
+
+ work_str += " "*(cur_rank-1) + CLOSING[rank_stack.pop()]
+
+ return work_str
+
+
+#=======================================#
+# 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'%(
- db.domain_articles, eval(raw)[1]
- )
- ).read()
- raw_html = '\n'%(
- db.domain_css, eval(raw)[2]
- ) + \
- ' '
+ 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 = ''%raw_alt
+
for line in raw_file.rsplit('\n'):
- raw_html = '%s\n %s'%(
- raw_html, line
- )
-
- raw_html = '%s\n
\n
'%(raw_html)
- post_bottom = post_bottom.replace(eval(raw)[0],
- raw_html
- )
-
+ if not line:
+ continue
+ raw_inc = '%s\n%s'%(raw_inc, line)
+
+ raw_inc = '%s\n'%(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 tag
indiv = False
@@ -748,9 +912,17 @@ def wip_tabs():
'6' : '16'
}
+ cs = 0
for line in post_bottom.rsplit('\n'):
# Titles
- if line.startswith(''):
tab = int(tab) - 2
article_temp = '%s\n%s%s'%(article_temp, int(tab) * ' ', line)
@@ -780,95 +953,4 @@ def wip_tabs():
article_temp = '%s\n%s%s'%(article_temp, int(tab) * ' ', line)
post_bottom = article_temp
-
-#=================================#
-# Convert list in markers to HTML #
-# Def from neox <- Thx a lot #
-#---------------------------------#
-def convert_list(markdown_str):
-
- # First step : reshape lines
-
- items = []
- inside_item = 0
- index = -1
-
- # Cut string with \n's
- strlist = markdown_slangs.site.split("\n")
-
- # Find items
- for i in range(len(strlist)):
- if "-(" in strlist[i] or "-)" in strlist[i]:
- continue
-
- if strlist[i][0] != "=" and strlist[i][0] != "+":
- if inside_item != 1:
- inside_item = 1
- else:
- inside_item = 0
-
- if inside_item == 0:
- items.append(strlist[i])
- index += 1
-
- if inside_item == 1:
- items[index] += strlist[i].lstrip()
-
- #print("[{}] index {}, inside_item {}, curstr {}\n".format(i, index, inside_item, strlist[i]))
-
- # Second step : parsing
- UL = 1
- OL = 2
- CLOSING = ["ERROR", "
\n", "\n"]
- OPENING = ["ERROR", "\n", "\n"]
-
- rank_stack = []
- rank = 0
- cur_rank = 0
- state = 0
- old_state = 0
- work_str = ""
-
- for i in range(len(items)):
- if "-(" in items[i] or "-)" in items[i]:
- continue
- rank = cur_rank
- descriptor = items[i].split(" ")[0]
- text = items[i][items[i].find(" "):]
- cur_rank = len(descriptor)
-
- if "=" in descriptor:
- state = UL
- elif "+" in descriptor:
- state = OL
- else:
- raise(Exception)
-
- # rank up
- if cur_rank > rank:
- for i in range(cur_rank - rank - 1):
- work_str += " "*(rank+i) + OPENING[rank_stack.append(UL)]
- rank_stack.append(state)
-
- work_str += " "*rank + OPENING[state]
-
- # rank down
- elif cur_rank < rank:
- for i in range(rank - cur_rank - 1):
- work_str += " "*(rank-i-1) + CLOSING[rank_stack.pop()]
-
- work_str += " "*cur_rank + CLOSING[rank_stack.pop()]
-
-
- work_str += " "*cur_rank + "- " + text + "
\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()]
-
- return(work_str)
-
-
-#print(convert_list(str_exemple))
diff --git a/src/var/lib/tyto/translations/logs_en.py b/src/var/lib/tyto/translations/logs_en.py
index 847ccc6..ae40f69 100644
--- a/src/var/lib/tyto/translations/logs_en.py
+++ b/src/var/lib/tyto/translations/logs_en.py
@@ -46,6 +46,7 @@ post_val = "Article is valid"
post_chg = "Article changed: 'check' it first"
sep_inv = "Unused separator in article"
unused_v = "Unused value in article"
+unused_t = "Unused value in header"
unused_p = "Empty article"
mark_np = "Not paired marks"
symb_np = "Not paired symbols"
diff --git a/src/var/lib/tyto/translations/logs_fr.py b/src/var/lib/tyto/translations/logs_fr.py
index 87ca173..c598c4a 100644
--- a/src/var/lib/tyto/translations/logs_fr.py
+++ b/src/var/lib/tyto/translations/logs_fr.py
@@ -46,6 +46,7 @@ post_val = "Article valide"
post_chg = "Article modifié : commencer par 'check'"
sep_inv = "Séparateur manquant dans l'article"
unused_v = "Valeur manquante dans l'article"
+unused_t = "Valeur manquante dans l'entête"
unused_p = "L'article est vide"
mark_np = "Marqueurs non jumelés"
symb_np = "Symboles non jumelés"
diff --git a/src/var/lib/tyto/translations/site_en.py b/src/var/lib/tyto/translations/site_en.py
index 92b4caf..663c852 100644
--- a/src/var/lib/tyto/translations/site_en.py
+++ b/src/var/lib/tyto/translations/site_en.py
@@ -29,7 +29,7 @@ footer = 'Footer'
title = 'Title'
File = 'File'
name = 'Name'
-by = 'par'
+by = "by"
q = '?'
i = '!'
pp = ":"
@@ -45,7 +45,8 @@ tyto_psrc = "Show this article's source code in Tyto format"
w_written = "was written the"
w_published = "was published the"
written = "written the"
-published = "wpublished the"
+written_by = 'written by'
+published = "Published the"
# Sidebar
site_sdb_t = "Featured..."
diff --git a/src/var/lib/tyto/translations/site_fr.py b/src/var/lib/tyto/translations/site_fr.py
index ade2b16..1187b06 100644
--- a/src/var/lib/tyto/translations/site_fr.py
+++ b/src/var/lib/tyto/translations/site_fr.py
@@ -29,7 +29,7 @@ footer = 'Pied de Page'
title = 'Titre'
File = 'Fichier'
name = 'Nom'
-by = 'par'
+by = "par"
q = ' ?'
i = ' !'
pp = " :"
@@ -45,7 +45,8 @@ tyto_psrc = "Voir le code source au format Tyto de cet article"
w_written = "a été écrit le"
w_published = "a été publié le"
written = "écrit le"
-published = "publié le"
+written_by = 'écrit par'
+published = "Publié le"
# Barre latérale
site_sdb_t = "À l'affiche..."