This commit is contained in:
Cyrille L 2023-05-07 09:14:15 +02:00
parent 7d44eb781e
commit 22ce2f0aed
25 changed files with 1169 additions and 953 deletions

View File

@ -24,28 +24,26 @@
# File: /usr/bin/tyto # File: /usr/bin/tyto
#---------------------------------------------------------------------- #----------------------------------------------------------------------
#------------ #-------------------------
# funny stats # Funny Stats Project
#------------ #-------------------------
# scripts files: # Project files : 20
# app lines: # Project lines : 7479
# app comments: # Project comments : 1131
# app functions: # Project functions: 108
# lines: #
# functions: # file lines : 91
# comments: # file comments : 31
#---------------------------------------------------------------------- # file functions: 0
#--------------------------
#**********************************************************************
import sys import sys
sys.path.insert(0, '/var/lib/tyto/program') sys.path.insert(0, '/var/lib/tyto/program')
#====================# #====================#
# MAIN # # MAIN #
# Treat Arguments # # Treat Arguments #
#--------------------#------------------------------------------------- #--------------------#
import logs import logs
if not __name__ == "__main__": if not __name__ == "__main__":
@ -65,15 +63,16 @@ status.domain()
import check, form, html, new, publish, show, wip, infos, creators import check, form, html, new, publish, show, wip, infos, creators
actions = { actions = {
"check" : check.manage, "check" : check.manage,
"create" : creators.manage,
"help" : infos.tyto, "help" : infos.tyto,
"edit" : show.manage, "edit" : show.manage,
"edit-about" : show.manage, "edit-about" : show.manage,
"edit-db" : show.manage, "edit-db" : show.manage,
"edit-wip" : show.manage, "edit-wip" : show.manage,
"edit-www" : show.manage, "edit-www" : show.manage,
"force-wip" : wip.manage,
"new" : new.manage, "new" : new.manage,
"publish" : publish.manage, "publish" : publish.manage,
"preview" : show.manage,
"quick-pub" : publish.manage, "quick-pub" : publish.manage,
"show" : show.manage, "show" : show.manage,
"show-about" : show.manage, "show-about" : show.manage,
@ -81,7 +80,6 @@ actions = {
"show-wip" : show.manage, "show-wip" : show.manage,
"show-www" : show.manage, "show-www" : show.manage,
"status" : status.check, "status" : status.check,
"template" : publish.manage,
"wip" : wip.manage, "wip" : wip.manage,
} }

View File

@ -23,10 +23,18 @@
# File: /usr/share/bash-completion/completions/tyto # File: /usr/share/bash-completion/completions/tyto
#---------------------------------------------------------------------- #----------------------------------------------------------------------
#-------------------------
# Funny Stats Project
#-------------------------
# file lines : 310
# file comments : 44
# file functions: 0
#--------------------------
#=====================================================================#
#=================#
# Actions section # # Actions section #
#=====================================================================# #=================#============================================================
# Actions: argument 1 # # Actions: argument 1 #
#---------------------# #---------------------#
@ -39,6 +47,7 @@ edit-about
edit-db edit-db
edit-wip edit-wip
edit-www edit-www
force-wip
help help
new new
show show
@ -46,6 +55,7 @@ show-about
show-db show-db
show-wip show-wip
show-www show-www
preview
publish publish
quick-pub quick-pub
status status
@ -96,12 +106,12 @@ EOL
} }
#=====================================================================# #=================#
# Targets section # # Targets section #
#=====================================================================# #=================#============================================================
# Targets with wip or publish # Targets for articles and modules
#---------------------------- #--------------------------------
_tyto_targets_wp() { _tyto_targets_wp() {
cat <<EOL cat <<EOL
added added
@ -182,11 +192,12 @@ footer
metas metas
navbar navbar
sidebar sidebar
sitemap
EOL EOL
} }
# # Targets to NOT activate --force
# #--------------------------------
_tyto_targets_not_options() { _tyto_targets_not_options() {
grep -F -q -x "$1" <<EOL grep -F -q -x "$1" <<EOL
added added
@ -203,19 +214,25 @@ EOL
} }
#=====================================================================# #=================#
# Targets section # # Options section #
#=====================================================================# #=================#============================================================
_tyto_options() { _tyto_options() {
cat <<EOL cat <<EOL
--force
--static --static
EOL EOL
} }
#=====================================================================# # Only with [publish template]
_tyto_options_pt() {
cat <<EOL
--no-mods
EOL
}
#=====================#
# Main autocompletion # # Main autocompletion #
#=====================================================================# #=====================#========================================================
_tyto_completions() { _tyto_completions() {
local cur local cur
cur="${COMP_WORDS[COMP_CWORD]}" cur="${COMP_WORDS[COMP_CWORD]}"
@ -237,7 +254,12 @@ _tyto_completions() {
COMPREPLY=( $(compgen -W "$(_tyto_targets_new)" -- ${cur}) ) COMPREPLY=( $(compgen -W "$(_tyto_targets_new)" -- ${cur}) )
return 0 return 0
elif [ "$prev" == "quick-pub" ];then elif [ "$prev" == "quick-pub" ] ||
[ "$prev" == "preview" ];then
COMPREPLY=( $(compgen -W "$(_tyto_targets_qp)" -- ${cur}) )
return 0
elif [ "$prev" == "force-wip" ];then
COMPREPLY=( $(compgen -W "$(_tyto_targets_qp)" -- ${cur}) ) COMPREPLY=( $(compgen -W "$(_tyto_targets_qp)" -- ${cur}) )
return 0 return 0
@ -273,6 +295,12 @@ _tyto_completions() {
COMPREPLY=( $(compgen -W "$(_tyto_options)" -- ${cur}) ) COMPREPLY=( $(compgen -W "$(_tyto_options)" -- ${cur}) )
return 0 return 0
fi fi
# Only with [publish template]
elif [ "$prev2" == "publish" ] && \
[ "$prev1" == "template" ];then
COMPREPLY=( $(compgen -W "$(_tyto_options_pt)" -- ${cur}) )
return 0
fi fi
;; ;;

View File

@ -7,12 +7,8 @@ Tyto - Littérateur
- License: https://git.a-lec.org/echolib/tyto-litterateur/-/blob/master/LICENSE - License: https://git.a-lec.org/echolib/tyto-litterateur/-/blob/master/LICENSE
- Documentation: https://tyto.echolib.re - Documentation: https://tyto.echolib.re
## {0.10.5] ## [0.10.5]
- added sitemap with `tyto create sitemap` - New sitemap
- added escaped markers - Very Last testings
- added bash-autocompletion (not yet all)
- updated help
- changed function to protect icodes
- very lots more
- pre 1.0

View File

@ -3,6 +3,16 @@
* DOMAIN MUST be changed by domain css set in configuration * DOMAIN MUST be changed by domain css set in configuration
*/ */
/* include header to footer */
div#site_container {
}
/* Include article + sidebar */
div#article_sidebar_container {
}
/*===================================================================== /*=====================================================================
* Header * Header
*/ */

View File

@ -19,7 +19,6 @@ navbar_f = ""
sidebar_f = "" sidebar_f = ""
metas_f = "" metas_f = ""
footer_f = "" footer_f = ""
footer_about_f = ""
# Domain # Domain
shortname = "" shortname = ""

View File

@ -23,19 +23,23 @@
# File: /var/lib/tyto/program/args.py # File: /var/lib/tyto/program/args.py
#---------------------------------------------------------------------- #----------------------------------------------------------------------
#------------ #-------------------------
# funny stats # Funny Stats Project
#------------ #-------------------------
# lines: # file lines : 173
# functions: # file comments : 28
# comments: # file functions: 2
#---------------------------------------------------------------------- #--------------------------
#**********************************************************************
import os, sys import os, sys
import infos import infos
try:
action
target
except:
# Arguments from command line # Arguments from command line
# tyto [action] [target] # tyto [action] [target]
@ -43,26 +47,32 @@ import infos
actions = \ actions = \
( (
'check', 'check',
'create',
'edit', 'edit',
'edit-db', 'edit-db',
'edit-wip', 'edit-wip',
'edit-www', 'edit-www',
'quick-pub', 'force-wip',
'new', 'new',
'preview',
'publish',
'quick-pub',
'show', 'show',
'show-db', 'show-db',
'show-wip', 'show-wip',
'show-www', 'show-www',
'status', 'status',
'wip', 'wip',
'publish' )
quicks = \
(
'force-wip',
'quick-pub',
) )
options = \ options = \
( (
'--static', '--static',
'--force',
) )
pass_actions = ('new') pass_actions = ('new')
@ -75,7 +85,9 @@ pass_db = \
'edit-db', 'edit-db',
'edit-wip', 'edit-wip',
'edit-www', 'edit-www',
'force-wip',
'publish', 'publish',
'preview',
'quick-pub', 'quick-pub',
'show', 'show',
'show-about', 'show-about',

View File

@ -24,17 +24,14 @@
# File: /var/lib/tyto/program/check.py # File: /var/lib/tyto/program/check.py
#---------------------------------------------------------------------- #----------------------------------------------------------------------
#------------ #-------------------------
# funny stats # Funny Stats Project
#------------ #-------------------------
# lines: # file lines : 1141
# functions: # file comments : 162
# comments: # file functions: 25
#---------------------------------------------------------------------- #--------------------------
#**********************************************************************
# Import needed libs
import time, importlib, sys, os, re, datetime import time, importlib, sys, os, re, datetime
from datetime import datetime from datetime import datetime
from time import gmtime, strftime from time import gmtime, strftime
@ -767,8 +764,8 @@ def check_anchors():
db.uri_file db.uri_file
), False) ), False)
post_err = True post_err = True
return
else:
globals()['post_%s'%tyto.anchor_tags[4]] = int(c_opened) globals()['post_%s'%tyto.anchor_tags[4]] = int(c_opened)
@ -805,6 +802,8 @@ def check_anchors():
# Check if anchor link has target one # Check if anchor link has target one
else: else:
for ln, line in enumerate(post_bottom.rsplit('\n'), 1): for ln, line in enumerate(post_bottom.rsplit('\n'), 1):
ln = ln + ln_header + 1
# Anchor link # Anchor link
if tyto.anchor_tags[0] and tyto.anchor_tags[1] in line: if tyto.anchor_tags[0] and tyto.anchor_tags[1] in line:
anchors = re.findall(r">_(.*?)_<", line) anchors = re.findall(r">_(.*?)_<", line)
@ -812,7 +811,7 @@ def check_anchors():
anchor_name = anchor.rsplit(':')[0].lstrip() anchor_name = anchor.rsplit(':')[0].lstrip()
if not anchor_name in anchors_names: if not anchor_name in anchors_names:
logs.out("12", 'L=%s. anchor "%s" > %s'%( logs.out("12", 'L=%s. anchor "%s" > %s'%(
ln + 1 + ln_header, anchor_name, db.uri_file ln, anchor_name, db.uri_file
), False) ), False)
post_err = True post_err = True
@ -844,7 +843,7 @@ def check_titles():
def check_words_tags(): def check_words_tags():
global post_err, post_bottom global post_err, post_bottom
for tag in tyto.words_tags: for tag in tyto.markers_tags:
c_opened = c_closed = 0 c_opened = c_closed = 0
c_opened = post_bottom.count(tag[0]) c_opened = post_bottom.count(tag[0])
@ -896,6 +895,8 @@ def check_contents_list():
if post_lists > 0: if post_lists > 0:
inlist = False inlist = False
for ln, line in enumerate(post_bottom.rsplit('\n'), 1): for ln, line in enumerate(post_bottom.rsplit('\n'), 1):
ln = ln + ln_header + 1
if line.startswith(tyto.block_tags[3][0]): if line.startswith(tyto.block_tags[3][0]):
inlist = True inlist = True
continue continue
@ -907,13 +908,14 @@ def check_contents_list():
if inlist and not line or not line[0] in tyto.markers_lists: if inlist and not line or not line[0] in tyto.markers_lists:
logs.out("3", 'L=%s. %s %s > %s'%( logs.out("3", 'L=%s. %s %s > %s'%(
ln + ln_header, ln,
tyto.block_tags[3][4], tyto.block_tags[3][4],
tyto.markers_lists, tyto.markers_lists,
db.uri_file db.uri_file
), False) ), False)
post_err = True post_err = True
#==================================# #==================================#
# Legacy HTML Tags, check if aired # # Legacy HTML Tags, check if aired #
#----------------------------------# #----------------------------------#

