This commit is contained in:
Cyrille L 2023-03-24 17:19:30 +01:00
parent 55bac503ce
commit d487b21c57
22 changed files with 2286 additions and 1492 deletions

View File

@ -26,15 +26,16 @@
import sys import sys
sys.path.insert(0, '/var/lib/tyto/program') sys.path.insert(0, '/var/lib/tyto/program')
#====================# #====================#
# MAIN # # MAIN #
# Treat Arguments # # Treat Arguments #
#--------------------#------------------------------------------------- #--------------------#-------------------------------------------------
import logs import logs
if not __name__ == "__main__": if not __name__ == "__main__":
logs.out("14", '', True) logs.out("14", '', True)
# Check arguments # Check arguments
import args import args
action = args.set_action() action = args.set_action()
@ -42,22 +43,24 @@ target = args.set_target()
# Command start argument # Command start argument
import check, domain, html, new, publish, show, wip, infos import check, form, html, new, publish, show, wip, infos
actions = { actions = {
'check' : check.manage_check, 'check' : check.manage,
'help' : infos.tyto, 'help' : infos.tyto,
'edit' : show.manage_show, 'edit' : show.manage,
'edit-db' : show.manage_show, 'edit-about' : show.manage,
'edit-wip' : show.manage_show, 'edit-db' : show.manage,
'edit-www' : show.manage_show, 'edit-wip' : show.manage,
'new' : new.manage_new, 'edit-www' : show.manage,
'publish' : publish.manage_publish, 'new' : new.manage,
'show' : show.manage_show, 'publish' : publish.manage_publish,
'show-db' : show.manage_show, 'show' : show.manage,
'show-wip' : show.manage_show, 'show-about' : show.manage,
'show-www' : show.manage_show, 'show-db' : show.manage,
'template' : publish.manage_publish, 'show-wip' : show.manage,
'wip' : wip.manage_wip, 'show-www' : show.manage,
'template' : publish.manage_publish,
'wip' : wip.manage_wip,
} }

View File

