misc changes and fixes

This commit is contained in:
Cyrille L 2023-03-13 16:50:31 +01:00
parent a7397a09e0
commit a1154029d1
6 changed files with 60 additions and 93 deletions

View File

@ -53,16 +53,11 @@ domain_values = \
'domain_files', 'domain_files',
'domain_images', 'domain_images',
'articles_db', 'articles_db',
'html_db',
'navbars_dir', 'navbars_dir',
'navbar_load', 'navbar_load',
'navbar_load_db',
'sidebar_load', 'sidebar_load',
'sidebar_load_db',
'metas_load', 'metas_load',
'metas_load_db',
'footer_load', 'footer_load',
'footer_load_db',
'domain_short', 'domain_short',
'domain_www_url', 'domain_www_url',
'domain_wip_url', 'domain_wip_url',

View File

@ -139,16 +139,11 @@ def create_domain(target):
'domain_files = "%sarticles/files/"\n'%db.conf_dir + \ 'domain_files = "%sarticles/files/"\n'%db.conf_dir + \
'domain_images = "%sarticles/images/"\n'%db.conf_dir + \ 'domain_images = "%sarticles/images/"\n'%db.conf_dir + \
'articles_db = "%sarticles/"\n'%db_dir + \ 'articles_db = "%sarticles/"\n'%db_dir + \
'html_db = "%s"\n'%db_dir_html + \
'navbars_dir = "%s"\n'%navbars_conf + \ 'navbars_dir = "%s"\n'%navbars_conf + \
'navbar_load = "%styto.navbar"\n'%navbars_conf + \ 'navbar_load = "%styto.navbar"\n'%navbars_conf + \
'navbar_load_db = "%snavbar_load.conf"\n'%db_dir_html + \
'sidebar_load = "%styto.sidebar"\n'%navbars_conf + \ 'sidebar_load = "%styto.sidebar"\n'%navbars_conf + \
'sidebar_load_db = "%ssidebar_load.conf"\n'%db_dir_html + \
'metas_load = "%styto.metas.html"\n'%navbars_conf + \ 'metas_load = "%styto.metas.html"\n'%navbars_conf + \
'metas_load_db = "%smetas_load.conf"\n'%db_dir_html + \
'footer_load = "%styto.footer.html"\n'%navbars_conf + \ 'footer_load = "%styto.footer.html"\n'%navbars_conf + \
'footer_load_db = "%sfooter_load.conf"\n'%db_dir_html + \
'\ndomain_short = "%s"\n'%domain_short + \ '\ndomain_short = "%s"\n'%domain_short + \
'domain_www_url = "%s"\n'%domain_www_url + \ 'domain_www_url = "%s"\n'%domain_www_url + \
'domain_wip_url = "%s"\n'%domain_wip_url 'domain_wip_url = "%s"\n'%domain_wip_url
@ -549,7 +544,6 @@ def create_domain(target):
set_f = '\n# Custom HTML (ONE Line)\n' + \ set_f = '\n# Custom HTML (ONE Line)\n' + \
"domain_footer_about = '%s'"%domain_footer_about "domain_footer_about = '%s'"%domain_footer_about
except: except:
domain_about = db.domain_about
set_f = '\n# Custom HTML (ONE Line)\n' + \ set_f = '\n# Custom HTML (ONE Line)\n' + \
"domain_footer_about = '<p>%s</p>'"%domain_about "domain_footer_about = '<p>%s</p>'"%domain_about
@ -593,7 +587,7 @@ def create_domain(target):
db.srv_wip_tpl, db.srv_wip_images, db.srv_wip_files, db.srv_wip_tpl, db.srv_wip_images, db.srv_wip_files,
db.srv_www_tpl, db.srv_www_images, db.srv_www_files, db.srv_www_tpl, db.srv_www_images, db.srv_www_files,
db.domain_files, db.domain_images, db.navbars_dir, db.domain_files, db.domain_images, db.navbars_dir,
db.articles_db, db.html_db db.articles_db
) )
print('') print('')
@ -689,7 +683,6 @@ def create_sidebar(option):
elif tyto.n == 1: sdb_load = sdb_load_en elif tyto.n == 1: sdb_load = sdb_load_en
tyto.set_file(db.sidebar_load, 'new', sdb_load) tyto.set_file(db.sidebar_load, 'new', sdb_load)
tyto.create_db_load(db.sidebar_load, db.sidebar_load_db)
logs.out("33", db.sidebar_load, False) logs.out("33", db.sidebar_load, False)
@ -766,7 +759,6 @@ def create_navbar(option):
elif tyto.n == 1: nvb_load = nav_load_en elif tyto.n == 1: nvb_load = nav_load_en
tyto.set_file(db.navbar_load, 'new', nvb_load) tyto.set_file(db.navbar_load, 'new', nvb_load)
tyto.create_db_load(db.navbar_load, db.navbar_load_db)
logs.out("33", db.navbar_load, False) logs.out("33", db.navbar_load, False)
@ -840,7 +832,6 @@ def create_metas(option):
if not res in ['y', 'Y']: return if not res in ['y', 'Y']: return
tyto.set_file(db.metas_load, 'new', metas_tags) tyto.set_file(db.metas_load, 'new', metas_tags)
tyto.create_db_load(db.metas_load, db.metas_load_db)
logs.out("33", db.metas_load, False) logs.out("33", db.metas_load, False)
@ -989,7 +980,6 @@ def create_footer(option):
'</footer>' '</footer>'
tyto.set_file(db.footer_load, 'new', footer) tyto.set_file(db.footer_load, 'new', footer)
tyto.create_db_load(db.footer_load, db.footer_load_db)
logs.out("33", db.footer_load, False) logs.out("33", db.footer_load, False)
# Generic HTML list in footer # Generic HTML list in footer

