[0.10.3]
This commit is contained in:
parent
1b13f8e1df
commit
4825c25f63
|
@ -6,6 +6,9 @@ Tyto - Littérateur
|
|||
- Changelog: https://git.a-lec.org/echolib/tyto-litterateur/-/blob/master/CHANGELOG.md
|
||||
- License: https://git.a-lec.org/echolib/tyto-litterateur/-/blob/master/LICENSE
|
||||
|
||||
## {0.10.3]
|
||||
- pre 1.0
|
||||
|
||||
## [0.10.2]
|
||||
- Citer dans un texte > `[_` + `_]`
|
||||
- Italique `<em>` > `;_` + `_;`
|
||||
|
|
10
README.md
10
README.md
|
@ -54,19 +54,17 @@ abbr: abbrev
|
|||
# Les titres HTML vont de 1 à 6.
|
||||
# Utiliser #N, où N est entre 1 et 6.
|
||||
# Si du contenu existe entre les titres, une <div> est ajoutée
|
||||
# Astuce: on commence en général par #2 dans l'article le titre du site
|
||||
# étant en #1
|
||||
|
||||
# Source
|
||||
#2 Titre 1
|
||||
#1 Titre 1
|
||||
Contenu 1
|
||||
|
||||
#3 Titre 2
|
||||
#2 Titre 2
|
||||
|
||||
#4 Titre 3
|
||||
#3 Titre 3
|
||||
contenu 2
|
||||
|
||||
#5 Titre 4
|
||||
#4 Titre 4
|
||||
```
|
||||
|
||||
### Balise div
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
Package: tyto
|
||||
Version: 0.10.2
|
||||
Version: 0.10.3
|
||||
Section: custom
|
||||
Priority: optional
|
||||
Architecture: all
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
#!/usr/bin/env python3
|
||||
# Version: 0.10.2
|
||||
# Version: 0.10.3
|
||||
# Tyto - Littérateur
|
||||
#
|
||||
# Copyright (C) 2023 Cyrille Louarn <echolib+tyto@a-lec.org>
|
||||
|
|
|
@ -52,10 +52,11 @@ a.site_menu_link {
|
|||
article#article_main {
|
||||
}
|
||||
|
||||
h1#main_title {
|
||||
}
|
||||
h2.title_2 {
|
||||
/* article title */
|
||||
h2#main_title {
|
||||
}
|
||||
|
||||
/* Writer titles*/
|
||||
h3.title_3 {
|
||||
}
|
||||
h4.title_4 {
|
||||
|
@ -65,9 +66,17 @@ h5.title_5 {
|
|||
h6.title_6 {
|
||||
}
|
||||
|
||||
/* Between every <h2-6> IF CONTENTS */
|
||||
/* Between every <h3-6> IF CONTENTS */
|
||||
div.contents {
|
||||
}
|
||||
div.contents_3 {
|
||||
}
|
||||
div.contents_4 {
|
||||
}
|
||||
div.contents_5 {
|
||||
}
|
||||
div.contents_6 {
|
||||
}
|
||||
|
||||
/* Default if not set in post */
|
||||
p.DOMAIN {
|
||||
|
@ -138,7 +147,7 @@ a#article_code_link {
|
|||
|
||||
aside#sidebar {
|
||||
}
|
||||
h1#sidebar_title {
|
||||
h2#sidebar_title {
|
||||
}
|
||||
ul#sidebar_list {
|
||||
}
|
||||
|
@ -146,7 +155,7 @@ li.sidebar_item {
|
|||
}
|
||||
a.sidebar_item_link {
|
||||
}
|
||||
h2.sidebar_item_title {
|
||||
h3.sidebar_item_title {
|
||||
}
|
||||
p.sidebar_item_about {
|
||||
}
|
||||
|
@ -165,7 +174,7 @@ div#footer_container {
|
|||
/* Block*/
|
||||
div#footer_infos {
|
||||
}
|
||||
h1#footer_site_title {
|
||||
h2#footer_site_title {
|
||||
}
|
||||
p#footer_about {
|
||||
}
|
||||
|
|
|
@ -166,15 +166,25 @@ def check_all(option):
|
|||
# Check articles process #
|
||||
#------------------------#
|
||||
def check_process(target):
|
||||
global post_err
|
||||
|
||||
if not db.post:
|
||||
logs.out("1", db.post, True)
|
||||
logs.out("1", db.post, False)
|
||||
post_err = True
|
||||
return
|
||||
|
||||
# Start checking processes
|
||||
#-------------------------
|
||||
# Convert file to string
|
||||
# Also check for separator and empty article
|
||||
file_to_string()
|
||||
if post_err:
|
||||
return
|
||||
|
||||
global post_bottom, article_bottom
|
||||
global date_wip, hash_wip, date_www, hash_www, post_bottom
|
||||
global post_err
|
||||
|
||||
date_wip = hash_wip = date_www = hash_www = ''
|
||||
post_err = False
|
||||
|
||||
# Set values for wip and www from DB
|
||||
if db.exists:
|
||||
|
@ -213,12 +223,6 @@ def check_process(target):
|
|||
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
|
||||
#-------------------------
|
||||
# Convert file to string
|
||||
# Also check for separator and empty article
|
||||
file_to_string()
|
||||
|
||||
# Check for icodes, bcodes, quotes
|
||||
# check icodes marks on same line
|
||||
if_icodes_bcodes_quotes(post_bottom)
|
||||
|
@ -269,14 +273,21 @@ def check_process(target):
|
|||
# Check if separator or exit #
|
||||
#---------------------------------#
|
||||
def file_to_string():
|
||||
global post_err
|
||||
global article, post_header, post_bottom
|
||||
global ln_header, ln_bottom, ln_article
|
||||
|
||||
post_err = False
|
||||
post_header = post_bottom = ''
|
||||
sep = content = False
|
||||
article = open(db.uri_file, 'r').read()
|
||||
|
||||
for line in article.rsplit('\n'):
|
||||
if line.startswith(logs.shebang):
|
||||
logs.out("82", db.uri_file, False)
|
||||
post_err = True
|
||||
return
|
||||
|
||||
if line.startswith('-----'):
|
||||
if not sep:
|
||||
sep = True
|
||||
|
@ -292,12 +303,16 @@ def file_to_string():
|
|||
|
||||
# Check if separator or exit
|
||||
if not sep:
|
||||
logs.out("6", '"-----" > %s'%db.uri_file, True)
|
||||
logs.out("6", '"-----" > %s'%db.uri_file, False)
|
||||
post_err = True
|
||||
return
|
||||
|
||||
if not content:
|
||||
if db.exists and tyto.exists(db.config):
|
||||
os.remove(db.config)
|
||||
logs.out("18", db.uri_file, True)
|
||||
logs.out("18", db.uri_file, False)
|
||||
post_err = True
|
||||
return
|
||||
|
||||
# +2 > (start at 0 + separator line)
|
||||
ln_article = len(article.splitlines()) + 1
|
||||
|
@ -313,11 +328,11 @@ def file_to_string():
|
|||
def count_words(post_bottom):
|
||||
global post_words
|
||||
post_words = 0
|
||||
|
||||
for line in post_bottom:
|
||||
if not line \
|
||||
or line.startswith(tyto.nolinewords) \
|
||||
or line.startswith("#") and \
|
||||
not line.startswith(tyto.titles_tags):
|
||||
or line.startswith("#") and not line.startswith(tyto.titles_user):
|
||||
continue
|
||||
|
||||
post_words = post_words + len(line.strip().split(" "))
|
||||
|
@ -330,11 +345,11 @@ def count_words(post_bottom):
|
|||
#---------------------------------------------#
|
||||
def if_icodes_bcodes_quotes(post_bottom):
|
||||
global icode, quote, bcode, post_err
|
||||
global post_titles, nbr_quotes, nbr_bcodes, nbr_ancs, post_comments
|
||||
global nbr_quotes, nbr_bcodes, nbr_ancs, post_comments
|
||||
global post_images, post_raws, fcodes
|
||||
|
||||
icode = quote = in_quote = bcode = in_bcode = in_bq = False
|
||||
post_titles = nbr_quotes = nbr_bcodes = nbr_ancs = 0
|
||||
nbr_quotes = nbr_bcodes = nbr_ancs = 0
|
||||
post_images = post_comments = post_raws = fcodes = 0
|
||||
|
||||
for ln, line in enumerate(post_bottom.rsplit('\n'), 1):
|
||||
|
@ -363,10 +378,7 @@ def if_icodes_bcodes_quotes(post_bottom):
|
|||
if in_bq:
|
||||
continue
|
||||
|
||||
elif line.startswith(tyto.titles_tags):
|
||||
post_titles += 1
|
||||
continue
|
||||
elif line.startswith('#'):
|
||||
elif line.startswith('#') and not line.startswith(tyto.titles_user):
|
||||
post_comments += 1
|
||||
continue
|
||||
elif line.startswith(tyto.single_tags[1][0]):
|
||||
|
@ -769,12 +781,36 @@ def check_anchors():
|
|||
post_err = True
|
||||
|
||||
|
||||
#==========================#
|
||||
# Check titles and content #
|
||||
#--------------------------#
|
||||
def check_titles():
|
||||
global post_err, post_titles
|
||||
post_titles = 0
|
||||
|
||||
for ln, line in enumerate(post_bottom.rsplit('\n'), 1):
|
||||
ln = ln + ln_header + 1
|
||||
|
||||
if line.startswith(tyto.titles_user):
|
||||
title_name = line[2: len(line)].lstrip()
|
||||
if not title_name:
|
||||
post_err = True
|
||||
logs.out("84", 'L=%s > %s'%(ln, db.uri_file), False)
|
||||
continue
|
||||
|
||||
post_titles += 1
|
||||
|
||||
|
||||
|
||||
|
||||
#===========================#
|
||||
# Check tags in post_bottom #
|
||||
#---------------------------#
|
||||
def check_content(post_bottom):
|
||||
global post_err
|
||||
|
||||
check_titles()
|
||||
|
||||
# Check tags for words (strongs, italics...)
|
||||
# Set stats for each one
|
||||
#-------------------------------------------
|
||||
|
|
|
@ -50,83 +50,93 @@ except:
|
|||
except:
|
||||
hole = True
|
||||
|
||||
# Set current user name
|
||||
try:
|
||||
user
|
||||
except:
|
||||
try:
|
||||
user = os.environ.get('USER')
|
||||
except:
|
||||
user = ''
|
||||
|
||||
|
||||
# Settings for domain, check if db is not corrupted
|
||||
dom_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_css_f',
|
||||
'wip_logo_f',
|
||||
'wip_navbar_f',
|
||||
'wip_sidebar_f',
|
||||
'wip_metas_f',
|
||||
'wip_footer_f',
|
||||
'wip_stats_f',
|
||||
'www_css_f',
|
||||
'www_navbar_f',
|
||||
'www_sidebar_f',
|
||||
'www_metas_f',
|
||||
'www_footer_f',
|
||||
'www_stats_f',
|
||||
'www_logo_f',
|
||||
'www_rss_f',
|
||||
'logo',
|
||||
'styles',
|
||||
'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'
|
||||
)
|
||||
(
|
||||
'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_css_f',
|
||||
'wip_logo_f',
|
||||
'wip_navbar_f',
|
||||
'wip_sidebar_f',
|
||||
'wip_metas_f',
|
||||
'wip_footer_f',
|
||||
'wip_stats_f',
|
||||
'www_css_f',
|
||||
'www_navbar_f',
|
||||
'www_sidebar_f',
|
||||
'www_metas_f',
|
||||
'www_footer_f',
|
||||
'www_stats_f',
|
||||
'www_logo_f',
|
||||
'www_rss_f',
|
||||
'logo',
|
||||
'styles',
|
||||
'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'
|
||||
)
|
||||
|
||||
create_files = \
|
||||
(
|
||||
'navbar_f',
|
||||
'sidebar_f',
|
||||
'metas_f',
|
||||
'footer_f',
|
||||
'footer_about_f'
|
||||
)
|
||||
(
|
||||
'navbar_f',
|
||||
'sidebar_f',
|
||||
'metas_f',
|
||||
'footer_f',
|
||||
'footer_about_f'
|
||||
)
|
||||
|
||||
wip_html_mods = ()
|
||||
err_val = (()) # Make a list from values error
|
||||
|
@ -186,18 +196,8 @@ if not hole:
|
|||
value_set = False
|
||||
incomplete = True
|
||||
active = False
|
||||
|
||||
|
||||
if value.endswith('_d'):
|
||||
if value_set:
|
||||
if not os.path.exists(eval(str(value))):
|
||||
try:
|
||||
os.makedirs(eval(str(value)), exist_ok=True)
|
||||
dir_new = dir_new + ((eval(str(value))),)
|
||||
except:
|
||||
dir_unu = dir_unu + ((eval(str(value))),)
|
||||
|
||||
elif value.endswith('_f'):
|
||||
|
||||
if value.endswith('_f'):
|
||||
if value_set:
|
||||
if not os.path.exists(eval(str(value))):
|
||||
if value in create_files:
|
||||
|
@ -210,84 +210,99 @@ if not hole:
|
|||
# When an active and complete domain is needed #
|
||||
#----------------------------------------------#
|
||||
if exists and not incomplete and not corrupt:
|
||||
wip_html_mods = \
|
||||
(
|
||||
eval(str('wip_navbar_f')),
|
||||
eval(str('wip_sidebar_f')),
|
||||
eval(str('wip_metas_f')),
|
||||
eval(str('wip_footer_f'))
|
||||
)
|
||||
if active:
|
||||
ready = True
|
||||
|
||||
metas = (
|
||||
eval(str('metas_f')),
|
||||
eval(str('wip_metas_f')),
|
||||
eval(str('www_metas_f'))
|
||||
)
|
||||
navbars = (
|
||||
eval(str('navbar_f')),
|
||||
eval(str('wip_navbar_f')),
|
||||
eval(str('www_navbar_f'))
|
||||
)
|
||||
sidebars = (
|
||||
eval(str('sidebar_f')),
|
||||
eval(str('wip_sidebar_f')),
|
||||
eval(str('www_sidebar_f'))
|
||||
)
|
||||
footers = (
|
||||
eval(str('footer_f')),
|
||||
eval(str('wip_footer_f')),
|
||||
eval(str('www_footer_f')),
|
||||
eval(str('footer_about_f'))
|
||||
)
|
||||
wip_html_mods = \
|
||||
(
|
||||
eval(str('wip_navbar_f')),
|
||||
eval(str('wip_sidebar_f')),
|
||||
eval(str('wip_metas_f')),
|
||||
eval(str('wip_footer_f'))
|
||||
)
|
||||
www_html_mods = \
|
||||
(
|
||||
eval(str('www_navbar_f')),
|
||||
eval(str('www_sidebar_f')),
|
||||
eval(str('www_metas_f')),
|
||||
eval(str('www_footer_f'))
|
||||
)
|
||||
metas = \
|
||||
(
|
||||
eval(str('metas_f')),
|
||||
eval(str('wip_metas_f')),
|
||||
eval(str('www_metas_f'))
|
||||
)
|
||||
navbars = \
|
||||
(
|
||||
eval(str('navbar_f')),
|
||||
eval(str('wip_navbar_f')),
|
||||
eval(str('www_navbar_f'))
|
||||
)
|
||||
sidebars = \
|
||||
(
|
||||
eval(str('sidebar_f')),
|
||||
eval(str('wip_sidebar_f')),
|
||||
eval(str('www_sidebar_f'))
|
||||
)
|
||||
footers = \
|
||||
(
|
||||
eval(str('footer_f')),
|
||||
eval(str('wip_footer_f')),
|
||||
eval(str('www_footer_f')),
|
||||
eval(str('footer_about_f'))
|
||||
)
|
||||
|
||||
templates = (
|
||||
eval(str('wip_logo_f')),
|
||||
eval(str('wip_css_f')),
|
||||
eval(str('wip_navbar_f')),
|
||||
eval(str('wip_sidebar_f')),
|
||||
eval(str('wip_metas_f')),
|
||||
eval(str('wip_footer_f')),
|
||||
eval(str('wip_stats_f')),
|
||||
eval(str('www_logo_f')),
|
||||
eval(str('www_css_f')),
|
||||
eval(str('www_navbar_f')),
|
||||
eval(str('www_sidebar_f')),
|
||||
eval(str('www_metas_f')),
|
||||
eval(str('www_footer_f')),
|
||||
eval(str('www_stats_f')),
|
||||
eval(str('www_rss_f')),
|
||||
)
|
||||
|
||||
modules = {
|
||||
"metas" : metas,
|
||||
"navbar" : navbars,
|
||||
"sidebar" : sidebars,
|
||||
"footer" : footers,
|
||||
"template": templates,
|
||||
}
|
||||
templates = \
|
||||
(
|
||||
eval(str('wip_logo_f')),
|
||||
eval(str('wip_css_f')),
|
||||
eval(str('wip_navbar_f')),
|
||||
eval(str('wip_sidebar_f')),
|
||||
eval(str('wip_metas_f')),
|
||||
eval(str('wip_footer_f')),
|
||||
eval(str('wip_stats_f')),
|
||||
eval(str('www_logo_f')),
|
||||
eval(str('www_css_f')),
|
||||
eval(str('www_navbar_f')),
|
||||
eval(str('www_sidebar_f')),
|
||||
eval(str('www_metas_f')),
|
||||
eval(str('www_footer_f')),
|
||||
eval(str('www_stats_f')),
|
||||
eval(str('www_rss_f')),
|
||||
)
|
||||
|
||||
modules = \
|
||||
{
|
||||
"metas" : metas,
|
||||
"navbar" : navbars,
|
||||
"sidebar" : sidebars,
|
||||
"footer" : footers,
|
||||
"template": templates,
|
||||
}
|
||||
|
||||
templates_files_wip = \
|
||||
(
|
||||
eval(str('wip_logo_f')),
|
||||
eval(str('wip_css_f')),
|
||||
eval(str('wip_navbar_f')),
|
||||
eval(str('wip_sidebar_f')),
|
||||
eval(str('wip_metas_f')),
|
||||
eval(str('wip_footer_f')),
|
||||
eval(str('wip_stats_f')),
|
||||
)
|
||||
|
||||
templates_wip = {
|
||||
eval(str('wip_logo_f')),
|
||||
eval(str('wip_css_f')),
|
||||
eval(str('wip_navbar_f')),
|
||||
eval(str('wip_sidebar_f')),
|
||||
eval(str('wip_metas_f')),
|
||||
eval(str('wip_footer_f')),
|
||||
eval(str('wip_stats_f')),
|
||||
}
|
||||
|
||||
templates_www = {
|
||||
eval(str('www_logo_f')),
|
||||
eval(str('www_css_f')),
|
||||
eval(str('www_navbar_f')),
|
||||
eval(str('www_sidebar_f')),
|
||||
eval(str('www_metas_f')),
|
||||
eval(str('www_footer_f')),
|
||||
eval(str('www_stats_f')),
|
||||
eval(str('www_rss_f'))
|
||||
}
|
||||
templates_files_www = \
|
||||
(
|
||||
eval(str('www_logo_f')),
|
||||
eval(str('www_css_f')),
|
||||
eval(str('www_navbar_f')),
|
||||
eval(str('www_sidebar_f')),
|
||||
eval(str('www_metas_f')),
|
||||
eval(str('www_footer_f')),
|
||||
eval(str('www_stats_f')),
|
||||
eval(str('www_rss_f'))
|
||||
)
|
||||
|
||||
#====================================#
|
||||
# Check if domain is ready and ready #
|
||||
|
|
|
@ -681,11 +681,20 @@ def create_domain(target):
|
|||
|
||||
# Create in _configs/ modules files
|
||||
#----------------------------------
|
||||
|
||||
html.create_user_metass('new')
|
||||
html.create_navbar('new')
|
||||
html.create_sidebar('new')
|
||||
html.create_user_footer('new')
|
||||
create_footer_about('new')
|
||||
|
||||
'''
|
||||
create_metas('form')
|
||||
create_navbar('form')
|
||||
create_sidebar('form')
|
||||
create_footer('form')
|
||||
create_footer_about('form')
|
||||
'''
|
||||
|
||||
print(langs.site.form_ready)
|
||||
|
||||
|
@ -700,16 +709,18 @@ def create_domain(target):
|
|||
#------------------------#
|
||||
def create_metas(option):
|
||||
if not dom.ready: dom.valid()
|
||||
|
||||
|
||||
print(' │\n ├ %s'%langs.site.metas_inf)
|
||||
if option != "new": return
|
||||
|
||||
# Create new default config file, or ask if exists
|
||||
if tyto.exists(dom.metas_f):
|
||||
answer = asking(' ├ %s. %s%s '%(
|
||||
langs.site.metas, langs.site.form_reset,
|
||||
langs.site.q
|
||||
answer = asking(' ├ %s%s '%(
|
||||
langs.site.form_reset, langs.site.q
|
||||
), False)
|
||||
|
||||
if not answer in answer_yes:
|
||||
if option == "form": return
|
||||
if option == "new": return
|
||||
logs.out("255", '', True)
|
||||
|
||||
# Set default content for
|
||||
|
@ -766,10 +777,6 @@ def create_metas(option):
|
|||
'<meta name="revisit-after" content="3 days">'
|
||||
|
||||
tyto.set_file(dom.metas_f, 'New', metas_tags)
|
||||
|
||||
# Create an empty html file in wip/www server if not exists
|
||||
if not tyto.exists(dom.wip_metas_f):
|
||||
html.create_user_metas('wip')
|
||||
|
||||
|
||||
#=============================#
|
||||
|
@ -778,15 +785,17 @@ def create_metas(option):
|
|||
def create_navbar(option):
|
||||
if not dom.ready: dom.valid()
|
||||
|
||||
print(' │\n ├ %s'%langs.site.navbar_inf)
|
||||
if option != "new": return
|
||||
|
||||
# Create new config file, or ask if exists
|
||||
if tyto.exists(dom.navbar_f):
|
||||
answer = asking(' ├ %s. %s%s '%(
|
||||
langs.site.navbar, langs.site.form_reset,
|
||||
langs.site.q
|
||||
answer = asking(' ├ %s%s '%(
|
||||
langs.site.form_reset, langs.site.q
|
||||
), False)
|
||||
|
||||
if not answer in answer_yes:
|
||||
if option == "form": return
|
||||
if option == "new": return
|
||||
logs.out("255", '', True)
|
||||
|
||||
|
||||
|
@ -827,9 +836,6 @@ def create_navbar(option):
|
|||
navbar_lang = navbar_lang%(tyto.Tyto, dom.navbar_f)
|
||||
|
||||
tyto.set_file(dom.navbar_f, 'New', navbar_lang)
|
||||
|
||||
# Create wip navbar file
|
||||
html.create_navbar('wip')
|
||||
|
||||
|
||||
#==============================#
|
||||
|
@ -838,19 +844,21 @@ def create_navbar(option):
|
|||
def create_sidebar(option):
|
||||
if not dom.ready: dom.valid()
|
||||
|
||||
print(' │\n ├ %s'%langs.site.sidebar_inf)
|
||||
if option != "new": return
|
||||
|
||||
# Create an empty html file in wip/www server if not exists
|
||||
if not tyto.exists(dom.wip_sidebar_f):
|
||||
tyto.set_file(dom.wip_sidebar_f, 'new', '')
|
||||
|
||||
# Create new config file, or ask if exists with option = 'reset'
|
||||
if tyto.exists(dom.sidebar_f):
|
||||
answer = asking(' ├ %s. %s%s '%(
|
||||
langs.site.sidebar, langs.site.form_reset,
|
||||
langs.site.q
|
||||
answer = asking(' ├ %s%s '%(
|
||||
langs.site.form_reset, langs.site.q
|
||||
), False)
|
||||
|
||||
if not answer in answer_yes:
|
||||
if option == "form": return
|
||||
if option == "new": return
|
||||
logs.out("255", '', True)
|
||||
|
||||
|
||||
|
@ -900,6 +908,10 @@ def create_sidebar(option):
|
|||
def create_footer(option):
|
||||
if not dom.ready: dom.valid()
|
||||
|
||||
print(' │\n ├ %s'%langs.site.footer_inf)
|
||||
create_footer_about(option)
|
||||
if option != "new": return
|
||||
|
||||
# Default footer contents
|
||||
#------------------------
|
||||
Tytosrc = \
|
||||
|
@ -999,15 +1011,15 @@ def create_footer(option):
|
|||
# Final HTML footer code
|
||||
footer = \
|
||||
'%s\n'%footer_lang%(tyto.Tyto, dom.footer_f) + \
|
||||
'<footer id="footer_page">\n' + \
|
||||
'<footer accesskey="f" id="footer_page">\n' + \
|
||||
' <div id="footer_container"> \n' + \
|
||||
' <div id="footer_infos">\n' + \
|
||||
' <h1 id="footer_site_title"\n' + \
|
||||
' <h2 id="footer_site_title"\n' + \
|
||||
' title="%s %s">%s %s\n'%(
|
||||
langs.site.add_inf, dom.title,
|
||||
langs.site.about, dom.title
|
||||
) + \
|
||||
' </h1>\n' + \
|
||||
' </h2>\n' + \
|
||||
'%s\n'%(footer_about) + \
|
||||
' </div>\n' + \
|
||||
'\n' + \
|
||||
|
@ -1052,21 +1064,16 @@ def create_footer(option):
|
|||
|
||||
# Create new default file, or ask if exists
|
||||
if tyto.exists(dom.footer_f):
|
||||
answer = asking(' ├ %s. %s%s '%(
|
||||
langs.site.footer, langs.site.form_reset,
|
||||
langs.site.q
|
||||
answer = asking(' ├ %s%s '%(
|
||||
langs.site.form_reset, langs.site.q
|
||||
), False)
|
||||
|
||||
if not answer in answer_yes:
|
||||
if option == "form": return
|
||||
if option == "new": return
|
||||
logs.out("255", '', True)
|
||||
|
||||
tyto.set_file(dom.footer_f, 'New', footer)
|
||||
|
||||
# Create footer file in wip server if not exists
|
||||
if not tyto.exists(dom.wip_footer_f):
|
||||
html.create_user_footer('wip')
|
||||
|
||||
|
||||
# Generic HTML list in footer
|
||||
"""
|
||||
|
@ -1084,9 +1091,9 @@ def create_footer(option):
|
|||
def create_footer_about(option):
|
||||
if not tyto.exists(dom.footer_about_f):
|
||||
set_f = '%s\n'%langs.site.footer_about_doc%(tyto.Tyto,
|
||||
dom.footer_about_f
|
||||
dom.footer_about_f
|
||||
) + \
|
||||
'<p id="footer_about">%s</p>'%dom.about
|
||||
|
||||
tyto.set_file(dom.footer_about_f, False, set_f)
|
||||
tyto.set_file(dom.footer_about_f, 'New', set_f)
|
||||
|
||||
|
|
|
@ -36,6 +36,7 @@ import os, sys, importlib
|
|||
import logs, db, dom, tyto, form, langs
|
||||
|
||||
# Publish option can be
|
||||
wip_opts = ('wip', 'new')
|
||||
pub_opts = ('www', 'pub')
|
||||
|
||||
# Not a line if it starts with...(for sidebar, navbar)
|
||||
|
@ -158,18 +159,18 @@ def create_main_page(target, article_bottom):
|
|||
' %s\n'%logo_html + \
|
||||
' </div>\n' + \
|
||||
' <div id="site_infos">\n' + \
|
||||
' <a href="/"\n' + \
|
||||
' title="%s"\n'%(langs.site.home) + \
|
||||
' id="site_link">\n' + \
|
||||
' <h1 id="site_title">%s</h1>\n'%dom.title + \
|
||||
' </a>\n' + \
|
||||
' <h1 id="site_title">\n' + \
|
||||
' <a href="/"\n' + \
|
||||
' title="%s"\n'%(langs.site.home) + \
|
||||
' id="site_link">%s</a>\n'%dom.title + \
|
||||
' </h1>\n' + \
|
||||
' <p id="site_about">%s</p>\n'%dom.about + \
|
||||
' </div>\n' + \
|
||||
' </header>\n' + \
|
||||
tyto.tags_html_mods[dom.wip_navbar_f] + '\n' + \
|
||||
' <article id="article_main">\n' + \
|
||||
' <h1 id="main_title"\n' + \
|
||||
' title="[%s] %s %s %s %s">%s</h1>\n'%(
|
||||
' <h1 accesskey="t" id="post_title"\n' + \
|
||||
' title="[%s] %s %s %s %s">%s</h1>\n'%(
|
||||
db.title, langs.site.w_written, db.date,
|
||||
langs.site.by, db.author,
|
||||
db.title,
|
||||
|
@ -250,15 +251,15 @@ def create_html_time_meta(process):
|
|||
def create_user_metas(option):
|
||||
dom.valid()
|
||||
|
||||
if option == 'wip': target = dom.wip_metas_f
|
||||
form.create_metas(option)
|
||||
|
||||
if option in wip_opts: target = dom.wip_metas_f
|
||||
elif option in pub_opts: target = dom.www_metas_f
|
||||
|
||||
if option == 'www' and tyto.exists(target):
|
||||
form.asking(' ├ %s. %s%s '%(
|
||||
langs.site.metas, langs.site.form_rep, langs.site.q
|
||||
), True)
|
||||
|
||||
print(' │\n ├ %s'%langs.site.metas_inf)
|
||||
|
||||
# Create wip metas.html file according to option
|
||||
#-----------------------------------------------
|
||||
|
@ -284,10 +285,12 @@ def create_user_metas(option):
|
|||
def create_navbar(option):
|
||||
dom.valid()
|
||||
|
||||
form.create_navbar(option)
|
||||
|
||||
if not tyto.exists(dom.navbar_f):
|
||||
logs.out("1", dom.navbar_f, True)
|
||||
|
||||
if option == 'wip': target = dom.wip_navbar_f
|
||||
if option in wip_opts: target = dom.wip_navbar_f
|
||||
elif option in pub_opts: target = dom.www_navbar_f
|
||||
|
||||
if option == 'www' and tyto.exists(target):
|
||||
|
@ -296,14 +299,12 @@ def create_navbar(option):
|
|||
option, langs.site.q
|
||||
), True)
|
||||
|
||||
print(' │\n ├ %s'%langs.site.navbar_inf)
|
||||
|
||||
# navbar has items
|
||||
navbar_items = False
|
||||
|
||||
# Set first HTML line
|
||||
menu_html = \
|
||||
'%s<nav id="site_menu">\n'%(4 * ' ') + \
|
||||
'%s<nav accesskey="m" id="site_menu">\n'%(4 * ' ') + \
|
||||
'%s<menu id="site_menu_items">'%(6 * ' ')
|
||||
|
||||
navbar_lines = open(dom.navbar_f, 'r').read()
|
||||
|
@ -345,7 +346,7 @@ def create_navbar(option):
|
|||
continue
|
||||
|
||||
# index.html server files must exist (or 404 error)
|
||||
if option == 'wip':
|
||||
if option in wip_opts:
|
||||
if not tyto.exists(wip_index):
|
||||
logs.out('26', '> %s'%(wip_index), False)
|
||||
no_wip_index = True
|
||||
|
@ -374,10 +375,7 @@ def create_navbar(option):
|
|||
|
||||
# Nothing to do
|
||||
if not navbar_items:
|
||||
if not tyto.exists(target):
|
||||
tyto.set_file(target, 'New', '')
|
||||
logs.out('28', '%s'%langs.log.navbar, False)
|
||||
return
|
||||
tyto.set_file(target, 'New', '')
|
||||
|
||||
# Create ending HTML file
|
||||
else:
|
||||
|
@ -392,12 +390,14 @@ def create_navbar(option):
|
|||
def create_sidebar(option):
|
||||
dom.valid()
|
||||
|
||||
form.create_sidebar(option)
|
||||
|
||||
if not tyto.exists(dom.sidebar_f):
|
||||
logs.out("1", dom.sidebar_f, True)
|
||||
|
||||
if int(dom.sidebar_items) > 16: db.sidebar_items = 6
|
||||
|
||||
if option == 'wip': target = dom.wip_sidebar_f
|
||||
if option in wip_opts: target = dom.wip_sidebar_f
|
||||
elif option in pub_opts: target = dom.www_sidebar_f
|
||||
|
||||
if option == 'www' and tyto.exists(target):
|
||||
|
@ -405,15 +405,13 @@ def create_sidebar(option):
|
|||
langs.site.sidebar, langs.site.form_rep, langs.site.q
|
||||
), True)
|
||||
|
||||
print(' │\n ├ %s'%langs.site.sidebar_inf)
|
||||
|
||||
sidebar_items = False
|
||||
|
||||
# Set HTML sidebar
|
||||
sidebar_list = ''
|
||||
sidebar_html = \
|
||||
'<aside id="sidebar">\n' + \
|
||||
' <h1 id="sidebar_title">%s</h1>\n' + \
|
||||
'<aside accesskey="s" id="sidebar">\n' + \
|
||||
' <h2 id="sidebar_title">%s</h2>\n' + \
|
||||
' <ul id="sidebar_list">\n' + \
|
||||
'%s' + \
|
||||
' </ul>\n' + \
|
||||
|
@ -447,7 +445,7 @@ def create_sidebar(option):
|
|||
exec(open(db_uri).read(),globals())
|
||||
|
||||
# Check wip status and if article exists in server
|
||||
if option == 'wip':
|
||||
if option in wip_opts:
|
||||
if hash_wip != hash_chk:
|
||||
logs.out("30", line, False)
|
||||
continue
|
||||
|
@ -477,7 +475,7 @@ def create_sidebar(option):
|
|||
' <li class="sidebar_item">\n' + \
|
||||
' <a class="sidebar_item_link"\n' + \
|
||||
' href="/%s">\n'%short_srv + \
|
||||
' <h2 class="sidebar_item_title">%s</h2>\n'%title + \
|
||||
' <h3 class="sidebar_item_title">%s</h2>\n'%title + \
|
||||
' <p class="sidebar_item_about"\n' + \
|
||||
' title="%s">\n'%link_title + \
|
||||
' %s [%s] - %s\n'%(date, author, about) + \
|
||||
|
@ -487,10 +485,7 @@ def create_sidebar(option):
|
|||
|
||||
# Nothing to do
|
||||
if not sidebar_items:
|
||||
if not tyto.exists(target):
|
||||
tyto.set_file(target, 'New', '')
|
||||
logs.out('28', '%s'%langs.log.sidebar, False)
|
||||
return
|
||||
tyto.set_file(target, 'New', '')
|
||||
|
||||
else:
|
||||
# Create HTML complete sidebar
|
||||
|
@ -510,7 +505,9 @@ def create_sidebar(option):
|
|||
def create_user_footer(option):
|
||||
dom.valid()
|
||||
|
||||
if option == 'wip': target = dom.wip_footer_f
|
||||
form.create_footer(option)
|
||||
|
||||
if option in wip_opts: target = dom.wip_footer_f
|
||||
elif option in pub_opts: target = dom.www_footer_f
|
||||
|
||||
if option == 'www' and tyto.exists(target):
|
||||
|
@ -518,8 +515,6 @@ def create_user_footer(option):
|
|||
langs.site.footer, langs.site.form_rep, langs.site.q
|
||||
), True)
|
||||
|
||||
print(' │\n ├ %s'%langs.site.footer_inf)
|
||||
|
||||
try: footer_f = open(dom.footer_f, 'r').read()
|
||||
except: logs.out("1", dom.footer_f, True)
|
||||
|
||||
|
|
|
@ -36,6 +36,9 @@
|
|||
import os, sys
|
||||
import langs
|
||||
|
||||
# Use to mark new article
|
||||
shebang = "#!/usr/bin/tyto"
|
||||
|
||||
# Set colors
|
||||
CS = '\033[0;0m'
|
||||
CR = '\033[1;31m'
|
||||
|
@ -97,6 +100,9 @@ def out(nbr, value, out):
|
|||
'60' : ' │\n ╞ %s'%langs.log.status_r,
|
||||
'61' : ' ╞ %s%s%s > %s'%(CG, langs.log.file_e, CS, value),
|
||||
'85' : ' ╞═ %s%s%s > %s'%(CY, langs.log.was_pub, CS, value),
|
||||
'81' : ' ╘ %s%s%s > %s'%(CR, langs.log.post_exists, CS, value),
|
||||
'82' : ' ╞ %s%s "%s"%s > %s'%(CR, langs.log.shebang_r, shebang, CS, value),
|
||||
'84' : ' ╞ %s%s%s %s'%(CR, langs.log.title_no, CS, value),
|
||||
'91' : ' ╞═ %s%s%s > %s'%(CY, langs.log.post_nfd, CS, value),
|
||||
'92' : ' ╞═ %s%s%s > %s'%(CG, langs.log.post_yfd, CS, value),
|
||||
'94' : ' ╞═ %s%s%s > %s'%(CY, langs.log.st_chk_o, CS, value),
|
||||
|
|
|
@ -34,7 +34,7 @@
|
|||
#**********************************************************************
|
||||
|
||||
import sys
|
||||
import args, dom, logs, form, html
|
||||
import args, dom, logs, langs, form, html, tyto, show
|
||||
|
||||
|
||||
#===============================================#
|
||||
|
@ -42,21 +42,41 @@ import args, dom, logs, form, html
|
|||
# - domain: target becomes 3rd command argument #
|
||||
#-----------------------------------------------#
|
||||
def manage(target):
|
||||
# Generic option, except for domain
|
||||
option = 'new'
|
||||
# "domain" target
|
||||
#----------------
|
||||
option = args.action
|
||||
if target == "domain":
|
||||
try: option = sys.argv[3]
|
||||
except: option = ''
|
||||
except: option = args.action
|
||||
|
||||
if target in args.pass_targets:
|
||||
actions = {
|
||||
'domain' : form.manage,
|
||||
'sidebar' : form.create_sidebar,
|
||||
'navbar' : form.create_navbar,
|
||||
'metas' : form.create_metas,
|
||||
'footer' : form.create_footer
|
||||
'sidebar' : html.create_sidebar,
|
||||
'navbar' : html.create_navbar,
|
||||
'metas' : html.create_user_metas,
|
||||
'footer' : html.create_user_footer
|
||||
}
|
||||
|
||||
actions[target](option)
|
||||
|
||||
# article target
|
||||
#---------------
|
||||
else:
|
||||
logs.out("11", '"%s" with "%s"'%(target, option), True)
|
||||
filepost = "%s%s.tyto"%(dom.user_dir, args.target)
|
||||
if tyto.exists(filepost):
|
||||
logs.out("81", filepost, True)
|
||||
|
||||
else:
|
||||
form.asking(" ├ %s%s %s"%(
|
||||
langs.site.new_post,
|
||||
langs.site.q,
|
||||
filepost
|
||||
), True)
|
||||
|
||||
post = tyto.new_article%(args.target,
|
||||
dom.user,
|
||||
tyto.nowdate().rsplit(' ')[0]
|
||||
)
|
||||
tyto.set_file(filepost, True, post)
|
||||
show.read_lines(filepost, True)
|
||||
|
|
|
@ -33,7 +33,8 @@
|
|||
|
||||
#**********************************************************************
|
||||
|
||||
import args, dom, logs, tyto, form, db
|
||||
import os
|
||||
import args, dom, logs, tyto, html, db
|
||||
|
||||
def domain():
|
||||
if dom.hole: logs.out("13", '', True)
|
||||
|
@ -53,29 +54,85 @@ def domain():
|
|||
|
||||
# Show unused values
|
||||
for err_val in dom.err_val:
|
||||
logs.out("16", err_val, False)
|
||||
logs.out("16", err_val, True)
|
||||
|
||||
# Create unused directories
|
||||
srv_show_wip = srv_show_www = local_show = dom_err = False
|
||||
for value in dom.dom_values:
|
||||
set_value = eval(str('dom.%s'%value))
|
||||
|
||||
# Missing directories (was created)
|
||||
for dir_new in dom.dir_new:
|
||||
logs.out("33", dir_new, False)
|
||||
# wip directories
|
||||
if value.endswith('_d'):
|
||||
if value.startswith("srv_wip"):
|
||||
if not tyto.exists(set_value):
|
||||
if not srv_show_wip:
|
||||
print(' │\n │ [wip]')
|
||||
srv_show_wip = True
|
||||
try:
|
||||
os.makedirs(set_value, exist_ok=True)
|
||||
logs.out("33", set_value, False)
|
||||
except:
|
||||
logs.out("1", set_value, False)
|
||||
dom_err = True
|
||||
|
||||
# www directories
|
||||
elif value.startswith("srv_www"):
|
||||
if not tyto.exists(set_value):
|
||||
if not srv_show_www:
|
||||
print(' │\n │ [www]')
|
||||
srv_show_www = True
|
||||
try:
|
||||
os.makedirs(set_value, exist_ok=True)
|
||||
logs.out("33", set_value, False)
|
||||
except:
|
||||
logs.out("1", set_value, False)
|
||||
dom_err = True
|
||||
|
||||
# local directories
|
||||
else:
|
||||
if not tyto.exists(set_value):
|
||||
if not local_show:
|
||||
print(' │\n │ [local]')
|
||||
local_show = True
|
||||
try:
|
||||
os.makedirs(set_value, exist_ok=True)
|
||||
logs.out("33", set_value, False)
|
||||
except:
|
||||
logs.out("1", set_value, False)
|
||||
dom_err = True
|
||||
|
||||
|
||||
# Create missing modules files
|
||||
if not tyto.exists(dom.metas_f) or \
|
||||
not tyto.exists(dom.wip_metas_f):
|
||||
html.create_user_metas('new')
|
||||
|
||||
if not tyto.exists(dom.navbar_f) or \
|
||||
not tyto.exists(dom.wip_navbar_f):
|
||||
html.create_navbar('new')
|
||||
|
||||
if not tyto.exists(dom.sidebar_f) or \
|
||||
not tyto.exists(dom.wip_sidebar_f):
|
||||
html.create_sidebar('new')
|
||||
|
||||
if not tyto.exists(dom.footer_f) or \
|
||||
not tyto.exists(dom.wip_footer_f):
|
||||
html.create_user_footer('new')
|
||||
|
||||
|
||||
'''
|
||||
create_files = \
|
||||
{
|
||||
'navbar_f' : form.create_navbar,
|
||||
'sidebar_f' : form.create_sidebar,
|
||||
'metas_f' : form.create_metas,
|
||||
'footer_f' : form.create_footer,
|
||||
'footer_about_f': form.create_footer_about
|
||||
}
|
||||
{
|
||||
'navbar_f' : form.create_navbar,
|
||||
'sidebar_f' : form.create_sidebar,
|
||||
'metas_f' : form.create_metas,
|
||||
'footer_f' : form.create_footer,
|
||||
'footer_about_f': form.create_footer_about
|
||||
}
|
||||
|
||||
for value in dom.file_mod:
|
||||
create_files[value]('form')
|
||||
|
||||
for file_mods in dom.wip_html_mods:
|
||||
if not tyto.exists(file_mods):
|
||||
logs.out("1", file_mods, False)
|
||||
|
||||
'''
|
||||
|
||||
#==============================#
|
||||
# On demand with status action #
|
||||
|
@ -86,21 +143,10 @@ def check(target):
|
|||
logs.out("5", '[target]', True)
|
||||
|
||||
# Domain statuses
|
||||
elif target == "domain":
|
||||
conf_err = False
|
||||
|
||||
if dom.dir_unu or dom.file_unu:
|
||||
logs.out("60", '', False)
|
||||
|
||||
for dir_unu in dom.dir_unu:
|
||||
logs.out("1", dir_unu, False)
|
||||
conf_err = True
|
||||
|
||||
for file_unu in dom.file_unu:
|
||||
logs.out("24", file_unu, False)
|
||||
|
||||
if conf_err:
|
||||
logs.out("31", '', True)
|
||||
elif target == "domain":
|
||||
# Check unused files in servers
|
||||
check_domain_files("wip")
|
||||
check_domain_files("www")
|
||||
return
|
||||
|
||||
# target is an article
|
||||
|
@ -147,4 +193,21 @@ def check(target):
|
|||
# Article has NO DB
|
||||
elif not db.exists:
|
||||
logs.out("25", db.uri_file, True)
|
||||
|
||||
|
||||
#
|
||||
#
|
||||
#
|
||||
def check_domain_files(srv):
|
||||
if srv == "www": template_files = dom.templates_files_www
|
||||
elif srv == "wip": template_files = dom.templates_files_wip
|
||||
else: return
|
||||
|
||||
dom_err = False
|
||||
print(' │\n │ [%s]'%srv)
|
||||
for f in template_files:
|
||||
if not tyto.exists(f):
|
||||
dom_err = True
|
||||
logs.out("1", f, False)
|
||||
|
||||
if not dom_err:
|
||||
logs.out("28", 'tout va bien', False)
|
||||
|
|
|
@ -45,128 +45,163 @@ Tytoweb = 'https://tyto.echolib.re'
|
|||
|
||||
# Needed header tags
|
||||
needed_header_tags = \
|
||||
(
|
||||
'title',
|
||||
'about',
|
||||
'author',
|
||||
'tags',
|
||||
'date'
|
||||
)
|
||||
(
|
||||
'title',
|
||||
'about',
|
||||
'author',
|
||||
'tags',
|
||||
'date'
|
||||
)
|
||||
|
||||
# Optional header tags
|
||||
opt_header_tags = \
|
||||
(
|
||||
'file',
|
||||
'image',
|
||||
'link',
|
||||
'abbr',
|
||||
'raw',
|
||||
'code',
|
||||
'snpic'
|
||||
)
|
||||
(
|
||||
'file',
|
||||
'image',
|
||||
'link',
|
||||
'abbr',
|
||||
'raw',
|
||||
'code',
|
||||
'snpic'
|
||||
)
|
||||
|
||||
opt_tags_long_name = \
|
||||
(
|
||||
'link',
|
||||
'file'
|
||||
)
|
||||
(
|
||||
'link',
|
||||
'file'
|
||||
)
|
||||
|
||||
opt_tags_check_uri = \
|
||||
(
|
||||
'image',
|
||||
'file',
|
||||
'raw',
|
||||
'code'
|
||||
)
|
||||
(
|
||||
'image',
|
||||
'file',
|
||||
'raw',
|
||||
'code'
|
||||
)
|
||||
|
||||
# Set all tags used in article's header
|
||||
headers = \
|
||||
(
|
||||
'title:',
|
||||
'about:',
|
||||
'author:',
|
||||
'tags:',
|
||||
'date:',
|
||||
'link:',
|
||||
'image:',
|
||||
'file:',
|
||||
'abbr:',
|
||||
'code:',
|
||||
'raw:',
|
||||
'#',
|
||||
'snpic:',
|
||||
)
|
||||
(
|
||||
'title:',
|
||||
'about:',
|
||||
'author:',
|
||||
'tags:',
|
||||
'date:',
|
||||
'link:',
|
||||
'image:',
|
||||
'file:',
|
||||
'abbr:',
|
||||
'code:',
|
||||
'raw:',
|
||||
'#',
|
||||
'snpic:',
|
||||
)
|
||||
|
||||
|
||||
# Words and template Tags (paragraphs, lists, bold, strong...)
|
||||
# Words Tags (paragraphs, lists, bold, strong...)
|
||||
# Used to check, and replace (wip) tags
|
||||
# As base64 is used, do NOT set marker: =_ _=
|
||||
# ! As base64 is used, do NOT set marker: =_ _=
|
||||
# [5] = name for stats and log.
|
||||
# [6] = Check content differently. 't' = startswith
|
||||
#-------------------------------------------------------------
|
||||
words_tags = [
|
||||
('>_', '_<',
|
||||
'<a class="anchor_link" href="#%s">',
|
||||
'</a>', 'anchors', 'w'
|
||||
),
|
||||
('*_', '_*', '<strong class="strong">', '</strong>', 'strongs', 'w'),
|
||||
('+_', '_+', '<b class="bold">', '</b>', 'bolds', 'w'),
|
||||
(';_', '_;', '<em class="em">', '</em>', 'emphasis', 'w'),
|
||||
(':_', '_:', '<i class="italic">', '</i>', 'italics', 'w'),
|
||||
('~_', '_~', '<del class="del">', '</del>', 'dels', 'w'),
|
||||
('._', '_.', '<u class="underline">', '</u>', 'underlines', 'w'),
|
||||
('[_', '_]', '<cite class="cite">', '</cite>', 'cites', 'w'),
|
||||
('%_', '_%', '<span class="custom">', '</span>', 'customs', 'w'),
|
||||
('{_', '_}', '<code class="icode">', '</code>', 'codes', 'w'),
|
||||
(
|
||||
'>_', '_<',
|
||||
'<a class="anchor_link" href="#%s">', '</a>',
|
||||
'anchors'
|
||||
),
|
||||
(
|
||||
'*_', '_*',
|
||||
'<strong class="strong">', '</strong>',
|
||||
'strongs'
|
||||
),
|
||||
(
|
||||
'+_', '_+',
|
||||
'<b class="bold">', '</b>',
|
||||
'bolds'
|
||||
),
|
||||
(
|
||||
';_', '_;',
|
||||
'<em class="em">', '</em>',
|
||||
'emphasis'
|
||||
),
|
||||
(
|
||||
':_', '_:',
|
||||
'<i class="italic">', '</i>',
|
||||
'italics'
|
||||
),
|
||||
(
|
||||
'~_', '_~',
|
||||
'<del class="del">', '</del>',
|
||||
'dels'
|
||||
),
|
||||
(
|
||||
'._', '_.', '<u class="underline">',
|
||||
'</u>',
|
||||
'underlines'
|
||||
),
|
||||
(
|
||||
'[_', '_]',
|
||||
'<cite class="cite">', '</cite>',
|
||||
'cites'
|
||||
),
|
||||
(
|
||||
'%_', '_%',
|
||||
'<span class="custom">', '</span>',
|
||||
'customs'
|
||||
),
|
||||
(
|
||||
'{_', '_}',
|
||||
'<code class="icode">', '</code>',
|
||||
'codes'
|
||||
),
|
||||
]
|
||||
|
||||
# At begining line, create block contents
|
||||
block_tags = \
|
||||
[
|
||||
('((', '))', '<p class="%s">', '</p>', 'paragraphs'),
|
||||
('[[', ']]', '[[', ']]', 'quotes'),
|
||||
('{{', '}}', '{{', '}}', 'bcodes'),
|
||||
('-(', '-)', '-(', '-)', 'lists'),
|
||||
('<<', '>>', '<div class="%s">', '</div>', 'div'),
|
||||
block_tags = [
|
||||
('((', '))', '<p class="%s">', '</p>', 'paragraphs'),
|
||||
('[[', ']]', '[[', ']]', 'quotes'),
|
||||
('{{', '}}', '{{', '}}', 'bcodes'),
|
||||
('-(', '-)', '-(', '-)', 'lists'),
|
||||
('<<', '>>', '<div class="%s">', '</div>', 'div'),
|
||||
]
|
||||
|
||||
# Tags that do not need to be paired
|
||||
#-----------------------------------
|
||||
single_tags = [
|
||||
('|', '<br class="%s" />'), # New Line
|
||||
('->', '<a class="anchor_target" id="%s"></a>'), # Anchors
|
||||
('|', '<br class="%s">'), # New Line
|
||||
('->', '<a class="anchor_target" id="%s"></a>'), # Anchors
|
||||
]
|
||||
|
||||
# When counting words, do no count line starting with:
|
||||
nolinewords = \
|
||||
(
|
||||
block_tags[0][0], block_tags[0][1], # paragraphs
|
||||
block_tags[1][0], block_tags[1][1], # quotes
|
||||
block_tags[2][0], block_tags[2][1], # bcodes
|
||||
block_tags[3][0], block_tags[3][1], # lists
|
||||
single_tags[0][0], single_tags[1][0], # New line, anchor
|
||||
'_%s:'%opt_header_tags[1], '_%s:'%opt_header_tags[4], # _image:, _raw:
|
||||
'_%s:'%opt_header_tags[5] # _code
|
||||
)
|
||||
(
|
||||
block_tags[0][0], block_tags[0][1], # paragraphs
|
||||
block_tags[1][0], block_tags[1][1], # quotes
|
||||
block_tags[2][0], block_tags[2][1], # bcodes
|
||||
block_tags[3][0], block_tags[3][1], # lists
|
||||
single_tags[0][0], single_tags[1][0], # New line, anchor
|
||||
'_%s:'%opt_header_tags[1], '_%s:'%opt_header_tags[4], # _image:, _raw:
|
||||
'_%s:'%opt_header_tags[5] # _code
|
||||
)
|
||||
|
||||
# warning symbols (Check if paired)
|
||||
#----------------------------------
|
||||
tpl_tags = [
|
||||
('(', ')'),
|
||||
('[', ']'),
|
||||
('{', '}'),
|
||||
('«', '»'),
|
||||
('(', ')'),
|
||||
('[', ']'),
|
||||
('{', '}'),
|
||||
('«', '»'),
|
||||
]
|
||||
|
||||
# When including HTML in article, check some paired tags
|
||||
#-------------------------------------------------------
|
||||
leg_html_tags = [
|
||||
('<!--', '-->'),
|
||||
('<div', '</div>'),
|
||||
('<ul', '</ul>'),
|
||||
('<li', '</li>'),
|
||||
('<p', '</p>'),
|
||||
('<span','</span>'),
|
||||
('<!--', '-->'),
|
||||
('<div', '</div>'),
|
||||
('<ul', '</ul>'),
|
||||
('<li', '</li>'),
|
||||
('<p', '</p>'),
|
||||
('<span','</span>'),
|
||||
]
|
||||
|
||||
|
||||
|
@ -176,16 +211,25 @@ markers_lists = ('+', '=', ' ', '#')
|
|||
|
||||
# Tags used for titles
|
||||
#---------------------
|
||||
titles_tags = ('#1 ', '#2 ', '#3 ', '#4 ', '#5 ', '#6 ')
|
||||
titles_user = ('#1', '#2', '#3', '#4', '#5')
|
||||
titles_html = ('<h1', '<h2', '<h3', '<h4', '<h5', '<h6')
|
||||
titles_tags = [
|
||||
("", "",),
|
||||
('#1 ', '<h2 class="title_2">%s</h2>'),
|
||||
('#2 ', '<h3 class="title_3">%s</h3>'),
|
||||
('#3 ', '<h4 class="title_5">%s</h4>'),
|
||||
('#4 ', '<h5 class="title_6">%s</h5>'),
|
||||
('#5 ', '<h6 class="title_6">%s</h6>')
|
||||
]
|
||||
|
||||
|
||||
# Tags for quote
|
||||
quote_tags = [
|
||||
('_cite:', 'author'),
|
||||
('_date:', 'date'),
|
||||
('_link:', 'link'),
|
||||
('_book:', 'book'),
|
||||
('_lang:', 'lang')
|
||||
('_cite:', 'author'),
|
||||
('_date:', 'date'),
|
||||
('_link:', 'link'),
|
||||
('_book:', 'book'),
|
||||
('_lang:', 'lang')
|
||||
]
|
||||
|
||||
# Tags to check in header in content _TAG
|
||||
|
@ -205,6 +249,33 @@ chrs_invalid = \
|
|||
set('{}[]_()+*=/:%~´')
|
||||
|
||||
|
||||
new_article = """%s
|
||||
# tyto new %s
|
||||
|
||||
title:
|
||||
about:
|
||||
author: %s
|
||||
tags:
|
||||
date: %s
|
||||
|
||||
#abbr: TYTO
|
||||
Le générateur de sites web Libre
|
||||
Tyto - Littérateur
|
||||
|
||||
#image: Image-1
|
||||
URI
|
||||
Texte-alternatif
|
||||
|
||||
#link: lien 1
|
||||
URi/URL
|
||||
Text-alternatif
|
||||
|
||||
-----
|
||||
|
||||
#3
|
||||
|
||||
"""
|
||||
|
||||
# Stats for icodes, bcodes, quotes
|
||||
nbr_icodes = 0
|
||||
|
||||
|
|
|
@ -425,6 +425,7 @@ def get_wh_image(value):
|
|||
if not sizes[0][1]: return('%spx'%value)
|
||||
else: return(value)
|
||||
|
||||
|
||||
#=================================#
|
||||
# Find all _image, get parameters #
|
||||
# Convert _images:%name to HTML #
|
||||
|
@ -517,6 +518,7 @@ def quote_params(qline):
|
|||
globals()[tag[1]] = qline.rsplit('%s '%tag[0])[1].lstrip()
|
||||
return(True)
|
||||
|
||||
|
||||
#==========================#
|
||||
# Convert quote in article #
|
||||
#--------------------------#
|
||||
|
@ -720,75 +722,69 @@ def wip_bcodes():
|
|||
|
||||
#========================================#
|
||||
# Convert titles to HTML #
|
||||
# Check between titles to set div or not #
|
||||
# #1 = <h3>, #2 = <h4>... #
|
||||
#----------------------------------------#
|
||||
def wip_titles():
|
||||
if db.titles == 0: return
|
||||
|
||||
global post_bottom
|
||||
|
||||
article_temp = post_bottom
|
||||
article_tmp2 = '' # Construct article, without empty lines
|
||||
|
||||
for line in post_bottom.rsplit('\n'):
|
||||
for line in post_bottom.rsplit('\n'):
|
||||
if line.startswith('#'):
|
||||
hx = line[1]
|
||||
title_cont = line[2: len(line)].lstrip()
|
||||
title_html = '<h%s class="title_%s">%s</h%s>'%(
|
||||
hx, hx, title_cont, hx
|
||||
)
|
||||
article_temp = article_temp.replace(line, title_html)
|
||||
|
||||
tx = int(line[1])
|
||||
title_name = line[2: len(line)].lstrip()
|
||||
title_html = tyto.titles_tags[tx][1]%title_name
|
||||
replace_in_post(line, title_html)
|
||||
|
||||
# Remove useless empty lines from article
|
||||
for line in article_temp.rsplit('\n'):
|
||||
if line:
|
||||
if article_tmp2: article_tmp2 = '%s\n%s'%(article_tmp2, line)
|
||||
else: article_tmp2 = line
|
||||
wip_titles_div()
|
||||
|
||||
article_temp = article_tmp2
|
||||
|
||||
#======================================#
|
||||
# Create div between titles if content #
|
||||
#--------------------------------------#
|
||||
def wip_titles_div():
|
||||
global post_bottom
|
||||
|
||||
# Add div after title if needed
|
||||
for ln, line in enumerate(article_tmp2.rsplit('\n')):
|
||||
if line.startswith('<h'):
|
||||
try: article_tmp2.rsplit('\n')[ln + 1]
|
||||
except: continue
|
||||
|
||||
if article_tmp2.rsplit('\n')[ln + 1].startswith('<h'):
|
||||
continue
|
||||
else:
|
||||
article_temp = \
|
||||
article_temp.replace(line,
|
||||
'%s\n<div class="contents">'%(line)
|
||||
)
|
||||
continue
|
||||
else:
|
||||
continue
|
||||
article_tmp = ''
|
||||
|
||||
# Close div before title if needed
|
||||
article_tmp2 = article_temp
|
||||
indiv = False
|
||||
for ln, line in enumerate(article_tmp2.rsplit('\n')):
|
||||
try: article_tmp2.rsplit('\n')[ln + 1]
|
||||
except: continue
|
||||
div_close = False
|
||||
for ln, line in enumerate(post_bottom.rsplit('\n')):
|
||||
# Remove empty lines
|
||||
if not line: continue
|
||||
|
||||
if line.startswith('<h') and indiv:
|
||||
article_temp = \
|
||||
article_temp.replace(line,
|
||||
'</div>\n%s'%line
|
||||
)
|
||||
indiv = False
|
||||
|
||||
if article_tmp2.rsplit('\n')[ln + 1].startswith('<div'):
|
||||
indiv = True
|
||||
continue
|
||||
div_open = False
|
||||
# Title <hX> found
|
||||
if line.startswith(tyto.titles_html):
|
||||
hx = line[2]
|
||||
|
||||
# Div need to be close vefore title
|
||||
if div_close:
|
||||
line = '</div>\n%s'%line
|
||||
div_close = False
|
||||
|
||||
# Has content after, open div
|
||||
try:
|
||||
post_bottom.rsplit('\n')[ln + 1]
|
||||
div_open = True
|
||||
except:
|
||||
continue
|
||||
|
||||
# New div
|
||||
if div_open:
|
||||
line = '%s\n<div class="contents contents_%s">'%(line, hx)
|
||||
div_close = True
|
||||
|
||||
# Save new article with div and no empty lines
|
||||
#---------------------------------------------
|
||||
if not article_tmp: article_tmp = line
|
||||
else: article_tmp = "%s\n%s"%(article_tmp, line)
|
||||
|
||||
if indiv:
|
||||
article_temp = '%s\n</div>'%article_temp
|
||||
# Close last div (if any)
|
||||
if div_close:
|
||||
article_tmp = "%s\n</div>"%(article_tmp)
|
||||
|
||||
# Replace article with new contents
|
||||
post_bottom = article_temp
|
||||
|
||||
post_bottom = article_tmp
|
||||
|
||||
|
||||
#==============================================#
|
||||
# Convert raw file to HTML with <pre> + <code> #
|
||||
|
|
|
@ -41,14 +41,18 @@ file_n = "File changed"
|
|||
file_e = "File exists"
|
||||
dir_c = "Directory created"
|
||||
dir_e = "Directory exists"
|
||||
post_exists = "Ab article already exists"
|
||||
|
||||
# chk
|
||||
shebang_r= 'Remove shebang'
|
||||
nycheck = "Article not yet checked"
|
||||
was_chk = "Article was 'check'"
|
||||
st_chk_o = "Old 'check' status"
|
||||
post_inc = "Unused in article"
|
||||
post_inv = "Article not valid"
|
||||
post_val = "Article is valid"
|
||||
title_no = "Empty title"
|
||||
unused_p = "Empty article"
|
||||
|
||||
# wip
|
||||
nywip = "Article not yet wip"
|
||||
|
@ -71,7 +75,6 @@ post_chg = "Article changed: 'check' it first"
|
|||
sep_inv = "Unused separator in article"
|
||||
unused_v = "Unused value in article"
|
||||
unused_t = "Unused value in header"
|
||||
unused_p = "Empty article"
|
||||
mark_np = "Not paired marks"
|
||||
symb_np = "Not paired symbols"
|
||||
snpic_d = "Using default snpic. Not found"
|
||||
|
|
|
@ -40,14 +40,18 @@ file_n = "Fichier modifié"
|
|||
file_e = "Fichier présent"
|
||||
dir_c = "Dossier créé"
|
||||
dir_e = "Dossier présent"
|
||||
post_exists = "Un article existe déjà"
|
||||
|
||||
# chk
|
||||
shebang_r= 'Enlever le shebang'
|
||||
nycheck = "Article pas encore 'check'"
|
||||
was_chk = "Article déjà vérifié"
|
||||
st_chk_o = "Statut 'check' Ancien"
|
||||
post_inc = "Donnée manquante dans l'article"
|
||||
post_inv = "Article non valide"
|
||||
post_val = "Article valide"
|
||||
title_no = "Titre vide"
|
||||
unused_p = "Article vide"
|
||||
|
||||
# Wip
|
||||
nywip = "Article pas encore 'wip'"
|
||||
|
@ -72,7 +76,6 @@ post_chg = "Article modifié : commencer par 'check'"
|
|||
sep_inv = "Séparateur manquant dans l'article"
|
||||
unused_v = "Valeur manquante dans l'article"
|
||||
unused_t = "Valeur manquante dans l'entête"
|
||||
unused_p = "L'article est vide"
|
||||
mark_np = "Marqueurs non jumelés"
|
||||
symb_np = "Symboles non jumelés"
|
||||
snpic_d = "snpic utilisé par défaut. Manquant"
|
||||
|
|
|
@ -73,6 +73,7 @@ generator = "Generator"
|
|||
# Check
|
||||
check_a = "Check again this article"
|
||||
post_chg = "Article was edited. Check it"
|
||||
new_post = "Create article"
|
||||
|
||||
# Wip
|
||||
wip_new = "Create a new HTML page in 'wip' server again"
|
||||
|
|
|
@ -73,6 +73,7 @@ generator = "Generateur"
|
|||
# Check
|
||||
check_a = "Vérifier encore l'article"
|
||||
post_chg = "Article édité. Le vérifier"
|
||||
new_post = "Créer l'article"
|
||||
|
||||
# Wip
|
||||
wip_new = "Créer encore une page HTML dans le serveur 'wip'"
|
||||
|
|
Loading…
Reference in New Issue