View File

@ -24,15 +24,14 @@
# File: /var/lib/tyto/program/creators.py # File: /var/lib/tyto/program/creators.py
#---------------------------------------------------------------------- #----------------------------------------------------------------------
#------------ #-------------------------
# funny stats # Funny Stats Project
#------------ #-------------------------
# lines: # file lines : 240
# functions: # file comments : 40
# comments: # file functions: 3
#---------------------------------------------------------------------- #--------------------------
#**********************************************************************
import os, importlib, datetime, subprocess import os, importlib, datetime, subprocess
import args, dom, db, langs, tyto, check, wip, logs import args, dom, db, langs, tyto, check, wip, logs
@ -42,16 +41,14 @@ import args, dom, db, langs, tyto, check, wip, logs
# Manage action [create] # # Manage action [create] #
#------------------------# #------------------------#
def manage(target): def manage(target):
target = args.target
creators = { creators = {
"sitemap" : create_sitemap, "sitemap" : create_sitemap,
} }
try: try: creators[target](target)
creators[target](target) except: logs.out("28", "%s + %s"%(args.action, args.target), True)
except:
logs.out("28", "%s + %s"%(args.action, args.target), True)
#=====================# #=====================#
@ -73,7 +70,7 @@ def create_sitemap(target):
# Define sitemap.tyto # Define sitemap.tyto
sitemap_tyto = \ sitemap_tyto = \
'# %s Tyto - Littérateur [tyto create sitemap]\n'%langs.site.sitemap_gen + \ '# %s Tyto - Littérateur [tyto new sitemap]\n'%langs.site.sitemap_gen + \
'# NoSitemap\n' + \ '# NoSitemap\n' + \
'title: %s (%s %s)\n'%(langs.site.sitemap_t, '%s', langs.site.links) + \ 'title: %s (%s %s)\n'%(langs.site.sitemap_t, '%s', langs.site.links) + \
'about: %s Tyto - Littérateur\n'%langs.site.sitemap_gen + \ 'about: %s Tyto - Littérateur\n'%langs.site.sitemap_gen + \
@ -85,14 +82,23 @@ def create_sitemap(target):
'-----\n' + \ '-----\n' + \
'\n' + \ '\n' + \
'%s\n' + \ '%s\n' + \
'-)' '|\n' + \
'<hr class="hr">\n' + \
print(sitemap_tyto) '|\n' + \
'\n' + \
'%s\n'
tab = 8 tab = 8
uri_dir_set = "" uri_dir_set = ""
# Contents in article's Header
links = "" links = ""
contents = "#1 /\n-( sitemap"
# Index of all links in article
index_l = '-( index\n= <a href="#index">/</a>'
# All links in sitemap
contents = '-( sitemap\n= / <z id="index"></a>'
# Not real articles folder # Not real articles folder
forbid_dir = ( forbid_dir = (
@ -107,8 +113,11 @@ def create_sitemap(target):
if r.startswith(forbid_dir): if r.startswith(forbid_dir):
continue continue
# Take only .tyto files
for f in files: for f in files:
if f.endswith(".tyto"): if not f.endswith(".tyto"):
continue
try: try:
uri_file = r.rsplit(dom.articles_d)[1] uri_file = r.rsplit(dom.articles_d)[1]
uri_file = os.path.join(uri_file, f) uri_file = os.path.join(uri_file, f)
@ -153,33 +162,79 @@ def create_sitemap(target):
# Create list link line # Create list link line
if not uri_dir.startswith(uri_dir_set): curr_dir = uri_dir.count("/")
root_dir = uri_dir.rsplit("/")[0] root_dir = uri_dir.rsplit("/")[0]
contents = "%s\n-)\n\n#1 %s\n-( sitemap"%(contents, root_dir) ranc_dir = root_dir.replace(" ", "_")
uri_dir_set = uri_dir.rsplit("/")[0]
uls = uri_dir.count("/")
contents = \ try: prev_dir
"%s\n%s [%s] _%s (%s)"%( except: prev_dir = curr_dir
try: name_dir
except: name_dir = root_dir
#print(":",prev_dir, name_dir, curr_dir, root_dir)
#print(": %s"%(uri_dir.rsplit("/")[int(curr_dir - 1)]))
#print(">", subdirs, uri_dir.rsplit("/"))
#print(":", prev_dir, curr_dir)
if name_dir != root_dir:
index_l = '%s\n= <a href="#%s">%s</a>'%(
index_l,
ranc_dir,
root_dir
)
contents = '%s\n%s [%s] <a id="%s"></a>'%(
contents, contents,
uls * "=", db.date, db.title, db.author int(curr_dir) * "=",
root_dir,
ranc_dir
)
name_dir = root_dir
prev_dir = curr_dir
if prev_dir != curr_dir:
sanc_dir = uri_dir.rsplit("/")[int(curr_dir - 1)].replace(" ", "_")
index_l = '%s\n%s <a href="#%s">%s</a>'%(
index_l,
int(curr_dir) * "=",
sanc_dir,
uri_dir.rsplit("/")[int(curr_dir - 1)]
)
contents = '%s\n%s [%s] <a id="%s"></a>'%(
contents,
int(curr_dir) * "=",
uri_dir.rsplit("/")[int(curr_dir - 1)],
sanc_dir
)
prev_dir = curr_dir
contents = "%s\n%s _%s"%(
contents,
int(curr_dir + 1) * '=',
db.title
) )
# Ending markers
index_l = "%s\n-)"%index_l
contents = "%s\n-)"%contents
# Fill new sitemap.tyto and create
sitemap_tyto = \ sitemap_tyto = \
sitemap_tyto%( sitemap_tyto%(
nbr_files, nbr_files,
links, links,
index_l,
contents contents
) )
sitemap_file = "%ssitemap.tyto"%dom.articles_d sitemap_file = "%ssitemap.tyto"%dom.articles_d
tyto.set_file(sitemap_file, "New", sitemap_tyto) tyto.set_file(sitemap_file, "New", sitemap_tyto)
# Check and wip # Check and wip
print()
www = subprocess.run( www = subprocess.run(
[ [
'/usr/bin/tyto', '/usr/bin/tyto',
'wip', 'force-wip',
'sitemap.tyto', 'sitemap.tyto'
'--force'
], ],
) )

View File

@ -23,15 +23,14 @@
# File: /var/lib/tyto/program/db.py # File: /var/lib/tyto/program/db.py
#---------------------------------------------------------------------- #----------------------------------------------------------------------
#------------ #-------------------------
# funny stats # Funny Stats Project
#------------ #-------------------------
# lines: # file lines : 195
# functions: # file comments : 35
# comments: # file functions: 0
#---------------------------------------------------------------------- #--------------------------
#**********************************************************************
import os import os
import args, logs, dom, form, tyto, check, publish import args, logs, dom, form, tyto, check, publish

View File

@ -23,19 +23,24 @@
# File: /var/lib/tyto/program/dom.py # File: /var/lib/tyto/program/dom.py
#---------------------------------------------------------------------- #----------------------------------------------------------------------
#------------ #-------------------------
# funny stats # Funny Stats Project
#------------ #-------------------------
# lines: # file lines : 317
# functions: # file comments : 30
# comments: # file functions: 1
#---------------------------------------------------------------------- #--------------------------
#**********************************************************************
import os, sys, importlib, langs import os, sys, importlib, langs
import args import args
try:
ready
except:
lib = 'tyto_domain' lib = 'tyto_domain'
exists = incomplete = active = ready = shortname = corrupt = False exists = incomplete = active = ready = shortname = corrupt = False
local_user = articles_db_d = False local_user = articles_db_d = False

View File

@ -25,20 +25,22 @@
# File: /var/lib/tyto/program/form.py # File: /var/lib/tyto/program/form.py
#---------------------------------------------------------------------- #----------------------------------------------------------------------
#------------ #-------------------------
# funny stats # Funny Stats Project
#------------ #-------------------------
# lines: # file lines : 1096
# functions: # file comments : 103
# comments: # file functions: 7
#---------------------------------------------------------------------- #--------------------------
#**********************************************************************
from datetime import datetime from datetime import datetime
import os, sys, shutil, re, locale, importlib import os, sys, shutil, re, locale, importlib
import logs, dom, tyto, html, show, langs import logs, dom, tyto, html, show, langs
try:
lang_site
except:
# locale translation directory # locale translation directory
trans_dir = '/var/lib/tyto/translations' trans_dir = '/var/lib/tyto/translations'
@ -52,9 +54,13 @@ except:
lang_site = lang_sys lang_site = lang_sys
# Generic answer # Generic answer
"""
answer_yes = ('y', 'Y', 'yes', 'Yes', 'YES', answer_yes = ('y', 'Y', 'yes', 'Yes', 'YES',
'o', 'O', 'oui', 'Oui', 'Oui' 'o', 'O', 'oui', 'Oui', 'Oui'
) )
"""
try: answer_yes
except: answer_yes = langs.answer_yes
#=======================================# #=======================================#
@ -72,7 +78,11 @@ def asking(question, yes_no):
logs.out("255", '', True) logs.out("255", '', True)
if yes_no: if yes_no:
if not answer in answer_yes: go = False
for yes_names in answer_yes:
if answer.lower() in yes_names:
go = True
if not go:
logs.out("255", '', True) logs.out("255", '', True)
else: else:

View File

@ -22,19 +22,19 @@
# File: /var/lib/tyto/program/html.py # File: /var/lib/tyto/program/html.py
#---------------------------------------------------------------------- #----------------------------------------------------------------------
#------------ #-------------------------
# funny stats # Funny Stats Project
#------------ #-------------------------
# lines: # file lines : 543
# functions: # file comments : 70
# comments: # file functions: 8
#---------------------------------------------------------------------- #--------------------------
#**********************************************************************
import os, sys, importlib import os, sys, importlib
import logs, db, dom, tyto, form, langs import logs, db, dom, tyto, form, langs
# Publish option can be # Publish option can be
wip_opts = ('wip', 'new') wip_opts = ('wip', 'new')
pub_opts = ('www', 'pub') pub_opts = ('www', 'pub')
@ -163,6 +163,7 @@ def create_main_page(target, article_bottom):
'%s\n'%metas + \ '%s\n'%metas + \
' </head>\n\n' + \ ' </head>\n\n' + \
' <body>\n' + \ ' <body>\n' + \
' <div id="site_container">\n' + \
' <header id="header_page">\n' + \ ' <header id="header_page">\n' + \
' <div id="site_logo">\n' + \ ' <div id="site_logo">\n' + \
' %s\n'%logo_html + \ ' %s\n'%logo_html + \
@ -177,6 +178,7 @@ def create_main_page(target, article_bottom):
' </div>\n' + \ ' </div>\n' + \
' </header>\n' + \ ' </header>\n' + \
tags_html_mods[dom.wip_navbar_f] + '\n' + \ tags_html_mods[dom.wip_navbar_f] + '\n' + \
' <div id="article_sidebar_container">\n' + \
' <article id="article_main">\n' + \ ' <article id="article_main">\n' + \
' <h1 accesskey="t" id="post_title"\n' + \ ' <h1 accesskey="t" id="post_title"\n' + \
' title="[%s] %s %s %s %s">%s</h1>\n'%( ' title="[%s] %s %s %s %s">%s</h1>\n'%(
@ -199,7 +201,9 @@ def create_main_page(target, article_bottom):
' </article>\n' + \ ' </article>\n' + \
'\n' + \ '\n' + \
tags_html_mods[dom.wip_sidebar_f] + '\n' + \ tags_html_mods[dom.wip_sidebar_f] + '\n' + \
' </div>\n' + \
tags_html_mods[dom.wip_footer_f] + '\n' + \ tags_html_mods[dom.wip_footer_f] + '\n' + \
' </div>\n' + \
' </body>\n' + \ ' </body>\n' + \
'</html>' '</html>'
@ -484,10 +488,10 @@ def create_sidebar(option):
' <li class="sidebar_item">\n' + \ ' <li class="sidebar_item">\n' + \
' <a class="sidebar_item_link"\n' + \ ' <a class="sidebar_item_link"\n' + \
' href="/%s">\n'%short_srv + \ ' href="/%s">\n'%short_srv + \
' <h3 class="sidebar_item_title">%s</h2>\n'%title + \ ' <h3 class="sidebar_item_title">%s</h3>\n'%title + \
' <p class="sidebar_item_about"\n' + \ ' <p class="sidebar_item_about"\n' + \
' title="%s">\n'%link_title + \ ' title="%s">\n'%link_title + \
' %s [%s] - %s\n'%(date, author, about) + \ ' %s - %s\n'%(date, about) + \
' </p>\n' + \ ' </p>\n' + \
' </a>\n' + \ ' </a>\n' + \
' </li>\n' ' </li>\n'

View File

@ -23,20 +23,20 @@
# File: /var/lib/tyto/program/infos.py # File: /var/lib/tyto/program/infos.py
#---------------------------------------------------------------------- #----------------------------------------------------------------------
#------------ #-------------------------
# funny stats # Funny Stats Project
#------------ #-------------------------
# lines: # file lines : 130
# functions: # file comments : 26
# comments: # file functions: 3
#---------------------------------------------------------------------- #--------------------------
#**********************************************************************
import os, sys, importlib import os, sys, importlib
import langs import langs
importlib.reload(langs) importlib.reload(langs)
# Set colors # Set colors
CS = '\033[0;0m' CS = '\033[0;0m'
CR = '\033[1;31m' CR = '\033[1;31m'

View File

@ -23,23 +23,39 @@
# File: /var/lib/tyto/program/langs.py # File: /var/lib/tyto/program/langs.py
#---------------------------------------------------------------------- #----------------------------------------------------------------------
#------------ #-------------------------
# funny stats # Funny Stats Project
#------------ #-------------------------
# lines: # file lines : 89
# functions: # file comments : 27
# comments: # file functions: 0
#---------------------------------------------------------------------- #--------------------------
#**********************************************************************
import locale, sys, os, importlib import locale, sys, os, importlib
import dom import dom
try:
site.yes
except:
# Import translation directory # Import translation directory
trans_dir = '/var/lib/tyto/translations' trans_dir = '/var/lib/tyto/translations'
sys.path.insert(0, trans_dir) sys.path.insert(0, trans_dir)
# Create yes array with all yes languages
try:
answer_yes
except:
answer_yes = (())
for lang_file in os.listdir(trans_dir):
if lang_file.startswith("site_") and lang_file.endswith(".py"):
lang_file = lang_file.replace(".py", "")
lang = importlib.import_module(lang_file)
answer_yes = answer_yes + ((lang.yes),)
# Get default system language # Get default system language
# or set "en" (english) if no translation file # or set "en" (english) if no translation file
@ -70,3 +86,4 @@ try:
site = importlib.import_module('site_%s'%lang_site, package=None) site = importlib.import_module('site_%s'%lang_site, package=None)
except: except:
site = importlib.import_module('site_%s'%lang_sys, package=None) site = importlib.import_module('site_%s'%lang_sys, package=None)

View File

@ -23,19 +23,22 @@
# File: /var/lib/tyto/program/logs.py # File: /var/lib/tyto/program/logs.py
#---------------------------------------------------------------------- #----------------------------------------------------------------------
#------------ #-------------------------
# funny stats # Funny Stats Project
#------------ #-------------------------
# lines: # file lines : 126
# functions: # file comments : 22
# comments: # file functions: 1
#---------------------------------------------------------------------- #--------------------------
#**********************************************************************
import os, sys import os, sys
import langs import langs
try:
shebang
except:
# Use to mark new article # Use to mark new article
shebang = "#!/NEW" shebang = "#!/NEW"

View File

@ -23,19 +23,18 @@
# File: /var/lib/tyto/program/new.py # File: /var/lib/tyto/program/new.py
#---------------------------------------------------------------------- #----------------------------------------------------------------------
#------------ #-------------------------
# funny stats # Funny Stats Project
#------------ #-------------------------
# lines: # file lines : 93
# functions: # file comments : 26
# comments: # file functions: 1
#---------------------------------------------------------------------- #--------------------------
#**********************************************************************
import sys import sys
from unidecode import unidecode from unidecode import unidecode
import args, dom, logs, langs, form, html, tyto, show import args, dom, logs, langs, form, html, tyto, show, creators
#===============================================# #===============================================#
@ -56,7 +55,8 @@ def manage(target):
'sidebar' : html.create_sidebar, 'sidebar' : html.create_sidebar,
'navbar' : html.create_navbar, 'navbar' : html.create_navbar,
'metas' : html.create_user_metas, 'metas' : html.create_user_metas,
'footer' : html.create_user_footer 'footer' : html.create_user_footer,
'sitemap' : creators.manage
} }
actions[target](option) actions[target](option)

View File

@ -23,20 +23,20 @@
# File: /var/lib/tyto/program/publish.py # File: /var/lib/tyto/program/publish.py
#---------------------------------------------------------------------- #----------------------------------------------------------------------
#------------ #-------------------------
# funny stats # Funny Stats Project
#------------ #-------------------------
# lines: # file lines : 293
# functions: # file comments : 49
# comments: # file functions: 6
#---------------------------------------------------------------------- #--------------------------
#**********************************************************************
import os, sys, shutil, importlib import os, sys, shutil, importlib, subprocess
from pathlib import Path from pathlib import Path
import logs, args, dom, db, wip, html, tyto, form, stats, rss, langs, check import logs, args, dom, db, wip, html, tyto, form, stats, rss, langs, check
#==============================# #==============================#
# Manage action, get post db # # Manage action, get post db #
# check if publish can be done # # check if publish can be done #
@ -46,15 +46,17 @@ def manage(target):
# Specific QUICK processes: check > wip > publish # Specific QUICK processes: check > wip > publish
if args.action == "quick-pub": if args.action == "quick-pub":
try: try: db.uri_file
db.uri_file except: logs.out("28", "%s + %s"%(args.action, args.target), True)
except:
logs.out("28", "%s + %s"%(args.action, args.target), True)
print(" ! Quick Publish") wip = subprocess.run(
check.check_process(target) [
importlib.reload(db) '/usr/bin/tyto',
wip.wip_article(db.uri_file) 'force-wip',
target
],
)
print()
importlib.reload(db) importlib.reload(db)
check_to_publish('one') check_to_publish('one')
publish_article() publish_article()
@ -280,6 +282,9 @@ def publish_template(option):
logs.out("32", item_dst, False) logs.out("32", item_dst, False)
# Create new file from _configs/ files # Create new file from _configs/ files
if args.option == "--no-mods":
return
html.create_sidebar('pub') html.create_sidebar('pub')
html.create_navbar('pub') html.create_navbar('pub')
html.create_user_metas('pub') html.create_user_metas('pub')

View File

@ -23,15 +23,14 @@
# File: /var/lib/tyto/program/rss.py # File: /var/lib/tyto/program/rss.py
#---------------------------------------------------------------------- #----------------------------------------------------------------------
#------------ #-------------------------
# funny stats # Funny Stats Project
#------------ #-------------------------
# lines: # file lines : 128
# functions: # file comments : 27
# comments: # file functions: 1
#---------------------------------------------------------------------- #--------------------------
#*********************************************************************
import os import os
from pathlib import Path from pathlib import Path
@ -86,6 +85,10 @@ def create_feed():
if not hash_www or hash_chk != hash_www: if not hash_www or hash_chk != hash_www:
continue continue
# NoSitemap
if not db.sitemap:
continue
rss_item = True rss_item = True
nbr_item += 1 nbr_item += 1

View File

@ -24,19 +24,19 @@
# File: /var/lib/tyto/program/show.py # File: /var/lib/tyto/program/show.py
#---------------------------------------------------------------------- #----------------------------------------------------------------------
#------------ #-------------------------
# funny stats # Funny Stats Project
#------------ #-------------------------
# lines: # file lines : 215
# functions: # file comments : 38
# comments: # file functions: 3
#---------------------------------------------------------------------- #--------------------------
#**********************************************************************
import os, sys, importlib import os, sys, importlib, subprocess
import args, logs, langs, dom, db, form, tyto, check, html, stats import args, logs, langs, dom, db, form, tyto, check, html, stats
#========================# #========================#
# Read lines from a file # # Read lines from a file #
# alone: True/False # # alone: True/False #
@ -94,9 +94,6 @@ def manage(target):
try: post_www = db.post_www try: post_www = db.post_www
except: pass except: pass
# Except for show-about > Show post DB
if args.action == "show-about":
target = 'post'
# Convert command action to do[] # Convert command action to do[]
@ -106,6 +103,7 @@ def manage(target):
"show" : 'src', "show" : 'src',
"edit" : 'src', "edit" : 'src',
"post" : 'src', "post" : 'src',
"preview" : 'wip',
"show-db" : 'db', "show-db" : 'db',
"edit-db" : 'db', "edit-db" : 'db',
"show-wip" : 'wip', "show-wip" : 'wip',
@ -141,6 +139,7 @@ def manage(target):
"navbar" : dom.wip_navbar_f, "navbar" : dom.wip_navbar_f,
"sidebar" : dom.wip_sidebar_f, "sidebar" : dom.wip_sidebar_f,
"post" : post_wip, "post" : post_wip,
"sitemap" : '%ssitemap.html'%dom.srv_wip,
"stats" : dom.wip_stats_f, "stats" : dom.wip_stats_f,
}, },
'www' : { 'www' : {
@ -155,19 +154,25 @@ def manage(target):
} }
# Read or edit file, according to legacy args.action # Read or edit file, according to legacy args.action
try:
file = do[action][target] file = do[action][target]
if not file:
logs.out("28", '%s + %s'%(args.action, args.target), True)
if args.action in actions_read: if not file or not tyto.exists(file):
logs.out("1", file, True)
# Except for show-about > Show post DB
if args.action == "preview":
preview_wip(file)
return
elif args.action in actions_read:
read_lines(file, True) read_lines(file, True)
elif args.action in actions_edit: elif args.action in actions_edit:
curr_hash = tyto.get_filesum(file, True) curr_hash = tyto.get_filesum(file, True)
tyto.edit_file(file) tyto.edit_file(file)
except:
logs.out("28", '%s + %s'%(args.action, target), True)
# If edit article and hash changed, ask to check # If edit article and hash changed, ask to check
if args.action == "edit": if args.action == "edit":
@ -178,16 +183,33 @@ def manage(target):
# Launch process for some changed file # Launch process for some changed file
#------------------------------------- #-------------------------------------
if file == post_src: if file == post_src:
form.asking('%s%s '%(
langs.site.post_chg, langs.site.q
), True)
# Reload post DB (if edited article, and check it if ask "y") # Reload post DB (if edited article, and check it if ask "y")
importlib.reload(db) importlib.reload(db)
check.manage(post_src) check = subprocess.run(
[
'/usr/bin/tyto',
'check',
args.target
]
)
elif file == dom.sidebar_f: html.create_sidebar('wip') elif file == dom.sidebar_f: html.create_sidebar('wip')
elif file == dom.navbar_f: html.create_navbar('wip') elif file == dom.navbar_f: html.create_navbar('wip')
elif file == dom.metas_f: html.create_user_metas('wip') elif file == dom.metas_f: html.create_user_metas('wip')
#=====================================#
# Preview in browser wip page #
# Ensure xdg-open (useless in server) #
#-------------------------------------#
def preview_wip(file):
try:
xdg = subprocess.run(
[
'/usr/bin/xdg-open',
file,
],
)
except:
logs.out("28", "/usr/bin/xdg-open %s"%file, True)