View File

@ -180,23 +180,23 @@ def create_html_infos_section(process):
date_pub = date_new[2] + '/' + date_new[1] + '/' + date_new[0] date_pub = date_new[2] + '/' + date_new[1] + '/' + date_new[0]
# in <article> > section info : line with new date # in <article> > section info : line with new date
post_pub = '%s<p>'%(8 * ' ') + \ post_pub = \
'<span id="article_title" title="%s">Article</span> '%( '%s<p>'%(8 * ' ') + \
title '<span id="article_title" title="%s">Article</span> '%(title) + \
) + \ '<span title="%s %s">%s</span> '%(tyto.trans[10][tyto.n],
'<span title="%s %s">%s</span> '%( date[0],
tyto.trans[10][tyto.n], date[0], tyto.trans[7][tyto.n] tyto.trans[7][tyto.n]
) + \ ) + \
'<span id="article_author">%s</span>. %s '%( '<span id="article_author">%s</span>. %s '%(author,
author, tyto.trans[8][tyto.n] tyto.trans[8][tyto.n]
) + \ ) + \
'<time datetime="%s">'%date_raw + \ '<time datetime="%s">'%date_raw + \
'<span id="article_date">%s</span> %s '%( '<span id="article_date">%s</span> %s '%(date_pub,
date_pub, tyto.trans[9][tyto.n] tyto.trans[9][tyto.n]
) + \ ) + \
'<span id="article_time">%s</span>'%time_pub + \ '<span id="article_time">%s</span>'%time_pub + \
'</time>' + \ '</time>' + \
'</p>' '</p>'
# meta search_date= # meta search_date=
meta_pub = ' <meta name="search_date" content="%s" />\n'%( meta_pub = ' <meta name="search_date" content="%s" />\n'%(
@ -498,7 +498,6 @@ def create_user_metas(option):
logs.out("255", '', True) logs.out("255", '', True)
user_file = open(db.metas_load, 'r').read() user_file = open(db.metas_load, 'r').read()
for line in user_file.rsplit('\n'): for line in user_file.rsplit('\n'):
if line.startswith(metas_used): if line.startswith(metas_used):
if user_metas: user_metas = "%s\n %s"%(user_metas, line) if user_metas: user_metas = "%s\n %s"%(user_metas, line)

View File

@ -71,5 +71,4 @@ def out(nbr, value, out):
msg = logs[nbr] msg = logs[nbr]
print(msg) print(msg)
if int(nbr) >= 20: nbr = 0
if out: sys.exit(int(nbr)) if out: sys.exit(int(nbr))

View File

@ -20,7 +20,6 @@
import os, sys, shutil, importlib import os, sys, shutil, importlib
import logs, args, db, html, tyto, domain, stats, rss import logs, args, db, html, tyto, domain, stats, rss
#==============================# #==============================#
# Manage action, get post db # # Manage action, get post db #
# check if publish can be done # # check if publish can be done #
@ -46,37 +45,18 @@ def manage_publish(target):
do[target]('www') do[target]('www')
return return
# Database must exists...
# Publish in www server an article
#---------------------------------
err_pub = False # Default (error to publish)
if not db.db_exists: if not db.db_exists:
logs.out("25", db.uri_file, True) logs.out("25", db.uri_file, True)
# Checking if article can be publish
if not db.hash_chk:
logs.out("25", db.uri_file, False)
err_pub = True
elif not db.hash_wip:
logs.out("30", db.uri_file, False)
err_pub = True
if db.hash_wip:
# wip and current article have different hash
if db.hash_post != db.hash_chk:
logs.out("9", db.uri_file, False)
err_pub = True
elif db.hash_wip != db.hash_chk:
logs.out("30", db.uri_file, False)
err_pub = True
if not os.path.exists(db.post_wip):
logs.out("1", db.post_wip, True)
if err_pub: sys.exit(1)
# Publish in www server an article
check_to_publish('one')
publish_article() publish_article()
# Create new ATOM/RSS file
rss.create_feed()
#===============# #===============#
# Let's publish # # Let's publish #
@ -96,9 +76,6 @@ def publish_article():
# Replace publish HTML line # Replace publish HTML line
replace_line_pub() replace_line_pub()
# Create new ATOM/RSS file
rss.create_feed()
#=================================================# #=================================================#
# Replace line in article containing publish date # # Replace line in article containing publish date #
@ -207,20 +184,45 @@ def create_all(option):
print(':> [%s] | %s'%(db.title, db.post_src)) print(':> [%s] | %s'%(db.title, db.post_src))
hash_post = tyto.get_filesum(db.post_src, True) # From content file hash_post = tyto.get_filesum(db.post_src, True) # From content file
if not db.hash_chk: check_to_publish('all')
logs.out("25", db.uri_file, False) if err_pub: continue
continue
if db.hash_chk != db.hash_post:
logs.out("9", db.uri_file, False)
continue
if db.hash_wip != db.hash_chk:
logs.out("30", db.uri_file, False)
continue
published = True published = True
publish_article() publish_article()
if not published: if not published:
logs.out("28", '(publish)', True) logs.out("28", '(publish)', True)
else:
# Create new ATOM/RSS file
rss.create_feed()
#==============================#
# Check if it can be published #
#------------------------------#
def check_to_publish(process):
global err_pub
err_pub = False
# Article must exists in wip server
if not os.path.exists(db.post_wip):
logs.out("1", db.post_wip, True)
# Checking if article can be publish
if not db.hash_chk:
logs.out("25", db.uri_file, False)
err_pub = 25
elif not db.hash_wip:
logs.out("30", db.uri_file, False)
err_pub = 30
elif db.hash_post != db.hash_chk:
logs.out("9", db.uri_file, False)
err_pub = 9
elif db.hash_wip != db.hash_chk:
logs.out("30", db.uri_file, False)
err_pub = 30
if err_pub:
if process == 'all': return
elif process == 'one': sys.exit(err_pub)

View File

@ -214,24 +214,6 @@ def set_file(path, new, text):
logs.out("4", path, True) logs.out("4", path, True)
#========================================================#
# Create DB file with hash from [type]_load file content #
#--------------------------------------------------------#
def create_db_load(file_load, file_db):
hash_load = get_filesum(file_load, True)
if not os.path.exists(file_db):
line = 'file_load_hash = "%s"'%hash_load
set_file(file_db, True, line)
return
global file_load_hash
file_load_hash = ''
exec(open(file_db, 'r').read(), globals())
if not file_load_hash == hash_load:
line = 'file_load_hash = "%s"'%hash_load
set_file(file_db, True, line)
#==========================# #==========================#
# Get CSS from line if set # # Get CSS from line if set #
#--------------------------# #--------------------------#