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

View File

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

View File

@ -18,37 +18,65 @@
#**********************************************************************
# Import needed libs
import sys, os, re, datetime
import time, importlib, sys, os, re, datetime
from datetime import datetime
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
#=========================#
# Manage Argument 'check' #
# Start checking article #
#-------------------------#--------------------------------------------
def manage_check(target):
domain.domain_needed()
def manage(target):
dom.valid()
# target needed
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 \
and db.db_exists \
and db.exists \
and not db.old_chk:
logs.out("20", db.date_chk, False)
ask = ' ├ Check again this article ? '
logs.out("20", '%s > %s'%(db.date_chk, db.uri_file), False)
ask = ''
try:
res = input(ask)
ask = input('%s%s '%(tr.check_a, tr.q))
except KeyboardInterrupt:
print('')
logs.out("255", '', True)
if not res in ['y', 'Y']:
if not ask in form.answer_yes:
return
check_process(target)
@ -59,7 +87,7 @@ def manage_check(target):
check_process(target)
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 #
#------------------------#
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_words
@ -104,7 +132,7 @@ def check_process(target):
post_err = False
# Set values for wip and www from DB
if db.db_exists:
if db.exists:
date_wip = db.date_wip
hash_wip = db.hash_wip
date_www = db.date_www
@ -116,10 +144,11 @@ def check_process(target):
# Get uri after articles/ (no starting / in value)
global src_post_short_uri, srv_post_short_uri, direc_src
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_wip_uri = db.srv_wip + srv_post_short_uri
srv_post_www_uri = db.srv_www + srv_post_short_uri
srv_post_wip_uri = dom.srv_wip + 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.rsplit(direc_src)[0]
@ -127,23 +156,26 @@ def check_process(target):
global sub_uri
sub_uri = db.uri_file.rsplit('articles/')[1]
sub_nbr = sub_uri.count('/')
if sub_nbr == 0 : sub_uri = './'
else: sub_uri = sub_nbr * '../'
if sub_nbr == 0: sub_uri = './'
else: sub_uri = sub_nbr * '../'
# Set HTTP link for wip and www
global http_www, http_wip
if srv_post_short_uri.endswith('index.html'):
http_www = "%s/%s"%(db.domain_www_url, direc_src)
http_wip = '%s/%s'%(db.domain_wip_url, direc_src)
http_www = "%s/%s"%(dom.www_url, direc_src)
http_wip = '%s/%s'%(dom.wip_url, direc_src)
else:
http_www = "%s/%s"%(db.domain_www_url, srv_post_short_uri)
http_wip = '%s/%s'%(db.domain_wip_url, srv_post_short_uri)
http_www = "%s/%s"%(dom.www_url, srv_post_short_uri)
http_wip = '%s/%s'%(dom.wip_url, srv_post_short_uri)
# 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)
# Protect block-codes and quotes
@ -156,25 +188,34 @@ def check_process(target):
tyto.protect_icodes(post_bottom)
post_bottom = tyto.protect_article
# Count words in article. Quotes, block-codes, icode = 1 per each
post_words = len(post_bottom.strip().split(" "))
# Check tags configuration
check_headers(post_header.rsplit('\n'))
if post_err: return
# Check for valid contents
check_content(post_bottom)
post_bottom = post_bottom.rsplit('\n')
#post_header = post_header.rsplit('\n')
check_headers(post_header.rsplit('\n'))
# Exit if unused needed tags
# Remove db (if exists) on post error and return
if post_err:
if db.db_exists and os.path.exists(db.post_db):
os.remove(db.post_db)
#logs.out("7", '', False)
if db.exists and tyto.exists(db.config):
os.remove(db.config)
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()
@ -182,12 +223,12 @@ def check_process(target):
# Create string article from file #
# Check if separator or exit #
#---------------------------------#
def file_to_string(post_file):
def file_to_string():
global article, post_header, post_bottom
post_header = post_bottom = ''
sep = False
article = open(post_file, 'r').read()
sep = content = False
article = open(db.uri_file, 'r').read()
for line in article.rsplit('\n'):
if line.startswith('-----'):
@ -195,6 +236,7 @@ def file_to_string(post_file):
continue
if sep:
if line: content = True
if not post_bottom: post_bottom = line
else: post_bottom = '%s\n%s'%(post_bottom, line)
else:
@ -203,7 +245,12 @@ def file_to_string(post_file):
# Check if separator or exit
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 #
#---------------------------------------------#
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
icode = quote = in_quote = bcode = in_bcode = False
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_m2 = line.count(tyto.words_tags[9][1])
if icode_m1 != icode_m2:
logs.out("8", 'inline-code: line %s. %s %s'%(ln,
tyto.words_tags[9][0], tyto.words_tags[9][1]
), True
print(" ├─", line)
logs.out("8", 'icode: L=%s. "%s %s" > %s'%(ln,
tyto.words_tags[9][0], tyto.words_tags[9][1],
db.uri_file
), False
)
post_err = True
else:
icode = True
@ -325,10 +376,10 @@ def check_headers(post_header):
if line.startswith(tag):
if date: continue
date = line.rsplit(tag)[1].lstrip()
check_date(date, ln)
check_date(date, ln, line)
if not post_err:
if tyto.n == 0:
if lang_site == 'fr':
date = date.rsplit('-')
date = date[2] + '/' + date[1] + '/' + date[0]
date = (date, date_check)
@ -338,18 +389,19 @@ def check_headers(post_header):
# Check needed tags #
#-------------------#
# Set needed tags
need_headers = {
tyto.headers[0] : title,
tyto.headers[1] : about,
tyto.headers[2] : author,
tyto.headers[3] : tags,
tyto.headers[4] : date
}
need_headers = \
{
tyto.headers[0] : title,
tyto.headers[1] : about,
tyto.headers[2] : author,
tyto.headers[3] : tags,
tyto.headers[4] : date
}
# Check if set needed tags
for tag in need_headers:
if not need_headers[tag]:
logs.out("6", tag, False)
logs.out("17", tag, False)
post_err = True
@ -560,7 +612,7 @@ def check_headers(post_header):
#----------------------------------------------
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:
if line.startswith(tag):
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()
check_file_uri('image', image_uri, ln + 1)
snshare = True
snpic_url = '%s%s'%(db.domain_www_url, web_uri)
snpic_url = '%s%s'%(dom.www_url, web_uri)
break
if not snshare:
@ -582,7 +634,7 @@ def check_headers(post_header):
# Check Date format and validity #
# Create False date_check #
#--------------------------------#
def check_date(date, ln):
def check_date(date, ln, line):
global post_err, date_check
# Check if article date is valid (True)
@ -592,7 +644,10 @@ def check_date(date, ln):
bool(datetime.strptime(date, fmt_article))
except ValueError:
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
if not post_err:
@ -626,7 +681,7 @@ def check_file_uri(filetype, filename, ln):
fileuri = post_dir + filename
# Check if file exists
if not os.path.exists(fileuri):
if not tyto.exists(fileuri):
logs.out("1", "Line %s, %s"%(ln, fileuri), False)
post_err = True
return
@ -640,6 +695,9 @@ def check_file_uri(filetype, filename, ln):
def check_content(post_bottom):
global post_err
#print("post_bottom")
#print(post_bottom)
# Check tags for words (strongs, italics...)
# Set stats for each one
#-------------------------------------------
@ -766,12 +824,12 @@ def create_database():
'date_www = "%s"\n'%date_www + \
'hash_www = "%s"\n'%hash_www + \
'\n# Post configuration from needed tags\n' + \
'title = "%s"\n'%title + \
'about = "%s"\n'%about + \
'author = "%s"\n'%author + \
'tags = "%s"\n'%tags + \
'date = %s\n'%str(date) + \
'snpic = "%s"\n'%snpic_url + \
'title = "%s"\n'%title + \
'about = "%s"\n'%about + \
'author = "%s"\n'%author + \
'tags = "%s"\n'%tags + \
'date = %s\n'%str(date) + \
'snpic = "%s"\n'%snpic_url + \
'\n# Used files\n' + \
'uris = (%s)\n'%files_post + \
'\n# Post configuration from optional tags'
@ -806,16 +864,19 @@ def create_database():
database, i, globals()['raw_%s'%i]
)
# Count real words
stat_words = post_words - nbr_titles
db_stats = '\n# Statistics from optional tags\n' + \
'uniq_anchors = %d\n'%nbr_ancs + \
'uniq_abbrs = %d\n'%stat_abbrs + \
'uniq_links = %d\n'%stat_links + \
'uniq_images = %d\n'%stat_images + \
'uniq_files = %d\n'%stat_files + \
'uniq_raws = %d\n'%stat_raws + \
'uniq_anchors = %d\n'%nbr_ancs + \
'uniq_abbrs = %d\n'%stat_abbrs + \
'uniq_links = %d\n'%stat_links + \
'uniq_images = %d\n'%stat_images + \
'uniq_files = %d\n'%stat_files + \
'uniq_raws = %d\n'%stat_raws + \
'\n# Statistics from post content\n' + \
'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_paragraphs = %d\n'%post_paragraphs + \
'stat_anchors = %d\n'%post_anchors + \
@ -834,8 +895,8 @@ def create_database():
database = '%s\n%s'%(database, db_stats)
tyto.set_file(db.post_db, 'new', database)
logs.out("21", '', False)
tyto.set_file(db.config, 'new', database)
logs.out("21", db.uri_file, False)
#=====================#