View File

@ -23,19 +23,19 @@
# File: /var/lib/tyto/program/stats.py # File: /var/lib/tyto/program/stats.py
#---------------------------------------------------------------------- #----------------------------------------------------------------------
#------------ #-------------------------
# funny stats # Funny Stats Project
#------------ #-------------------------
# lines: # file lines : 225
# functions: # file comments : 37
# comments: # file functions: 4
#---------------------------------------------------------------------- #--------------------------
#**********************************************************************
import os, importlib import os, importlib
import args, dom, logs, form, tyto, show, langs import args, dom, logs, form, tyto, show, langs
sti_articles = 0 sti_articles = 0
#=======================# #=======================#

View File

@ -23,40 +23,73 @@
# File: /var/lib/tyto/program/status.py # File: /var/lib/tyto/program/status.py
#---------------------------------------------------------------------- #----------------------------------------------------------------------
#------------ #-------------------------
# funny stats # Funny Stats Project
#------------ #-------------------------
# lines: # file lines : 238
# functions: # file comments : 50
# comments: # file functions: 3
#---------------------------------------------------------------------- #--------------------------
#**********************************************************************
import os import os
import args, dom, logs, tyto, html, db import args, dom, logs
#=====================#
# Check domain status #
#---------------------#
def domain(): def domain():
if dom.hole: logs.out("13", '', True) if dom.hole:
elif args.action == 'new' and args.target == "domain": return logs.out("13", '', True)
elif args.act_err: logs.out("11", args.action, True)
elif not dom.exists: logs.out("10", '', True)
elif dom.corrupt: logs.out("39", dom.shortname, True)
print("") # Only condition to not check domain status here
if dom.incomplete: logs.out("41", dom.shortname, False) if args.action == 'new' and \
elif dom.active: logs.out("42", dom.shortname, False) args.target == "domain":
elif not dom.active: logs.out("40", dom.shortname, False) return
# No backward in target # As subprocesses, avoid show domain status each time
if "../" in args.target: if args.action in args.quicks:
logs.out("11", '"../"', True) return
# [action] not in list
if args.act_err:
logs.out("11", args.action, True)
# No domain found
if not dom.exists:
logs.out("10", '', True)
# Domain id corrupted
if dom.corrupt:
logs.out("39", dom.shortname, True)
# Domain is incomplete
if dom.incomplete:
logs.out("41", dom.shortname, False)
# Show unused values # Show unused values
for err_val in dom.err_val: for err_val in dom.err_val:
logs.out("16", err_val, True) logs.out("16", err_val, True)
# Create unused directories # Domain not activated
if not dom.active:
logs.out("40", dom.shortname, True)
# Domain is activated
if dom.active:
logs.out("42", dom.shortname, False)
# No backward in [target]
if "../" in args.target:
logs.out("11", '"../"', True)
#===========================#
# Create unused directories #
#---------------------------#
import tyto
srv_show_wip = srv_show_www = local_show = dom_err = False srv_show_wip = srv_show_www = local_show = dom_err = False
for value in dom.dom_values: for value in dom.dom_values:
set_value = eval(str('dom.%s'%value)) set_value = eval(str('dom.%s'%value))
@ -103,6 +136,8 @@ def domain():
# Create missing modules files # Create missing modules files
import html
if not tyto.exists(dom.metas_f) or \ if not tyto.exists(dom.metas_f) or \
not tyto.exists(dom.wip_metas_f): not tyto.exists(dom.wip_metas_f):
html.create_user_metas('new') html.create_user_metas('new')
@ -124,6 +159,8 @@ def domain():
# On demand with status action # # On demand with status action #
#------------------------------# #------------------------------#
def check(target): def check(target):
import db
# target needed # target needed
if not target: if not target:
logs.out("5", '[target]', True) logs.out("5", '[target]', True)

