Fix wip anchors + other fixes
This commit is contained in:
parent
a19ba8dcf8
commit
ba9961e357
|
@ -84,9 +84,9 @@ pass_db = \
|
||||||
|
|
||||||
pass_targets = \
|
pass_targets = \
|
||||||
(
|
(
|
||||||
'updated',
|
'added',
|
||||||
'again',
|
'again',
|
||||||
'newer',
|
'updated',
|
||||||
'domain',
|
'domain',
|
||||||
'footer',
|
'footer',
|
||||||
'metas',
|
'metas',
|
||||||
|
@ -96,7 +96,7 @@ pass_targets = \
|
||||||
'template'
|
'template'
|
||||||
)
|
)
|
||||||
|
|
||||||
multi_chk = ('updated', 'again', 'newer')
|
multi_chk = ('added', 'again', 'updated')
|
||||||
|
|
||||||
action = ''
|
action = ''
|
||||||
target = ''
|
target = ''
|
||||||
|
|
|
@ -115,7 +115,7 @@ def check_all(option):
|
||||||
global domain_dir
|
global domain_dir
|
||||||
found = False
|
found = False
|
||||||
|
|
||||||
if option == "newer":
|
if option == "added":
|
||||||
os.chdir(dom.articles_d)
|
os.chdir(dom.articles_d)
|
||||||
domain_dir = True
|
domain_dir = True
|
||||||
|
|
||||||
|
@ -404,6 +404,7 @@ def check_needed_tags(post_header):
|
||||||
# Set data from tag
|
# Set data from tag
|
||||||
if line.startswith('%s:'%tag):
|
if line.startswith('%s:'%tag):
|
||||||
globals()[tag] = line.rsplit('%s:'%tag)[1].lstrip()
|
globals()[tag] = line.rsplit('%s:'%tag)[1].lstrip()
|
||||||
|
globals()[tag] = globals()[tag].replace('"', '')
|
||||||
# Stat for "tags:"
|
# Stat for "tags:"
|
||||||
if tag == 'tags':
|
if tag == 'tags':
|
||||||
stat_tags = len(globals()[tag].strip().split(","))
|
stat_tags = len(globals()[tag].strip().split(","))
|
||||||
|
@ -669,6 +670,59 @@ def check_snpic(name):
|
||||||
snpic_url = dom.www_url + web_uri
|
snpic_url = dom.www_url + web_uri
|
||||||
|
|
||||||
|
|
||||||
|
#==========================================#
|
||||||
|
# Check anchors target and links #
|
||||||
|
# Check for duplicate anchor name target #
|
||||||
|
# Cannot have anchors links without target #
|
||||||
|
#------------------------------------------#
|
||||||
|
def check_anchors():
|
||||||
|
global post_err
|
||||||
|
|
||||||
|
# Anchor target
|
||||||
|
if nbr_ancs > 0:
|
||||||
|
# Create anchors names targets
|
||||||
|
anchors_names = (())
|
||||||
|
for line in post_bottom.rsplit('\n'):
|
||||||
|
if line.startswith(tyto.single_tags[1][0]):
|
||||||
|
name = tyto.get_css(line)
|
||||||
|
anchors_names = anchors_names + ((name),)
|
||||||
|
|
||||||
|
# Check for uniq anchor_name
|
||||||
|
for name in list(anchors_names):
|
||||||
|
if anchors_names.count(name) > 1:
|
||||||
|
post_err = True
|
||||||
|
logs.out("15", '"%s %s" > %s'%(
|
||||||
|
tyto.single_tags[1][0], name, db.uri_file
|
||||||
|
), False)
|
||||||
|
break
|
||||||
|
|
||||||
|
# Anchor link
|
||||||
|
if post_anchors == 0:
|
||||||
|
return
|
||||||
|
|
||||||
|
# Article has anchors links but no anchor target
|
||||||
|
elif nbr_ancs == 0:
|
||||||
|
logs.out("12", "%s [NAME] > %s"%(
|
||||||
|
tyto.single_tags[1][0], db.uri_file
|
||||||
|
), False)
|
||||||
|
post_err = True
|
||||||
|
return
|
||||||
|
|
||||||
|
# Check in 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:
|
||||||
|
anchors = re.findall(r">_(.*?)_<", line)
|
||||||
|
for anchor in anchors:
|
||||||
|
anchor_name = anchor.rsplit(':')[0].lstrip()
|
||||||
|
if not anchor_name in anchors_names:
|
||||||
|
logs.out("12", 'L=%s. anchor "%s" > %s'%(
|
||||||
|
ln + 1 + ln_header, anchor_name, db.uri_file
|
||||||
|
), False)
|
||||||
|
post_err = True
|
||||||
|
|
||||||
|
|
||||||
#===========================#
|
#===========================#
|
||||||
# Check tags in post_bottom #
|
# Check tags in post_bottom #
|
||||||
#---------------------------#
|
#---------------------------#
|
||||||
|
@ -705,33 +759,7 @@ def check_content(post_bottom):
|
||||||
# Check if anchor has target
|
# Check if anchor has target
|
||||||
# Count anchors target
|
# Count anchors target
|
||||||
#---------------------------
|
#---------------------------
|
||||||
if post_anchors > 0:
|
check_anchors()
|
||||||
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:
|
|
||||||
anchors = re.findall(r">_(.*?)_<", line)
|
|
||||||
for anchor in anchors:
|
|
||||||
css_anchor = anchor.rsplit(':')[0]
|
|
||||||
tag = '%s %s'%(tyto.single_tags[1][0], css_anchor)
|
|
||||||
if not tag in post_bottom:
|
|
||||||
logs.out("12", 'L=%s. anchor "%s" > %s'%(
|
|
||||||
ln + ln_header, tag, db.uri_file
|
|
||||||
), False)
|
|
||||||
post_err = True
|
|
||||||
|
|
||||||
# Anchor "->" id must be uniq
|
|
||||||
if nbr_ancs > 0:
|
|
||||||
if line.startswith(tyto.single_tags[1][0]):
|
|
||||||
set_css = tyto.get_css(line)
|
|
||||||
is_uniq_anchor = "%s %s"%(tyto.single_tags[1][0], set_css)
|
|
||||||
c_uniq_anchor = post_bottom.count(is_uniq_anchor)
|
|
||||||
if c_uniq_anchor > 1:
|
|
||||||
logs.out("15", 'L=%s. %sx "%s" > %s'%(
|
|
||||||
ln + ln_header, c_uniq_anchor, is_uniq_anchor,
|
|
||||||
db.uri_file
|
|
||||||
), False)
|
|
||||||
post_err = True
|
|
||||||
break
|
|
||||||
|
|
||||||
|
|
||||||
# Lists: check if contents are valid
|
# Lists: check if contents are valid
|
||||||
|
|
|
@ -50,9 +50,9 @@ def manage_publish(target):
|
||||||
#-----------------------------------------
|
#-----------------------------------------
|
||||||
if target in args.pass_targets:
|
if target in args.pass_targets:
|
||||||
do = {
|
do = {
|
||||||
'all' : publish_all,
|
'updated' : publish_all,
|
||||||
'again' : publish_all,
|
'again' : publish_all,
|
||||||
'newer' : publish_all,
|
'added' : publish_all,
|
||||||
'sidebar' : html.create_sidebar,
|
'sidebar' : html.create_sidebar,
|
||||||
'navbar' : html.create_navbar,
|
'navbar' : html.create_navbar,
|
||||||
'metas' : html.create_user_metas,
|
'metas' : html.create_user_metas,
|
||||||
|
@ -208,7 +208,7 @@ def publish_all(option):
|
||||||
|
|
||||||
if not db.hash_wip: continue
|
if not db.hash_wip: continue
|
||||||
if option == "again" and not db.sync_srvs: continue
|
if option == "again" and not db.sync_srvs: continue
|
||||||
if option == "newer" and not db.old_www: continue
|
if option == "added" and not db.old_www: continue
|
||||||
|
|
||||||
print(':> [%s] - %s'%(db.title, db.post_src))
|
print(':> [%s] - %s'%(db.title, db.post_src))
|
||||||
if db.old_chk:
|
if db.old_chk:
|
||||||
|
|
|
@ -57,7 +57,7 @@ def manage(target):
|
||||||
do = {
|
do = {
|
||||||
'updated' : wip_all,
|
'updated' : wip_all,
|
||||||
'again' : wip_all,
|
'again' : wip_all,
|
||||||
'newer' : wip_all,
|
'added' : wip_all,
|
||||||
'sidebar' : html.create_sidebar,
|
'sidebar' : html.create_sidebar,
|
||||||
'navbar' : html.create_navbar,
|
'navbar' : html.create_navbar,
|
||||||
'metas' : html.create_user_metas,
|
'metas' : html.create_user_metas,
|
||||||
|
@ -105,10 +105,10 @@ def wip_all(process):
|
||||||
langs.site.wip_again, langs.site.q
|
langs.site.wip_again, langs.site.q
|
||||||
), True)
|
), True)
|
||||||
|
|
||||||
elif args.target == "updated":
|
elif args.target == "addedd":
|
||||||
print(' │ %s'%langs.site.wip_older)
|
print(' │ %s'%langs.site.wip_older)
|
||||||
|
|
||||||
elif args.target == "newer":
|
elif args.target == "updated":
|
||||||
print(' │ %s'%langs.site.wip_newer)
|
print(' │ %s'%langs.site.wip_newer)
|
||||||
|
|
||||||
# Sort by newer articles (created by last check)
|
# Sort by newer articles (created by last check)
|
||||||
|
@ -137,7 +137,7 @@ def wip_all(process):
|
||||||
continue
|
continue
|
||||||
|
|
||||||
# newer: article not yet wip
|
# newer: article not yet wip
|
||||||
elif option == "newer" and db.hash_wip:
|
elif option == "added" and db.hash_wip:
|
||||||
continue
|
continue
|
||||||
|
|
||||||
# All: only old wip
|
# All: only old wip
|
||||||
|
@ -251,14 +251,14 @@ def wip_single_tags():
|
||||||
)
|
)
|
||||||
|
|
||||||
# Anchor source
|
# Anchor source
|
||||||
for line in post_bottom.rsplit('\n'):
|
for ln, line in enumerate(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)
|
||||||
replace_in_post(line,
|
|
||||||
|
replace_in_post(post_bottom.rsplit('\n')[ln],
|
||||||
tyto.single_tags[1][1]%set_css
|
tyto.single_tags[1][1]%set_css
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
#==================================#
|
#==================================#
|
||||||
# Convert tags (strong, icodes...) #
|
# Convert tags (strong, icodes...) #
|
||||||
# Convert Paragraphs #
|
# Convert Paragraphs #
|
||||||
|
@ -369,12 +369,13 @@ def wip_links():
|
||||||
def wip_abbrs():
|
def wip_abbrs():
|
||||||
if db.uniq_abbrs == 0: return
|
if db.uniq_abbrs == 0: return
|
||||||
|
|
||||||
abbr_src = '<abbr title="%s">%s</abbr>'
|
abbr_src = '<abbr class="%s" title="%s">%s</abbr>'
|
||||||
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
|
||||||
try: abbr_show = eval(abbr)[2]
|
try: abbr_show = eval(abbr)[2]
|
||||||
except: abbr_show = eval(abbr)[0]
|
except: abbr_show = eval(abbr)[0]
|
||||||
abbr_html = abbr_src%(eval(abbr)[1],
|
abbr_html = abbr_src%(dom.css,
|
||||||
|
eval(abbr)[1],
|
||||||
abbr_show
|
abbr_show
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
@ -278,8 +278,8 @@ args_helps = """\n# Nouveau domaine :
|
||||||
# Traitement en masse
|
# Traitement en masse
|
||||||
updated : Mise à jour des articles modifiés (déjà vérifiés)
|
updated : Mise à jour des articles modifiés (déjà vérifiés)
|
||||||
again : Forcer TOUS les articles déjà vérifiés
|
again : Forcer TOUS les articles déjà vérifiés
|
||||||
newer : [check] Vérifier tous les article .tyto dans le domaine
|
added : [check] Vérifier tous les article .tyto dans le domaine
|
||||||
qui n'ont pas été déjà vérifiés
|
qui n'ont pas été déjà validés
|
||||||
[wip, publish] Créer les pages HTML des articles
|
[wip, publish] Créer les pages HTML des articles
|
||||||
qui ont été modifiés et vérifiés
|
qui ont été modifiés et vérifiés
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue