Some fixes + help update. No more www server file created with new domain
This commit is contained in:
parent
ba161305eb
commit
d866e0f34f
|
@ -39,7 +39,7 @@ post_exists = False
|
|||
home_dir = os.path.expanduser('~')
|
||||
|
||||
try: in_dir = os.getcwd()
|
||||
except: logs.out("13", '', False)
|
||||
except: logs.out("13", '', True)
|
||||
|
||||
domain_conf = in_dir
|
||||
|
||||
|
|
|
@ -517,7 +517,7 @@ def create_domain(target):
|
|||
if not ask.isdigit(): logs.out("3", ask, True)
|
||||
elif int(ask) in range(1,17): sidebar_items = int(ask)
|
||||
|
||||
set_f = 'sidebar_items = %d'%sidebar_items
|
||||
set_f = 'sidebar_items = %d'%int(sidebar_items)
|
||||
tyto.set_file(db.domain_conf, False, set_f)
|
||||
|
||||
# Create domain_footer_about (user custom description in footer)
|
||||
|
@ -576,10 +576,10 @@ def create_domain(target):
|
|||
|
||||
print(' │')
|
||||
for folder in folders:
|
||||
if not os.path.exists(folder):
|
||||
print(' ├ Create directory: %s'%folder)
|
||||
if not os.makedirs(folder, exist_ok=True):
|
||||
print(' │ Exists directory: %s'%folder)
|
||||
else:
|
||||
print(' ├ Create directory: %s'%folder)
|
||||
|
||||
# Create in _configs files
|
||||
# Parameter could be used later
|
||||
|
@ -606,9 +606,6 @@ def create_sidebar(option):
|
|||
if not os.path.exists(db.wip_sidebar):
|
||||
tyto.set_file(db.wip_sidebar, 'new', '')
|
||||
print(' ├ Create empty file: %s'%db.wip_sidebar)
|
||||
if not os.path.exists(db.www_sidebar):
|
||||
tyto.set_file(db.www_sidebar, 'new', '')
|
||||
print(' ├ Create empty file: %s'%db.www_sidebar)
|
||||
|
||||
# Create new file, or ask if exists with option = 'reset'
|
||||
ask = ' ├ Reset sidebar configuration file ? '
|
||||
|
@ -626,7 +623,7 @@ def create_sidebar(option):
|
|||
sdb_load_fr = \
|
||||
'# Pour : Tyto - Littérateur\n' + \
|
||||
'# Type : fichier texte\n' + \
|
||||
'# Description : Fichier appelé par "tyto sidebar"\n' + \
|
||||
'# Description : Fichier utilisé par "tyto wip/publish"\n' + \
|
||||
'# (Liste d\'articles)\n' + \
|
||||
'# Fichier : %s\n'%db.sidebar_load + \
|
||||
"# Commandes: tyto new sidebar (réinitialiser)\n" + \
|
||||
|
@ -646,7 +643,7 @@ def create_sidebar(option):
|
|||
sdb_load_en = \
|
||||
'# For: Tyto - Littérateur\n' + \
|
||||
'# Type: Text file\n' + \
|
||||
'# Description: file called with "tyto sidebar"\n' + \
|
||||
'# Description: file used with "tyto wip/publish"\n' + \
|
||||
'# (articles\'s list)\n' + \
|
||||
'# File: %s\n'%db.sidebar_load + \
|
||||
'# Commands: tyto new sidebar (reset)\n' + \
|
||||
|
@ -682,9 +679,6 @@ def create_navbar(option):
|
|||
if not os.path.exists(db.wip_navbar):
|
||||
tyto.set_file(db.wip_navbar, 'new', '')
|
||||
print(' ├ Create empty file: %s'%db.wip_navbar)
|
||||
if not os.path.exists(db.www_navbar):
|
||||
tyto.set_file(db.www_navbar, 'new', '')
|
||||
print(' ├ Create empty file: %s'%db.www_navbar)
|
||||
|
||||
# Create new file, or ask if exists
|
||||
ask = ' ├ Reset navbar configuration file ? '
|
||||
|
@ -702,18 +696,18 @@ def create_navbar(option):
|
|||
# French navbar_load content
|
||||
nav_load_fr = '# Pour : Tyto - Littérateur\n' + \
|
||||
'# Type : fichier texte\n' + \
|
||||
'# Description : Fichier utilisé par "tyto wip"\n' + \
|
||||
'# Description : Fichier utilisé par "tyto wip/publish"\n' + \
|
||||
'# (Liste des catégories)\n' + \
|
||||
'# Fichier : %s\n'%db.navbar_load + \
|
||||
'# Comment : 1 nom de dossier par ligne *1\n' + \
|
||||
'# (depuis articles/)\n' + \
|
||||
'# Ne commence pas par "/"\n' + \
|
||||
'# L\'ordre définit la position\n' + \
|
||||
'# Note: Pour éviter l\'erreur 404 :\n' + \
|
||||
'# Note : Pour éviter l\'erreur 404 :\n' + \
|
||||
'# - ajouter un article index.{ext}\n' + \
|
||||
'# dans le dossier mentionné\n' + \
|
||||
'# - utiliser check et wip dessus\n' + \
|
||||
'# Option *1: Pour définir un titre de lien :\n' + \
|
||||
'# *1 Option : Pour définir un titre de lien :\n' + \
|
||||
'# - ajouter "# titre de lien"\n' + \
|
||||
'\n# %s\n'%(15 * "-") +\
|
||||
'# Exemples :\n' + \
|
||||
|
@ -724,7 +718,7 @@ def create_navbar(option):
|
|||
# English navbar_load content
|
||||
nav_load_en = '# For: Tyto - Littérateur\n' + \
|
||||
'# Type: Text file\n' + \
|
||||
'# Description: file used with "tyto wip"\n' + \
|
||||
'# Description: file used with "tyto wip/publish"\n' + \
|
||||
'# (categories\'s list)\n' + \
|
||||
'# File : %s\n'%db.navbar_load + \
|
||||
'# Comment: 1 folder name per line *1\n' + \
|
||||
|
@ -735,7 +729,7 @@ def create_navbar(option):
|
|||
'# - add index.{ext} file article\n' + \
|
||||
'# in set folder\n' + \
|
||||
'# - check and wip it\n' + \
|
||||
'# Option *1: To define a title link:' + \
|
||||
'# *1 Option : To define a title link:' + \
|
||||
'# - add "# title link"\n' + \
|
||||
'\n# %s\n'%(15 * "-") +\
|
||||
'# Examples :\n' + \
|
||||
|
@ -763,54 +757,52 @@ def create_metas(option):
|
|||
# Set metas_load default content
|
||||
#-------------------------------
|
||||
metas_tags = \
|
||||
'<!-- Custom HTML metas for all pages\n' + \
|
||||
'# Custom HTML metas for all pages\n' + \
|
||||
'# You can add/edit HTML tags\n' + \
|
||||
'# ! Only <meta > and <link > lines are used !\n' + \
|
||||
'# After editing, use "tyto wip/publish metas"\n' + \
|
||||
'# (You should not copy this file to template)' + \
|
||||
'# (You should NOT copy this file to template)\n' + \
|
||||
'\n' + \
|
||||
'# Already set metas with values:\n' + \
|
||||
'# <meta charset="UTF-8">\n' + \
|
||||
'# <meta name="viewport" ...>\n' + \
|
||||
'# <meta name=”url” ...>\n' + \
|
||||
'# <meta name="language" ...>\n' + \
|
||||
'# <meta name="reply-to" ...>\n' + \
|
||||
'# <meta name="copyright" ...>\n' + \
|
||||
'# <meta name="generator" ...>\n' + \
|
||||
'# <meta name="title" ...>\n' + \
|
||||
'# <meta name="author" ...>\n' + \
|
||||
'# <meta name="description" ...>\n' + \
|
||||
'# <meta name="keywords" ...>\n' + \
|
||||
'# <meta name="search_date" ...>\n' + \
|
||||
'# <link rel="canonical" ..." />\n' + \
|
||||
'# <link rel="alternate" ..." /> # RSS\n' + \
|
||||
'# <link rel="stylesheet" ... />\n' + \
|
||||
'# <link rel="shortcut icon" ... />\n' + \
|
||||
'# <link rel="me" ... > # if profile url in config\n' + \
|
||||
'# <meta name="viewport" ...\n' + \
|
||||
'# <meta name=”url” ...\n' + \
|
||||
'# <meta name="language" ...\n' + \
|
||||
'# <meta name="reply-to" ...\n' + \
|
||||
'# <meta name="copyright" ...\n' + \
|
||||
'# <meta name="generator" ...\n' + \
|
||||
'# <meta name="title" ...\n' + \
|
||||
'# <meta name="author" ...\n' + \
|
||||
'# <meta name="description" ...\n' + \
|
||||
'# <meta name="keywords" ...\n' + \
|
||||
'# <meta name="search_date" ...\n' + \
|
||||
'# <link rel="canonical" ...\n' + \
|
||||
'# <link rel="alternate" ... # RSS\n' + \
|
||||
'# <link rel="stylesheet" ...\n' + \
|
||||
'# <link rel="shortcut icon" ...\n' + \
|
||||
'# <link rel="me" ... # if profile url in config\n' + \
|
||||
'\n' + \
|
||||
'# Open Graph data\n' + \
|
||||
'# <meta property="og:site_name" ... />\n' + \
|
||||
'# <meta property="og:title" ... />\n' + \
|
||||
'# <meta property="og:type" ... />\n' + \
|
||||
'# <meta property="og:url" ... />\n' + \
|
||||
'# <meta property="og:description" ... />\n' + \
|
||||
'# <meta property="og:image" ... />\n' + \
|
||||
'-->\n' + \
|
||||
'<meta name="robots" content="all">\n' + \
|
||||
'<meta name="medium" content="website">\n' + \
|
||||
'<meta name="revisit-after" content="3 days">'
|
||||
'# <meta property="og:site_name" ...\n' + \
|
||||
'# <meta property="og:title" ...\n' + \
|
||||
'# <meta property="og:type" ...\n' + \
|
||||
'# <meta property="og:url" ...\n' + \
|
||||
'# <meta property="og:description" ...\n' + \
|
||||
'# <meta property="og:image" ...\n\n' + \
|
||||
'<meta charset="UTF-8" />\n' + \
|
||||
'<meta name="robots" content="all" />\n' + \
|
||||
'<meta name="medium" content="website" />\n' + \
|
||||
'<meta name="revisit-after" content="3 days" />'
|
||||
|
||||
metas_srvs = \
|
||||
' <meta name="robots" content="all">\n' + \
|
||||
' <meta name="medium" content="website">\n' + \
|
||||
' <meta name="revisit-after" content="3 days">'
|
||||
' <meta charset="UTF-8" />\n' + \
|
||||
' <meta name="robots" content="all" />\n' + \
|
||||
' <meta name="medium" content="website" />\n' + \
|
||||
' <meta name="revisit-after" content="3 days" />'
|
||||
|
||||
# Create an empty html file in wip/www server if not exists
|
||||
if not os.path.exists(db.wip_metas):
|
||||
tyto.set_file(db.wip_metas, 'new', metas_srvs)
|
||||
print(' ├ Create empty file: %s'%db.wip_metas)
|
||||
if not os.path.exists(db.www_metas):
|
||||
tyto.set_file(db.www_metas, 'new', metas_srvs)
|
||||
print(' ├ Create empty file: %s'%db.www_metas)
|
||||
|
||||
# Create new default file, or ask if exists
|
||||
ask = ' ├ Reset metas configuration file ? '
|
||||
|
@ -840,9 +832,6 @@ def create_footer(option):
|
|||
if not os.path.exists(db.wip_footer):
|
||||
tyto.set_file(db.wip_footer, 'new', '')
|
||||
print(' ├ Create empty file: %s'%db.wip_footer)
|
||||
if not os.path.exists(db.www_footer):
|
||||
tyto.set_file(db.www_footer, 'new', '')
|
||||
print(' ├ Create empty file: %s'%db.www_footer)
|
||||
|
||||
# Create new default file, or ask if exists
|
||||
ask = ' ├ Reset footer configuration file ? '
|
||||
|
@ -923,15 +912,16 @@ def create_footer(option):
|
|||
|
||||
# Final HTML footer code
|
||||
footer = \
|
||||
'<!-- Default <footer> generated by %s\n'%tyto.Tyto + \
|
||||
' file: /articles/_configs/tyto.footer.html\n' + \
|
||||
' Type: "tyto wip/publish footer"\n' + \
|
||||
' to use this default configuration on your website,\n' + \
|
||||
' or change it to create your own on your website.\n' + \
|
||||
' Type: "tyto new footer"\n' + \
|
||||
' to reset it (you\'ll have to confirm)\n' + \
|
||||
' Type: tyto edit footer to edit this configuration\n' + \
|
||||
'-->\n' + \
|
||||
'# Default <footer> generated by %s\n'%tyto.Tyto + \
|
||||
'# file: /articles/_configs/tyto.footer.html\n' + \
|
||||
'# Type: "tyto wip/publish footer"\n' + \
|
||||
'# to use this default configuration on your website,\n' + \
|
||||
'# or change it to create your own footer,\n' + \
|
||||
'# Please, keep Tyto\'s credits ;)\n' + \
|
||||
'# Type: "tyto new footer"\n' + \
|
||||
'# to reset it (you\'ll have to confirm)\n' + \
|
||||
'# Type: tyto edit footer to edit this configuration\n' + \
|
||||
'# (You should NOT copy this file to template)\n\n' + \
|
||||
'<footer id="footer_page">\n' + \
|
||||
' <div id="footer_infos">\n' + \
|
||||
' <h1 id="footer_site_title">%s %s\n'%(
|
||||
|
|
|
@ -66,7 +66,7 @@ def create_metas_page():
|
|||
#-----------------------
|
||||
global metas
|
||||
metas = \
|
||||
' <meta charset="UTF-8" />\n' + \
|
||||
'<!--# include virtual="/template/metas.html"-->\n'
|
||||
' <meta name="viewport" content="%s" />\n'%scale + \
|
||||
' <meta name=”url” content=”%s” />\n'%db.domain_www_url + \
|
||||
' <meta name="language" content="%s" />\n'%db.domain_lang + \
|
||||
|
@ -90,7 +90,6 @@ def create_metas_page():
|
|||
' <meta property="og:description" content="%s" />\n'%db.about + \
|
||||
' <meta property="og:image" content="%s" />\n'%db.snpic + \
|
||||
'%s'%relme + \
|
||||
'<!--# include virtual="/template/metas.html"-->\n' + \
|
||||
' <title>%s</title>'%db.title
|
||||
|
||||
|
||||
|
@ -345,10 +344,7 @@ def create_sidebar(option):
|
|||
#------------------------------------#
|
||||
def create_navbar(option):
|
||||
# Check if can process
|
||||
if not db.domain_exists \
|
||||
or db.incomplete_domain \
|
||||
or not db.domain_active:
|
||||
return
|
||||
domain.domain_needed()
|
||||
|
||||
try:
|
||||
db.navbar_load
|
||||
|
@ -370,7 +366,8 @@ def create_navbar(option):
|
|||
nolines = ('#', '/')
|
||||
navbar_lines = open(db.navbar_load, 'r').read()
|
||||
for line in navbar_lines.rsplit('\n'):
|
||||
if not line or line.startswith(nolines): continue
|
||||
if not line or line.startswith(nolines):
|
||||
continue
|
||||
|
||||
navbar_has = True
|
||||
# Get HTML title if defined (commented after)
|
||||
|
@ -392,6 +389,7 @@ def create_navbar(option):
|
|||
index_wip = False
|
||||
index_www = False
|
||||
for f in os.listdir(dir_uri):
|
||||
# An index file must be in the directory
|
||||
if f.startswith("index."):
|
||||
index_src = True
|
||||
if option == 'wip':
|
||||
|
@ -408,9 +406,11 @@ def create_navbar(option):
|
|||
index_www = True
|
||||
else:
|
||||
break
|
||||
|
||||
if not index_src:
|
||||
logs.out("26", 'in "%s": %s'%(direc, dir_uri), False)
|
||||
continue
|
||||
|
||||
if not index_wip and option == 'wip': continue
|
||||
if not index_www and option == 'www': continue
|
||||
|
||||
|
@ -514,7 +514,7 @@ def create_user_footer(option):
|
|||
user_footer = ''
|
||||
user_file = open(db.footer_load, 'r').read()
|
||||
for line in user_file.rsplit('\n'):
|
||||
if not line: continue
|
||||
if not line or line.startswith('#'): continue
|
||||
if user_footer: user_footer = "%s\n %s"%(user_footer, line)
|
||||
else: user_footer = ' %s'%line
|
||||
|
||||
|
|
|
@ -35,27 +35,28 @@ def tyto(target):
|
|||
db_domains = '%s/.local/tyto'%os.path.expanduser('~')
|
||||
user = os.environ.get('USER')
|
||||
hashdomain = False
|
||||
print('# Registred domains for', user)
|
||||
for folder in os.listdir(db_domains):
|
||||
if os.path.isdir('%s/%s'%(db_domains, folder)):
|
||||
if hashdomain:
|
||||
hasdomain = False
|
||||
hashdomain = True
|
||||
print('# Registred domains for', user)
|
||||
print('-', folder)
|
||||
|
||||
print(' -', folder)
|
||||
except:
|
||||
noinfo = True
|
||||
print(':< No .../.local/tyto')
|
||||
|
||||
# Show Usage
|
||||
print(
|
||||
'\nUsage: tyto [action] [target] \n'
|
||||
' After created domain (tyto new domain [URL]),\n'
|
||||
' create article\'s file in articles/ directory.\n'
|
||||
' Use this actions on article\'s file: Check > wip > publish\n'
|
||||
' Config\'s files are in _configs/ directory,\n'
|
||||
' and used to create HTML file in your template.\n\n'
|
||||
'- [action] according to [target]:\n'
|
||||
'\n# New domain:\n'
|
||||
' - Create your domain folder, and go in\n'
|
||||
' - Create domain with "tyto new domain [URL]"\n'
|
||||
' - Create article\'s file in articles/ directory\n'
|
||||
' - Use these actions on article\'s file: Check > wip > publish\n'
|
||||
' ! Config\'s files are in _configs/ directory\n'
|
||||
' and used to create HTML file in your template\n\n'
|
||||
'# Usage: tyto [action] [target] \n'
|
||||
' - [action] according to [target]:\n'
|
||||
' edit : Edit article\'s file\n'
|
||||
' edit-db : Edit article\'s database (TAKE CARE !)\n'
|
||||
' edit-wip: Edit html file in wip server\n'
|
||||
|
@ -68,21 +69,21 @@ def tyto(target):
|
|||
' check : Check if article is valid\n'
|
||||
' wip : Create page in wip server\n'
|
||||
' publish : Create page in www server\n\n'
|
||||
'- [target] according to [action]\n'
|
||||
' all : Convert again all already converted articles'
|
||||
' - [target] according to [action]\n'
|
||||
' all : Convert again all already converted articles\n'
|
||||
' domain : Create/Show config file\n'
|
||||
' [file] : URI of an article\'s file (autocompletion is your friend)\n'
|
||||
' footer : Create/Show footer HTML config\'s file\n'
|
||||
' metas : Create/Show metas HTML config\'s file\n'
|
||||
' navbar : Create/Show navbar config\'s file\n'
|
||||
' sidebar : Create/Show sidebar config\'s file\n\n'
|
||||
'Examples:\n'
|
||||
'- Check article\'s syntax: tyto check mysubdir/index.tyto\n'
|
||||
'- Create default _configs/tyto.sidebar: tyto new sidebar\n'
|
||||
'- Edit _configs/tyto.navbar: tyto edit navbar\n'
|
||||
'- Edit index.html in www server: tyto edit-www index.tyto\n'
|
||||
'- Create sidebar.html in wip server: tyto wip sidebar\n'
|
||||
'- Show sidebar.html in wip server: tyto show-wip sidebar\n'
|
||||
'- Create navbar.html in www server: tyto publish navbar\n'
|
||||
'- Show navbar.html in www server: tyto show-www navbar\n'
|
||||
'# Examples:\n'
|
||||
' - Check article\'s syntax: tyto check mysubdir/index.tyto\n'
|
||||
' - Create default _configs/tyto.sidebar: tyto new sidebar\n'
|
||||
' - Edit _configs/tyto.navbar: tyto edit navbar\n'
|
||||
' - Edit index.html in www server: tyto edit-www index.tyto\n'
|
||||
' - Create sidebar.html in wip server: tyto wip sidebar\n'
|
||||
' - Show sidebar.html in wip server: tyto show-wip sidebar\n'
|
||||
' - Create navbar.html in www server: tyto publish navbar\n'
|
||||
' - Show navbar.html in www server: tyto show-www navbar\n'
|
||||
)
|
||||
|
|
|
@ -23,7 +23,8 @@ from hashlib import blake2b
|
|||
import db, logs
|
||||
domain_active = False
|
||||
home_dir = os.path.expanduser('~')
|
||||
in_dir = os.getcwd()
|
||||
try: in_dir = os.getcwd()
|
||||
except: logs.out("13", '', True)
|
||||
domain_conf = in_dir
|
||||
|
||||
# Set translations: french, english
|
||||
|
|
Loading…
Reference in New Issue