View File

@ -1,7 +1,7 @@
#!/usr/bin/env python3
# Name: Tyto - Littérateur
# Type: DBs tools
# Description: Search DBs (domain + post) and exec
# Type: DB for article
# Description: Search article database and exec
# file: db.py
# Folder: /var/lib/tyto/program/
# By echolib (XMPP: im@echolib.re)
@ -17,259 +17,116 @@
#**********************************************************************
import os, sys
import args, logs, tyto, domain, wip, publish
import os
action = args.action
target = args.target
#======================#
#----------------------#
# 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('~')
import args, dom, form, tyto, logs
remove = exists = post = corrupt = False
try: in_dir = os.getcwd()
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 \
and args.action in args.pass_db \
and not args.target in args.pass_targets:
# Domain must be valid
domain.domain_needed()
dom.valid()
uri_file = '%s/%s'%(in_dir, args.target)
uri_id = tyto.get_filesum(uri_file, False)
# DB
post_db = '%s%s.conf'%(articles_db, uri_id)
if os.path.exists(post_db): db_exists = True
else: db_exists = False
config = '%s%s.config'%(dom.articles_db_d, uri_id)
if tyto.exists(config):
exists = True
exec(open(config).read())
else:
exists = False
# Article
if os.path.exists(uri_file):
post_exists = True
if tyto.exists(uri_file):
post = True
hash_post = tyto.get_filesum(uri_file, True)
else:
post_exists = False
post = False
remove = True
logs.out("1", uri_file, False)
# Remove DB if unused source article or corrupted DB
if db_exists:
if not post_exists:
db_remove = True
elif os.stat(post_db).st_size < 1000:
db_remove = True
logs.out('23', post_db, False)
else:
exec(open(post_db).read(),globals())
if exists:
# Check if database config is valid (contains values)
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'
)
for value in values:
try:
eval(str(value))
except:
remove = True
corrupt = True
break
# Check if database conf is valid
for conf in article_values:
try: eval(str(conf))
except: db_remove = True
if db_remove:
os.remove(post_db)
db_exists = False
logs.out("23", post_db, False)
if remove and exists:
os.remove(config)
exists = False
logs.out("23", config, 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
if db_exists:
if exists:
# File exists on servers
if os.path.exists(post_wip): file_wip = True
if os.path.exists(post_www): file_www = True
if tyto.exists(post_wip): file_wip = True
if tyto.exists(post_www): file_www = True
# Source article has changed
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 logs, db, tyto, domain
import os, sys, importlib
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 = ''
scale = 'width=device-width, initial-scale=1.0'
all_tags = db.domain_tags + ',' + db.tags
css_file = 'template/style.css'
css_ref = 'media="screen" href="%s%s"'%(db.sub_uri, css_file)
css_file = 'styles.css'
css_ref = 'href="%stemplate/%s"'%(db.sub_uri, css_file)
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.domain_title, db.domain_sep, db.domain_short
)
@ -98,10 +122,10 @@ def create_metas_page():
def create_main_page(target, article_bottom):
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)
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)
# Create link for website's logo
@ -228,7 +252,7 @@ def create_sidebar(option):
try:
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)
except:
logs.out("1", 'Sidebar load file', True)
@ -273,14 +297,14 @@ def create_sidebar(option):
# Get full article URI and check if exists
sidebar_has = True
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)
continue
# Get Hash from uri to get db file
hash_uri = tyto.get_filesum(f_uri, False)
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)
continue
@ -292,14 +316,14 @@ def create_sidebar(option):
if not hash_wip == hash_chk:
logs.out("30", '%s "%s"'%(line, title), False)
continue
if not os.path.exists(post_wip):
if not tyto.exists(post_wip):
logs.out("24", 'in wip: %s'%post_wip, False)
continue
elif option in pub_opts:
if not hash_www == hash_chk:
logs.out("30", '%s "%s"'%(line, title), False)
continue
if not os.path.exists(post_www):
if not tyto.exists(post_www):
logs.out("24", 'in www: %s'%post_www, False)
continue
@ -353,7 +377,7 @@ def create_sidebar(option):
ask_html = ' ├ Replace %s ? '%target
res = ''
if not option == 'pub' and os.path.exists(target):
if not option == 'pub' and tyto.exists(target):
res = input(ask_html)
if not res in ['y', 'Y']:
logs.out("255", '', True)
@ -374,7 +398,7 @@ def create_navbar(option):
# more confitions to pass
try:
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)
except:
logs.out("1", 'Navbar load file', True)
@ -437,10 +461,10 @@ def create_navbar(option):
# Showing unused index.html server file
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)
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)
e_www_index = True
continue
@ -473,7 +497,7 @@ def create_navbar(option):
# 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
res = ''
@ -498,11 +522,11 @@ def create_navbar(option):
# To manage new creation if changes #
#--------------------------------------------------------#
def create_user_metas(option):
domain.domain_needed()
dom.valid()
if option == 'wip': target = db.wip_metas
elif option == 'www': target = db.www_metas
elif option == 'pub': target = db.www_metas
if option == 'wip': target = dom.wip_metas_f
elif option == 'www': target = dom.www_metas_f
elif option == 'pub': target = dom.www_metas_f
# Create wip metas.html file according to option
#-----------------------------------------------
@ -511,7 +535,7 @@ def create_user_metas(option):
metas_used = ('<meta ', '<link ')
res = ''
if not option == 'pub' and os.path.exists(target):
if not option == 'pub' and tyto.exists(target):
try:
res = input(ask_html)
except KeyboardInterrupt:
@ -534,31 +558,30 @@ def create_user_metas(option):
# Create generic footer from domain datas #
#-----------------------------------------#
def create_user_footer(option):
domain.domain_needed()
dom.valid()
if option == 'wip': target = db.wip_footer
elif option == 'www': target = db.www_footer
elif option == 'pub': target = db.www_footer
if option == 'wip': target = dom.wip_footer_f
elif option == 'www': target = dom.www_footer_f
elif option == 'pub': target = dom.www_footer_f
ask_load = ' ├ Replace HTML footer: %s ? '%target
res = ''
if not option == 'pub' and os.path.exists(target):
if not option == 'pub' and tyto.exists(target):
ask = ''
try:
res = input(ask_load)
ask = input('%s. %s%s '%(tr.footer, tr.form_rep, tr.q))
except KeyboardInterrupt:
print('')
logs.out("255", '', True)
if not res in ['y', 'Y']:
if not ask in form.answer_yes:
logs.out("255", '', True)
user_footer = ''
user_file = open(db.footer_load, 'r').read()
for line in user_file.rsplit('\n'):
footer = ''
footer_f = open(dom.footer_f, 'r').read()
for line in footer_f.rsplit('\n'):
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)
logs.out("33", target, False)
if footer: footer = "%s\n %s"%(footer, line)
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'
CR = '\033[1;31m'
CY = '\033[1;33m'
@ -30,44 +31,49 @@ CG = '\033[1;32m'
#--------------------------------#
def out(nbr, value, out):
logs = {
'1' : ':< %sUnused resource%s: %s'%(CR, CS, value),
'2' : ':< %sIncomplete data%s: %s'%(CR, CS, value),
'3' : ':< %sInvalid data%s: "%s"'%(CR, CS, value),
'4' : ':< %sUnable to create file%s: %s'%(CR, CS, value),
'5' : ':< %sUnused argument%s: [file]'%(CR, CS),
'6' : ':< %sUnused "%s"%s in article'%(CR, value, CS),
'7' : ':< Article %snot yet valid%s'%(CR, CS),
'8' : ':< %sNot paired%s %s'%(CR, CS, value),
'9' : ':< Article %shas changed%s. Check it first'%(CR, CS),
'10' : ':< %sUnused domain configuration%s: %s'%(CR, CS, value),
'11' : ':< %sUnused argument%s: %s'%(CR, CS, value),
'12' : ':< %sUnused "%s"%s in article\'s header'%(CR, value, CS),
'13' : ':< %sNo file or directory%s here (deleted ?)'%(CR, CS),
'14' : ':< %sMismatch%s program start'%(CR, CS),
'15' : ':< Anchor %snot uniq%s: %s'%(CR, CS, value),
'16' : ':< %sUnused database configuration%s: %s'%(CR, CS, value),
'19' : ':D Article %swip%s on: %s'%(CG, CS, value),
'20' : ':D Article %scheck%s on: %s'%(CG, CS, value),
'21' : ':D Article %sValid%s. Ready to wip'%(CG, CS),
'22' : ':? %sNot paired%s symbols: %s'%(CY, CS, value),
'23' : ':? %sCorrupted database%s: %s'%(CY, CS, value),
'24' : ':? %sUnused resource%s %s'%(CY, CS, value),
'25' : ':? Article %snot yet checked%s: %s'%(CY, CS, value),
'26' : ':? %sNo index%s article %s'%(CY, CS, value),
'28' : ':? Nothing to do %s'%value,
'29' : ':? %sEmpty configuration%s %s'%(CY, CS, value),
'30' : ':? Article %snot yet wip%s: %s'%(CY, CS, value),
'31' : ':? Not included. %sMax items reached%s %s'%(CY, CS, value),
'33' : ':D %sCreated file%s: %s'%(CG, CS, value),
'34' : ':D %sChanged file%s %s'%(CG, CS, value),
'35' : ':D %sAdd item%s %s'%(CG, CS, value),
'40' : ':/ %sInactive%s domain "%s"'%(CY, CS, value),
'41' : ':? %sIncomplete%s domain "%s"'%(CR, CS, value),
'42' : ':D %sActive%s domain "%s"'%(CG, CS, value),
'43' : ':? %sNo domain%s configured here: %s'%(CY, CS, value),
'44' : ':! %sCheck again manually%s "tyto check %s"'%(CY, CS, value),
'51' : ':? %sIncomplete data%s: %s'%(CY, CS, value),
'255' : ';) Maybe later...'
'1' : '%s%s%s > %s'%(CR, lang.unused_r, CS, value),
'2' : '%s%s%s > %s'%(CR, lang.data_inc, CS, value),
'3' : '%s%s%s %s'%(CR, lang.data_inv, CS, value),
'4' : '%sUnable to create file%s: %s'%(CR, CS, value),
'5' : '%s%s%s > "%s"'%(CR, lang.no_arg, CS, value),
'6' : '%s%s%s "-----" > %s'%(CR, lang.sep_inv, CS, value),
'7' : '%s%s%s > %s'%(CR, lang.post_inv, CS, value),
'8' : '%s%s%s %s'%(CR, lang.mark_np, CS, value),
'9' : ' ╞ Article %shas changed%s. Check it first'%(CR, CS),
'10' : '%sUnused domain configuration%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),
'13' : '%s%s%s'%(CR, lang.no_fidi, CS),
'14' : '%sMismatch%s program start'%(CR, CS),
'15' : ' ╞ Anchor %snot uniq%s: %s'%(CR, CS, value),
'16' : '%s%s%s "%s = ?"'%(CR, lang.unused_c, CS, value),
'17' : '%s%s%s "%s ?"'%(CR, lang.unused_v, CS, value),
'18' : '%s%s%s > %s'%(CR, lang.unused_p, CS, value),
'19' : ' ╞ Article %swip%s on: %s'%(CG, CS, value),
'20' : '%s%s%s %s'%(CG, lang.check_on, CS, value),
'21' : '%s%s%s > %s'%(CG, lang.post_val, CS, value),
'22' : '%sNot paired%s symbols: %s'%(CY, CS, value),
'23' : '%s%s%s: %s'%(CY, lang.db_inv, CS, value),
'24' : '%sUnused resource%s %s'%(CY, CS, value),
'25' : ' ╞ Article %snot yet checked%s: %s'%(CY, CS, value),
'26' : '%sNo index%s article %s'%(CY, CS, value),
'28' : ' ╘ Nothing to do %s'%value,
'29' : '%sEmpty configuration%s %s'%(CY, CS, value),
'30' : ' ╞ Article %snot yet wip%s: %s'%(CY, CS, value),
'31' : ' ╞ Not included. %sMax items reached%s %s'%(CY, CS, value),
'32' : ' ╞══ %s%s%s > %s'%(CG, lang.file_c, CS, value),
'33' : ' ╞══ %s%s%s > %s'%(CG, lang.dir_c, CS, value),
'34' : ' ╞══ %s%s%s > %s'%(CG, lang.file_n, CS, value),
'35' : '%sAdd item%s %s'%(CG, CS, value),
'36' : '%s %s'%(lang.file_e, value),
'37' : '%s %s'%(lang.dir_e, value),
'40' : '%s%s%s > "%s"'%(CY, lang.dom_ina, CS, value),
'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]
@ -75,3 +81,5 @@ def out(nbr, value, out):
if int(nbr) == 21: nbr = 0
if out: sys.exit(int(nbr))
status.domain()

View File

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

View File

@ -20,7 +20,7 @@
import os, sys, shutil, importlib
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 #

View File

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

View File

@ -17,8 +17,8 @@
#**********************************************************************
import os, importlib
import args, db, logs, domain, tyto, check, stats
import os, sys, importlib
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 #
# final html, db, load #
#----------------------#
def manage_show(target):
# Domain configuration must exists
#if not db.domain_exists: sys.exit(43)
domain.domain_needed()
def manage(target):
if not target == "domain": dom.valid()
do = False
actions_read = ('show', 'show-db', 'show-wip', 'show-www')
actions_edit = ('edit', 'edit-db', 'edit-wip', 'edit-www')
actions_read = ('show', 'show-about', 'show-db', 'show-wip', 'show-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_www = ('show-www', 'edit-www')
@ -48,11 +47,16 @@ def manage_show(target):
if target in args.pass_targets:
if args.action in actions_post:
do = {
"domain" : db.domain_conf,
"footer" : db.footer_load,
"metas" : db.metas_load,
"navbar" : db.navbar_load,
"sidebar" : db.sidebar_load
"domain" : dom.config,
"footer" : dom.footer_f,
"metas" : dom.metas_f,
"navbar" : dom.navbar_f,
"sidebar" : dom.sidebar_f
}
elif args.action in actions_about:
do = {
"footer" : dom.footer_about_f
}
elif args.action in actions_wip:
@ -61,11 +65,11 @@ def manage_show(target):
return
do = {
"domain" : db.domain_conf,
"footer" : db.wip_footer,
"metas" : db.wip_metas,
"navbar" : db.wip_navbar,
"sidebar" : db.wip_sidebar
"domain" : dom.config,
"footer" : dom.wip_footer_f,
"metas" : dom.wip_metas_f,
"navbar" : dom.wip_navbar_f,
"sidebar" : dom.wip_sidebar_f
}
elif args.action in actions_www:
@ -74,11 +78,11 @@ def manage_show(target):
return
do = {
"domain" : db.domain_conf,
"footer" : db.www_footer,
"metas" : db.www_metas,
"navbar" : db.www_navbar,
"sidebar" : db.www_sidebar
"domain" : dom.config,
"footer" : dom.www_footer_f,
"metas" : dom.www_metas_f,
"navbar" : dom.www_navbar_f,
"sidebar" : dom.www_sidebar_f
}
# Target is a post uri
@ -94,9 +98,9 @@ def manage_show(target):
do = {"post" : db.uri_file}
# Post has database
elif db.db_exists:
elif db.exists:
do = {
"db" : db.post_db,
"db" : db.config,
"wip" : db.post_wip,
"www" : db.post_www
}
@ -107,7 +111,8 @@ def manage_show(target):
#print('> show: target', target)
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
if args.action in actions_read: read_lines(do[target])
@ -136,8 +141,11 @@ def manage_show(target):
#--------------------------------------------#
def read_lines(f):
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()
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 args, logs, db, domain, tyto, show
import args, logs, dom, form, tyto, show
sti_anchors = sti_abbrs = sti_links = 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
from hashlib import blake2b
import args, logs, db
import args, dom, logs
domain_active = False
home_dir = os.path.expanduser('~')
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]
# TEMP
lang = 'fr'
if lang.lower() == 'fr': n = 0
else: n = 1
#--
# :D
Tyto = 'Tyto - Littérateur'
@ -58,7 +51,7 @@ trans = [
('Générateur :', 'Generator:'), # 12
('Contacter par courriel', 'Contact by mail'), # 13
('Courriel', 'Mail'), # 14
('C.G.U.', 'T.O.U'), # 15
('C.G.U.', 'T.o.U'), # 15
('Mentions légales', 'Legal Notice'), # 16
('Conditions Générales d\'Utilisation', 'Terms of Use'), # 17
('Loi', 'Law'), # 18
@ -108,6 +101,15 @@ words_tags = [
('-(', '-)', '-(', '-)', 'lists', 't')
]
# When counting words, do no count line starting with:
nolinewords = \
(
'((', '))',
'{{', ']]',
'{{', '}}',
'->', '|',
'_image:', '_taw:'
)
# warning symbols (Check if paired)
#----------------------------------
@ -148,16 +150,30 @@ quote_tags = [
# Tags to check in header in content _TAG
head_tags = ("image:", "raw:")
# Stats for icodes, bcodes, quotes
nbr_icodes = 0
#=======#
# TOOLS #
#=======#--------------------------------------------------------------
#
# Return True if file exists
#
def exists(uri):
if os.path.exists(uri): return(True)
else: return(False)
#=======================#
# Return sum of srcfile #
# src: True = Content #
# False = URI #
#-----------------------#
def get_filesum(path, src):
if not exists(path):
logs.out("1", path, True)
file_sum = blake2b(digest_size=4)
if src: file_sum.update(open(path, 'rb').read())
@ -338,7 +354,6 @@ def protect_icodes(post_bottom):
global protect_article
global nbr_icodes
nbr_icodes = 0 # Stats here for DB as content will change
protect_article = post_bottom
in_icode = False
src_code = rep_code = ''

View File

@ -20,7 +20,7 @@
import os, re, sys, shutil, importlib
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
# Check if can process
domain.domain_needed()
dom.valid()
# 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 * "-")