View File

@ -23,20 +23,20 @@
# File: /var/lib/tyto/program/tyto.py # File: /var/lib/tyto/program/tyto.py
#---------------------------------------------------------------------- #----------------------------------------------------------------------
#------------ #-------------------------
# funny stats # Funny Stats Project
#------------ #-------------------------
# lines: # file lines : 724
# functions: # file comments : 120
# comments: # file functions: 14
#---------------------------------------------------------------------- #--------------------------
#**********************************************************************
import os, sys, re, subprocess, locale, base64, datetime, shutil import os, sys, re, subprocess, locale, base64, datetime, shutil
from hashlib import blake2b from hashlib import blake2b
import args, dom, logs, langs import args, dom, logs, langs
# :D # :D
Tyto = 'Tyto - Littérateur' Tyto = 'Tyto - Littérateur'
Tytogit = 'https://git.a-lec.org/echolib/tyto-litterateur' Tytogit = 'https://git.a-lec.org/echolib/tyto-litterateur'
@ -103,50 +103,6 @@ headers = \
# ! As base64 is used, do NOT set marker: =_ _= # ! As base64 is used, do NOT set marker: =_ _=
# [5] = name for stats and log. # [5] = name for stats and log.
#------------------------------------------------------------- #-------------------------------------------------------------
words_tags = [
(
'*_', '_*',
'<strong class="%s">'%dom.css, '</strong>',
'strongs'
),
(
'+_', '_+',
'<b class="%s">'%dom.css, '</b>',
'bolds'
),
(
';_', '_;',
'<em class="%s">'%dom.css, '</em>',
'emphasis'
),
(
':_', '_:',
'<i class="%s">'%dom.css, '</i>',
'italics'
),
(
'~_', '_~',
'<del class="%s">'%dom.css, '</del>',
'dels'
),
(
'._', '_.', '<u class="%s">'%dom.css,
'</u>',
'underlines'
),
(
'[_', '_]',
'<cite class="%s">'%dom.css, '</cite>',
'cites'
),
(
'%_', '_%',
'<span class="custom">', '</span>',
'customs'
),
]
icode_tags = \ icode_tags = \
( (
'{_', '_}', '{_', '_}',
@ -154,6 +110,7 @@ icode_tags = \
'icodes', 'icodes',
'\\{_', '\\_}' '\\{_', '\\_}'
) )
strong_tags = \ strong_tags = \
( (
'*_', '_*', '*_', '_*',
@ -162,6 +119,7 @@ strong_tags = \
'\\*_', '\\_*', '\\*_', '\\_*',
'-S1-', '-S2-' '-S1-', '-S2-'
) )
bold_tags = \ bold_tags = \
( (
'+_', '_+', '+_', '_+',
@ -170,6 +128,7 @@ bold_tags = \
'\\+_', '\\_+', '\\+_', '\\_+',
'-B1-', '-B2-' '-B1-', '-B2-'
) )
em_tags = \ em_tags = \
( (
';_', '_;', ';_', '_;',
@ -178,6 +137,7 @@ em_tags = \
'\\;_', '\\_;', '\\;_', '\\_;',
'-EM1-', '-EM2-' '-EM1-', '-EM2-'
) )
i_tags = \ i_tags = \
( (
':_', '_:', ':_', '_:',
@ -186,6 +146,7 @@ i_tags = \
'\\:_', '\\_:', '\\:_', '\\_:',
'-I1-', '-I2-' '-I1-', '-I2-'
) )
u_tags = \ u_tags = \
( (
'._', '_.', '<u class="%s">'%dom.css, '._', '_.', '<u class="%s">'%dom.css,
@ -194,6 +155,7 @@ u_tags = \
'\\._', '\\_.', '\\._', '\\_.',
'-U1-', '-U2-' '-U1-', '-U2-'
) )
del_tags = \ del_tags = \
( (
'~_', '_~', '~_', '_~',
@ -202,6 +164,7 @@ del_tags = \
'\\~_', '\\_~', '\\~_', '\\_~',
'-DE1-', '-DE2-' '-DE1-', '-DE2-'
) )
cite_tags = \ cite_tags = \
( (
'[_', '_]', '[_', '_]',
@ -210,6 +173,7 @@ cite_tags = \
'\\[_', '\\_]', '\\[_', '\\_]',
'-CI1-', '-CI2-' '-CI1-', '-CI2-'
) )
custom1_tags = \ custom1_tags = \
( (
'%_', '_%', '%_', '_%',
@ -219,7 +183,6 @@ custom1_tags = \
'-CU1-', '-CU2-' '-CU1-', '-CU2-'
) )
markers_tags = \ markers_tags = \
[ [
strong_tags, strong_tags,
@ -344,7 +307,7 @@ date: %s
Texte-alternatif Texte-alternatif
#link: lien 1 #link: lien 1
URi/URL URI/URL
Text-alternatif Text-alternatif
----- -----
@ -361,48 +324,6 @@ date: %s
nbr_icodes = 0 nbr_icodes = 0
#==============================#
# Replace escaped markers #
# check: with "" #
# wip: with altternate #
# (recover when wip done) #
#------------------------------#
def protect_escaped(post_bottom, reverse):
for m1, m2, h1, h2, n, e1, e2, r1, r2 in markers_tags:
# In check mode, No need to keep escaped markers
if args.action == "check":
r1 = r2 = ''
if reverse:
post_bottom = post_bottom.replace(r1, m1)
post_bottom = post_bottom.replace(r2, m2)
else:
post_bottom = post_bottom.replace(e1, r1)
post_bottom = post_bottom.replace(e2, r2)
return post_bottom
# -- tests
def find_between( s, first, last ):
try:
start = s.index( first ) + len( first )
end = s.index( last, start )
return s[start:end]
except ValueError:
return ""
def find_between_r( s, first, last ):
try:
start = s.rindex( first ) + len( first )
end = s.rindex( last, start )
return s[start:end]
except ValueError:
return ""
# -- tests
#=======# #=======#
# TOOLS # # TOOLS #
#=======#-------------------------------------------------------------- #=======#--------------------------------------------------------------
@ -432,9 +353,6 @@ def convert_altname(altname):
# False = URI # # False = URI #
#-----------------------# #-----------------------#
def get_filesum(path, src): def get_filesum(path, src):
#if not src and not exists(path):
# logs.out("1", path, True)
file_sum = blake2b(digest_size=4) file_sum = blake2b(digest_size=4)
if src: file_sum.update(open(path, 'rb').read()) if src: file_sum.update(open(path, 'rb').read())
@ -506,6 +424,29 @@ def get_css(line):
return css return css
#==============================#
# Replace escaped markers #
# check: with "" #
# wip: with altternate #
# reverse: True/False #
#------------------------------#
def protect_escaped(post_bottom, reverse):
for m1, m2, h1, h2, n, e1, e2, r1, r2 in markers_tags:
# In check mode, No need to keep escaped markers
if args.action == "check":
r1 = r2 = ''
if reverse:
post_bottom = post_bottom.replace(r1, m1)
post_bottom = post_bottom.replace(r2, m2)
else:
post_bottom = post_bottom.replace(e1, r1)
post_bottom = post_bottom.replace(e2, r2)
return post_bottom
#=============================================# #=============================================#
# First check process to protect contents # # First check process to protect contents #
# Protect block-Codes, quotes # # Protect block-Codes, quotes #
@ -580,11 +521,14 @@ def protect_bcodes_quotes(process, post_bottom):
if not bcode: bcode = line if not bcode: bcode = line
else: bcode = '%s\n%s'%(bcode, line) else: bcode = '%s\n%s'%(bcode, line)
line = '' line = ''
continue
elif in_quote: elif in_quote:
# Convert lines to b64 # Convert lines to b64
if not quote: quote = line if not quote: quote = line
else: quote = '%s\n%s'%(quote, line) else: quote = '%s\n%s'%(quote, line)
line = '' line = ''
continue
# Set new content # Set new content
@ -614,28 +558,28 @@ def protect_icodes(post_bottom):
# Get only lines that contains code # Get only lines that contains code
in_icode = ok_icode = go_icode = False in_icode = ok_icode = go_icode = False
for ln, line in enumerate(post_bottom.rsplit('\n')): for ln, line in enumerate(post_bottom.rsplit('\n')):
if not "{_" in line or not "_}" in line: if not icode_tags[0] in line or \
not icode_tags[1] in line:
continue continue
code = "" code = ""
for i, c in enumerate(line): for i, c in enumerate(line):
if c == "_": if c == "_":
try: try:
if line[i-1] == "{" and line[i-2] != "\\": # {_
if line[i-1] == icode_tags[0][0] and line[i-2] != "\\":
in_icode = True in_icode = True
ok_icode = False ok_icode = False
go_icode = True #go_icode = True
elif line[i+1] == "}" and line[i-2] != "\\": continue
# _}
elif line[i+1] == icode_tags[1][1] and line[i-2] != "\\":
in_icode = False in_icode = False
ok_icode = True ok_icode = True
go_icode = False go_icode = False
except: except:
continue continue
if go_icode :
go_icode = False
continue
if in_icode: if in_icode:
ok_icode = False ok_icode = False
code = "%s%s"%(code, c) code = "%s%s"%(code, c)
@ -650,7 +594,7 @@ def protect_icodes(post_bottom):
post_bottom = post_bottom.replace(tyto_code , '') post_bottom = post_bottom.replace(tyto_code , '')
elif args.action == "wip": elif args.action == "wip":
code = convert_altname(code) code = convert_altname(code) # HTML sympbols
html_code = "%s%s%s"%( html_code = "%s%s%s"%(
icode_tags[2], code, icode_tags[3]) icode_tags[2], code, icode_tags[3])
b64_code = b64('Encode', html_code, 'I64.', '.I64') b64_code = b64('Encode', html_code, 'I64.', '.I64')

View File

@ -26,17 +26,16 @@
# File: /var/lib/tyto/program/wip.py # File: /var/lib/tyto/program/wip.py
#---------------------------------------------------------------------- #----------------------------------------------------------------------
#------------ #-------------------------
# funny stats # Funny Stats Project
#------------ #-------------------------
# lines: # file lines : 1112
# functions: # file comments : 166
# comments: # file functions: 26
#---------------------------------------------------------------------- #--------------------------
#**********************************************************************
import os, re, sys, locale, shutil, importlib, time import os, re, sys, locale, shutil, importlib, time, subprocess
from pathlib import Path from pathlib import Path
import args, logs, langs, dom, db, tyto, html, form, stats, check import args, logs, langs, dom, db, tyto, html, form, stats, check
@ -53,13 +52,28 @@ def manage(target):
logs.out("5", '[target]', True) logs.out("5", '[target]', True)
# option --force to check and wip processes # option --force to check and wip processes
if args.option == '--force': if args.action == 'force-wip':
if args.target in args.pass_targets: if args.target in args.pass_targets:
logs.out("28", "%s + %s"%(args.target, args.option), True) logs.out("28", "%s + %s"%(args.target, args.option), True)
check.manage(target)
#importlib.reload(db) chk = subprocess.run(
wip_article(target) [
'/usr/bin/tyto',
'check',
target,
'--force'
],
)
print()
wip = subprocess.run(
[
'/usr/bin/tyto',
'wip',
target,
],
)
return return
# Modules and multi-articles # Modules and multi-articles
@ -323,7 +337,7 @@ def wip_single_tags():
#----------------------------------# #----------------------------------#
def wip_words_tags(): def wip_words_tags():
# Strongs, italics... # Strongs, italics...
for tag in tyto.words_tags: for tag in tyto.markers_tags:
# Open tag # Open tag
replace_in_post(tag[0], replace_in_post(tag[0],
tag[2] tag[2]
@ -375,12 +389,38 @@ def wip_words_tags():
) )
#========================# #============================#
# from wip_links #
# Get arrays, in DB #
# sort all links by length #
# (avoic abcd to target abc) #
# return db.NAME_i array #
#----------------------------#
def wip_return_link_nbr(marker, nbr):
items = [()]
links = (())
# Get length link and i (from all arrays ) in new array
for i in range(1, nbr + 1):
item = 'db.%s_%s'%(marker, i)
len_link = len(eval(item)[1])
items = items + [(len_link, i),]
# Sort length by bigger in new array
for i in sorted(items,reverse=True):
try:
print(i[1])
links = links + ((i[1]),)
except:
pass
return links
#=========================#
# Convert links set in DB # # Convert links set in DB #
# - file_%i # # - file_%i #
# - link_%i # # - link_%i #
# from marker to HTML # #-------------------------#
#------------------------#
def wip_links(): def wip_links():
if db.uniq_files == 0 and db.uniq_links == 0: return if db.uniq_files == 0 and db.uniq_links == 0: return
@ -391,7 +431,12 @@ def wip_links():
# ! Doing link files, first, becase of similar marker # ! Doing link files, first, becase of similar marker
#---------------------------------------------------- #----------------------------------------------------
if db.uniq_files > 0: if db.uniq_files > 0:
for i in range(1, db.uniq_files + 1):
links = wip_return_link_nbr("file", db.uniq_files)
for i in links:
if not i:
return
flink = 'db.file_%s'%i flink = 'db.file_%s'%i
flink_css = "link_file" flink_css = "link_file"
flink_name = eval(flink)[0][2:] flink_name = eval(flink)[0][2:]
@ -408,7 +453,12 @@ def wip_links():
# Convert simple links # Convert simple links
#--------------------- #---------------------
if db.uniq_links > 0: if db.uniq_links > 0:
for i in range(1, db.uniq_links + 1):
links = wip_return_link_nbr("link", db.uniq_links)
for i in links:
if not i:
return
link = 'db.link_%s'%i link = 'db.link_%s'%i
link_css = "link" link_css = "link"
link_name = eval(link)[0][1:] link_name = eval(link)[0][1:]
@ -417,6 +467,7 @@ def wip_links():
link_set = link_html%( link_set = link_html%(
link_css, link_anc, link_title, "%s", link_name link_css, link_anc, link_title, "%s", link_name
) )
print(">", eval(link)[1])
replace_in_post(eval(link)[0]+'+', link_set%link_tb) replace_in_post(eval(link)[0]+'+', link_set%link_tb)
replace_in_post(eval(link)[0], link_set%link_ts) replace_in_post(eval(link)[0], link_set%link_ts)
@ -514,7 +565,7 @@ def wip_images():
else: else:
style = '' style = ''
# set <img /> from parameter # set <img> from parameter
image_target = eval(image)[1] image_target = eval(image)[1]
image_target = db.sub_uri + image_target[1:] image_target = db.sub_uri + image_target[1:]
image_src = image_show%( image_src = image_show%(

View File

@ -18,6 +18,9 @@
# - "\n" # - "\n"
# - "+ \" # - "+ \"
# Keep array ! ('','',)
yes = ("y", "yes",)
# Generic # Generic
article = "Article" article = "Article"
links = "links" links = "links"
@ -268,6 +271,7 @@ args_helps = """\n# New domain :
[sidebar, navbar, footer, metas] Create and replace [sidebar, navbar, footer, metas] Create and replace
with default module configuration file with default module configuration file
[filename] (no .tyto) Create article in current folder [filename] (no .tyto) Create article in current folder
[sitemap], create new website sitemap
# Show contents file (with line number) # Show contents file (with line number)
show : Show source file, source configuration module show : Show source file, source configuration module
@ -280,8 +284,10 @@ args_helps = """\n# New domain :
# Create HTML page # Create HTML page
check : Check the validity of a tyto format file check : Check the validity of a tyto format file
wip : Create article HTML page in server 'wip' wip : Create article HTML page in server 'wip'
force-wip : [file], check, and then, wip
preview : [module]/[file], open 'wip' file on default browser
publish : Create article HTML page in server 'www' publish : Create article HTML page in server 'www'
quick-pub : Do check, wip, publish ([file] only) quick-pub : [file], check, wip, publish
# [target] > According to [action] # [target] > According to [action]
# Multiple articles # Multiple articles
@ -306,10 +312,12 @@ args_helps = """\n# New domain :
navbar : Navbar configuration file navbar : Navbar configuration file
sidebar : Sidebar configuration file sidebar : Sidebar configuration file
stats : Stats file (server 'wip' er 'www') stats : Stats file (server 'wip' er 'www')
sitemap : sitemap.tyto/.html file
# [option] : # [option] :
--static : Créer une page HTML entièrement statique --static : Créer une page HTML entièrement statique
--force : Avec [wip], vérifier l'article et créer la page HTML""" --no-mods : With [publish template], do not recreate modules
"""
ex_helps = """# Examples : ex_helps = """# Examples :
# Check article (according to sub-folder) # Check article (according to sub-folder)

View File

@ -18,6 +18,9 @@
# - "\n" # - "\n"
# - "+ \" # - "+ \"
# Garder ! ('','',)
yes = ("o", "oui",)
# Generic # Generic
article = "Article" article = "Article"
links = "liens" links = "liens"
@ -267,6 +270,7 @@ args_helps = """\n# Nouveau domaine :
fichier de configuration du module par le défaut fichier de configuration du module par le défaut
[filename] (sans .tyto) Créer un article dans le [filename] (sans .tyto) Créer un article dans le
dossier actuel dossier actuel
[sitemap], créer le plan du site (sitemap)
# Afficher un fichier (avec numéros de ligne) # Afficher un fichier (avec numéros de ligne)
show : Fichier source, module de configuration show : Fichier source, module de configuration
@ -277,8 +281,10 @@ args_helps = """\n# Nouveau domaine :
# Processus de création / Mise en ligne # Processus de création / Mise en ligne
check : Vérifier la validité d'un article au format tyto check : Vérifier la validité d'un article au format tyto
wip : Créer une page HTML de l'article dans le serveur 'wip' wip : Créer une page HTML de l'article dans le serveur 'wip'
force-wip : [file], check, wip
preview : [module]/[file], ouvre le fichier 'wip' dans le navigateur par défaut
publish : Créer une page HTML de l'article dans le serveur 'www' publish : Créer une page HTML de l'article dans le serveur 'www'
quick-pub : Faire check, wip, publish ([file] seulement) quick-pub : [file] , check, wip, publish
# [target] > Selon l'action [action] # [target] > Selon l'action [action]
# Traitement en masse # Traitement en masse
@ -303,10 +309,12 @@ args_helps = """\n# Nouveau domaine :
navbar : Fichier de configuration du menu de navigation navbar : Fichier de configuration du menu de navigation
sidebar : Fichier de configuration de la barre latérale sidebar : Fichier de configuration de la barre latérale
stats : Fichier de statistiques (serveur 'wip' ou 'www') stats : Fichier de statistiques (serveur 'wip' ou 'www')
sitemap : Fichier sitemap.tyto/.html
# [option] # [option]
--static : Créer une page HTML entièrement statique --static : Créer une page HTML entièrement statique
--force : Avec [wip], vérifier l'article et créer la page HTML""" --no-mods : Avec [publish template], ne pas recréer les modules
"""
ex_helps = """# Exemples : ex_helps = """# Exemples :
# Vérifier l'article dans le sous dossier (suivant l'emplacement) # Vérifier l'article dans le sous dossier (suivant l'emplacement)