@ -27,12 +27,14 @@ actions = \
( (
'check', 'check',
'edit', 'edit',
'edit-about',
'edit-db', 'edit-db',
'edit-wip', 'edit-wip',
'edit-www', 'edit-www',
'help', 'help',
'new', 'new',
'show', 'show',
'show-about',
'show-db', 'show-db',
'show-wip', 'show-wip',
'show-www', 'show-www',

View File

@ -18,37 +18,65 @@
#********************************************************************** #**********************************************************************
# Import needed libs # Import needed libs
import sys, os, re, datetime import time, importlib, sys, os, re, datetime
from datetime import datetime from datetime import datetime
from time import gmtime, strftime from time import gmtime, strftime
import time, importlib
import args, logs, db, domain, tyto import args, logs, dom, db, form, tyto
# load locale translation
trans_dir = '/var/lib/tyto/translations'
sys.path.insert(0, trans_dir)
# Get default system language
# or set "en" (english) if no translation file
try:
lang_site = locale.getdefaultlocale()[0].split('_')[0]
os.path.exists('%s/site_%s.py'%(trans_dir, lang_site))
except:
lang_site = 'en'
lang_sys = lang_site
# Set language site/form from configuration domain
# or set default english if not known
try:
dom.exists
lang_site = dom.lang_site
os.path.exists('%s/site_%s.py'%(trans_dir, lang_site))
tr = importlib.import_module('site_%s'%lang_site, package=None)
except:
tr = importlib.import_module('site_%s'%lang_site, package=None)
post_err = False post_err = False
#=========================# #=========================#
# Manage Argument 'check' # # Manage Argument 'check' #
# Start checking article # # Start checking article #
#-------------------------#-------------------------------------------- #-------------------------#--------------------------------------------
def manage_check(target): def manage(target):
domain.domain_needed() dom.valid()
# target needed # target needed
if not target: if not target:
logs.out("5", '', True) logs.out("5", args.action, True)
elif not db.post:
sys.exit(1)
elif not target in args.multi_chk \ elif not target in args.multi_chk \
and db.db_exists \ and db.exists \
and not db.old_chk: and not db.old_chk:
logs.out("20", db.date_chk, False) logs.out("20", '%s > %s'%(db.date_chk, db.uri_file), False)
ask = ' ├ Check again this article ? ' ask = ''
try: try:
res = input(ask) ask = input('%s%s '%(tr.check_a, tr.q))
except KeyboardInterrupt: except KeyboardInterrupt:
print('') print('')
logs.out("255", '', True) logs.out("255", '', True)
if not res in ['y', 'Y']: if not ask in form.answer_yes:
return return
check_process(target) check_process(target)
@ -59,7 +87,7 @@ def manage_check(target):
check_process(target) check_process(target)
if post_err and not target in args.multi_chk: if post_err and not target in args.multi_chk:
logs.out("7", '', True) logs.out("7", db.uri_file, True)
#==============================================# #==============================================#
@ -94,7 +122,7 @@ def check_all(option):
# Check articles process # # Check articles process #
#------------------------# #------------------------#
def check_process(target): def check_process(target):
if not db.post_exists: sys.exit(1) if not db.post: sys.exit(1)
global post_bottom, article_bottom global post_bottom, article_bottom
global post_words global post_words
@ -104,7 +132,7 @@ def check_process(target):
post_err = False post_err = False
# Set values for wip and www from DB # Set values for wip and www from DB
if db.db_exists: if db.exists:
date_wip = db.date_wip date_wip = db.date_wip
hash_wip = db.hash_wip hash_wip = db.hash_wip
date_www = db.date_www date_www = db.date_www
@ -116,10 +144,11 @@ def check_process(target):
# Get uri after articles/ (no starting / in value) # Get uri after articles/ (no starting / in value)
global src_post_short_uri, srv_post_short_uri, direc_src global src_post_short_uri, srv_post_short_uri, direc_src
global srv_post_wip_uri, srv_post_www_uri global srv_post_wip_uri, srv_post_www_uri
src_post_short_uri = db.uri_file.rsplit(db.domain_articles)[1]
src_post_short_uri = db.uri_file.rsplit(dom.articles_d)[1]
srv_post_short_uri = src_post_short_uri.replace(ext_src[1], '.html') srv_post_short_uri = src_post_short_uri.replace(ext_src[1], '.html')
srv_post_wip_uri = db.srv_wip + srv_post_short_uri srv_post_wip_uri = dom.srv_wip + srv_post_short_uri
srv_post_www_uri = db.srv_www + srv_post_short_uri srv_post_www_uri = dom.srv_www + srv_post_short_uri
direc_src = src_post_short_uri.split("/")[-1] direc_src = src_post_short_uri.split("/")[-1]
direc_src = src_post_short_uri.rsplit(direc_src)[0] direc_src = src_post_short_uri.rsplit(direc_src)[0]
@ -127,23 +156,26 @@ def check_process(target):
global sub_uri global sub_uri
sub_uri = db.uri_file.rsplit('articles/')[1] sub_uri = db.uri_file.rsplit('articles/')[1]
sub_nbr = sub_uri.count('/') sub_nbr = sub_uri.count('/')
if sub_nbr == 0 : sub_uri = './' if sub_nbr == 0: sub_uri = './'
else: sub_uri = sub_nbr * '../' else: sub_uri = sub_nbr * '../'
# Set HTTP link for wip and www # Set HTTP link for wip and www
global http_www, http_wip global http_www, http_wip
if srv_post_short_uri.endswith('index.html'): if srv_post_short_uri.endswith('index.html'):
http_www = "%s/%s"%(db.domain_www_url, direc_src) http_www = "%s/%s"%(dom.www_url, direc_src)
http_wip = '%s/%s'%(db.domain_wip_url, direc_src) http_wip = '%s/%s'%(dom.wip_url, direc_src)
else: else:
http_www = "%s/%s"%(db.domain_www_url, srv_post_short_uri) http_www = "%s/%s"%(dom.www_url, srv_post_short_uri)
http_wip = '%s/%s'%(db.domain_wip_url, srv_post_short_uri) http_wip = '%s/%s'%(dom.wip_url, srv_post_short_uri)
# Start checking processes # Start checking processes
#------------------------- #-------------------------
file_to_string(db.uri_file) # Convert file to string
# Also check for separator and empty article
file_to_string()
# Specific to inline-code: check markers on same line # Check for icodes, bcodes, quotes
# check icodes marks on same line
if_icodes_bcodes_quotes(post_bottom) if_icodes_bcodes_quotes(post_bottom)
# Protect block-codes and quotes # Protect block-codes and quotes
@ -156,25 +188,34 @@ def check_process(target):
tyto.protect_icodes(post_bottom) tyto.protect_icodes(post_bottom)
post_bottom = tyto.protect_article post_bottom = tyto.protect_article
# Check tags configuration
# Count words in article. Quotes, block-codes, icode = 1 per each check_headers(post_header.rsplit('\n'))
post_words = len(post_bottom.strip().split(" ")) if post_err: return
# Check for valid contents # Check for valid contents
check_content(post_bottom) check_content(post_bottom)
post_bottom = post_bottom.rsplit('\n')
#post_header = post_header.rsplit('\n') # Remove db (if exists) on post error and return
check_headers(post_header.rsplit('\n'))
# Exit if unused needed tags
if post_err: if post_err:
if db.db_exists and os.path.exists(db.post_db): if db.exists and tyto.exists(db.config):
os.remove(db.post_db) os.remove(db.config)
#logs.out("7", '', False)
return return
# No error
# Count words in article.
# Quotes, block-codes, icode = 1 per each
# At db creation, remove title numbers
post_words = 0
for line in post_bottom.rsplit("\n"):
if not line \
or line.startswith(tyto.nolinewords) \
or line.startswith("#") and \
not line.startswith(tyto.titles_tags):
continue
post_words = post_words + len(line.strip().split(" "))
# Create article's database
create_database() create_database()
@ -182,12 +223,12 @@ def check_process(target):
# Create string article from file # # Create string article from file #
# Check if separator or exit # # Check if separator or exit #
#---------------------------------# #---------------------------------#
def file_to_string(post_file): def file_to_string():
global article, post_header, post_bottom global article, post_header, post_bottom
post_header = post_bottom = '' post_header = post_bottom = ''
sep = False sep = content = False
article = open(post_file, 'r').read() article = open(db.uri_file, 'r').read()
for line in article.rsplit('\n'): for line in article.rsplit('\n'):
if line.startswith('-----'): if line.startswith('-----'):
@ -195,6 +236,7 @@ def file_to_string(post_file):
continue continue
if sep: if sep:
if line: content = True
if not post_bottom: post_bottom = line if not post_bottom: post_bottom = line
else: post_bottom = '%s\n%s'%(post_bottom, line) else: post_bottom = '%s\n%s'%(post_bottom, line)
else: else:
@ -203,7 +245,12 @@ def file_to_string(post_file):
# Check if separator or exit # Check if separator or exit
if not sep: if not sep:
logs.out("6", '-----', True) logs.out("6", db.uri_file, True)
if not content:
if db.exists and tyto.exists(db.config):
os.remove(db.config)
logs.out("18", db.uri_file, True)
#=============================================# #=============================================#
@ -212,8 +259,9 @@ def file_to_string(post_file):
# Stats for titles, quotes, bcodes, uniq_ancs # # Stats for titles, quotes, bcodes, uniq_ancs #
#---------------------------------------------# #---------------------------------------------#
def if_icodes_bcodes_quotes(post_bottom): def if_icodes_bcodes_quotes(post_bottom):
global icode, quote, bcode global icode, quote, bcode, post_err
global nbr_titles, nbr_quotes, nbr_bcodes, nbr_ancs global nbr_titles, nbr_quotes, nbr_bcodes, nbr_ancs
icode = quote = in_quote = bcode = in_bcode = False icode = quote = in_quote = bcode = in_bcode = False
nbr_titles = nbr_quotes = nbr_bcodes = nbr_ancs = 0 nbr_titles = nbr_quotes = nbr_bcodes = nbr_ancs = 0
@ -255,10 +303,13 @@ def if_icodes_bcodes_quotes(post_bottom):
icode_m1 = line.count(tyto.words_tags[9][0]) icode_m1 = line.count(tyto.words_tags[9][0])
icode_m2 = line.count(tyto.words_tags[9][1]) icode_m2 = line.count(tyto.words_tags[9][1])
if icode_m1 != icode_m2: if icode_m1 != icode_m2:
logs.out("8", 'inline-code: line %s. %s %s'%(ln, print(" ├─", line)
tyto.words_tags[9][0], tyto.words_tags[9][1] logs.out("8", 'icode: L=%s. "%s %s" > %s'%(ln,
), True tyto.words_tags[9][0], tyto.words_tags[9][1],
db.uri_file
), False
) )
post_err = True
else: else:
icode = True icode = True
@ -325,10 +376,10 @@ def check_headers(post_header):
if line.startswith(tag): if line.startswith(tag):
if date: continue if date: continue
date = line.rsplit(tag)[1].lstrip() date = line.rsplit(tag)[1].lstrip()
check_date(date, ln) check_date(date, ln, line)
if not post_err: if not post_err:
if tyto.n == 0: if lang_site == 'fr':
date = date.rsplit('-') date = date.rsplit('-')
date = date[2] + '/' + date[1] + '/' + date[0] date = date[2] + '/' + date[1] + '/' + date[0]
date = (date, date_check) date = (date, date_check)
@ -338,18 +389,19 @@ def check_headers(post_header):
# Check needed tags # # Check needed tags #
#-------------------# #-------------------#
# Set needed tags # Set needed tags
need_headers = { need_headers = \
tyto.headers[0] : title, {
tyto.headers[1] : about, tyto.headers[0] : title,
tyto.headers[2] : author, tyto.headers[1] : about,
tyto.headers[3] : tags, tyto.headers[2] : author,
tyto.headers[4] : date tyto.headers[3] : tags,
} tyto.headers[4] : date
}
# Check if set needed tags # Check if set needed tags
for tag in need_headers: for tag in need_headers:
if not need_headers[tag]: if not need_headers[tag]:
logs.out("6", tag, False) logs.out("17", tag, False)
post_err = True post_err = True
@ -560,7 +612,7 @@ def check_headers(post_header):
#---------------------------------------------- #----------------------------------------------
if snpic_name: continue if snpic_name: continue
snpic_url = '%s/template/%s'%(db.domain_www_url, db.domain_logo) snpic_url = '%s/template/%s'%(dom.www_url, dom.logo)
tag = tyto.headers[11] # snpic: tag = tyto.headers[11] # snpic:
if line.startswith(tag): if line.startswith(tag):
snpic_name = post_header[ln - 1].rsplit(tag)[1].lstrip() snpic_name = post_header[ln - 1].rsplit(tag)[1].lstrip()
@ -570,7 +622,7 @@ def check_headers(post_header):
image_uri = post_header[ln].lstrip() image_uri = post_header[ln].lstrip()
check_file_uri('image', image_uri, ln + 1) check_file_uri('image', image_uri, ln + 1)
snshare = True snshare = True
snpic_url = '%s%s'%(db.domain_www_url, web_uri) snpic_url = '%s%s'%(dom.www_url, web_uri)
break break
if not snshare: if not snshare:
@ -582,7 +634,7 @@ def check_headers(post_header):
# Check Date format and validity # # Check Date format and validity #
# Create False date_check # # Create False date_check #
#--------------------------------# #--------------------------------#
def check_date(date, ln): def check_date(date, ln, line):
global post_err, date_check global post_err, date_check
# Check if article date is valid (True) # Check if article date is valid (True)
@ -592,7 +644,10 @@ def check_date(date, ln):
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", 'Line %s (date, %s)'%(ln, date), False) print(" ├─", line)
logs.out("3", 'date: L=%s. "%s" > %s'%(
ln, 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:
@ -626,7 +681,7 @@ def check_file_uri(filetype, filename, ln):
fileuri = post_dir + filename fileuri = post_dir + filename
# Check if file exists # Check if file exists
if not os.path.exists(fileuri): if not tyto.exists(fileuri):
logs.out("1", "Line %s, %s"%(ln, fileuri), False) logs.out("1", "Line %s, %s"%(ln, fileuri), False)
post_err = True post_err = True
return return
@ -640,6 +695,9 @@ def check_file_uri(filetype, filename, ln):
def check_content(post_bottom): def check_content(post_bottom):
global post_err global post_err
#print("post_bottom")
#print(post_bottom)
# Check tags for words (strongs, italics...) # Check tags for words (strongs, italics...)
# Set stats for each one # Set stats for each one
#------------------------------------------- #-------------------------------------------
@ -766,12 +824,12 @@ def create_database():
'date_www = "%s"\n'%date_www + \ 'date_www = "%s"\n'%date_www + \
'hash_www = "%s"\n'%hash_www + \ 'hash_www = "%s"\n'%hash_www + \
'\n# Post configuration from needed tags\n' + \ '\n# Post configuration from needed tags\n' + \
'title = "%s"\n'%title + \ 'title = "%s"\n'%title + \
'about = "%s"\n'%about + \ 'about = "%s"\n'%about + \
'author = "%s"\n'%author + \ 'author = "%s"\n'%author + \
'tags = "%s"\n'%tags + \ 'tags = "%s"\n'%tags + \
'date = %s\n'%str(date) + \ 'date = %s\n'%str(date) + \
'snpic = "%s"\n'%snpic_url + \ 'snpic = "%s"\n'%snpic_url + \
'\n# Used files\n' + \ '\n# Used files\n' + \
'uris = (%s)\n'%files_post + \ 'uris = (%s)\n'%files_post + \
'\n# Post configuration from optional tags' '\n# Post configuration from optional tags'
@ -806,16 +864,19 @@ def create_database():
database, i, globals()['raw_%s'%i] database, i, globals()['raw_%s'%i]
) )
# Count real words
stat_words = post_words - nbr_titles
db_stats = '\n# Statistics from optional tags\n' + \ db_stats = '\n# Statistics from optional tags\n' + \
'uniq_anchors = %d\n'%nbr_ancs + \ 'uniq_anchors = %d\n'%nbr_ancs + \
'uniq_abbrs = %d\n'%stat_abbrs + \ 'uniq_abbrs = %d\n'%stat_abbrs + \
'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_raws = %d\n'%stat_raws + \ 'uniq_raws = %d\n'%stat_raws + \
'\n# Statistics from post content\n' + \ '\n# Statistics from post content\n' + \
'stat_tags = %d\n'%post_tags + \ 'stat_tags = %d\n'%post_tags + \
'stat_words = %d\n'%post_words + \ 'stat_words = %d\n'%stat_words + \
'stat_titles = %d\n'%nbr_titles + \ 'stat_titles = %d\n'%nbr_titles + \
'stat_paragraphs = %d\n'%post_paragraphs + \ 'stat_paragraphs = %d\n'%post_paragraphs + \
'stat_anchors = %d\n'%post_anchors + \ 'stat_anchors = %d\n'%post_anchors + \
@ -834,8 +895,8 @@ def create_database():
database = '%s\n%s'%(database, db_stats) database = '%s\n%s'%(database, db_stats)
tyto.set_file(db.post_db, 'new', database) tyto.set_file(db.config, 'new', database)
logs.out("21", '', False) logs.out("21", db.uri_file, False)
#=====================# #=====================#

View File

@ -1,7 +1,7 @@
#!/usr/bin/env python3 #!/usr/bin/env python3
# Name: Tyto - Littérateur # Name: Tyto - Littérateur
# Type: DBs tools # Type: DB for article
# Description: Search DBs (domain + post) and exec # Description: Search article database and exec
# file: db.py # file: db.py
# Folder: /var/lib/tyto/program/ # Folder: /var/lib/tyto/program/
# By echolib (XMPP: im@echolib.re) # By echolib (XMPP: im@echolib.re)
@ -17,259 +17,116 @@
#********************************************************************** #**********************************************************************
import os, sys import os
import args, logs, tyto, domain, wip, publish
action = args.action import args, dom, form, tyto, logs
target = args.target remove = exists = post = corrupt = False
#======================#
#----------------------#
# DOMAIN Configuration #
#----------------------#
#======================#
# Settings
#---------
domain_active = False
incomplete_domain = False
db_exists = post_exists = db_remove = False
no_chk = no_wip = no_www = False
old_chk = old_wip = old_www = False
file_wip = file_www = False
sync_srvs = False
home_dir = os.path.expanduser('~')
try: in_dir = os.getcwd() try: in_dir = os.getcwd()
except: logs.out("13", '', True) except: logs.out("13", '', True)
domain_conf = in_dir
# Settings for domain, check if db is not corrupted
domain_values = \
(
'domain_dir',
'domain_conf',
'domain_articles',
'domain_files',
'domain_images',
'articles_db',
'navbars_dir',
'navbar_load',
'sidebar_load',
'metas_load',
'footer_load',
'domain_short',
'domain_www_url',
'domain_wip_url',
'domain_title',
'domain_date',
'domain_about',
'domain_lang',
'domain_mail',
'domain_tags',
'domain_logo',
'domain_license',
'domain_licurl',
'domain_legalurl',
'domain_termsurl',
'domain_css',
'domain_sep',
'domain_relme',
'sidebar_title',
'sidebar_items',
'srv_root',
'srv_domain',
'srv_wip',
'srv_wip_tpl',
'srv_wip_images',
'srv_wip_files',
'srv_www',
'srv_www_tpl',
'srv_www_images',
'srv_www_files',
'wip_navbar',
'wip_sidebar',
'wip_metas',
'wip_footer',
'www_navbar',
'www_sidebar',
'www_metas',
'www_footer',
'www_rss',
'domain_rss',
'domain_rssitems',
'domain_footer_about',
'domain_active',
)
# Values in article's database
article_values = \
(
'post_id',
'post_src',
'post_wip',
'post_www',
'direc_src',
'short_src',
'short_srv',
'sub_uri',
'http_wip',
'http_www',
'date_chk',
'hash_chk',
'date_wip',
'hash_wip',
'date_www',
'hash_www',
'title',
'about',
'author',
'tags',
'date',
'snpic',
'uris',
'uniq_anchors',
'uniq_abbrs',
'uniq_links',
'uniq_images',
'uniq_files',
'uniq_raws',
'stat_tags',
'stat_words',
'stat_titles',
'stat_paragraphs',
'stat_anchors',
'stat_strongs',
'stat_bolds',
'stat_emphasis',
'stat_italics',
'stat_dels',
'stat_underlines',
'stat_cites',
'stat_customs',
'stat_icodes',
'stat_bcodes',
'stat_quotes',
'stat_lists'
)
# If error in DB, continue process for these options
domain_pass_args = \
(
'new',
'edit',
'show',
''
)
# Search and set domain conf file
# from current directory or from argument
#----------------------------------------
if '/articles' in in_dir: domain_conf = in_dir.rsplit('/articles')[0]
else: domain_conf = in_dir
conf_dir = domain_conf + "/"
domain_conf = '%s/tyto_domain.conf'%domain_conf
if os.path.exists(domain_conf): domain_exists = True
else: domain_exists = False
stdout = '%s %s domain "%s" in %s' # Show domain status
if domain_exists:
exec(open(domain_conf).read())
# Check if domain conf is valid
for conf in domain_values:
try:
eval(str(conf))
except:
incomplete_domain = True
logs.out("10", conf, False)
# Stop process if error, continue if 'new'
if not action in args.pass_actions:
if incomplete_domain: sys.exit(1)
try: domain_active
except: domain_active = False
# Internal process. No need to show when import reloaded
try:
domain_show
except:
if incomplete_domain: logs.out("41", domain_short, False)
elif domain_active: logs.out("42", domain_short, False)
else: logs.out("40", domain_short, False)
domain_show = True
else:
logs.out("43", domain_conf, False)
domain_show = True
#==================#
#------------------#
# ARTICLE DATABASE #
#------------------#
#================================#
# Get post DB from target #
# Conditions from command line #
# Get some post settings fom uri #
#--------------------------------#
if args.target \ if args.target \
and args.action in args.pass_db \ and args.action in args.pass_db \
and not args.target in args.pass_targets: and not args.target in args.pass_targets:
# Domain must be valid # Domain must be valid
domain.domain_needed() dom.valid()
uri_file = '%s/%s'%(in_dir, args.target) uri_file = '%s/%s'%(in_dir, args.target)
uri_id = tyto.get_filesum(uri_file, False) uri_id = tyto.get_filesum(uri_file, False)
# DB # DB
post_db = '%s%s.conf'%(articles_db, uri_id) config = '%s%s.config'%(dom.articles_db_d, uri_id)
if os.path.exists(post_db): db_exists = True if tyto.exists(config):
else: db_exists = False exists = True
exec(open(config).read())
else:
exists = False
# Article # Article
if os.path.exists(uri_file): if tyto.exists(uri_file):
post_exists = True post = True
hash_post = tyto.get_filesum(uri_file, True) hash_post = tyto.get_filesum(uri_file, True)
else: else:
post_exists = False post = False
remove = True
logs.out("1", uri_file, False) logs.out("1", uri_file, False)
# Remove DB if unused source article or corrupted DB # Remove DB if unused source article or corrupted DB
if db_exists: if exists:
if not post_exists: # Check if database config is valid (contains values)
db_remove = True values = \
elif os.stat(post_db).st_size < 1000: (
db_remove = True 'post_id',
logs.out('23', post_db, False) 'post_src',
else: 'post_wip',
exec(open(post_db).read(),globals()) 'post_www',
'direc_src',
'short_src',
'short_srv',
'sub_uri',
'http_wip',
'http_www',
'date_chk',
'hash_chk',
'date_wip',
'hash_wip',
'date_www',
'hash_www',
'title',
'about',
'author',
'tags',
'date',
'snpic',
'uris',
'uniq_anchors',
'uniq_abbrs',
'uniq_links',
'uniq_images',
'uniq_files',
'uniq_raws',
'stat_tags',
'stat_words',
'stat_titles',
'stat_paragraphs',
'stat_anchors',
'stat_strongs',
'stat_bolds',
'stat_emphasis',
'stat_italics',
'stat_dels',
'stat_underlines',
'stat_cites',
'stat_customs',
'stat_icodes',
'stat_bcodes',
'stat_quotes',
'stat_lists'
)
for value in values:
try:
eval(str(value))
except:
remove = True
corrupt = True
break
# Check if database conf is valid if remove and exists:
for conf in article_values: os.remove(config)
try: eval(str(conf)) exists = False
except: db_remove = True logs.out("23", config, False)
if db_remove:
os.remove(post_db)
db_exists = False
logs.out("23", post_db, False)
file_wip = file_www = False
old_chk = old_wip = old_www = False
no_chk = no_wip = no_www = False
sync_srvs = False
# Set Statuses for chk, wip, www # Set Statuses for chk, wip, www
if db_exists: if exists:
# File exists on servers # File exists on servers
if os.path.exists(post_wip): file_wip = True if tyto.exists(post_wip): file_wip = True
if os.path.exists(post_www): file_www = True if tyto.exists(post_www): file_www = True
# Source article has changed # Source article has changed
if hash_post != hash_chk: old_chk = True if hash_post != hash_chk: old_chk = True

View File

@ -0,0 +1,148 @@
#!/usr/bin/env python3
# Name: Tyto - Littérateur
# Type: DB for domain
# Description: Search domain datas and get statuses
# file: dom.py
# Folder: /var/lib/tyto/program/
# By echolib (XMPP: im@echolib.re)
# License: GNU AFFERO GENERAL PUBLIC LICENSE Version 3, 19 November 2007
#------------
# funny stats
#------------
# lines:
# functions:
# comments:
#----------------------------------------------------------------------
#**********************************************************************
import os, sys, importlib, locale
lib = 'tyto_domain'
exists = incomplete = active = valid = shortname = False
local_user = articles_db = activated = False
hole = False
# Set current directory
try: in_dir = os.getcwd()
except: hole = True
if not hole:
home_dir = os.path.expanduser('~')
# Set configuration domain directory
folder = in_dir
if '/articles' in in_dir:
folder = in_dir.rsplit('/articles')[0]
# Set configuration domain file
config = '%s/tyto_domain.py'%folder
# Set exists if configuration file
if os.path.exists(config):
exists = True
exec(open(config).read())
# For logs: show uri if not shortname known
try: shortname
except: shortname = config
if activated:
active = True
# Settings for domain, check if db is not corrupted
values = \
(
'directory',
'database',
'local_user',
'lang_sys',
'lang_logs',
'articles_db_d',
'articles_d',
'files_d',
'images_d',
'modules_d',
'navbar_f',
'sidebar_f',
'metas_f',
'footer_f',
'footer_about_f',
'shortname',
'www_url',
'wip_url',
'srv_root',
'srv_domain',
'srv_wip',
'srv_wip_tpl_d',
'srv_wip_images_d',
'srv_wip_files_d',
'srv_www',
'srv_www_tpl_d',
'srv_www_images_d',
'srv_www_files_d',
'wip_navbar_f',
'wip_sidebar_f',
'wip_metas_f',
'wip_footer_f',
'www_navbar_f',
'www_sidebar_f',
'www_metas_f',
'www_footer_f',
'wip_logo_f',
'www_logo_f',
'www_rss_f',
'logo',
'rss',
'rss_items',
'title',
'date',
'about',
'lang_site',
'mail',
'tags',
'license',
'license_url',
'legal_url',
'terms_url',
'css',
'sep',
'article_code',
'relme',
'sidebar_title',
'sidebar_items',
'activated'
)
err_val = (()) # Make a list from values error
dir_new = (()) # Make a list for directories to create
for value in values:
try:
eval(str(value))
except:
err_val = err_val + ((value),)
incomplete = True
active = False
# Check if directory exists
if not incomplete and value.endswith('_d'):
if not os.path.exists(eval(str(value))):
os.makedirs(eval(str(value)), exist_ok=True)
dir_new = dir_new + ((eval(str(value))),)
if articles_db and not os.path.exists(articles_db):
incomplete = True
#==============================================#
# When an active and complete domain is needed #
#----------------------------------------------#
if exists and not incomplete and active: valid = True
#====================================#
# Check if domain is valid and ready #
#------------------------------------#
def valid():
if incomplete: sys.exit(41)
elif not active: sys.exit(42)
elif not exists: sys.exit(1)

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -17,8 +17,32 @@
#********************************************************************** #**********************************************************************
import os, sys import os, sys, importlib
import logs, db, tyto, domain
import logs, dom, tyto, form
# load locale translation
trans_dir = '/var/lib/tyto/translations'
sys.path.insert(0, trans_dir)
# Get default system language
# or set "en" (english) if no translation file
try:
lang_site = locale.getdefaultlocale()[0].split('_')[0]
os.path.exists('%s/site_%s.py'%(trans_dir, lang_site))
except:
lang_site = 'en'
# Set language site/form from configuration domain
# or set default english if not known
try:
dom.exists
lang_site = dom.lang_site
os.path.exists('%s/site_%s.py'%(trans_dir, lang_site))
tr = importlib.import_module('site_%s'%lang_site, package=None)
except:
tr = importlib.import_module('site_%s'%lang_site, package=None)
#==========================# #==========================#
@ -41,10 +65,10 @@ def create_metas_page():
metas_page = '' metas_page = ''
scale = 'width=device-width, initial-scale=1.0' scale = 'width=device-width, initial-scale=1.0'
all_tags = db.domain_tags + ',' + db.tags all_tags = db.domain_tags + ',' + db.tags
css_file = 'template/style.css' css_file = 'styles.css'
css_ref = 'media="screen" href="%s%s"'%(db.sub_uri, css_file) css_ref = 'href="%stemplate/%s"'%(db.sub_uri, css_file)
rss_ref = 'type="application/rss+xml" ' + \ rss_ref = 'type="application/rss+xml" ' + \
'href="%s%s" title="RSS 2.0. %s %s %s'%( 'href="%s%s" title="RSS 2.0. %s %s %s"'%(
db.sub_uri, db.domain_rss, db.sub_uri, db.domain_rss,
db.domain_title, db.domain_sep, db.domain_short db.domain_title, db.domain_sep, db.domain_short
) )
@ -98,10 +122,10 @@ def create_metas_page():
def create_main_page(target, article_bottom): def create_main_page(target, article_bottom):
global main_page global main_page
if not os.path.exists(db.wip_footer): if not tyto.exists(db.wip_footer):
logs.out("1", db.wip_footer, True) logs.out("1", db.wip_footer, True)
if not os.path.exists(db.wip_metas): if not tyto.exists(db.wip_metas):
logs.out("24", '(HTML metas): %s'%db.wip_metas, False) logs.out("24", '(HTML metas): %s'%db.wip_metas, False)
# Create link for website's logo # Create link for website's logo
@ -228,7 +252,7 @@ def create_sidebar(option):
try: try:
db.sidebar_load db.sidebar_load
if not os.path.exists(db.sidebar_load): if not tyto.exists(db.sidebar_load):
logs.out("1", db.sidebar_load, True) logs.out("1", db.sidebar_load, True)
except: except:
logs.out("1", 'Sidebar load file', True) logs.out("1", 'Sidebar load file', True)
@ -273,14 +297,14 @@ def create_sidebar(option):
# Get full article URI and check if exists # Get full article URI and check if exists
sidebar_has = True sidebar_has = True
f_uri = '%s%s'%(db.domain_articles, line) f_uri = '%s%s'%(db.domain_articles, line)
if not os.path.exists(f_uri): if not tyto.exists(f_uri):
logs.out("24", f_uri, False) logs.out("24", f_uri, False)
continue continue
# Get Hash from uri to get db file # Get Hash from uri to get db file
hash_uri = tyto.get_filesum(f_uri, False) hash_uri = tyto.get_filesum(f_uri, False)
db_uri = '%s%s.conf'%(db.articles_db, hash_uri) db_uri = '%s%s.conf'%(db.articles_db, hash_uri)
if not os.path.exists(db_uri): if not tyto.exists(db_uri):
logs.out('25', line, False) logs.out('25', line, False)
continue continue
@ -292,14 +316,14 @@ def create_sidebar(option):
if not hash_wip == hash_chk: if not hash_wip == hash_chk:
logs.out("30", '%s "%s"'%(line, title), False) logs.out("30", '%s "%s"'%(line, title), False)
continue continue
if not os.path.exists(post_wip): if not tyto.exists(post_wip):
logs.out("24", 'in wip: %s'%post_wip, False) logs.out("24", 'in wip: %s'%post_wip, False)
continue continue
elif option in pub_opts: elif option in pub_opts:
if not hash_www == hash_chk: if not hash_www == hash_chk:
logs.out("30", '%s "%s"'%(line, title), False) logs.out("30", '%s "%s"'%(line, title), False)
continue continue
if not os.path.exists(post_www): if not tyto.exists(post_www):
logs.out("24", 'in www: %s'%post_www, False) logs.out("24", 'in www: %s'%post_www, False)
continue continue
@ -353,7 +377,7 @@ def create_sidebar(option):
ask_html = ' ├ Replace %s ? '%target ask_html = ' ├ Replace %s ? '%target
res = '' res = ''
if not option == 'pub' and os.path.exists(target): if not option == 'pub' and tyto.exists(target):
res = input(ask_html) res = input(ask_html)
if not res in ['y', 'Y']: if not res in ['y', 'Y']:
logs.out("255", '', True) logs.out("255", '', True)
@ -374,7 +398,7 @@ def create_navbar(option):
# more confitions to pass # more confitions to pass
try: try:
db.navbar_load db.navbar_load
if not os.path.exists(db.navbar_load): if not tyto.exists(db.navbar_load):
logs.out("1", db.navbar_load, True) logs.out("1", db.navbar_load, True)
except: except:
logs.out("1", 'Navbar load file', True) logs.out("1", 'Navbar load file', True)
@ -437,10 +461,10 @@ def create_navbar(option):
# Showing unused index.html server file # Showing unused index.html server file
if option == 'wip': if option == 'wip':
if not os.path.exists(wip_index): if not tyto.exists(wip_index):
logs.out('26', 'in wip "%s/": %s'%(direc, wip_index), False) logs.out('26', 'in wip "%s/": %s'%(direc, wip_index), False)
elif option in pub_opts: elif option in pub_opts:
if not os.path.exists(www_index): if not tyto.exists(www_index):
logs.out('26', 'in www "%s/": %s'%(direc, www_index), False) logs.out('26', 'in www "%s/": %s'%(direc, www_index), False)
e_www_index = True e_www_index = True
continue continue
@ -473,7 +497,7 @@ def create_navbar(option):
# Ask to replace (except from 'publish template') # Ask to replace (except from 'publish template')
if not option == 'pub' and os.path.exists(target): if not option == 'pub' and tyto.exists(target):
ask_html = ' ├ Replace %s ? '%target ask_html = ' ├ Replace %s ? '%target
res = '' res = ''
@ -498,11 +522,11 @@ def create_navbar(option):
# To manage new creation if changes # # To manage new creation if changes #
#--------------------------------------------------------# #--------------------------------------------------------#
def create_user_metas(option): def create_user_metas(option):
domain.domain_needed() dom.valid()
if option == 'wip': target = db.wip_metas if option == 'wip': target = dom.wip_metas_f
elif option == 'www': target = db.www_metas elif option == 'www': target = dom.www_metas_f
elif option == 'pub': target = db.www_metas elif option == 'pub': target = dom.www_metas_f
# Create wip metas.html file according to option # Create wip metas.html file according to option
#----------------------------------------------- #-----------------------------------------------
@ -511,7 +535,7 @@ def create_user_metas(option):
metas_used = ('<meta ', '<link ') metas_used = ('<meta ', '<link ')
res = '' res = ''
if not option == 'pub' and os.path.exists(target): if not option == 'pub' and tyto.exists(target):
try: try:
res = input(ask_html) res = input(ask_html)
except KeyboardInterrupt: except KeyboardInterrupt:
@ -534,31 +558,30 @@ def create_user_metas(option):
# Create generic footer from domain datas # # Create generic footer from domain datas #
#-----------------------------------------# #-----------------------------------------#
def create_user_footer(option): def create_user_footer(option):
domain.domain_needed() dom.valid()
if option == 'wip': target = db.wip_footer if option == 'wip': target = dom.wip_footer_f
elif option == 'www': target = db.www_footer elif option == 'www': target = dom.www_footer_f
elif option == 'pub': target = db.www_footer elif option == 'pub': target = dom.www_footer_f
ask_load = ' ├ Replace HTML footer: %s ? '%target if not option == 'pub' and tyto.exists(target):
res = '' ask = ''
if not option == 'pub' and os.path.exists(target):
try: try:
res = input(ask_load) ask = input('%s. %s%s '%(tr.footer, tr.form_rep, tr.q))
except KeyboardInterrupt: except KeyboardInterrupt:
print('') print('')
logs.out("255", '', True) logs.out("255", '', True)
if not res in ['y', 'Y']: if not ask in form.answer_yes:
logs.out("255", '', True) logs.out("255", '', True)
user_footer = '' footer = ''
user_file = open(db.footer_load, 'r').read() footer_f = open(dom.footer_f, 'r').read()
for line in user_file.rsplit('\n'): for line in footer_f.rsplit('\n'):
if not line or line.startswith('#'): continue if not line or line.startswith('#'): continue
if user_footer: user_footer = "%s\n %s"%(user_footer, line)
else: user_footer = ' %s'%line
tyto.set_file(target, 'New', user_footer) if footer: footer = "%s\n %s"%(footer, line)
logs.out("33", target, False) else: footer = ' %s'%line
tyto.set_file(target, 'New', footer)
logs.out("32", target, False)

View File

@ -0,0 +1,47 @@
#!/usr/bin/env python3
# Name: Tyto - Littérateur
# Type: Set logs lang
# Description: Set logs language according to user choice
# file: lang.py
# Folder: /var/lib/tyto/program/
# By echolib (XMPP: im@echolib.re)
# License: GNU AFFERO GENERAL PUBLIC LICENSE Version 3, 19 November 2007
#------------
# funny stats
#------------
# lines:
# functions:
# comments:
#----------------------------------------------------------------------
#**********************************************************************
import locale, sys, os
import dom
# Import translation directory
trans_dir = '/var/lib/tyto/translations'
sys.path.insert(0, trans_dir)
# Get default system language
# or set "en" (english) if no translation file
try:
lang_logs = locale.getdefaultlocale()[0].split('_')[0]
os.path.exists('%s/logs_%s.py'%(trans_dir, lang_logs))
except:
lang_logs = 'en'
# Set language logs from configuration domain
# or set default english if not known
try:
dom.exists
lang_logs = dom.lang_logs
os.path.exists('%s/logs_%s.py'%(trans_dir, lang_logs))
exec(open('%s/logs_%s.py'%(trans_dir, lang.logs)).read())
except:
exec(open('%s/logs_%s.py'%(trans_dir, lang_logs)).read())

View File

@ -17,9 +17,10 @@
#********************************************************************** #**********************************************************************
import sys import os, sys
import lang, status
# Colors # Set colors
CS = '\033[0;0m' CS = '\033[0;0m'
CR = '\033[1;31m' CR = '\033[1;31m'
CY = '\033[1;33m' CY = '\033[1;33m'
@ -30,44 +31,49 @@ CG = '\033[1;32m'
#--------------------------------# #--------------------------------#
def out(nbr, value, out): def out(nbr, value, out):
logs = { logs = {
'1' : ':< %sUnused resource%s: %s'%(CR, CS, value), '1' : '%s%s%s > %s'%(CR, lang.unused_r, CS, value),
'2' : ':< %sIncomplete data%s: %s'%(CR, CS, value), '2' : '%s%s%s > %s'%(CR, lang.data_inc, CS, value),
'3' : ':< %sInvalid data%s: "%s"'%(CR, CS, value), '3' : '%s%s%s %s'%(CR, lang.data_inv, CS, value),
'4' : ':< %sUnable to create file%s: %s'%(CR, CS, value), '4' : '%sUnable to create file%s: %s'%(CR, CS, value),
'5' : ':< %sUnused argument%s: [file]'%(CR, CS), '5' : '%s%s%s > "%s"'%(CR, lang.no_arg, CS, value),
'6' : ':< %sUnused "%s"%s in article'%(CR, value, CS), '6' : '%s%s%s "-----" > %s'%(CR, lang.sep_inv, CS, value),
'7' : ':< Article %snot yet valid%s'%(CR, CS), '7' : '%s%s%s > %s'%(CR, lang.post_inv, CS, value),
'8' : ':< %sNot paired%s %s'%(CR, CS, value), '8' : '%s%s%s %s'%(CR, lang.mark_np, CS, value),
'9' : ':< Article %shas changed%s. Check it first'%(CR, CS), '9' : ' ╞ Article %shas changed%s. Check it first'%(CR, CS),
'10' : ':< %sUnused domain configuration%s: %s'%(CR, CS, value), '10' : '%sUnused domain configuration%s: %s'%(CR, CS, value),
'11' : ':< %sUnused argument%s: %s'%(CR, CS, value), '11' : '%s%s%s: %s'%(CR, lang.err_arg, CS, value),
'12' : ':< %sUnused "%s"%s in article\'s header'%(CR, value, CS), '12' : '%sUnused "%s"%s in article\'s header'%(CR, value, CS),
'13' : ':< %sNo file or directory%s here (deleted ?)'%(CR, CS), '13' : '%s%s%s'%(CR, lang.no_fidi, CS),
'14' : ':< %sMismatch%s program start'%(CR, CS), '14' : '%sMismatch%s program start'%(CR, CS),
'15' : ':< Anchor %snot uniq%s: %s'%(CR, CS, value), '15' : ' ╞ Anchor %snot uniq%s: %s'%(CR, CS, value),
'16' : ':< %sUnused database configuration%s: %s'%(CR, CS, value), '16' : '%s%s%s "%s = ?"'%(CR, lang.unused_c, CS, value),
'19' : ':D Article %swip%s on: %s'%(CG, CS, value), '17' : '%s%s%s "%s ?"'%(CR, lang.unused_v, CS, value),
'20' : ':D Article %scheck%s on: %s'%(CG, CS, value), '18' : '%s%s%s > %s'%(CR, lang.unused_p, CS, value),
'21' : ':D Article %sValid%s. Ready to wip'%(CG, CS), '19' : ' ╞ Article %swip%s on: %s'%(CG, CS, value),
'22' : ':? %sNot paired%s symbols: %s'%(CY, CS, value), '20' : '%s%s%s %s'%(CG, lang.check_on, CS, value),
'23' : ':? %sCorrupted database%s: %s'%(CY, CS, value), '21' : '%s%s%s > %s'%(CG, lang.post_val, CS, value),
'24' : ':? %sUnused resource%s %s'%(CY, CS, value), '22' : '%sNot paired%s symbols: %s'%(CY, CS, value),
'25' : ':? Article %snot yet checked%s: %s'%(CY, CS, value), '23' : '%s%s%s: %s'%(CY, lang.db_inv, CS, value),
'26' : ':? %sNo index%s article %s'%(CY, CS, value), '24' : '%sUnused resource%s %s'%(CY, CS, value),
'28' : ':? Nothing to do %s'%value, '25' : ' ╞ Article %snot yet checked%s: %s'%(CY, CS, value),
'29' : ':? %sEmpty configuration%s %s'%(CY, CS, value), '26' : '%sNo index%s article %s'%(CY, CS, value),
'30' : ':? Article %snot yet wip%s: %s'%(CY, CS, value), '28' : ' ╘ Nothing to do %s'%value,
'31' : ':? Not included. %sMax items reached%s %s'%(CY, CS, value), '29' : '%sEmpty configuration%s %s'%(CY, CS, value),
'33' : ':D %sCreated file%s: %s'%(CG, CS, value), '30' : ' ╞ Article %snot yet wip%s: %s'%(CY, CS, value),
'34' : ':D %sChanged file%s %s'%(CG, CS, value), '31' : ' ╞ Not included. %sMax items reached%s %s'%(CY, CS, value),
'35' : ':D %sAdd item%s %s'%(CG, CS, value), '32' : ' ╞══ %s%s%s > %s'%(CG, lang.file_c, CS, value),
'40' : ':/ %sInactive%s domain "%s"'%(CY, CS, value), '33' : ' ╞══ %s%s%s > %s'%(CG, lang.dir_c, CS, value),
'41' : ':? %sIncomplete%s domain "%s"'%(CR, CS, value), '34' : ' ╞══ %s%s%s > %s'%(CG, lang.file_n, CS, value),
'42' : ':D %sActive%s domain "%s"'%(CG, CS, value), '35' : '%sAdd item%s %s'%(CG, CS, value),
'43' : ':? %sNo domain%s configured here: %s'%(CY, CS, value), '36' : '%s %s'%(lang.file_e, value),
'44' : ':! %sCheck again manually%s "tyto check %s"'%(CY, CS, value), '37' : '%s %s'%(lang.dir_e, value),
'51' : ':? %sIncomplete data%s: %s'%(CY, CS, value), '40' : '%s%s%s > "%s"'%(CY, lang.dom_ina, CS, value),
'255' : ';) Maybe later...' '41' : '%s%s%s > "%s"'%(CR, lang.dom_inc, CS, value),
'42' : '%s%s%s > "%s"'%(CG, lang.dom_act, CS, value),
'43' : '%s%s%s'%(CY, lang.dom_no, CS),
'44' : '%sCheck again manually%s "tyto check %s"'%(CY, CS, value),
'51' : '%s%s%s > %s'%(CY, lang.data_inc, CS, value),
'255' : '%s'%lang.laterout
} }
msg = logs[nbr] msg = logs[nbr]
@ -75,3 +81,5 @@ def out(nbr, value, out):
if int(nbr) == 21: nbr = 0 if int(nbr) == 21: nbr = 0
if out: sys.exit(int(nbr)) if out: sys.exit(int(nbr))
status.domain()

View File

@ -18,14 +18,14 @@
#********************************************************************** #**********************************************************************
import sys import sys
import logs, args, db, domain, html import args, dom, logs, form, html
#===============================================# #===============================================#
# manage argument new for # # manage argument new for #
# - domain: target becomes 3rd command argument # # - domain: target becomes 3rd command argument #
#-----------------------------------------------# #-----------------------------------------------#
def manage_new(target): def manage(target):
# Generic option, except for domain # Generic option, except for domain
option = 'new' option = 'new'
if target == "domain": if target == "domain":
@ -34,11 +34,11 @@ def manage_new(target):
if target in args.pass_targets: if target in args.pass_targets:
actions = { actions = {
'domain' : domain.manage_domain, 'domain' : form.manage,
'sidebar' : domain.create_sidebar, 'sidebar' : form.create_sidebar,
'navbar' : domain.create_navbar, 'navbar' : form.create_navbar,
'metas' : domain.create_metas, 'metas' : form.create_metas,
'footer' : domain.create_footer 'footer' : form.create_footer
} }
actions[target](option) actions[target](option)

View File

@ -20,7 +20,7 @@
import os, sys, shutil, importlib import os, sys, shutil, importlib
from pathlib import Path from pathlib import Path
import logs, args, db, html, tyto, domain, stats, rss import logs, args, dom, html, tyto, form, stats, rss
#==============================# #==============================#
# Manage action, get post db # # Manage action, get post db #

View File

@ -20,7 +20,7 @@
import os import os
from pathlib import Path from pathlib import Path
import logs, db, tyto import logs, dom, db, tyto
#============================# #============================#
@ -69,7 +69,7 @@ def create_feed():
rss_item = True rss_item = True
nbr_item += 1 nbr_item += 1
if nbr_item > db.domain_rssitems: break if nbr_item > dom.rss_items: break
set_f = \ set_f = \
'%s\n'%set_f + \ '%s\n'%set_f + \

View File

@ -17,8 +17,8 @@
#********************************************************************** #**********************************************************************
import os, importlib import os, sys, importlib
import args, db, logs, domain, tyto, check, stats import args, lang, logs, dom, db, form, tyto, check, stats
#======================# #======================#
@ -28,15 +28,14 @@ import args, db, logs, domain, tyto, check, stats
# Show or edit files # # Show or edit files #
# final html, db, load # # final html, db, load #
#----------------------# #----------------------#
def manage_show(target): def manage(target):
# Domain configuration must exists if not target == "domain": dom.valid()
#if not db.domain_exists: sys.exit(43)
domain.domain_needed()
do = False do = False
actions_read = ('show', 'show-db', 'show-wip', 'show-www') actions_read = ('show', 'show-about', 'show-db', 'show-wip', 'show-www')
actions_edit = ('edit', 'edit-db', 'edit-wip', 'edit-www') actions_edit = ('edit', 'edit-about', 'edit-db', 'edit-wip', 'edit-www')
actions_about= ('show-about', 'edit-about')
actions_wip = ('show-wip', 'edit-wip') actions_wip = ('show-wip', 'edit-wip')
actions_www = ('show-www', 'edit-www') actions_www = ('show-www', 'edit-www')
@ -48,11 +47,16 @@ def manage_show(target):
if target in args.pass_targets: if target in args.pass_targets:
if args.action in actions_post: if args.action in actions_post:
do = { do = {
"domain" : db.domain_conf, "domain" : dom.config,
"footer" : db.footer_load, "footer" : dom.footer_f,
"metas" : db.metas_load, "metas" : dom.metas_f,
"navbar" : db.navbar_load, "navbar" : dom.navbar_f,
"sidebar" : db.sidebar_load "sidebar" : dom.sidebar_f
}
elif args.action in actions_about:
do = {
"footer" : dom.footer_about_f
} }
elif args.action in actions_wip: elif args.action in actions_wip:
@ -61,11 +65,11 @@ def manage_show(target):
return return
do = { do = {
"domain" : db.domain_conf, "domain" : dom.config,
"footer" : db.wip_footer, "footer" : dom.wip_footer_f,
"metas" : db.wip_metas, "metas" : dom.wip_metas_f,
"navbar" : db.wip_navbar, "navbar" : dom.wip_navbar_f,
"sidebar" : db.wip_sidebar "sidebar" : dom.wip_sidebar_f
} }
elif args.action in actions_www: elif args.action in actions_www:
@ -74,11 +78,11 @@ def manage_show(target):
return return
do = { do = {
"domain" : db.domain_conf, "domain" : dom.config,
"footer" : db.www_footer, "footer" : dom.www_footer_f,
"metas" : db.www_metas, "metas" : dom.www_metas_f,
"navbar" : db.www_navbar, "navbar" : dom.www_navbar_f,
"sidebar" : db.www_sidebar "sidebar" : dom.www_sidebar_f
} }
# Target is a post uri # Target is a post uri
@ -94,9 +98,9 @@ def manage_show(target):
do = {"post" : db.uri_file} do = {"post" : db.uri_file}
# Post has database # Post has database
elif db.db_exists: elif db.exists:
do = { do = {
"db" : db.post_db, "db" : db.config,
"wip" : db.post_wip, "wip" : db.post_wip,
"www" : db.post_www "www" : db.post_www
} }
@ -107,7 +111,8 @@ def manage_show(target):
#print('> show: target', target) #print('> show: target', target)
if not do: if not do:
logs.out("11", '"%s" with "%s"'%(args.target, args.action), True) if not db.post: sys.exit(1)
# Read lines of, or edit file # Read lines of, or edit file
if args.action in actions_read: read_lines(do[target]) if args.action in actions_read: read_lines(do[target])
@ -136,8 +141,11 @@ def manage_show(target):
#--------------------------------------------# #--------------------------------------------#
def read_lines(f): def read_lines(f):
if not f: return # Maybe if not f: return # Maybe
if not os.path.exists(f): logs.out("1", f, True) if not tyto.exists(f): logs.out("1", f, True)
datas = open(f).read() datas = open(f).read()
for line in datas.rsplit('\n'): for line in datas.rsplit('\n'):
print(line) if not line: print('')
else: print(' ├─', line)
dom.valid()

View File

@ -18,7 +18,7 @@
#********************************************************************** #**********************************************************************
import os, importlib import os, importlib
import args, logs, db, domain, tyto, show import args, logs, dom, form, tyto, show
sti_anchors = sti_abbrs = sti_links = 0 sti_anchors = sti_abbrs = sti_links = 0
sti_images = sti_files = sti_raws = 0 sti_images = sti_files = sti_raws = 0

View File

@ -0,0 +1,34 @@
#!/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
#------------
# funny stats
#------------
# lines:
# functions:
# comments:
#----------------------------------------------------------------------
#**********************************************************************
import logs, dom, tyto
def domain():
if dom.hole: logs.out("13", '', True)
elif not dom.shortname: logs.out("43", '', False)
elif dom.incomplete: logs.out("41", dom.shortname, False)
elif dom.activated: logs.out("42", dom.shortname, False)
elif not dom.activated: logs.out("40", dom.shortname, False)
if dom.incomplete:
for err_val in dom.err_val:
logs.out("16", err_val, False)
for dir_new in dom.dir_new:
logs.out("33", dir_new, False)

View File

@ -20,20 +20,13 @@
import os, sys, subprocess, locale, base64, datetime, shutil import os, sys, subprocess, locale, base64, datetime, shutil
from hashlib import blake2b from hashlib import blake2b
import args, logs, db import args, dom, logs
domain_active = False # TEMP
home_dir = os.path.expanduser('~') lang = 'fr'
try: in_dir = os.getcwd()
except: logs.out("13", '', True)
domain_conf = in_dir
# Set translations: french, english
#----------------------------------
try: lang = domain_lang
except: lang = locale.getdefaultlocale()[0].split('_')[0]
if lang.lower() == 'fr': n = 0 if lang.lower() == 'fr': n = 0
else: n = 1 else: n = 1
#--
# :D # :D
Tyto = 'Tyto - Littérateur' Tyto = 'Tyto - Littérateur'
@ -58,7 +51,7 @@ trans = [
('Générateur :', 'Generator:'), # 12 ('Générateur :', 'Generator:'), # 12
('Contacter par courriel', 'Contact by mail'), # 13 ('Contacter par courriel', 'Contact by mail'), # 13
('Courriel', 'Mail'), # 14 ('Courriel', 'Mail'), # 14
('C.G.U.', 'T.O.U'), # 15 ('C.G.U.', 'T.o.U'), # 15
('Mentions légales', 'Legal Notice'), # 16 ('Mentions légales', 'Legal Notice'), # 16
('Conditions Générales d\'Utilisation', 'Terms of Use'), # 17 ('Conditions Générales d\'Utilisation', 'Terms of Use'), # 17
('Loi', 'Law'), # 18 ('Loi', 'Law'), # 18
@ -108,6 +101,15 @@ words_tags = [
('-(', '-)', '-(', '-)', 'lists', 't') ('-(', '-)', '-(', '-)', 'lists', 't')
] ]
# When counting words, do no count line starting with:
nolinewords = \
(
'((', '))',
'{{', ']]',
'{{', '}}',
'->', '|',
'_image:', '_taw:'
)
# warning symbols (Check if paired) # warning symbols (Check if paired)
#---------------------------------- #----------------------------------
@ -148,16 +150,30 @@ 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:")
# Stats for icodes, bcodes, quotes
nbr_icodes = 0
#=======# #=======#
# TOOLS # # TOOLS #
#=======#-------------------------------------------------------------- #=======#--------------------------------------------------------------
#
# Return True if file exists
#
def exists(uri):
if os.path.exists(uri): return(True)
else: return(False)
#=======================# #=======================#
# Return sum of srcfile # # Return sum of srcfile #
# src: True = Content # # src: True = Content #
# False = URI # # False = URI #
#-----------------------# #-----------------------#
def get_filesum(path, src): def get_filesum(path, src):
if not exists(path):
logs.out("1", path, True)
file_sum = blake2b(digest_size=4) file_sum = blake2b(digest_size=4)
if src: file_sum.update(open(path, 'rb').read()) if src: file_sum.update(open(path, 'rb').read())
@ -338,7 +354,6 @@ def protect_icodes(post_bottom):
global protect_article global protect_article
global nbr_icodes global nbr_icodes
nbr_icodes = 0 # Stats here for DB as content will change
protect_article = post_bottom protect_article = post_bottom
in_icode = False in_icode = False
src_code = rep_code = '' src_code = rep_code = ''

View File

@ -20,7 +20,7 @@
import os, re, sys, shutil, importlib import os, re, sys, shutil, importlib
from pathlib import Path from pathlib import Path
import args, logs, db, tyto, html, domain, stats import args, logs, dom, db, tyto, html, form, stats
#=========================================# #=========================================#
@ -30,7 +30,7 @@ def manage_wip(target):
global post_db, hash_post, target_all global post_db, hash_post, target_all
# Check if can process # Check if can process
domain.domain_needed() dom.valid()
# wip_article(db.post_src) ; return # Force wip without checking # wip_article(db.post_src) ; return # Force wip without checking

View File

@ -0,0 +1,42 @@
#!/usr/bin/env python3
# Name: Tyto - Littérateur
# Type: translation file
# Description: Only for logs (internal messages) [en]
# file: logs_en.py
# Folder: /var/lib/tyto/translations/
# By echolib (XMPP: im@echolib.re)
# Repo: https://git.a-lec.org/echolib/tyto.git
# License: GNU AFFERO GENERAL PUBLIC LICENSE Version 3, 19 November 2007
#**********************************************************************
# Generic
line = "Ligne"
unused_r = "Unused ressource"
unused_c = "Unused database value"
db_inv = "Corrupted article's database"
err_arg = "Argument error"
no_arg = "Unused argument with"
dom_ina = "Inactive domain"
dom_inc = "Incomplete domain"
dom_act = "Active domain"
data_inc = "Incomplete data"
data_inv = "Invalid data"
dom_no = "No domain found"
no_fidi = "Blask Hole: no file or directory here"
file_c = "File created"
file_n = "File changed"
file_e = "File exists"
dir_c = "Directory created"
dir_e = "Directory exists"
check_on = "Article was check the"
post_inv = "Article not valid"
post_val = "Article is valid"
sep_inv = "Unused separator in article"
unused_v = "Unused value in article"
unused_p = "Empty article"
mark_np = "Not paired marks"
laterout = "Maybe later..."

View File

@ -0,0 +1,42 @@
#!/usr/bin/env python3
# Nom: Tyto - Littérateur
# Type: Fichier de traduction
# Description: Seulement pour les logs (messages internes) [fr]
# Fichier: logs_fr.py
# Dossier: /var/lib/tyto/translations/
# Par echolib (XMPP: im@echolib.re)
# Dépôt: https://git.a-lec.org/echolib/tyto.git
# Licence: GNU AFFERO GENERAL PUBLIC LICENSE Version 3, 19 November 2007
#**********************************************************************
# Generique
linecol = "Line"
unused_r = "Ressource manquante"
unused_c = "Valeur de la base de donnée manquante"
db_inv = "Base de donnée de l'article corrompue"
err_arg = "Erreur d'argument"
no_arg = "Argument manquant avec"
dom_ina = "Domaine inactif"
dom_inc = "Domaine incomplet"
dom_act = "Domaine actif"
data_inc = "Donnée incomplète"
data_inv = "Donnée invalide"
dom_no = "Aucun domaine trouvé"
no_fidi = "Trou Noir: aucun fichier ou dossier ici"
file_c = "Fichier créé"
file_n = "Fichier modifié"
file_e = "Fichier présent"
dir_c = "Dossier créé"
dir_e = "Dossier présent"
check_on = "Article vérifié le"
post_inv = "Article non valide"
post_val = "Article valide"
sep_inv = "Séparateur manquant dans l'article"
unused_v = "Valeur manquante dans l'article"
unused_p = "L'article est vide"
mark_np = "Marqueurs non pairs"
laterout = "Pour plus tard..."

View File

@ -0,0 +1,211 @@
#!/usr/bin/env python3
# Name: Tyto - Littérateur
# Type: translation file
# Description: Only for website [en]
# file: site_en.py
# Folder: /var/lib/tyto/translations/
# By echolib (XMPP: im@echolib.re)
# Repo: https://git.a-lec.org/echolib/tyto.git
# License: GNU AFFERO GENERAL PUBLIC LICENSE Version 3, 19 November 2007
#**********************************************************************
# IMPORTANT Instructions
#-----------------------
'''
This is a python file, so... DO NOT REMOVE:
- "#"
- "%s", "%d"
- "\n"
- "+ \"
'''
# Generic
sidebar = 'Sidebar'
navbar = 'Navbar'
metas = 'HTML Metas Tags'
footer = 'Footer'
title = 'Title'
File = 'File'
q = '?'
i = '!'
pp = ":"
# Website
#----------------------------------------------------------------------
# Misc.
source_code = "Source code"
home = "Home"
go_home = "Go to Homepage"
read = "Read"
# Sidebar
site_sdb_t = "Featured..."
# Footer
tyto_site_t = "Official website of %s's Libre websites generator"
tyto_git_t = "%s's official source code repository"
legal_t = "Legal notice"
terms_t = "Terms of Use"
terms_s = "T.o.U"
law = "Law"
about = "About"
add_inf = "additional Informations %s"%about.lower()
licence = "License"
contact = "Contact"
mail = "Mail"
mail_to = "Contact by %s the admin of"%mail.lower()
feed = "Feed"
generator = "Generator"
# Form
#----------------------------------------------------------------------
form_edit = "Edit the domain with the form"
form_start = ' ├──────────────────────────────────────────────┐\n' + \
' │ Configure a new domain for current directory │\n' + \
' │ Answer Y/y = yes. Enter to keep {default}\n' + \
' │ Empty Answer cancel process, except for │\n' + \
' │ - [Optional] │\n' + \
' │ - known {default} value │\n' + \
' ├──────────────────────────────────────────────┘'
form_warn = '\n' + \
' ├──────────────────────────────────────┐\n' + \
' │ Please, READ the configuration datas │\n' + \
' ├──────────────────────────────────────┘'
form_ready = '\n' + \
' ├──────────────────────────────────────┐\n' + \
' │ Domain is ready. Have fun, writers ! │\n' + \
' └──────────────────────────────────────┘'
form_opt = "[Optional]"
form_url = "URL to official website?"
form_wip = "URL to 'wip' website?"
form_db_new = "Created new database"
form_trlog = "[2 char.] Logs language?"
form_srv = "Local server directory?"
form_logo = "Logo filename?"
form_rss_f = "Atom/RSS filename?"
form_rss_i = "Atom/RSS articles' number?"
form_title = "Website title?"
form_date = "Domain creation year?"
form_about = "Domain Description?"
form_mail = "Webmaster's mail?"
form_tags = "[comma separated] Domain tags?"
form_lic = "Domain License?"
form_licurl = "License URL?"
form_legal = "Legal Notice URL?"
form_terms = "Terms of Use URL?"
form_css = "[alnum] CSS Prefix?"
form_sep = "[1 char.] Pages titles separator?"
form_pscode = "Show Article's source code?"
form_relme = 'rel="me" URL?'
form_trsite = "[2 char.] Website language?"
form_sdb_i = "Article's number?"
form_activ = "Activate and prepare domain?"
form_dir_e = "Directory exists"
form_dir_c = "Directory created"
form_file_e = "File exists"
form_file_c = "File created"
form_reset = "Reset configuration?"
form_rep = "Replace HTML file"
check_a = "Check again this article"
# Documentation of configuration files
#-------------------------------------
metas_doc = \
'# For %s\n' + \
'# Type text/HTML file\n' + \
'# Description Configuration file for HTML <metas> tags\n' + \
'# Content inserted in <head> section\n' + \
'# File %s\n' + \
'# How Insert <metas ...> and <link ...>\n' + \
'# Notes - Ony these tags are added :\n' + \
'# - <metas>\n' + \
'~ - <link>\n' + \
'# - Do NOT copy this file to template directory\n' + \
'# - These tags are already set'
navbar_doc = \
'# For %s\n' + \
'# Type: Text file\n' + \
'# Description Configuration file for navbar"\n' + \
'# (directories\'s list)\n' + \
'# Commands tyto new navbar (reset)\n' + \
'# tyto wip/publish navbar (Create)\n' + \
'# tyto show navbar (show config)\n' + \
'# tyto show-wip/show-www navbar (Show HTML)\n' + \
'# tyto edit navbar (edit this file)\n' + \
'# File %s\n' + \
'# Comment 1 folder name per line *1\n' + \
'# (from articles/)\n' + \
'# not begining with "/"\n' + \
'# Order in sidebar position\n' + \
'# Remember To avoid 404 error, you must:\n' + \
'# - add article index.{tyto}\n' + \
'# in set folder\n' + \
'# - check and wip article\n' + \
'# *1 Option To define a title link:' + \
'# - add "# title link"\n' + \
'\n# %s\n'%(20 * "-") +\
'# Examples :\n' + \
'# documentation\n' + \
'# about # infos about this website\n' + \
'# %s\n\n'%(20 * "-")
sidebar_doc = \
'# For %s\n' + \
'# Type Text file\n' + \
'# Description Configuration file for sidebar\n' + \
'# (articles\'s list)\n' + \
'# File %s\n' + \
'# Commands tyto new sidebar (reset)\n' + \
'# tyto wip/publish sidebar (Create)\n' + \
'# tyto show sidebar (Show config)\n' + \
'# tyto show-wip/show-www sidebar (Show HTML)\n' + \
'# tyto edit sidebar (edit this file)\n' + \
'# How 1 article URI per line\n' + \
'# (from articles/)\n' + \
'# not begining with "/"\n' + \
'# Order in sidebar position\n' + \
'# Max articles = %d\n' + \
'# Option Tp set sidebar title:\n' + \
' ": Sidebar Title"\n' + \
'\n# %s\n'%(20 * "-") + \
'# Examples :\n' + \
'# : My new articles list'
'# index.tyto\n' + \
'# dir1/index.tyto\n' + \
'# %s\n\n'%(20 * "-")
footer_doc = \
'# For %s\n' + \
'# Type text/HTML file\n' + \
'# Description Configuration file for footer\n' + \
'# File %s\n' + \
'# Commands tyto new footer (reset)\n' + \
'# tyto wip/publish footer (Create)\n' + \
'# tyto show footer (Show config)\n' + \
'# tyto show-wip/show-www footer (Show HTML)\n' + \
'# tyto edit footer (edit this file)\n' + \
'# How Put any HTML code\n' + \
'# Notes - Lines are ignored if:\n' + \
'# - empty\n' + \
'# - begin with "#"\n' + \
'# - Do NOT copy to template directory'
'# %s\n'%(20 * "-")
footer_about_doc = \
'# For %s\n' + \
'# Type text/HTML file\n' + \
'# Description Used when a footer is generated\n' + \
'# Content inserted in "about" section\n' + \
'# File %s\n' + \
'# How Put any HTML code\n' + \
'# Notes - Lines are ignored if:\n' + \
'# - empty\n' + \
'# - begin with "#"\n' + \
'# - Do NOT copy to template directory\n' + \
'# %s\n'%(20 * "-")

View File

@ -0,0 +1,211 @@
#!/usr/bin/env python3
# Nom: Tyto - Littérateur
# Type: Fichier de traduction
# Description: Seulement pour le site web [fr]
# Fichier: site_fr.py
# Dossier: /var/lib/tyto/translations/
# Par echolib (XMPP: im@echolib.re)
# Dépôt: https://git.a-lec.org/echolib/tyto.git
# Licence: GNU AFFERO GENERAL PUBLIC LICENSE Version 3, 19 November 2007
#**********************************************************************
# Instructions IMPORTANTES
#-------------------------
'''
Ceci est un fichier python, donc... NE PAS ENLEVER :
- "#"
- "%s", "%d"
- "\n"
- "+ \"
'''
# Generic
sidebar = 'Barre Latérale'
navbar = 'Barre de navigation'
metas = 'Balises Metas HTML'
footer = "Pied de Page"
title = 'Titre'
File = 'Fichier'
q = ' ?'
i = ' !'
pp = " :"
# Site web
#----------------------------------------------------------------------
# Divers
source_code = "Code source"
home = "Accueil"
go_home = "Aller à la page d'accueil"
read = "À lire"
# Barre latérale
site_sdb_t = "À l'affiche..."
# Pied de page
tyto_site_t = "Site web officiel du générateur de sites web Libre %s"
tyto_git_t = "Dépôt officiel du code source de %s"
legal_t = "Mentions légales"
terms_t = "Conditions Générales d'Utilisation"
terms_s = "C.G.U"
law = "Loi"
about = "À propos de"
add_inf = "Information supplémentaires %s"%about.lower()
licence = "Licence"
contact = "Contact"
mail = "Courriel"
mail_to = "Contacter par %s l'administrateur de"%mail.lower()
feed = "Flux"
generator = "Generateur"
# Formulaire
#----------------------------------------------------------------------
form_edit = "Éditer le domaine avec le formulaire"
form_start = ' ├───────────────────────────────────────────────┐\n' + \
' │ Configurer un domaine pour le dossier courant │\n' + \
' │ Répondre O/o = Oui. Entrer garde le {default}\n' + \
' │ Sans réponse : arrêt, sauf pour │\n' + \
' │ - [Optionnel] │\n' + \
' │ - Valeur {default} connue │\n' + \
' ├───────────────────────────────────────────────┘'
form_warn = '\n' + \
' ├──────────────────────────────────────────┐\n' + \
' │ SVP, lisez les données de configurations │\n' + \
' ├──────────────────────────────────────────┘'
form_ready = '\n' + \
' ├─────────────────────────────────────────┐\n' + \
' │ Le domaine est prêt. Amusez-vous bien ! │\n' + \
' └─────────────────────────────────────────┘'
form_opt = "[Optionnel]"
form_url = "URL du site web officiel"
form_wip = "URL du site web 'wip'"
form_db_new = "Nouvelle base de données crée"
form_trlog = "[2 car.] Langue des messages"
form_srv = "Dossier du serveur local"
form_logo = "Nom du fichier du logo"
form_rss_f = "Nom du fichier Atom/RSS"
form_rss_i = "Nombre d'articles Atom/RSS"
form_title = "Titre du site web"
form_date = "Année de création du domaine"
form_about = "Description du domaine"
form_mail = "Courriel du webmestre"
form_tags = "[séparées par une virgule] Étiquettes du domaine"
form_lic = "Licence du domaine"
form_licurl = "URL de la licence"
form_legal = "URL des mentions légales"
form_terms = "URL des CGU"
form_css = "[alnum] Préfix CSS"
form_sep = "[1 car.] Séparateur des titres de pages"
form_pscode = "Montrer le code source des articles"
form_relme = 'URL pour rel="me"'
form_trsite = "[2 car.] Langue du site web"
form_sdb_i = "Nombre d'articles"
form_activ = "Activer et preparer le domaine"
form_dir_e = "Dossier présent"
form_dir_c = "Dossier créé"
form_file_e = "Fichier présent"
form_file_c = "Fichier créé"
form_reset = "Réinitialiser la configuration"
form_rep = "Remplacer le fichier HTML"
check_a = "Vérifier encore l'article"
# Documentation des fichiers de configuration
#--------------------------------------------
metas_doc = \
'# Pour %s\n' + \
'# Type Fichier text/HTML\n' + \
'# Description Fichier de configuration des balises <meta> HTML \n' + \
'# Contenu inséré dans la section <head>\n' + \
'# Fichier %s\n' + \
'# Comment Insérer des balises <metas ...> et <link ...>\n' + \
'# Notes - Sont ajoutées uniquement les balises :\n' + \
'# - <metas>\n' + \
'~ - <link>\n' + \
'# - Ne PAS copier ce fichier dans le dossier template\n' + \
'# - Les balises suivantes sont déjà présentes'
navbar_doc = \
'# Pour %s\n' + \
'# Type fichier texte\n' + \
'# Description Utilisé par "wip/publish navbar"\n' + \
'# (Liste des dossiers)\n' + \
"# Commandes tyto new navbar (réinitialiser)\n" + \
'# tyto wip/publish navbar (créer)\n' + \
'# tyto show navbar (afficher la configuration)\n' + \
'# tyto show-wip/show-www navbar (afficher l\'HTML)\n' + \
'# tyto edit navbar (editer ce fichier)\n' + \
'# Fichier %s\n' + \
'# Comment 1 nom de dossier par ligne *1\n' + \
'# (depuis articles/)\n' + \
'# Ne commence pas par "/"\n' + \
'# L\'ordre définit la position\n' + \
'# Note Pour éviter l\'erreur 404 :\n' + \
'# - ajouter un article index.{ext}\n' + \
'# dans le dossier mentionné\n' + \
'# - check et wip sur l\'article\n' + \
'# *1 Option Pour définir un titre de lien :\n' + \
'# - ajouter "# titre du lien"\n' + \
'\n# %s\n'%(20 * "-") +\
'# Exemples :\n' + \
'# documentation\n' + \
'# a-propos # Informations concernant ce site\n' + \
'# %s\n\n'%(20 * "-")
sidebar_doc = \
'# Pour %s\n' + \
'# Type fichier texte\n' + \
'# Description Fichier de configuration de la barre latérale\n' + \
'# (Liste d\'articles)\n' + \
'# Fichier %s\n' + \
"# Commandes tyto new sidebar (réinitialiser)\n" + \
'# tyto wip/publish sidebar (créer)\n' + \
'# tyto show sidebar (afficher la configuration)\n' + \
'# tyto show-wip/show-www sidebar (afficher l\'HTML)\n' + \
'# tyto edit sidebar (editer ce fichier)\n' + \
'# Comment 1 URI de l\'article par ligne\n' + \
'# (depuis articles/)\n' + \
'# Ne commence pas par "/"\n' + \
'# L\'ordre définit la position\n' + \
'# Articles max = %d\n' + \
'# Option Pour définir un titre à la barre latérale:\n' + \
' ": Titre de la sidebar"\n' + \
'\n# %s\n'%(20 * "-") + \
'# Exemples :\n' + \
'# : Ma liste des nouveaux articles\n' + \
'# index.tyto\n' + \
'# dir1/index.tyto\n' + \
'# %s\n\n'%(20 * "-")
footer_doc = \
'# Pour %s\n' + \
'# Type Fichier text/HTML\n' + \
'# Description Fichier de configuration du pied de page\n' + \
'# Fichier %s\n' + \
"# Commandes tyto new footer (réinitialiser)\n" + \
'# tyto wip/publish footer (créer)\n' + \
'# tyto show footer (afficher la configuration)\n' + \
'# tyto show-wip/show-www footer (afficher l\'HTML)\n' + \
'# tyto edit footer (editer ce fichier)\n' + \
'# Comment Insérer du code HTML\n' + \
'# Notes - Les lignes sont ignorées si :\n' + \
'# - vides\n' + \
'# - commencent par "#"\n' + \
'# - Ne PAS copier ce fichier dans le dossier template\n' + \
'# %s\n'%(20 * "-")
footer_about_doc = \
'# Pour %s\n' + \
'# Type Fichier text/HTML\n' + \
'# Description Utilisé lors de la génération du pied de page\n' + \
'# Contenu inséré dans la section "about"\n' + \
'# Fichier %s\n' + \
'# Comment Insérer du code HTML\n' + \
'# Notes - Les lignes sont ignorées si :\n' + \
'# - vides\n' + \
'# - commencent par "#"\n' + \
'# - Ne PAS copier ce fichier dans le dossier template\n' + \
'# %s\n'%(20 * "-")