[0.10.3]
This commit is contained in:
parent
4825c25f63
commit
26a39155a0
|
@ -8,11 +8,12 @@ Tyto - Littérateur
|
|||
|
||||
## {0.10.3]
|
||||
- pre 1.0
|
||||
- Lots of fixes
|
||||
|
||||
## [0.10.2]
|
||||
- Citer dans un texte > `[_` + `_]`
|
||||
- Italique `<em>` > `;_` + `_;`
|
||||
- Italique `<i>` > {_:_` + `_:`
|
||||
- Cite in a text > `[_` + `_]`
|
||||
- Italic `<em>` > `;_` + `_;`
|
||||
- Italic `<i>` > {_:_` + `_:`
|
||||
|
||||
## [0.10.1]
|
||||
- Fix with try in check for static page
|
||||
|
|
|
@ -38,7 +38,7 @@
|
|||
import time, importlib, sys, os, re, datetime
|
||||
from datetime import datetime
|
||||
from time import gmtime, strftime
|
||||
import args, dom, logs, status, db, form, tyto, langs, wip
|
||||
import args, dom, logs, status, db, form, tyto, langs, wip, html
|
||||
|
||||
domain_dir = post_err = multi_chk = False
|
||||
|
||||
|
@ -236,7 +236,8 @@ def check_process(target):
|
|||
if icode:
|
||||
tyto.protect_icodes(post_bottom)
|
||||
post_bottom = tyto.protect_article
|
||||
|
||||
|
||||
|
||||
# Check header tags configurations
|
||||
check_needed_tags(post_header.rsplit('\n'))
|
||||
if post_err:
|
||||
|
@ -245,15 +246,22 @@ def check_process(target):
|
|||
return
|
||||
print(' │\n ├ [%s] > %s'%(title, db.uri_file))
|
||||
|
||||
|
||||
# Check optional tags configuration
|
||||
check_opt_tags(post_header.rsplit('\n'))
|
||||
if post_err:
|
||||
if db.exists and tyto.exists(db.config):
|
||||
os.remove(db.config)
|
||||
return
|
||||
|
||||
|
||||
# Check for valid contents
|
||||
check_content(post_bottom)
|
||||
check_titles() # #1-5 (titles)
|
||||
check_words_tags() # Strongs, italics...
|
||||
check_blocks_tags() # Paragraphs, quotes...
|
||||
check_anchors() # Anchors
|
||||
check_contents_list() # Lists ul/ol contents
|
||||
check_legacy_HTML() # Real HTML tags
|
||||
check_tags_set() # Check _TAG:Name (_image:Name)
|
||||
check_contents_writer() # Convinience
|
||||
|
||||
# Remove db (if exists) on post error and return
|
||||
if post_err:
|
||||
|
@ -392,14 +400,14 @@ def if_icodes_bcodes_quotes(post_bottom):
|
|||
fcodes += 1
|
||||
|
||||
# icodes
|
||||
elif tyto.words_tags[9][0] or tyto.words_tags[9][1] in line:
|
||||
elif tyto.words_tags[8][0] or tyto.words_tags[8][1] in line:
|
||||
icode_m1 = icode_m2 = 0
|
||||
icode_m1 = line.count(tyto.words_tags[9][0])
|
||||
icode_m2 = line.count(tyto.words_tags[9][1])
|
||||
icode_m1 = line.count(tyto.words_tags[8][0])
|
||||
icode_m2 = line.count(tyto.words_tags[8][1])
|
||||
if icode_m1 != icode_m2:
|
||||
logs.out("8", 'L=%s. icode "%s" + "%s" > %s'%(
|
||||
ln + 1 + ln_header,
|
||||
tyto.words_tags[9][0], tyto.words_tags[9][1],
|
||||
tyto.words_tags[8][0], tyto.words_tags[8][1],
|
||||
db.uri_file
|
||||
), False
|
||||
)
|
||||
|
@ -736,6 +744,22 @@ def check_snpic(name):
|
|||
def check_anchors():
|
||||
global post_err
|
||||
|
||||
c_opened = c_closed = 0
|
||||
c_opened = post_bottom.count(tyto.anchor_tags[0])
|
||||
c_closed = post_bottom.count(tyto.anchor_tags[1])
|
||||
|
||||
if c_opened != c_closed:
|
||||
logs.out("8", '%s "%s" + "%s" > %s'%(
|
||||
tyto.anchor_tags[4],
|
||||
tyto.anchor_tags[0], tyto.anchor_tags[1],
|
||||
db.uri_file
|
||||
), False)
|
||||
post_err = True
|
||||
|
||||
else:
|
||||
globals()['post_%s'%tyto.anchor_tags[4]] = int(c_opened)
|
||||
|
||||
|
||||
# Anchor target
|
||||
if nbr_ancs > 0:
|
||||
# Create anchors names targets
|
||||
|
@ -766,11 +790,11 @@ def check_anchors():
|
|||
post_err = True
|
||||
return
|
||||
|
||||
# Check in anchor link has target one
|
||||
# Check if anchor link has target one
|
||||
else:
|
||||
for ln, line in enumerate(post_bottom.rsplit('\n'), 1):
|
||||
# Anchor link
|
||||
if tyto.words_tags[0][0] and tyto.words_tags[0][1] in line:
|
||||
if tyto.anchor_tags[0] and tyto.anchor_tags[1] in line:
|
||||
anchors = re.findall(r">_(.*?)_<", line)
|
||||
for anchor in anchors:
|
||||
anchor_name = anchor.rsplit(':')[0].lstrip()
|
||||
|
@ -800,20 +824,14 @@ def check_titles():
|
|||
|
||||
post_titles += 1
|
||||
|
||||
|
||||
|
||||
|
||||
#===========================#
|
||||
# Check tags in post_bottom #
|
||||
#---------------------------#
|
||||
def check_content(post_bottom):
|
||||
global post_err
|
||||
#============================================#
|
||||
# Check tags for words (strongs, italics...) #
|
||||
# Set stats for each one #
|
||||
#--------------------------------------------#
|
||||
def check_words_tags():
|
||||
global post_err, post_bottom
|
||||
|
||||
check_titles()
|
||||
|
||||
# Check tags for words (strongs, italics...)
|
||||
# Set stats for each one
|
||||
#-------------------------------------------
|
||||
for tag in tyto.words_tags:
|
||||
c_opened = c_closed = 0
|
||||
|
||||
|
@ -830,12 +848,16 @@ def check_content(post_bottom):
|
|||
post_err = True
|
||||
|
||||
else:
|
||||
globals()['post_%s'%tag[4]] = int(c_opened)
|
||||
globals()['post_%s'%tag[4]] = int(c_opened)
|
||||
|
||||
|
||||
# Check block tags paragraphs, qyotes...)
|
||||
# Set stats for each one
|
||||
#-------------------------------------------
|
||||
#=========================================#
|
||||
# Check block tags paragraphs, quotes...) #
|
||||
# Set stats for each one #
|
||||
#-----------------------------------------#-
|
||||
def check_blocks_tags():
|
||||
global post_err
|
||||
|
||||
for tag in tyto.block_tags:
|
||||
c_opened = c_closed = 0
|
||||
|
||||
|
@ -853,14 +875,12 @@ def check_content(post_bottom):
|
|||
globals()['post_%s'%tag[4]] = int(c_opened)
|
||||
|
||||
|
||||
# Check if anchor has target
|
||||
# Count anchors target
|
||||
#---------------------------
|
||||
check_anchors()
|
||||
#====================================#
|
||||
# Lists: check if contents are valid #
|
||||
#------------------------------------#
|
||||
def check_contents_list():
|
||||
global post_err
|
||||
|
||||
|
||||
# Lists: check if contents are valid
|
||||
#-----------------------------------
|
||||
if post_lists > 0:
|
||||
inlist = False
|
||||
for ln, line in enumerate(post_bottom.rsplit('\n'), 1):
|
||||
|
@ -881,10 +901,32 @@ def check_content(post_bottom):
|
|||
db.uri_file
|
||||
), False)
|
||||
post_err = True
|
||||
|
||||
|
||||
#==================================#
|
||||
# Legacy HTML Tags, check if aired #
|
||||
#----------------------------------#
|
||||
def check_legacy_HTML():
|
||||
global post_err
|
||||
|
||||
# Check for all match _TAGS:NAME from content in header
|
||||
#------------------------------------------------------
|
||||
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
|
||||
|
||||
|
||||
#================================#
|
||||
# Check for all match _TAGS:NAME #
|
||||
# (from content in header) #
|
||||
# _image:, _raw:... #
|
||||
#--------------------------------#
|
||||
def check_tags_set():
|
||||
global post_err
|
||||
|
||||
set_tags = ()
|
||||
for ln, line in enumerate(post_bottom):
|
||||
for htag in tyto.head_tags:
|
||||
|
@ -902,23 +944,13 @@ def check_content(post_bottom):
|
|||
if match: continue
|
||||
else:
|
||||
logs.out("12", "%s %s"%(htag, ptag_set), False)
|
||||
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) #
|
||||
#------------------------------------------------#
|
||||
def check_contents_writer():
|
||||
for tag in tyto.tpl_tags:
|
||||
tpl1 = post_bottom.count(tag[0])
|
||||
tpl2 = post_bottom.count(tag[1])
|
||||
|
@ -946,7 +978,7 @@ def check_static_posts():
|
|||
try:
|
||||
post_datas = open(srv_post, "r").read()
|
||||
if not re.findall(
|
||||
tyto.tags_html_mods[dom.wip_metas_f],
|
||||
html.tags_html_mods[dom.wip_metas_f],
|
||||
post_datas
|
||||
):
|
||||
globals()[static] = "True"
|
||||
|
|
|
@ -213,96 +213,96 @@ if not hole:
|
|||
if active:
|
||||
ready = True
|
||||
|
||||
wip_html_mods = \
|
||||
(
|
||||
eval(str('wip_navbar_f')),
|
||||
eval(str('wip_sidebar_f')),
|
||||
eval(str('wip_metas_f')),
|
||||
eval(str('wip_footer_f'))
|
||||
)
|
||||
www_html_mods = \
|
||||
(
|
||||
eval(str('www_navbar_f')),
|
||||
eval(str('www_sidebar_f')),
|
||||
eval(str('www_metas_f')),
|
||||
eval(str('www_footer_f'))
|
||||
)
|
||||
metas = \
|
||||
(
|
||||
eval(str('metas_f')),
|
||||
eval(str('wip_metas_f')),
|
||||
eval(str('www_metas_f'))
|
||||
)
|
||||
navbars = \
|
||||
(
|
||||
eval(str('navbar_f')),
|
||||
eval(str('wip_navbar_f')),
|
||||
eval(str('www_navbar_f'))
|
||||
)
|
||||
sidebars = \
|
||||
(
|
||||
eval(str('sidebar_f')),
|
||||
eval(str('wip_sidebar_f')),
|
||||
eval(str('www_sidebar_f'))
|
||||
)
|
||||
footers = \
|
||||
(
|
||||
eval(str('footer_f')),
|
||||
eval(str('wip_footer_f')),
|
||||
eval(str('www_footer_f')),
|
||||
eval(str('footer_about_f'))
|
||||
)
|
||||
|
||||
templates = \
|
||||
(
|
||||
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')),
|
||||
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')),
|
||||
)
|
||||
|
||||
modules = \
|
||||
{
|
||||
"metas" : metas,
|
||||
"navbar" : navbars,
|
||||
"sidebar" : sidebars,
|
||||
"footer" : footers,
|
||||
"template": templates,
|
||||
}
|
||||
|
||||
templates_files_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')),
|
||||
)
|
||||
wip_html_mods = \
|
||||
(
|
||||
eval(str('wip_navbar_f')),
|
||||
eval(str('wip_sidebar_f')),
|
||||
eval(str('wip_metas_f')),
|
||||
eval(str('wip_footer_f'))
|
||||
)
|
||||
www_html_mods = \
|
||||
(
|
||||
eval(str('www_navbar_f')),
|
||||
eval(str('www_sidebar_f')),
|
||||
eval(str('www_metas_f')),
|
||||
eval(str('www_footer_f'))
|
||||
)
|
||||
metas = \
|
||||
(
|
||||
eval(str('metas_f')),
|
||||
eval(str('wip_metas_f')),
|
||||
eval(str('www_metas_f'))
|
||||
)
|
||||
navbars = \
|
||||
(
|
||||
eval(str('navbar_f')),
|
||||
eval(str('wip_navbar_f')),
|
||||
eval(str('www_navbar_f'))
|
||||
)
|
||||
sidebars = \
|
||||
(
|
||||
eval(str('sidebar_f')),
|
||||
eval(str('wip_sidebar_f')),
|
||||
eval(str('www_sidebar_f'))
|
||||
)
|
||||
footers = \
|
||||
(
|
||||
eval(str('footer_f')),
|
||||
eval(str('wip_footer_f')),
|
||||
eval(str('www_footer_f')),
|
||||
eval(str('footer_about_f'))
|
||||
)
|
||||
|
||||
templates = \
|
||||
(
|
||||
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')),
|
||||
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')),
|
||||
)
|
||||
|
||||
templates_files_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'))
|
||||
)
|
||||
modules = \
|
||||
{
|
||||
"metas" : metas,
|
||||
"navbar" : navbars,
|
||||
"sidebar" : sidebars,
|
||||
"footer" : footers,
|
||||
"template": templates,
|
||||
}
|
||||
|
||||
templates_files_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_files_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 #
|
||||
|
|
|
@ -256,7 +256,7 @@ def create_domain(target):
|
|||
|
||||
srv_www_tpl = "%s/www/template/"%root_srv_dom
|
||||
set_f = \
|
||||
'# Servers directories\n' + \
|
||||
'\n# Servers directories\n' + \
|
||||
'srv_root = "%s/"\n'%srv + \
|
||||
'srv_domain = "%s/"\n'%root_srv_dom + \
|
||||
'srv_wip = "%s/wip/"\n'%root_srv_dom + \
|
||||
|
@ -284,7 +284,7 @@ def create_domain(target):
|
|||
'www_sidebar_f = "%ssidebar.html"\n'%srv_www_tpl + \
|
||||
'www_metas_f = "%smetas.html"\n'%srv_www_tpl + \
|
||||
'www_footer_f = "%sfooter.html"\n'%srv_www_tpl + \
|
||||
'www_stats_f = "%s"'%stats_www_f
|
||||
'www_stats_f = "%s"\n'%stats_www_f
|
||||
|
||||
tyto.set_file(dom.config, False, set_f)
|
||||
|
||||
|
@ -304,7 +304,7 @@ def create_domain(target):
|
|||
'\n# Domain user\'s settings\n' + \
|
||||
'logo = "%s"\n'%logo + \
|
||||
'styles = "styles.css"\n' + \
|
||||
'rss = "%s"'%rss
|
||||
'rss = "%s"\n'%rss
|
||||
|
||||
tyto.set_file(dom.config, False, set_f)
|
||||
|
||||
|
@ -322,7 +322,7 @@ def create_domain(target):
|
|||
if not str(rss_items).isdigit() or not int(rss_items) > 1:
|
||||
rss_items = 100
|
||||
|
||||
set_f = 'rss_items = %d'%int(rss_items)
|
||||
set_f = 'rss_items = %d\n'%int(rss_items)
|
||||
tyto.set_file(dom.config, False, set_f)
|
||||
|
||||
|
||||
|
@ -339,7 +339,7 @@ def create_domain(target):
|
|||
if not title: invalid = True
|
||||
else: title = tyto.convert_altname(title)
|
||||
|
||||
set_f = 'title = "%s"'%title
|
||||
set_f = 'title = "%s"\n'%title
|
||||
tyto.set_file(dom.config, False, set_f)
|
||||
|
||||
|
||||
|
@ -354,7 +354,7 @@ def create_domain(target):
|
|||
|
||||
if answer: date = answer
|
||||
|
||||
set_f = 'date = "%s"'%date
|
||||
set_f = 'date = "%s"\n'%date
|
||||
tyto.set_file(dom.config, False, set_f)
|
||||
|
||||
|
||||
|
@ -371,7 +371,7 @@ def create_domain(target):
|
|||
if not about: invalid = True
|
||||
else: about = tyto.convert_altname(about)
|
||||
|
||||
set_f = 'about = "%s"'%about
|
||||
set_f = 'about = "%s"\n'%about
|
||||
tyto.set_file(dom.config, False, set_f)
|
||||
|
||||
|
||||
|
@ -391,7 +391,7 @@ def create_domain(target):
|
|||
if not tyto.exists('%s/site_%s.py'%(trans_dir, lang_site)):
|
||||
lang_site = 'en'
|
||||
|
||||
set_f = 'lang_site = "%s"'%lang_site
|
||||
set_f = 'lang_site = "%s"\n'%lang_site
|
||||
tyto.set_file(dom.config, False, set_f)
|
||||
|
||||
|
||||
|
@ -404,12 +404,13 @@ def create_domain(target):
|
|||
langs.site.form_mail, langs.site.q, mail
|
||||
), False)
|
||||
|
||||
if answer: mail = answer
|
||||
if not re.search('^\w+@\w+.\w+$', mail):
|
||||
if answer: mail = answer
|
||||
passplus = mail.replace('+', '').replace('-', '')
|
||||
if not re.search('^\w+@\w+.\w+$', passplus):
|
||||
logs.out("3", mail, False)
|
||||
invalid = True
|
||||
|
||||
set_f = 'mail = "%s"'%mail
|
||||
set_f = 'mail = "%s"\n'%mail
|
||||
tyto.set_file(dom.config, False, set_f)
|
||||
|
||||
|
||||
|
@ -426,7 +427,7 @@ def create_domain(target):
|
|||
if not tags: invalid = True
|
||||
elif '"' in tags: tags = tags.replace('"', '')
|
||||
|
||||
set_f = 'tags = "%s"'%tags
|
||||
set_f = 'tags = "%s"\n'%tags
|
||||
tyto.set_file(dom.config, False, set_f)
|
||||
|
||||
|
||||
|
@ -442,7 +443,7 @@ def create_domain(target):
|
|||
if answer: domlicense = answer
|
||||
if '"' in domlicense: domlicense = domlicense.replace('"', '')
|
||||
|
||||
set_f = 'license = "%s"'%domlicense
|
||||
set_f = 'license = "%s"\n'%domlicense
|
||||
tyto.set_file(dom.config, False, set_f)
|
||||
|
||||
|
||||
|
@ -462,7 +463,7 @@ def create_domain(target):
|
|||
logs.out("2", '"http(s)://%s"%s'%(licurl, langs.site.q), False)
|
||||
licurl = ''
|
||||
|
||||
set_f = 'license_url = "%s"'%licurl
|
||||
set_f = 'license_url = "%s"\n'%licurl
|
||||
tyto.set_file(dom.config, False, set_f)
|
||||
|
||||
|
||||
|
@ -482,7 +483,7 @@ def create_domain(target):
|
|||
logs.out("2", '"http(s)://%s"%s'%(legalurl, langs.site.q), False)
|
||||
legalurl = ''
|
||||
|
||||
set_f = 'legal_url = "%s"'%legalurl
|
||||
set_f = 'legal_url = "%s"\n'%legalurl
|
||||
tyto.set_file(dom.config, False, set_f)
|
||||
|
||||
|
||||
|
@ -502,7 +503,7 @@ def create_domain(target):
|
|||
logs.out("2", '"http(s)://%s"%s'%(termsurl, langs.site.q), False)
|
||||
termsurl = ''
|
||||
|
||||
set_f = 'terms_url = "%s"'%termsurl
|
||||
set_f = 'terms_url = "%s"\n'%termsurl
|
||||
tyto.set_file(dom.config, False, set_f)
|
||||
|
||||
|
||||
|
@ -520,7 +521,7 @@ def create_domain(target):
|
|||
logs.out("3", css, False)
|
||||
css = 'tyto'
|
||||
|
||||
set_f = 'css = "%s"'%css
|
||||
set_f = 'css = "%s"\n'%css
|
||||
tyto.set_file(dom.config, False, set_f)
|
||||
|
||||
|
||||
|
@ -538,27 +539,27 @@ def create_domain(target):
|
|||
logs.out("3", answer, False)
|
||||
sep = "-"
|
||||
|
||||
set_f = 'sep = "%s"'%sep
|
||||
set_f = 'sep = "%s"\n'%sep
|
||||
tyto.set_file(dom.config, False, set_f)
|
||||
|
||||
|
||||
# Show article source ?
|
||||
#----------------------
|
||||
try:
|
||||
dom.article_code
|
||||
article_code = "True"
|
||||
if dom.article_code: article_code = "True"
|
||||
else: article_code = "False"
|
||||
except:
|
||||
article_code = "False"
|
||||
|
||||
answer = (' ├ %s%s {%s} '%(
|
||||
langs.site.form_pscode, langs.site.q, article_code
|
||||
answer = asking(' ├ %s%s {%s} (Y|n) '%(
|
||||
langs.site.form_pscode, langs.site.q, str(article_code)
|
||||
), False)
|
||||
|
||||
if answer:
|
||||
if answer in answer_yes: article_code = "True"
|
||||
else: article_code = "False"
|
||||
|
||||
set_f = 'article_code = %s'%article_code
|
||||
set_f = 'article_code = %s\n'%article_code
|
||||
tyto.set_file(dom.config, False, set_f)
|
||||
|
||||
|
||||
|
@ -578,7 +579,7 @@ def create_domain(target):
|
|||
logs.out("2", '"http(s)://%s"%s'%(relme, langs.site.q), False)
|
||||
relmel = ''
|
||||
|
||||
set_f = 'relme = "%s"'%relme
|
||||
set_f = 'relme = "%s"\n'%relme
|
||||
tyto.set_file(dom.config, False, set_f)
|
||||
|
||||
|
||||
|
@ -599,7 +600,7 @@ def create_domain(target):
|
|||
else:
|
||||
sdb_title = tyto.convert_altname(sdb_title)
|
||||
|
||||
set_f = 'sidebar_title = "%s"'%sdb_title
|
||||
set_f = 'sidebar_title = "%s"\n'%sdb_title
|
||||
tyto.set_file(dom.config, False, set_f)
|
||||
|
||||
|
||||
|
@ -617,7 +618,7 @@ def create_domain(target):
|
|||
if not str(sdb_items).isdigit() or not int(sdb_items) in range(1,17):
|
||||
sdb_items = 6
|
||||
|
||||
set_f = 'sidebar_items = %d'%int(sdb_items)
|
||||
set_f = 'sidebar_items = %d\n'%int(sdb_items)
|
||||
tyto.set_file(dom.config, False, set_f)
|
||||
|
||||
|
||||
|
@ -650,13 +651,17 @@ def create_domain(target):
|
|||
# Activate Domain
|
||||
#----------------
|
||||
tyto.set_file(dom.config, False, '\nactivated = True')
|
||||
shutil.copy2(dom.config, config_bkp)
|
||||
logs.out("32", config_bkp, False)
|
||||
|
||||
# RELoad config
|
||||
#--------------
|
||||
importlib.reload(dom)
|
||||
|
||||
# Backup and create local user dir
|
||||
if not os.makedirs(dom.articles_db_d, exist_ok=True):
|
||||
logs.out("33", dom.articles_db_d, False)
|
||||
shutil.copy2(dom.config, config_bkp)
|
||||
logs.out("32", config_bkp, False)
|
||||
|
||||
|
||||
# Create folders from configuration file
|
||||
#---------------------------------------
|
||||
|
@ -674,7 +679,7 @@ def create_domain(target):
|
|||
logs.out("37", folder, False)
|
||||
else:
|
||||
os.makedirs(folder, exist_ok=True)
|
||||
logs.out("33", foloder, False)
|
||||
logs.out("33", folder, False)
|
||||
|
||||
print(' │')
|
||||
|
||||
|
@ -682,7 +687,7 @@ def create_domain(target):
|
|||
# Create in _configs/ modules files
|
||||
#----------------------------------
|
||||
|
||||
html.create_user_metass('new')
|
||||
html.create_user_metas('new')
|
||||
html.create_navbar('new')
|
||||
html.create_sidebar('new')
|
||||
html.create_user_footer('new')
|
||||
|
@ -1043,7 +1048,7 @@ def create_footer(option):
|
|||
' <li class="footer_item">%s%s \n'%(
|
||||
langs.site.feed, langs.site.pp
|
||||
) + \
|
||||
' <a href="%s/%s"\n'%(dom.www_url, dom.rss) + \
|
||||
' <a href="/%s"\n'%(dom.rss) + \
|
||||
' title="RSS 2.0 - %s"\n'%dom.title + \
|
||||
' class="footer_item_link">RSS 2.0</a>\n' + \
|
||||
' </li>\n' + \
|
||||
|
|
|
@ -42,6 +42,16 @@ pub_opts = ('www', 'pub')
|
|||
# Not a line if it starts with...(for sidebar, navbar)
|
||||
nolines = ('#', '/')
|
||||
|
||||
# For static modules
|
||||
if dom.ready:
|
||||
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"-->'
|
||||
}
|
||||
|
||||
#==========================#
|
||||
# Load article DB #
|
||||
# Start HTML page sections #
|
||||
|
@ -85,7 +95,7 @@ def create_metas_page():
|
|||
#-----------------------
|
||||
global metas
|
||||
metas = \
|
||||
tyto.tags_html_mods[dom.wip_metas_f] + '\n' + \
|
||||
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 + \
|
||||
|
@ -167,7 +177,7 @@ def create_main_page(target, article_bottom):
|
|||
' <p id="site_about">%s</p>\n'%dom.about + \
|
||||
' </div>\n' + \
|
||||
' </header>\n' + \
|
||||
tyto.tags_html_mods[dom.wip_navbar_f] + '\n' + \
|
||||
tags_html_mods[dom.wip_navbar_f] + '\n' + \
|
||||
' <article id="article_main">\n' + \
|
||||
' <h1 accesskey="t" id="post_title"\n' + \
|
||||
' title="[%s] %s %s %s %s">%s</h1>\n'%(
|
||||
|
@ -189,8 +199,8 @@ def create_main_page(target, article_bottom):
|
|||
' </div>\n' + \
|
||||
' </article>\n' + \
|
||||
'\n' + \
|
||||
tyto.tags_html_mods[dom.wip_sidebar_f] + '\n' + \
|
||||
tyto.tags_html_mods[dom.wip_footer_f] + '\n' + \
|
||||
tags_html_mods[dom.wip_sidebar_f] + '\n' + \
|
||||
tags_html_mods[dom.wip_footer_f] + '\n' + \
|
||||
' </body>\n' + \
|
||||
'</html>'
|
||||
|
||||
|
|
|
@ -37,7 +37,7 @@ import os, sys
|
|||
import langs
|
||||
|
||||
# Use to mark new article
|
||||
shebang = "#!/usr/bin/tyto"
|
||||
shebang = "#!/NEW"
|
||||
|
||||
# Set colors
|
||||
CS = '\033[0;0m'
|
||||
|
|
|
@ -60,21 +60,24 @@ def manage(target):
|
|||
|
||||
actions[target](option)
|
||||
|
||||
|
||||
# article target
|
||||
#---------------
|
||||
else:
|
||||
filepost = "%s%s.tyto"%(dom.user_dir, args.target)
|
||||
else:
|
||||
filepost = "%s%s.tyto"%(dom.articles_d, args.target)
|
||||
if tyto.exists(filepost):
|
||||
logs.out("81", filepost, True)
|
||||
|
||||
else:
|
||||
form.asking(" ├ %s%s %s"%(
|
||||
form.asking(" ├ %s%s {%s}%s "%(
|
||||
langs.site.new_post,
|
||||
langs.site.q,
|
||||
filepost
|
||||
filepost,
|
||||
langs.site.q
|
||||
), True)
|
||||
|
||||
post = tyto.new_article%(args.target,
|
||||
post = tyto.new_article%(logs.shebang,
|
||||
args.target,
|
||||
dom.user,
|
||||
tyto.nowdate().rsplit(' ')[0]
|
||||
)
|
||||
|
|
|
@ -38,7 +38,7 @@ import args, dom, logs, tyto, html, db
|
|||
|
||||
def domain():
|
||||
if dom.hole: logs.out("13", '', True)
|
||||
elif args.action == 'new': return
|
||||
elif args.action == 'new' and args.target == "domain": return
|
||||
elif args.act_err: logs.out("11", args.action, True)
|
||||
elif not dom.exists: logs.out("10", '', True)
|
||||
elif dom.corrupt: logs.out("39", dom.shortname, True)
|
||||
|
|
|
@ -104,11 +104,6 @@ headers = \
|
|||
# [5] = name for stats and log.
|
||||
#-------------------------------------------------------------
|
||||
words_tags = [
|
||||
(
|
||||
'>_', '_<',
|
||||
'<a class="anchor_link" href="#%s">', '</a>',
|
||||
'anchors'
|
||||
),
|
||||
(
|
||||
'*_', '_*',
|
||||
'<strong class="strong">', '</strong>',
|
||||
|
@ -165,6 +160,14 @@ block_tags = [
|
|||
('<<', '>>', '<div class="%s">', '</div>', 'div'),
|
||||
]
|
||||
|
||||
# Anchor tags
|
||||
anchor_tags = \
|
||||
(
|
||||
'>_', '_<',
|
||||
'<a class="anchor_link" href="#%s">', '</a>',
|
||||
'anchors'
|
||||
)
|
||||
|
||||
# Tags that do not need to be paired
|
||||
#-----------------------------------
|
||||
single_tags = [
|
||||
|
@ -235,22 +238,13 @@ 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('{}[]_()+*=/:%~´')
|
||||
|
||||
|
||||
new_article = """%s
|
||||
# tyto new %s
|
||||
# Tyto - Litterateur (tyto new %s)
|
||||
|
||||
title:
|
||||
about:
|
||||
|
@ -262,7 +256,9 @@ date: %s
|
|||
Le générateur de sites web Libre
|
||||
Tyto - Littérateur
|
||||
|
||||
#image: Image-1
|
||||
# Use this image for social networks
|
||||
#snpic: Pic-1
|
||||
#image: Pic-1
|
||||
URI
|
||||
Texte-alternatif
|
||||
|
||||
|
@ -271,8 +267,12 @@ date: %s
|
|||
Text-alternatif
|
||||
|
||||
-----
|
||||
#_image:Pic-1 c=title_class
|
||||
|
||||
#3
|
||||
#1
|
||||
((
|
||||
|
||||
))
|
||||
|
||||
"""
|
||||
|
||||
|
@ -448,7 +448,7 @@ def protect_bcodes_quotes(process, post_bottom):
|
|||
if not in_quote and not in_bcode:
|
||||
if not line:
|
||||
continue
|
||||
elif line.startswith('#') and not line.startswith(titles_tags):
|
||||
elif line.startswith('#') and not line.startswith(titles_user):
|
||||
continue
|
||||
|
||||
# bcode convertion to base64
|
||||
|
@ -492,7 +492,7 @@ def protect_icodes(post_bottom):
|
|||
|
||||
# Get only lines that contains code
|
||||
for ln, line in enumerate(post_bottom.rsplit('\n')):
|
||||
if not words_tags[9][0] in line: continue
|
||||
if not words_tags[8][0] in line: continue
|
||||
|
||||
# Iterate (c)haracter in line
|
||||
for i, c in enumerate(line):
|
||||
|
@ -506,17 +506,17 @@ def protect_icodes(post_bottom):
|
|||
if c_b == '{' and not c_bb == '\\':
|
||||
in_icode = True
|
||||
nbr_icodes += 1
|
||||
code = words_tags[9][2]
|
||||
code = words_tags[8][2]
|
||||
continue
|
||||
|
||||
# No more in code if
|
||||
if c_a == '}' and not c_b == '\\':
|
||||
in_icode = False
|
||||
src_code = convert_altname(src_code)
|
||||
code = '%s%s%s'%(code, src_code, words_tags[9][3])
|
||||
code = '%s%s%s'%(code, src_code, words_tags[8][3])
|
||||
b64_code = b64('Encode', code, 'I64.', '.I64')
|
||||
rep_code = "%s%s%s"%(
|
||||
words_tags[9][0], rep_code, words_tags[9][1]
|
||||
words_tags[8][0], rep_code, words_tags[8][1]
|
||||
)
|
||||
protect_article = protect_article.replace(rep_code, b64_code)
|
||||
|
||||
|
|
|
@ -161,6 +161,7 @@ def wip_article(target):
|
|||
|
||||
|
||||
# Convert contents from modules
|
||||
wip_clean_lines() # Remove comments and empty lines
|
||||
wip_images() # Images_%i from headers in DB
|
||||
wip_single_tags() # br /, anchors
|
||||
wip_words_tags() # Paragraphs, strongs, italics
|
||||
|
@ -223,6 +224,31 @@ def file_to_string(post_file):
|
|||
else: post_header = '%s\n%s'%(post_header, line)
|
||||
|
||||
|
||||
#=================================#
|
||||
# Remove comments and empty lines #
|
||||
#---------------------------------#
|
||||
def wip_clean_lines():
|
||||
global post_bottom
|
||||
|
||||
# Remove comments
|
||||
if db.comments > 0:
|
||||
for line in post_bottom.rsplit('\n'):
|
||||
if line.startswith('#') and not line.startswith(tyto.titles_user):
|
||||
replace_in_post(line, "")
|
||||
|
||||
# Remove empty lines
|
||||
post_temp = ''
|
||||
|
||||
for line in post_bottom.rsplit('\n'):
|
||||
if not line: continue
|
||||
|
||||
if not post_temp: post_temp = line
|
||||
else: post_temp = "%s\n%s"%(post_temp, line)
|
||||
|
||||
post_bottom = post_temp
|
||||
|
||||
|
||||
|
||||
#=========================================#
|
||||
# Create real static page, by #
|
||||
# including modules contents in HTML page #
|
||||
|
@ -240,7 +266,7 @@ def wip_static():
|
|||
wip_module = open(module, 'r').read()
|
||||
wip_html_post = \
|
||||
wip_html_post.replace(
|
||||
tyto.tags_html_mods[module],
|
||||
html.tags_html_mods[module],
|
||||
wip_module
|
||||
)
|
||||
tyto.set_file(db.post_wip, "New", wip_html_post)
|
||||
|
@ -282,21 +308,7 @@ def wip_single_tags():
|
|||
#----------------------------------#
|
||||
def wip_words_tags():
|
||||
# Strongs, italics...
|
||||
# (Stop after 8 tags)
|
||||
# For anchor (0), must do it differently
|
||||
m = 0
|
||||
for tag in tyto.words_tags:
|
||||
if m == 0:
|
||||
m += 1
|
||||
# Close anchor (generic)
|
||||
replace_in_post(tag[1],
|
||||
tag[3]
|
||||
)
|
||||
continue
|
||||
|
||||
elif m > 8:
|
||||
break
|
||||
|
||||
# Open tag
|
||||
replace_in_post(tag[0],
|
||||
tag[2]
|
||||
|
@ -305,7 +317,6 @@ def wip_words_tags():
|
|||
replace_in_post(tag[1],
|
||||
tag[3]
|
||||
)
|
||||
m += 1
|
||||
|
||||
|
||||
for ln, line in enumerate(post_bottom.rsplit('\n')):
|
||||
|
@ -339,10 +350,14 @@ def wip_words_tags():
|
|||
|
||||
anchor_links = re.findall(r'>_(.+?):', line)
|
||||
for item in anchor_links:
|
||||
anchor_id = '%s%s:'%(tyto.words_tags[0][0], item)
|
||||
anchor_id = '%s%s:'%(tyto.anchor_tags[0], item)
|
||||
replace_in_post(anchor_id,
|
||||
tyto.words_tags[0][2]%item
|
||||
tyto.anchor_tags[2]%item
|
||||
)
|
||||
|
||||
replace_in_post(tyto.anchor_tags[1],
|
||||
tyto.anchor_tags[3]
|
||||
)
|
||||
|
||||
|
||||
#========================#
|
||||
|
@ -730,10 +745,10 @@ def wip_titles():
|
|||
global post_bottom
|
||||
|
||||
for line in post_bottom.rsplit('\n'):
|
||||
if line.startswith('#'):
|
||||
tx = int(line[1])
|
||||
if line.startswith(tyto.titles_user):
|
||||
tx = line[1]
|
||||
title_name = line[2: len(line)].lstrip()
|
||||
title_html = tyto.titles_tags[tx][1]%title_name
|
||||
title_html = tyto.titles_tags[int(tx)][1]%title_name
|
||||
replace_in_post(line, title_html)
|
||||
|
||||
wip_titles_div()
|
||||
|
|
Loading…
Reference in New Issue