[0.10.5]
This commit is contained in:
parent
7d44eb781e
commit
22ce2f0aed
|
@ -24,28 +24,26 @@
|
|||
# File: /usr/bin/tyto
|
||||
#----------------------------------------------------------------------
|
||||
|
||||
#------------
|
||||
# funny stats
|
||||
#------------
|
||||
# scripts files:
|
||||
# app lines:
|
||||
# app comments:
|
||||
# app functions:
|
||||
# lines:
|
||||
# functions:
|
||||
# comments:
|
||||
#----------------------------------------------------------------------
|
||||
|
||||
#**********************************************************************
|
||||
#-------------------------
|
||||
# Funny Stats Project
|
||||
#-------------------------
|
||||
# Project files : 20
|
||||
# Project lines : 7479
|
||||
# Project comments : 1131
|
||||
# Project functions: 108
|
||||
#
|
||||
# file lines : 91
|
||||
# file comments : 31
|
||||
# file functions: 0
|
||||
#--------------------------
|
||||
|
||||
import sys
|
||||
sys.path.insert(0, '/var/lib/tyto/program')
|
||||
|
||||
|
||||
#====================#
|
||||
# MAIN #
|
||||
# Treat Arguments #
|
||||
#--------------------#-------------------------------------------------
|
||||
#--------------------#
|
||||
import logs
|
||||
|
||||
if not __name__ == "__main__":
|
||||
|
@ -65,15 +63,16 @@ status.domain()
|
|||
import check, form, html, new, publish, show, wip, infos, creators
|
||||
actions = {
|
||||
"check" : check.manage,
|
||||
"create" : creators.manage,
|
||||
"help" : infos.tyto,
|
||||
"edit" : show.manage,
|
||||
"edit-about" : show.manage,
|
||||
"edit-db" : show.manage,
|
||||
"edit-wip" : show.manage,
|
||||
"edit-www" : show.manage,
|
||||
"force-wip" : wip.manage,
|
||||
"new" : new.manage,
|
||||
"publish" : publish.manage,
|
||||
"preview" : show.manage,
|
||||
"quick-pub" : publish.manage,
|
||||
"show" : show.manage,
|
||||
"show-about" : show.manage,
|
||||
|
@ -81,7 +80,6 @@ actions = {
|
|||
"show-wip" : show.manage,
|
||||
"show-www" : show.manage,
|
||||
"status" : status.check,
|
||||
"template" : publish.manage,
|
||||
"wip" : wip.manage,
|
||||
}
|
||||
|
||||
|
|
|
@ -23,10 +23,18 @@
|
|||
# File: /usr/share/bash-completion/completions/tyto
|
||||
#----------------------------------------------------------------------
|
||||
|
||||
#-------------------------
|
||||
# Funny Stats Project
|
||||
#-------------------------
|
||||
# file lines : 310
|
||||
# file comments : 44
|
||||
# file functions: 0
|
||||
#--------------------------
|
||||
|
||||
#=====================================================================#
|
||||
|
||||
#=================#
|
||||
# Actions section #
|
||||
#=====================================================================#
|
||||
#=================#============================================================
|
||||
|
||||
# Actions: argument 1 #
|
||||
#---------------------#
|
||||
|
@ -39,6 +47,7 @@ edit-about
|
|||
edit-db
|
||||
edit-wip
|
||||
edit-www
|
||||
force-wip
|
||||
help
|
||||
new
|
||||
show
|
||||
|
@ -46,6 +55,7 @@ show-about
|
|||
show-db
|
||||
show-wip
|
||||
show-www
|
||||
preview
|
||||
publish
|
||||
quick-pub
|
||||
status
|
||||
|
@ -96,12 +106,12 @@ EOL
|
|||
}
|
||||
|
||||
|
||||
#=====================================================================#
|
||||
#=================#
|
||||
# Targets section #
|
||||
#=====================================================================#
|
||||
#=================#============================================================
|
||||
|
||||
# Targets with wip or publish
|
||||
#----------------------------
|
||||
# Targets for articles and modules
|
||||
#--------------------------------
|
||||
_tyto_targets_wp() {
|
||||
cat <<EOL
|
||||
added
|
||||
|
@ -182,11 +192,12 @@ footer
|
|||
metas
|
||||
navbar
|
||||
sidebar
|
||||
sitemap
|
||||
EOL
|
||||
}
|
||||
|
||||
#
|
||||
#
|
||||
# Targets to NOT activate --force
|
||||
#--------------------------------
|
||||
_tyto_targets_not_options() {
|
||||
grep -F -q -x "$1" <<EOL
|
||||
added
|
||||
|
@ -203,19 +214,25 @@ EOL
|
|||
}
|
||||
|
||||
|
||||
#=====================================================================#
|
||||
# Targets section #
|
||||
#=====================================================================#
|
||||
#=================#
|
||||
# Options section #
|
||||
#=================#============================================================
|
||||
_tyto_options() {
|
||||
cat <<EOL
|
||||
--force
|
||||
--static
|
||||
EOL
|
||||
}
|
||||
|
||||
#=====================================================================#
|
||||
# Only with [publish template]
|
||||
_tyto_options_pt() {
|
||||
cat <<EOL
|
||||
--no-mods
|
||||
EOL
|
||||
}
|
||||
|
||||
#=====================#
|
||||
# Main autocompletion #
|
||||
#=====================================================================#
|
||||
#=====================#========================================================
|
||||
_tyto_completions() {
|
||||
local cur
|
||||
cur="${COMP_WORDS[COMP_CWORD]}"
|
||||
|
@ -237,7 +254,12 @@ _tyto_completions() {
|
|||
COMPREPLY=( $(compgen -W "$(_tyto_targets_new)" -- ${cur}) )
|
||||
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}) )
|
||||
return 0
|
||||
|
||||
|
@ -273,6 +295,12 @@ _tyto_completions() {
|
|||
COMPREPLY=( $(compgen -W "$(_tyto_options)" -- ${cur}) )
|
||||
return 0
|
||||
fi
|
||||
|
||||
# Only with [publish template]
|
||||
elif [ "$prev2" == "publish" ] && \
|
||||
[ "$prev1" == "template" ];then
|
||||
COMPREPLY=( $(compgen -W "$(_tyto_options_pt)" -- ${cur}) )
|
||||
return 0
|
||||
fi
|
||||
;;
|
||||
|
||||
|
|
|
@ -7,12 +7,8 @@ Tyto - Littérateur
|
|||
- License: https://git.a-lec.org/echolib/tyto-litterateur/-/blob/master/LICENSE
|
||||
- Documentation: https://tyto.echolib.re
|
||||
|
||||
## {0.10.5]
|
||||
- added sitemap with `tyto create sitemap`
|
||||
- added escaped markers
|
||||
- added bash-autocompletion (not yet all)
|
||||
- updated help
|
||||
- changed function to protect icodes
|
||||
- very lots more
|
||||
- pre 1.0
|
||||
## [0.10.5]
|
||||
- New sitemap
|
||||
- Very Last testings
|
||||
|
||||
|
||||
|
|
|
@ -3,6 +3,16 @@
|
|||
* 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
|
||||
*/
|
||||
|
|
|
@ -19,7 +19,6 @@ navbar_f = ""
|
|||
sidebar_f = ""
|
||||
metas_f = ""
|
||||
footer_f = ""
|
||||
footer_about_f = ""
|
||||
|
||||
# Domain
|
||||
shortname = ""
|
|
@ -23,59 +23,71 @@
|
|||
# File: /var/lib/tyto/program/args.py
|
||||
#----------------------------------------------------------------------
|
||||
|
||||
#------------
|
||||
# funny stats
|
||||
#------------
|
||||
# lines:
|
||||
# functions:
|
||||
# comments:
|
||||
#----------------------------------------------------------------------
|
||||
#-------------------------
|
||||
# Funny Stats Project
|
||||
#-------------------------
|
||||
# file lines : 173
|
||||
# file comments : 28
|
||||
# file functions: 2
|
||||
#--------------------------
|
||||
|
||||
#**********************************************************************
|
||||
|
||||
import os, sys
|
||||
import infos
|
||||
|
||||
try:
|
||||
action
|
||||
target
|
||||
|
||||
# Arguments from command line
|
||||
# tyto [action] [target]
|
||||
#----------------------------
|
||||
actions = \
|
||||
except:
|
||||
|
||||
# Arguments from command line
|
||||
# tyto [action] [target]
|
||||
#----------------------------
|
||||
actions = \
|
||||
(
|
||||
'check',
|
||||
'create',
|
||||
'edit',
|
||||
'edit-db',
|
||||
'edit-wip',
|
||||
'edit-www',
|
||||
'quick-pub',
|
||||
'force-wip',
|
||||
'new',
|
||||
'preview',
|
||||
'publish',
|
||||
'quick-pub',
|
||||
'show',
|
||||
'show-db',
|
||||
'show-wip',
|
||||
'show-www',
|
||||
'status',
|
||||
'wip',
|
||||
'publish'
|
||||
)
|
||||
|
||||
options = \
|
||||
quicks = \
|
||||
(
|
||||
'force-wip',
|
||||
'quick-pub',
|
||||
)
|
||||
|
||||
options = \
|
||||
(
|
||||
'--static',
|
||||
'--force',
|
||||
)
|
||||
|
||||
pass_actions = ('new')
|
||||
pass_actions = ('new')
|
||||
|
||||
# Actions that needs to check for article's database
|
||||
pass_db = \
|
||||
# Actions that needs to check for article's database
|
||||
pass_db = \
|
||||
(
|
||||
'check',
|
||||
'edit',
|
||||
'edit-db',
|
||||
'edit-wip',
|
||||
'edit-www',
|
||||
'force-wip',
|
||||
'publish',
|
||||
'preview',
|
||||
'quick-pub',
|
||||
'show',
|
||||
'show-about',
|
||||
|
@ -86,7 +98,7 @@ pass_db = \
|
|||
'wip',
|
||||
)
|
||||
|
||||
pass_targets = \
|
||||
pass_targets = \
|
||||
(
|
||||
'added',
|
||||
'again',
|
||||
|
@ -101,19 +113,19 @@ pass_targets = \
|
|||
'template'
|
||||
)
|
||||
|
||||
pass_status = \
|
||||
pass_status = \
|
||||
(
|
||||
'domain',
|
||||
)
|
||||
|
||||
multi_chk = \
|
||||
multi_chk = \
|
||||
(
|
||||
'added',
|
||||
'again',
|
||||
'updated'
|
||||
)
|
||||
|
||||
helps = \
|
||||
helps = \
|
||||
(
|
||||
'domains',
|
||||
'version',
|
||||
|
@ -121,37 +133,37 @@ helps = \
|
|||
)
|
||||
|
||||
|
||||
# action
|
||||
#-------
|
||||
try: action = sys.argv[1]
|
||||
except: action = ''
|
||||
# action
|
||||
#-------
|
||||
try: action = sys.argv[1]
|
||||
except: action = ''
|
||||
|
||||
act_err = False
|
||||
act_err = False
|
||||
|
||||
# With no argument, show help
|
||||
if not action:
|
||||
# With no argument, show help
|
||||
if not action:
|
||||
infos.tyto('full')
|
||||
sys.exit(0)
|
||||
|
||||
elif action in helps:
|
||||
elif action in helps:
|
||||
infos.tyto(action)
|
||||
|
||||
# Unused argument [action]
|
||||
elif not action in actions:
|
||||
# Unused argument [action]
|
||||
elif not action in actions:
|
||||
act_err = True
|
||||
|
||||
|
||||
# target
|
||||
#-------
|
||||
try:
|
||||
# target
|
||||
#-------
|
||||
try:
|
||||
target = sys.argv[2]
|
||||
except:
|
||||
except:
|
||||
infos.tyto('full')
|
||||
sys.exit(0)
|
||||
|
||||
# options
|
||||
try: option = sys.argv[3]
|
||||
except: option = ''
|
||||
# options
|
||||
try: option = sys.argv[3]
|
||||
except: option = ''
|
||||
|
||||
# Set action and target for binary
|
||||
def set_action():
|
||||
|
|
|
@ -24,17 +24,14 @@
|
|||
# File: /var/lib/tyto/program/check.py
|
||||
#----------------------------------------------------------------------
|
||||
|
||||
#------------
|
||||
# funny stats
|
||||
#------------
|
||||
# lines:
|
||||
# functions:
|
||||
# comments:
|
||||
#----------------------------------------------------------------------
|
||||
#-------------------------
|
||||
# Funny Stats Project
|
||||
#-------------------------
|
||||
# file lines : 1141
|
||||
# file comments : 162
|
||||
# file functions: 25
|
||||
#--------------------------
|
||||
|
||||
#**********************************************************************
|
||||
|
||||
# Import needed libs
|
||||
import time, importlib, sys, os, re, datetime
|
||||
from datetime import datetime
|
||||
from time import gmtime, strftime
|
||||
|
@ -767,8 +764,8 @@ def check_anchors():
|
|||
db.uri_file
|
||||
), False)
|
||||
post_err = True
|
||||
return
|
||||
|
||||
else:
|
||||
globals()['post_%s'%tyto.anchor_tags[4]] = int(c_opened)
|
||||
|
||||
|
||||
|
@ -805,6 +802,8 @@ def check_anchors():
|
|||
# Check if anchor link has target one
|
||||
else:
|
||||
for ln, line in enumerate(post_bottom.rsplit('\n'), 1):
|
||||
ln = ln + ln_header + 1
|
||||
|
||||
# Anchor link
|
||||
if tyto.anchor_tags[0] and tyto.anchor_tags[1] in line:
|
||||
anchors = re.findall(r">_(.*?)_<", line)
|
||||
|
@ -812,7 +811,7 @@ def check_anchors():
|
|||
anchor_name = anchor.rsplit(':')[0].lstrip()
|
||||
if not anchor_name in anchors_names:
|
||||
logs.out("12", 'L=%s. anchor "%s" > %s'%(
|
||||
ln + 1 + ln_header, anchor_name, db.uri_file
|
||||
ln, anchor_name, db.uri_file
|
||||
), False)
|
||||
post_err = True
|
||||
|
||||
|
@ -844,7 +843,7 @@ def check_titles():
|
|||
def check_words_tags():
|
||||
global post_err, post_bottom
|
||||
|
||||
for tag in tyto.words_tags:
|
||||
for tag in tyto.markers_tags:
|
||||
c_opened = c_closed = 0
|
||||
|
||||
c_opened = post_bottom.count(tag[0])
|
||||
|
@ -896,6 +895,8 @@ def check_contents_list():
|
|||
if post_lists > 0:
|
||||
inlist = False
|
||||
for ln, line in enumerate(post_bottom.rsplit('\n'), 1):
|
||||
ln = ln + ln_header + 1
|
||||
|
||||
if line.startswith(tyto.block_tags[3][0]):
|
||||
inlist = True
|
||||
continue
|
||||
|
@ -907,13 +908,14 @@ def check_contents_list():
|
|||
|
||||
if inlist and not line or not line[0] in tyto.markers_lists:
|
||||
logs.out("3", 'L=%s. %s %s > %s'%(
|
||||
ln + ln_header,
|
||||
ln,
|
||||
tyto.block_tags[3][4],
|
||||
tyto.markers_lists,
|
||||
db.uri_file
|
||||
), False)
|
||||
post_err = True
|
||||
|
||||
|
||||
#==================================#
|
||||
# Legacy HTML Tags, check if aired #
|
||||
#----------------------------------#
|
||||
|
|
|
@ -24,15 +24,14 @@
|
|||
# File: /var/lib/tyto/program/creators.py
|
||||
#----------------------------------------------------------------------
|
||||
|
||||
#------------
|
||||
# funny stats
|
||||
#------------
|
||||
# lines:
|
||||
# functions:
|
||||
# comments:
|
||||
#----------------------------------------------------------------------
|
||||
#-------------------------
|
||||
# Funny Stats Project
|
||||
#-------------------------
|
||||
# file lines : 240
|
||||
# file comments : 40
|
||||
# file functions: 3
|
||||
#--------------------------
|
||||
|
||||
#**********************************************************************
|
||||
|
||||
import os, importlib, datetime, subprocess
|
||||
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] #
|
||||
#------------------------#
|
||||
def manage(target):
|
||||
target = args.target
|
||||
|
||||
creators = {
|
||||
"sitemap" : create_sitemap,
|
||||
}
|
||||
|
||||
try:
|
||||
creators[target](target)
|
||||
except:
|
||||
logs.out("28", "%s + %s"%(args.action, args.target), True)
|
||||
|
||||
try: creators[target](target)
|
||||
except: logs.out("28", "%s + %s"%(args.action, args.target), True)
|
||||
|
||||
|
||||
#=====================#
|
||||
|
@ -73,7 +70,7 @@ def create_sitemap(target):
|
|||
|
||||
# Define 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' + \
|
||||
'title: %s (%s %s)\n'%(langs.site.sitemap_t, '%s', langs.site.links) + \
|
||||
'about: %s Tyto - Littérateur\n'%langs.site.sitemap_gen + \
|
||||
|
@ -85,14 +82,23 @@ def create_sitemap(target):
|
|||
'-----\n' + \
|
||||
'\n' + \
|
||||
'%s\n' + \
|
||||
'-)'
|
||||
|
||||
print(sitemap_tyto)
|
||||
'|\n' + \
|
||||
'<hr class="hr">\n' + \
|
||||
'|\n' + \
|
||||
'\n' + \
|
||||
'%s\n'
|
||||
|
||||
tab = 8
|
||||
uri_dir_set = ""
|
||||
|
||||
# Contents in article's Header
|
||||
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
|
||||
forbid_dir = (
|
||||
|
@ -107,11 +113,14 @@ def create_sitemap(target):
|
|||
if r.startswith(forbid_dir):
|
||||
continue
|
||||
|
||||
# Take only .tyto files
|
||||
for f in files:
|
||||
if f.endswith(".tyto"):
|
||||
if not f.endswith(".tyto"):
|
||||
continue
|
||||
|
||||
try:
|
||||
uri_file = r.rsplit(dom.articles_d)[1]
|
||||
uri_file = os.path.join(uri_file,f)
|
||||
uri_file = os.path.join(uri_file, f)
|
||||
except:
|
||||
uri_file = f
|
||||
|
||||
|
@ -153,33 +162,79 @@ def create_sitemap(target):
|
|||
|
||||
|
||||
# Create list link line
|
||||
if not uri_dir.startswith(uri_dir_set):
|
||||
curr_dir = uri_dir.count("/")
|
||||
root_dir = uri_dir.rsplit("/")[0]
|
||||
contents = "%s\n-)\n\n#1 %s\n-( sitemap"%(contents, root_dir)
|
||||
uri_dir_set = uri_dir.rsplit("/")[0]
|
||||
ranc_dir = root_dir.replace(" ", "_")
|
||||
|
||||
uls = uri_dir.count("/")
|
||||
contents = \
|
||||
"%s\n%s [%s] _%s (%s)"%(
|
||||
|
||||
try: prev_dir
|
||||
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,
|
||||
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%(
|
||||
nbr_files,
|
||||
links,
|
||||
index_l,
|
||||
contents
|
||||
)
|
||||
sitemap_file = "%ssitemap.tyto"%dom.articles_d
|
||||
tyto.set_file(sitemap_file, "New", sitemap_tyto)
|
||||
|
||||
# Check and wip
|
||||
print()
|
||||
www = subprocess.run(
|
||||
[
|
||||
'/usr/bin/tyto',
|
||||
'wip',
|
||||
'sitemap.tyto',
|
||||
'--force'
|
||||
'force-wip',
|
||||
'sitemap.tyto'
|
||||
],
|
||||
)
|
||||
|
|
|
@ -23,15 +23,14 @@
|
|||
# File: /var/lib/tyto/program/db.py
|
||||
#----------------------------------------------------------------------
|
||||
|
||||
#------------
|
||||
# funny stats
|
||||
#------------
|
||||
# lines:
|
||||
# functions:
|
||||
# comments:
|
||||
#----------------------------------------------------------------------
|
||||
#-------------------------
|
||||
# Funny Stats Project
|
||||
#-------------------------
|
||||
# file lines : 195
|
||||
# file comments : 35
|
||||
# file functions: 0
|
||||
#--------------------------
|
||||
|
||||
#**********************************************************************
|
||||
|
||||
import os
|
||||
import args, logs, dom, form, tyto, check, publish
|
||||
|
|
|
@ -23,45 +23,50 @@
|
|||
# File: /var/lib/tyto/program/dom.py
|
||||
#----------------------------------------------------------------------
|
||||
|
||||
#------------
|
||||
# funny stats
|
||||
#------------
|
||||
# lines:
|
||||
# functions:
|
||||
# comments:
|
||||
#----------------------------------------------------------------------
|
||||
#-------------------------
|
||||
# Funny Stats Project
|
||||
#-------------------------
|
||||
# file lines : 317
|
||||
# file comments : 30
|
||||
# file functions: 1
|
||||
#--------------------------
|
||||
|
||||
#**********************************************************************
|
||||
|
||||
import os, sys, importlib, langs
|
||||
import args
|
||||
|
||||
lib = 'tyto_domain'
|
||||
exists = incomplete = active = ready = shortname = corrupt = False
|
||||
local_user = articles_db_d = False
|
||||
hole = False
|
||||
|
||||
# Set current directory
|
||||
try:
|
||||
user_dir
|
||||
ready
|
||||
|
||||
except:
|
||||
|
||||
lib = 'tyto_domain'
|
||||
exists = incomplete = active = ready = shortname = corrupt = False
|
||||
local_user = articles_db_d = False
|
||||
hole = False
|
||||
|
||||
# Set current directory
|
||||
try:
|
||||
user_dir
|
||||
except:
|
||||
try:
|
||||
user_dir = os.getcwd() + "/"
|
||||
except:
|
||||
hole = True
|
||||
|
||||
# Set current user name
|
||||
try:
|
||||
# Set current user name
|
||||
try:
|
||||
user
|
||||
except:
|
||||
except:
|
||||
try:
|
||||
user = os.environ.get('USER')
|
||||
except:
|
||||
user = ''
|
||||
|
||||
|
||||
# Settings for domain, check if db is not corrupted
|
||||
dom_values = \
|
||||
# Settings for domain, check if db is not corrupted
|
||||
dom_values = \
|
||||
(
|
||||
'directory',
|
||||
'database',
|
||||
|
@ -131,7 +136,7 @@ dom_values = \
|
|||
'activated'
|
||||
)
|
||||
|
||||
create_files = \
|
||||
create_files = \
|
||||
(
|
||||
'navbar_f',
|
||||
'sidebar_f',
|
||||
|
@ -139,10 +144,10 @@ create_files = \
|
|||
'footer_f',
|
||||
)
|
||||
|
||||
wip_html_mods = ()
|
||||
err_val = (()) # Make a list from values error
|
||||
wip_html_mods = ()
|
||||
err_val = (()) # Make a list from values error
|
||||
|
||||
if not hole:
|
||||
if not hole:
|
||||
home_dir = os.path.expanduser('~')
|
||||
|
||||
# Set configuration domain directory
|
||||
|
|
|
@ -25,36 +25,42 @@
|
|||
# File: /var/lib/tyto/program/form.py
|
||||
#----------------------------------------------------------------------
|
||||
|
||||
#------------
|
||||
# funny stats
|
||||
#------------
|
||||
# lines:
|
||||
# functions:
|
||||
# comments:
|
||||
#----------------------------------------------------------------------
|
||||
#-------------------------
|
||||
# Funny Stats Project
|
||||
#-------------------------
|
||||
# file lines : 1096
|
||||
# file comments : 103
|
||||
# file functions: 7
|
||||
#--------------------------
|
||||
|
||||
#**********************************************************************
|
||||
|
||||
from datetime import datetime
|
||||
import os, sys, shutil, re, locale, importlib
|
||||
import logs, dom, tyto, html, show, langs
|
||||
|
||||
# locale translation directory
|
||||
trans_dir = '/var/lib/tyto/translations'
|
||||
|
||||
# Get default System language
|
||||
try:
|
||||
lang_site
|
||||
except:
|
||||
# locale translation directory
|
||||
trans_dir = '/var/lib/tyto/translations'
|
||||
|
||||
# Get default System language
|
||||
try:
|
||||
lang_sys = locale.getdefaultlocale()[0].split('_')[0]
|
||||
os.path.exists('%s/site_%s.py'%(trans_dir, lang_sys))
|
||||
except:
|
||||
except:
|
||||
lang_sys = 'en'
|
||||
|
||||
lang_site = lang_sys
|
||||
lang_site = lang_sys
|
||||
|
||||
# Generic answer
|
||||
"""
|
||||
answer_yes = ('y', 'Y', 'yes', 'Yes', 'YES',
|
||||
'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)
|
||||
|
||||
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)
|
||||
|
||||
else:
|
||||
|
|
|
@ -22,19 +22,19 @@
|
|||
# File: /var/lib/tyto/program/html.py
|
||||
#----------------------------------------------------------------------
|
||||
|
||||
#------------
|
||||
# funny stats
|
||||
#------------
|
||||
# lines:
|
||||
# functions:
|
||||
# comments:
|
||||
#----------------------------------------------------------------------
|
||||
#-------------------------
|
||||
# Funny Stats Project
|
||||
#-------------------------
|
||||
# file lines : 543
|
||||
# file comments : 70
|
||||
# file functions: 8
|
||||
#--------------------------
|
||||
|
||||
#**********************************************************************
|
||||
|
||||
import os, sys, importlib
|
||||
import logs, db, dom, tyto, form, langs
|
||||
|
||||
|
||||
# Publish option can be
|
||||
wip_opts = ('wip', 'new')
|
||||
pub_opts = ('www', 'pub')
|
||||
|
@ -163,6 +163,7 @@ def create_main_page(target, article_bottom):
|
|||
'%s\n'%metas + \
|
||||
' </head>\n\n' + \
|
||||
' <body>\n' + \
|
||||
' <div id="site_container">\n' + \
|
||||
' <header id="header_page">\n' + \
|
||||
' <div id="site_logo">\n' + \
|
||||
' %s\n'%logo_html + \
|
||||
|
@ -177,6 +178,7 @@ def create_main_page(target, article_bottom):
|
|||
' </div>\n' + \
|
||||
' </header>\n' + \
|
||||
tags_html_mods[dom.wip_navbar_f] + '\n' + \
|
||||
' <div id="article_sidebar_container">\n' + \
|
||||
' <article id="article_main">\n' + \
|
||||
' <h1 accesskey="t" id="post_title"\n' + \
|
||||
' title="[%s] %s %s %s %s">%s</h1>\n'%(
|
||||
|
@ -199,7 +201,9 @@ def create_main_page(target, article_bottom):
|
|||
' </article>\n' + \
|
||||
'\n' + \
|
||||
tags_html_mods[dom.wip_sidebar_f] + '\n' + \
|
||||
' </div>\n' + \
|
||||
tags_html_mods[dom.wip_footer_f] + '\n' + \
|
||||
' </div>\n' + \
|
||||
' </body>\n' + \
|
||||
'</html>'
|
||||
|
||||
|
@ -484,10 +488,10 @@ def create_sidebar(option):
|
|||
' <li class="sidebar_item">\n' + \
|
||||
' <a class="sidebar_item_link"\n' + \
|
||||
' 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' + \
|
||||
' title="%s">\n'%link_title + \
|
||||
' %s [%s] - %s\n'%(date, author, about) + \
|
||||
' %s - %s\n'%(date, about) + \
|
||||
' </p>\n' + \
|
||||
' </a>\n' + \
|
||||
' </li>\n'
|
||||
|
|
|
@ -23,20 +23,20 @@
|
|||
# File: /var/lib/tyto/program/infos.py
|
||||
#----------------------------------------------------------------------
|
||||
|
||||
#------------
|
||||
# funny stats
|
||||
#------------
|
||||
# lines:
|
||||
# functions:
|
||||
# comments:
|
||||
#----------------------------------------------------------------------
|
||||
#-------------------------
|
||||
# Funny Stats Project
|
||||
#-------------------------
|
||||
# file lines : 130
|
||||
# file comments : 26
|
||||
# file functions: 3
|
||||
#--------------------------
|
||||
|
||||
#**********************************************************************
|
||||
|
||||
import os, sys, importlib
|
||||
import langs
|
||||
importlib.reload(langs)
|
||||
|
||||
|
||||
# Set colors
|
||||
CS = '\033[0;0m'
|
||||
CR = '\033[1;31m'
|
||||
|
|
|
@ -23,50 +23,67 @@
|
|||
# File: /var/lib/tyto/program/langs.py
|
||||
#----------------------------------------------------------------------
|
||||
|
||||
#------------
|
||||
# funny stats
|
||||
#------------
|
||||
# lines:
|
||||
# functions:
|
||||
# comments:
|
||||
#----------------------------------------------------------------------
|
||||
#-------------------------
|
||||
# Funny Stats Project
|
||||
#-------------------------
|
||||
# file lines : 89
|
||||
# file comments : 27
|
||||
# file functions: 0
|
||||
#--------------------------
|
||||
|
||||
#**********************************************************************
|
||||
|
||||
import locale, sys, os, importlib
|
||||
import dom
|
||||
|
||||
# Import translation directory
|
||||
trans_dir = '/var/lib/tyto/translations'
|
||||
sys.path.insert(0, trans_dir)
|
||||
|
||||
|
||||
# Get default system language
|
||||
# or set "en" (english) if no translation file
|
||||
try:
|
||||
site.yes
|
||||
|
||||
except:
|
||||
# Import translation directory
|
||||
trans_dir = '/var/lib/tyto/translations'
|
||||
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
|
||||
# or set "en" (english) if no translation file
|
||||
try:
|
||||
lang_sys = locale.getdefaultlocale()[0].split('_')[0]
|
||||
os.path.exists('%s/logs_%s.py'%(trans_dir, lang_sys))
|
||||
except:
|
||||
except:
|
||||
lang_sys = 'en'
|
||||
|
||||
|
||||
# Set language logs from configuration domain
|
||||
# or set default english if not known
|
||||
try:
|
||||
# Set language logs from configuration domain
|
||||
# or set default english if not known
|
||||
try:
|
||||
dom.exists
|
||||
lang_logs = dom.lang_logs
|
||||
os.path.exists('%s/logs_%s.py'%(trans_dir, lang_logs))
|
||||
log = importlib.import_module('logs_%s'%lang_logs, package=None)
|
||||
except:
|
||||
except:
|
||||
log = importlib.import_module('logs_%s'%lang_sys, package=None)
|
||||
|
||||
|
||||
# Set language site/form from configuration domain
|
||||
# or set default english if not known
|
||||
try:
|
||||
# Set language site/form from configuration domain
|
||||
# or set default english if not known
|
||||
try:
|
||||
dom.exists
|
||||
lang_site = dom.lang_site
|
||||
os.path.exists('%s/site_%s.py'%(trans_dir, lang_site))
|
||||
site = importlib.import_module('site_%s'%lang_site, package=None)
|
||||
except:
|
||||
except:
|
||||
site = importlib.import_module('site_%s'%lang_sys, package=None)
|
||||
|
||||
|
|
|
@ -23,27 +23,30 @@
|
|||
# File: /var/lib/tyto/program/logs.py
|
||||
#----------------------------------------------------------------------
|
||||
|
||||
#------------
|
||||
# funny stats
|
||||
#------------
|
||||
# lines:
|
||||
# functions:
|
||||
# comments:
|
||||
#----------------------------------------------------------------------
|
||||
#-------------------------
|
||||
# Funny Stats Project
|
||||
#-------------------------
|
||||
# file lines : 126
|
||||
# file comments : 22
|
||||
# file functions: 1
|
||||
#--------------------------
|
||||
|
||||
#**********************************************************************
|
||||
|
||||
import os, sys
|
||||
import langs
|
||||
|
||||
# Use to mark new article
|
||||
shebang = "#!/NEW"
|
||||
|
||||
# Set colors
|
||||
CS = '\033[0;0m'
|
||||
CR = '\033[1;31m'
|
||||
CY = '\033[1;33m'
|
||||
CG = '\033[1;32m'
|
||||
try:
|
||||
shebang
|
||||
except:
|
||||
# Use to mark new article
|
||||
shebang = "#!/NEW"
|
||||
|
||||
# Set colors
|
||||
CS = '\033[0;0m'
|
||||
CR = '\033[1;31m'
|
||||
CY = '\033[1;33m'
|
||||
CG = '\033[1;32m'
|
||||
|
||||
|
||||
# Exit from program with message #
|
||||
|
|
|
@ -23,19 +23,18 @@
|
|||
# File: /var/lib/tyto/program/new.py
|
||||
#----------------------------------------------------------------------
|
||||
|
||||
#------------
|
||||
# funny stats
|
||||
#------------
|
||||
# lines:
|
||||
# functions:
|
||||
# comments:
|
||||
#----------------------------------------------------------------------
|
||||
#-------------------------
|
||||
# Funny Stats Project
|
||||
#-------------------------
|
||||
# file lines : 93
|
||||
# file comments : 26
|
||||
# file functions: 1
|
||||
#--------------------------
|
||||
|
||||
#**********************************************************************
|
||||
|
||||
import sys
|
||||
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,
|
||||
'navbar' : html.create_navbar,
|
||||
'metas' : html.create_user_metas,
|
||||
'footer' : html.create_user_footer
|
||||
'footer' : html.create_user_footer,
|
||||
'sitemap' : creators.manage
|
||||
}
|
||||
|
||||
actions[target](option)
|
||||
|
|
|
@ -23,20 +23,20 @@
|
|||
# File: /var/lib/tyto/program/publish.py
|
||||
#----------------------------------------------------------------------
|
||||
|
||||
#------------
|
||||
# funny stats
|
||||
#------------
|
||||
# lines:
|
||||
# functions:
|
||||
# comments:
|
||||
#----------------------------------------------------------------------
|
||||
#-------------------------
|
||||
# Funny Stats Project
|
||||
#-------------------------
|
||||
# file lines : 293
|
||||
# file comments : 49
|
||||
# file functions: 6
|
||||
#--------------------------
|
||||
|
||||
#**********************************************************************
|
||||
|
||||
import os, sys, shutil, importlib
|
||||
import os, sys, shutil, importlib, subprocess
|
||||
from pathlib import Path
|
||||
import logs, args, dom, db, wip, html, tyto, form, stats, rss, langs, check
|
||||
|
||||
|
||||
#==============================#
|
||||
# Manage action, get post db #
|
||||
# check if publish can be done #
|
||||
|
@ -46,15 +46,17 @@ def manage(target):
|
|||
|
||||
# Specific QUICK processes: check > wip > publish
|
||||
if args.action == "quick-pub":
|
||||
try:
|
||||
db.uri_file
|
||||
except:
|
||||
logs.out("28", "%s + %s"%(args.action, args.target), True)
|
||||
try: db.uri_file
|
||||
except: logs.out("28", "%s + %s"%(args.action, args.target), True)
|
||||
|
||||
print(" ! Quick Publish")
|
||||
check.check_process(target)
|
||||
importlib.reload(db)
|
||||
wip.wip_article(db.uri_file)
|
||||
wip = subprocess.run(
|
||||
[
|
||||
'/usr/bin/tyto',
|
||||
'force-wip',
|
||||
target
|
||||
],
|
||||
)
|
||||
print()
|
||||
importlib.reload(db)
|
||||
check_to_publish('one')
|
||||
publish_article()
|
||||
|
@ -280,6 +282,9 @@ def publish_template(option):
|
|||
logs.out("32", item_dst, False)
|
||||
|
||||
# Create new file from _configs/ files
|
||||
if args.option == "--no-mods":
|
||||
return
|
||||
|
||||
html.create_sidebar('pub')
|
||||
html.create_navbar('pub')
|
||||
html.create_user_metas('pub')
|
||||
|
|
|
@ -23,15 +23,14 @@
|
|||
# File: /var/lib/tyto/program/rss.py
|
||||
#----------------------------------------------------------------------
|
||||
|
||||
#------------
|
||||
# funny stats
|
||||
#------------
|
||||
# lines:
|
||||
# functions:
|
||||
# comments:
|
||||
#----------------------------------------------------------------------
|
||||
#-------------------------
|
||||
# Funny Stats Project
|
||||
#-------------------------
|
||||
# file lines : 128
|
||||
# file comments : 27
|
||||
# file functions: 1
|
||||
#--------------------------
|
||||
|
||||
#*********************************************************************
|
||||
|
||||
import os
|
||||
from pathlib import Path
|
||||
|
@ -86,6 +85,10 @@ def create_feed():
|
|||
if not hash_www or hash_chk != hash_www:
|
||||
continue
|
||||
|
||||
# NoSitemap
|
||||
if not db.sitemap:
|
||||
continue
|
||||
|
||||
rss_item = True
|
||||
nbr_item += 1
|
||||
|
||||
|
|
|
@ -24,19 +24,19 @@
|
|||
# File: /var/lib/tyto/program/show.py
|
||||
#----------------------------------------------------------------------
|
||||
|
||||
#------------
|
||||
# funny stats
|
||||
#------------
|
||||
# lines:
|
||||
# functions:
|
||||
# comments:
|
||||
#----------------------------------------------------------------------
|
||||
#-------------------------
|
||||
# Funny Stats Project
|
||||
#-------------------------
|
||||
# file lines : 215
|
||||
# file comments : 38
|
||||
# file functions: 3
|
||||
#--------------------------
|
||||
|
||||
#**********************************************************************
|
||||
|
||||
import os, sys, importlib
|
||||
import os, sys, importlib, subprocess
|
||||
import args, logs, langs, dom, db, form, tyto, check, html, stats
|
||||
|
||||
|
||||
#========================#
|
||||
# Read lines from a file #
|
||||
# alone: True/False #
|
||||
|
@ -94,9 +94,6 @@ def manage(target):
|
|||
try: post_www = db.post_www
|
||||
except: pass
|
||||
|
||||
# Except for show-about > Show post DB
|
||||
if args.action == "show-about":
|
||||
target = 'post'
|
||||
|
||||
|
||||
# Convert command action to do[]
|
||||
|
@ -106,6 +103,7 @@ def manage(target):
|
|||
"show" : 'src',
|
||||
"edit" : 'src',
|
||||
"post" : 'src',
|
||||
"preview" : 'wip',
|
||||
"show-db" : 'db',
|
||||
"edit-db" : 'db',
|
||||
"show-wip" : 'wip',
|
||||
|
@ -141,6 +139,7 @@ def manage(target):
|
|||
"navbar" : dom.wip_navbar_f,
|
||||
"sidebar" : dom.wip_sidebar_f,
|
||||
"post" : post_wip,
|
||||
"sitemap" : '%ssitemap.html'%dom.srv_wip,
|
||||
"stats" : dom.wip_stats_f,
|
||||
},
|
||||
'www' : {
|
||||
|
@ -155,19 +154,25 @@ def manage(target):
|
|||
}
|
||||
|
||||
# Read or edit file, according to legacy args.action
|
||||
try:
|
||||
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)
|
||||
|
||||
elif args.action in actions_edit:
|
||||
curr_hash = tyto.get_filesum(file, True)
|
||||
tyto.edit_file(file)
|
||||
|
||||
except:
|
||||
logs.out("28", '%s + %s'%(args.action, target), True)
|
||||
|
||||
|
||||
# If edit article and hash changed, ask to check
|
||||
if args.action == "edit":
|
||||
|
@ -178,16 +183,33 @@ def manage(target):
|
|||
# Launch process for some changed file
|
||||
#-------------------------------------
|
||||
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")
|
||||
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.navbar_f: html.create_navbar('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)
|
||||
|
||||
|
|
|
@ -23,19 +23,19 @@
|
|||
# File: /var/lib/tyto/program/stats.py
|
||||
#----------------------------------------------------------------------
|
||||
|
||||
#------------
|
||||
# funny stats
|
||||
#------------
|
||||
# lines:
|
||||
# functions:
|
||||
# comments:
|
||||
#----------------------------------------------------------------------
|
||||
#-------------------------
|
||||
# Funny Stats Project
|
||||
#-------------------------
|
||||
# file lines : 225
|
||||
# file comments : 37
|
||||
# file functions: 4
|
||||
#--------------------------
|
||||
|
||||
#**********************************************************************
|
||||
|
||||
import os, importlib
|
||||
import args, dom, logs, form, tyto, show, langs
|
||||
|
||||
|
||||
sti_articles = 0
|
||||
|
||||
#=======================#
|
||||
|
|
|
@ -23,40 +23,73 @@
|
|||
# File: /var/lib/tyto/program/status.py
|
||||
#----------------------------------------------------------------------
|
||||
|
||||
#------------
|
||||
# funny stats
|
||||
#------------
|
||||
# lines:
|
||||
# functions:
|
||||
# comments:
|
||||
#----------------------------------------------------------------------
|
||||
#-------------------------
|
||||
# Funny Stats Project
|
||||
#-------------------------
|
||||
# file lines : 238
|
||||
# file comments : 50
|
||||
# file functions: 3
|
||||
#--------------------------
|
||||
|
||||
#**********************************************************************
|
||||
|
||||
import os
|
||||
import args, dom, logs, tyto, html, db
|
||||
import args, dom, logs
|
||||
|
||||
|
||||
#=====================#
|
||||
# Check domain status #
|
||||
#---------------------#
|
||||
def domain():
|
||||
if dom.hole: logs.out("13", '', True)
|
||||
elif args.action == 'new' and args.target == "domain": return
|
||||
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)
|
||||
if dom.hole:
|
||||
logs.out("13", '', True)
|
||||
|
||||
print("")
|
||||
if dom.incomplete: logs.out("41", dom.shortname, False)
|
||||
elif dom.active: logs.out("42", dom.shortname, False)
|
||||
elif not dom.active: logs.out("40", dom.shortname, False)
|
||||
# Only condition to not check domain status here
|
||||
if args.action == 'new' and \
|
||||
args.target == "domain":
|
||||
return
|
||||
|
||||
# No backward in target
|
||||
if "../" in args.target:
|
||||
logs.out("11", '"../"', True)
|
||||
# As subprocesses, avoid show domain status each time
|
||||
if args.action in args.quicks:
|
||||
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
|
||||
for err_val in dom.err_val:
|
||||
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
|
||||
for value in dom.dom_values:
|
||||
set_value = eval(str('dom.%s'%value))
|
||||
|
@ -103,6 +136,8 @@ def domain():
|
|||
|
||||
|
||||
# Create missing modules files
|
||||
import html
|
||||
|
||||
if not tyto.exists(dom.metas_f) or \
|
||||
not tyto.exists(dom.wip_metas_f):
|
||||
html.create_user_metas('new')
|
||||
|
@ -124,6 +159,8 @@ def domain():
|
|||
# On demand with status action #
|
||||
#------------------------------#
|
||||
def check(target):
|
||||
import db
|
||||
|
||||
# target needed
|
||||
if not target:
|
||||
logs.out("5", '[target]', True)
|
||||
|
|
|
@ -23,20 +23,20 @@
|
|||
# File: /var/lib/tyto/program/tyto.py
|
||||
#----------------------------------------------------------------------
|
||||
|
||||
#------------
|
||||
# funny stats
|
||||
#------------
|
||||
# lines:
|
||||
# functions:
|
||||
# comments:
|
||||
#----------------------------------------------------------------------
|
||||
#-------------------------
|
||||
# Funny Stats Project
|
||||
#-------------------------
|
||||
# file lines : 724
|
||||
# file comments : 120
|
||||
# file functions: 14
|
||||
#--------------------------
|
||||
|
||||
#**********************************************************************
|
||||
|
||||
import os, sys, re, subprocess, locale, base64, datetime, shutil
|
||||
from hashlib import blake2b
|
||||
import args, dom, logs, langs
|
||||
|
||||
|
||||
# :D
|
||||
Tyto = 'Tyto - Littérateur'
|
||||
Tytogit = 'https://git.a-lec.org/echolib/tyto-litterateur'
|
||||
|
@ -103,50 +103,6 @@ headers = \
|
|||
# ! As base64 is used, do NOT set marker: =_ _=
|
||||
# [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 = \
|
||||
(
|
||||
'{_', '_}',
|
||||
|
@ -154,6 +110,7 @@ icode_tags = \
|
|||
'icodes',
|
||||
'\\{_', '\\_}'
|
||||
)
|
||||
|
||||
strong_tags = \
|
||||
(
|
||||
'*_', '_*',
|
||||
|
@ -162,6 +119,7 @@ strong_tags = \
|
|||
'\\*_', '\\_*',
|
||||
'-S1-', '-S2-'
|
||||
)
|
||||
|
||||
bold_tags = \
|
||||
(
|
||||
'+_', '_+',
|
||||
|
@ -170,6 +128,7 @@ bold_tags = \
|
|||
'\\+_', '\\_+',
|
||||
'-B1-', '-B2-'
|
||||
)
|
||||
|
||||
em_tags = \
|
||||
(
|
||||
';_', '_;',
|
||||
|
@ -178,6 +137,7 @@ em_tags = \
|
|||
'\\;_', '\\_;',
|
||||
'-EM1-', '-EM2-'
|
||||
)
|
||||
|
||||
i_tags = \
|
||||
(
|
||||
':_', '_:',
|
||||
|
@ -186,6 +146,7 @@ i_tags = \
|
|||
'\\:_', '\\_:',
|
||||
'-I1-', '-I2-'
|
||||
)
|
||||
|
||||
u_tags = \
|
||||
(
|
||||
'._', '_.', '<u class="%s">'%dom.css,
|
||||
|
@ -194,6 +155,7 @@ u_tags = \
|
|||
'\\._', '\\_.',
|
||||
'-U1-', '-U2-'
|
||||
)
|
||||
|
||||
del_tags = \
|
||||
(
|
||||
'~_', '_~',
|
||||
|
@ -202,6 +164,7 @@ del_tags = \
|
|||
'\\~_', '\\_~',
|
||||
'-DE1-', '-DE2-'
|
||||
)
|
||||
|
||||
cite_tags = \
|
||||
(
|
||||
'[_', '_]',
|
||||
|
@ -210,6 +173,7 @@ cite_tags = \
|
|||
'\\[_', '\\_]',
|
||||
'-CI1-', '-CI2-'
|
||||
)
|
||||
|
||||
custom1_tags = \
|
||||
(
|
||||
'%_', '_%',
|
||||
|
@ -219,7 +183,6 @@ custom1_tags = \
|
|||
'-CU1-', '-CU2-'
|
||||
)
|
||||
|
||||
|
||||
markers_tags = \
|
||||
[
|
||||
strong_tags,
|
||||
|
@ -344,7 +307,7 @@ date: %s
|
|||
Texte-alternatif
|
||||
|
||||
#link: lien 1
|
||||
URi/URL
|
||||
URI/URL
|
||||
Text-alternatif
|
||||
|
||||
-----
|
||||
|
@ -361,48 +324,6 @@ date: %s
|
|||
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 #
|
||||
#=======#--------------------------------------------------------------
|
||||
|
@ -432,9 +353,6 @@ def convert_altname(altname):
|
|||
# False = URI #
|
||||
#-----------------------#
|
||||
def get_filesum(path, src):
|
||||
#if not src and not exists(path):
|
||||
# logs.out("1", path, True)
|
||||
|
||||
file_sum = blake2b(digest_size=4)
|
||||
|
||||
if src: file_sum.update(open(path, 'rb').read())
|
||||
|
@ -506,6 +424,29 @@ def get_css(line):
|
|||
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 #
|
||||
# Protect block-Codes, quotes #
|
||||
|
@ -580,11 +521,14 @@ def protect_bcodes_quotes(process, post_bottom):
|
|||
if not bcode: bcode = line
|
||||
else: bcode = '%s\n%s'%(bcode, line)
|
||||
line = ''
|
||||
continue
|
||||
|
||||
elif in_quote:
|
||||
# Convert lines to b64
|
||||
if not quote: quote = line
|
||||
else: quote = '%s\n%s'%(quote, line)
|
||||
line = ''
|
||||
continue
|
||||
|
||||
|
||||
# Set new content
|
||||
|
@ -614,28 +558,28 @@ def protect_icodes(post_bottom):
|
|||
# Get only lines that contains code
|
||||
in_icode = ok_icode = go_icode = False
|
||||
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
|
||||
|
||||
code = ""
|
||||
for i, c in enumerate(line):
|
||||
if c == "_":
|
||||
try:
|
||||
if line[i-1] == "{" and line[i-2] != "\\":
|
||||
# {_
|
||||
if line[i-1] == icode_tags[0][0] and line[i-2] != "\\":
|
||||
in_icode = True
|
||||
ok_icode = False
|
||||
go_icode = True
|
||||
elif line[i+1] == "}" and line[i-2] != "\\":
|
||||
#go_icode = True
|
||||
continue
|
||||
# _}
|
||||
elif line[i+1] == icode_tags[1][1] and line[i-2] != "\\":
|
||||
in_icode = False
|
||||
ok_icode = True
|
||||
go_icode = False
|
||||
except:
|
||||
continue
|
||||
|
||||
if go_icode :
|
||||
go_icode = False
|
||||
continue
|
||||
|
||||
if in_icode:
|
||||
ok_icode = False
|
||||
code = "%s%s"%(code, c)
|
||||
|
@ -650,7 +594,7 @@ def protect_icodes(post_bottom):
|
|||
post_bottom = post_bottom.replace(tyto_code , '')
|
||||
|
||||
elif args.action == "wip":
|
||||
code = convert_altname(code)
|
||||
code = convert_altname(code) # HTML sympbols
|
||||
html_code = "%s%s%s"%(
|
||||
icode_tags[2], code, icode_tags[3])
|
||||
b64_code = b64('Encode', html_code, 'I64.', '.I64')
|
||||
|
|
|
@ -26,17 +26,16 @@
|
|||
# File: /var/lib/tyto/program/wip.py
|
||||
#----------------------------------------------------------------------
|
||||
|
||||
#------------
|
||||
# funny stats
|
||||
#------------
|
||||
# lines:
|
||||
# functions:
|
||||
# comments:
|
||||
#----------------------------------------------------------------------
|
||||
#-------------------------
|
||||
# Funny Stats Project
|
||||
#-------------------------
|
||||
# file lines : 1112
|
||||
# file comments : 166
|
||||
# file functions: 26
|
||||
#--------------------------
|
||||
|
||||
#**********************************************************************
|
||||
|
||||
import os, re, sys, locale, shutil, importlib, time
|
||||
import os, re, sys, locale, shutil, importlib, time, subprocess
|
||||
from pathlib import Path
|
||||
import args, logs, langs, dom, db, tyto, html, form, stats, check
|
||||
|
||||
|
@ -53,13 +52,28 @@ def manage(target):
|
|||
logs.out("5", '[target]', True)
|
||||
|
||||
# option --force to check and wip processes
|
||||
if args.option == '--force':
|
||||
if args.action == 'force-wip':
|
||||
if args.target in args.pass_targets:
|
||||
logs.out("28", "%s + %s"%(args.target, args.option), True)
|
||||
|
||||
check.manage(target)
|
||||
#importlib.reload(db)
|
||||
wip_article(target)
|
||||
|
||||
chk = subprocess.run(
|
||||
[
|
||||
'/usr/bin/tyto',
|
||||
'check',
|
||||
target,
|
||||
'--force'
|
||||
],
|
||||
)
|
||||
|
||||
print()
|
||||
wip = subprocess.run(
|
||||
[
|
||||
'/usr/bin/tyto',
|
||||
'wip',
|
||||
target,
|
||||
],
|
||||
)
|
||||
return
|
||||
|
||||
# Modules and multi-articles
|
||||
|
@ -323,7 +337,7 @@ def wip_single_tags():
|
|||
#----------------------------------#
|
||||
def wip_words_tags():
|
||||
# Strongs, italics...
|
||||
for tag in tyto.words_tags:
|
||||
for tag in tyto.markers_tags:
|
||||
# Open tag
|
||||
replace_in_post(tag[0],
|
||||
tag[2]
|
||||
|
@ -375,12 +389,38 @@ def wip_words_tags():
|
|||
)
|
||||
|
||||
|
||||
#========================#
|
||||
# Convert links set inDB #
|
||||
#============================#
|
||||
# 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 #
|
||||
# - file_%i #
|
||||
# - link_%i #
|
||||
# from marker to HTML #
|
||||
#------------------------#
|
||||
#-------------------------#
|
||||
def wip_links():
|
||||
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
|
||||
#----------------------------------------------------
|
||||
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_css = "link_file"
|
||||
flink_name = eval(flink)[0][2:]
|
||||
|
@ -408,7 +453,12 @@ def wip_links():
|
|||
# Convert simple links
|
||||
#---------------------
|
||||
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_css = "link"
|
||||
link_name = eval(link)[0][1:]
|
||||
|
@ -417,6 +467,7 @@ def wip_links():
|
|||
link_set = link_html%(
|
||||
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_ts)
|
||||
|
@ -514,7 +565,7 @@ def wip_images():
|
|||
else:
|
||||
style = ''
|
||||
|
||||
# set <img /> from parameter
|
||||
# set <img> from parameter
|
||||
image_target = eval(image)[1]
|
||||
image_target = db.sub_uri + image_target[1:]
|
||||
image_src = image_show%(
|
||||
|
|
|
@ -18,6 +18,9 @@
|
|||
# - "\n"
|
||||
# - "+ \"
|
||||
|
||||
# Keep array ! ('','',)
|
||||
yes = ("y", "yes",)
|
||||
|
||||
# Generic
|
||||
article = "Article"
|
||||
links = "links"
|
||||
|
@ -268,6 +271,7 @@ args_helps = """\n# New domain :
|
|||
[sidebar, navbar, footer, metas] Create and replace
|
||||
with default module configuration file
|
||||
[filename] (no .tyto) Create article in current folder
|
||||
[sitemap], create new website sitemap
|
||||
|
||||
# Show contents file (with line number)
|
||||
show : Show source file, source configuration module
|
||||
|
@ -280,8 +284,10 @@ args_helps = """\n# New domain :
|
|||
# Create HTML page
|
||||
check : Check the validity of a tyto format file
|
||||
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'
|
||||
quick-pub : Do check, wip, publish ([file] only)
|
||||
quick-pub : [file], check, wip, publish
|
||||
|
||||
# [target] > According to [action]
|
||||
# Multiple articles
|
||||
|
@ -306,10 +312,12 @@ args_helps = """\n# New domain :
|
|||
navbar : Navbar configuration file
|
||||
sidebar : Sidebar configuration file
|
||||
stats : Stats file (server 'wip' er 'www')
|
||||
sitemap : sitemap.tyto/.html file
|
||||
|
||||
# [option] :
|
||||
--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 :
|
||||
# Check article (according to sub-folder)
|
||||
|
|
|
@ -18,6 +18,9 @@
|
|||
# - "\n"
|
||||
# - "+ \"
|
||||
|
||||
# Garder ! ('','',)
|
||||
yes = ("o", "oui",)
|
||||
|
||||
# Generic
|
||||
article = "Article"
|
||||
links = "liens"
|
||||
|
@ -267,6 +270,7 @@ args_helps = """\n# Nouveau domaine :
|
|||
fichier de configuration du module par le défaut
|
||||
[filename] (sans .tyto) Créer un article dans le
|
||||
dossier actuel
|
||||
[sitemap], créer le plan du site (sitemap)
|
||||
|
||||
# Afficher un fichier (avec numéros de ligne)
|
||||
show : Fichier source, module de configuration
|
||||
|
@ -277,8 +281,10 @@ args_helps = """\n# Nouveau domaine :
|
|||
# Processus de création / Mise en ligne
|
||||
check : Vérifier la validité d'un article au format tyto
|
||||
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'
|
||||
quick-pub : Faire check, wip, publish ([file] seulement)
|
||||
quick-pub : [file] , check, wip, publish
|
||||
|
||||
# [target] > Selon l'action [action]
|
||||
# Traitement en masse
|
||||
|
@ -303,10 +309,12 @@ args_helps = """\n# Nouveau domaine :
|
|||
navbar : Fichier de configuration du menu de navigation
|
||||
sidebar : Fichier de configuration de la barre latérale
|
||||
stats : Fichier de statistiques (serveur 'wip' ou 'www')
|
||||
sitemap : Fichier sitemap.tyto/.html
|
||||
|
||||
# [option]
|
||||
--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 :
|
||||
# Vérifier l'article dans le sous dossier (suivant l'emplacement)
|
||||
|
|
Loading…
Reference in New Issue