indev: external html config file manage
This commit is contained in:
parent
3b501b75fe
commit
73546b5966
|
@ -26,7 +26,7 @@
|
||||||
import sys
|
import sys
|
||||||
sys.path.insert(0, '/var/lib/tyto/program')
|
sys.path.insert(0, '/var/lib/tyto/program')
|
||||||
|
|
||||||
import check, domain, wip, navbars
|
import check, domain, wip, html
|
||||||
|
|
||||||
#====================#
|
#====================#
|
||||||
# MAIN #
|
# MAIN #
|
||||||
|
@ -45,8 +45,10 @@ actions = {
|
||||||
'check' : check.manage_check,
|
'check' : check.manage_check,
|
||||||
'wip' : wip.manage_wip,
|
'wip' : wip.manage_wip,
|
||||||
'domain' : domain.manage_domain,
|
'domain' : domain.manage_domain,
|
||||||
'sidebar' : navbars.manage_navbars,
|
'sidebar' : html.manage_configs,
|
||||||
'navbar' : navbars.manage_navbars
|
'navbar' : html.manage_configs,
|
||||||
|
'metas' : html.manage_configs,
|
||||||
|
'footer' : html.manage_configs
|
||||||
}
|
}
|
||||||
|
|
||||||
# Dict for Options
|
# Dict for Options
|
||||||
|
|
|
@ -19,7 +19,7 @@
|
||||||
|
|
||||||
import os, locale
|
import os, locale
|
||||||
|
|
||||||
import tyto
|
import tyto, html
|
||||||
|
|
||||||
#==========================#
|
#==========================#
|
||||||
# Manage Argument 'domain' #
|
# Manage Argument 'domain' #
|
||||||
|
@ -107,16 +107,19 @@ def create_domain(target, option):
|
||||||
|
|
||||||
|
|
||||||
db_dir = '%s/.local/tyto/%s/'%(tyto.home_dir, domain_short)
|
db_dir = '%s/.local/tyto/%s/'%(tyto.home_dir, domain_short)
|
||||||
navbars_conf= '%sarticles/navbars/'%tyto.conf_dir
|
navbars_conf= '%sarticles/_configs/'%tyto.conf_dir
|
||||||
conf_domain = 'domain_dir = "%s"\n'%tyto.conf_dir + \
|
conf_domain = 'domain_dir = "%s"\n'%tyto.conf_dir + \
|
||||||
'domain_conf = "%s"\n'%tyto.domain_conf + \
|
'domain_conf = "%s"\n'%tyto.domain_conf + \
|
||||||
'domain_articles = "%sarticles/"\n'%tyto.conf_dir + \
|
'domain_articles = "%sarticles/"\n'%tyto.conf_dir + \
|
||||||
'domain_files = "%sarticles/files/"\n'%tyto.conf_dir + \
|
'domain_files = "%sarticles/files/"\n'%tyto.conf_dir + \
|
||||||
'domain_images = "%sarticles/images/"\n'%tyto.conf_dir + \
|
'domain_images = "%sarticles/images/"\n'%tyto.conf_dir + \
|
||||||
'domain_db = "%sarticles/"\n'%(db_dir) + \
|
'domain_db = "%sarticles/"\n'%(db_dir) + \
|
||||||
|
'html_db = "%shtml/"\n'%(db_dir) + \
|
||||||
'navbars_dir = "%s"\n'%navbars_conf + \
|
'navbars_dir = "%s"\n'%navbars_conf + \
|
||||||
'navbar_load = "%styto.navbar"\n'%navbars_conf + \
|
'navbar_load = "%styto.navbar"\n'%navbars_conf + \
|
||||||
'sidebar_load = "%styto.sidebar"\n'%navbars_conf + \
|
'sidebar_load = "%styto.sidebar"\n'%navbars_conf + \
|
||||||
|
'metas_load = "%styto.metas.html"\n'%navbars_conf + \
|
||||||
|
'footer_load = "%styto.footer.html"\n'%navbars_conf + \
|
||||||
'\ndomain_short = "%s"\n'%domain_short + \
|
'\ndomain_short = "%s"\n'%domain_short + \
|
||||||
'domain_url = "%s"\n'%domain_url + \
|
'domain_url = "%s"\n'%domain_url + \
|
||||||
'domain_wipurl = "%s"\n'%domain_wipurl
|
'domain_wipurl = "%s"\n'%domain_wipurl
|
||||||
|
@ -416,7 +419,7 @@ def create_domain(target, option):
|
||||||
srv_wip_tpl, srv_wip_images, srv_wip_files,
|
srv_wip_tpl, srv_wip_images, srv_wip_files,
|
||||||
srv_www_tpl, srv_www_images, srv_www_files,
|
srv_www_tpl, srv_www_images, srv_www_files,
|
||||||
domain_files, domain_images, navbars_dir,
|
domain_files, domain_images, navbars_dir,
|
||||||
domain_db,
|
domain_db, html_db
|
||||||
)
|
)
|
||||||
|
|
||||||
print(' │')
|
print(' │')
|
||||||
|
@ -428,9 +431,14 @@ def create_domain(target, option):
|
||||||
|
|
||||||
# Create tyto.sidebar and metas.html
|
# Create tyto.sidebar and metas.html
|
||||||
print(' │')
|
print(' │')
|
||||||
create_sidebar(option, navbars_dir)
|
create_sidebar(option)
|
||||||
create_navbar(option, navbars_dir)
|
html.manage_configs('sidebar', '-n')
|
||||||
create_metas_file(srv_wip_tpl)
|
create_navbar(option)
|
||||||
|
html.manage_configs('navbar', '-n')
|
||||||
|
create_metas_file(option)
|
||||||
|
html.manage_configs('metas', '-n')
|
||||||
|
html.create_footer(option)
|
||||||
|
html.manage_configs('footer', '-n')
|
||||||
|
|
||||||
print(' │')
|
print(' │')
|
||||||
print(' ├──────────────────────────────────────┐')
|
print(' ├──────────────────────────────────────┐')
|
||||||
|
@ -441,21 +449,13 @@ def create_domain(target, option):
|
||||||
#========================================#
|
#========================================#
|
||||||
# Create metas.html with default content #
|
# Create metas.html with default content #
|
||||||
#----------------------------------------#
|
#----------------------------------------#
|
||||||
def create_metas_file(srv_wip_tpl):
|
def create_metas_file(option):
|
||||||
metas_file = '%smetas.html'%srv_wip_tpl
|
metas_load = tyto.metas_load
|
||||||
if os.path.exists(metas_file):
|
metas_tags = '<!-- Custom HTML metas for all pages\n' + \
|
||||||
ask = ''
|
'# You can add/edit HTML tags\n' + \
|
||||||
ask = input(' ├ Initialize default metas.html ? ')
|
|
||||||
if not ask in ['y', 'Y']:
|
|
||||||
return
|
|
||||||
|
|
||||||
metas_tags = '# Custom metas\n' + \
|
|
||||||
'# You can add HTML meta tags or edit them\n' + \
|
|
||||||
'# As Tyto makes static pages,\n' + \
|
|
||||||
'# for any changes, you will have to commands:\n' + \
|
|
||||||
'# "tyto wip again" and "tyto publish again"\n' + \
|
|
||||||
'# to apply new changes to your live articles.\n' + \
|
|
||||||
'# ! Only <meta > and <link > lines are used !\n' + \
|
'# ! Only <meta > and <link > lines are used !\n' + \
|
||||||
|
'# After editing, use "tyto metas -n"\n' + \
|
||||||
|
'# (You should not copy this file to template)' + \
|
||||||
'\n' + \
|
'\n' + \
|
||||||
'# Already set metas with values:\n' + \
|
'# Already set metas with values:\n' + \
|
||||||
'# <meta charset="UTF-8">\n' + \
|
'# <meta charset="UTF-8">\n' + \
|
||||||
|
@ -475,29 +475,42 @@ def create_metas_file(srv_wip_tpl):
|
||||||
'# <link rel="stylesheet" ... />\n' + \
|
'# <link rel="stylesheet" ... />\n' + \
|
||||||
'# <link rel="shortcut icon" ... />\n' + \
|
'# <link rel="shortcut icon" ... />\n' + \
|
||||||
'# <link rel="me" ... > # if profile url in config\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="robots" content="all">\n' + \
|
||||||
'<meta name="medium" content="website">\n' + \
|
'<meta name="medium" content="website">\n' + \
|
||||||
'<meta name="revisit-after" content="3 days">'
|
'<meta name="revisit-after" content="3 days">'
|
||||||
|
|
||||||
tyto.set_file(metas_file, True, metas_tags)
|
|
||||||
print(' ├ Create file: %s'%metas_file)
|
# Create new file, or ask if exists
|
||||||
print(' │ ! Check this file, before starting !')
|
ask = ' ├ Use default tyto.metas.html ? '
|
||||||
|
log = ' ├ Create file: %s'%metas_load
|
||||||
|
|
||||||
|
if os.path.exists(metas_load):
|
||||||
|
if option == '-i': return # Continue to create template/metas.html
|
||||||
|
res = input(ask)
|
||||||
|
if not res in ['y', 'Y']: return
|
||||||
|
|
||||||
|
tyto.set_file(metas_load, 'new', metas_tags)
|
||||||
|
print(log)
|
||||||
|
|
||||||
|
|
||||||
#==============================#
|
#==============================#
|
||||||
# sidebar load file translated #
|
# sidebar load file translated #
|
||||||
#------------------------------#
|
#------------------------------#
|
||||||
def create_sidebar(opt, navbars_dir):
|
def create_sidebar(option):
|
||||||
try: sidebar_load
|
sidebar_load = tyto.sidebar_load
|
||||||
except: sidebar_load = "%styto.sidebar"%navbars_dir
|
|
||||||
|
|
||||||
sdb_load_fr = '# Pour : Tyto - Littérateur\n' + \
|
sdb_load_fr = '# Pour : Tyto - Littérateur\n' + \
|
||||||
'# Type : fichier texte\n' + \
|
'# Type : fichier texte\n' + \
|
||||||
'# Description : Fichier appelé par "tyto sidebar"\n' + \
|
'# Description : Fichier appelé par "tyto sidebar"\n' + \
|
||||||
'# (Liste d\'articles)\n' + \
|
'# (Liste d\'articles)\n' + \
|
||||||
'# Fichier : tyto.sidebar\n' + \
|
'# Fichier : %s\n'%sidebar_load + \
|
||||||
'# Dossier : %s\n'%navbars_dir + \
|
|
||||||
'# Comment : 1 URI de l\'article par ligne\n' + \
|
'# Comment : 1 URI de l\'article par ligne\n' + \
|
||||||
'# (depuis articles/)\n' + \
|
'# (depuis articles/)\n' + \
|
||||||
'# Ne commence pas par "/"\n' + \
|
'# Ne commence pas par "/"\n' + \
|
||||||
|
@ -512,8 +525,7 @@ def create_sidebar(opt, navbars_dir):
|
||||||
'# Type: Text file\n' + \
|
'# Type: Text file\n' + \
|
||||||
'# Description: file called with "tyto sidebar"\n' + \
|
'# Description: file called with "tyto sidebar"\n' + \
|
||||||
'# (articles\'s list)\n' + \
|
'# (articles\'s list)\n' + \
|
||||||
'# File: tyto.sidebar\n' + \
|
'# File: %s\n'%sidebar_load + \
|
||||||
'# Directory: %s\n'%navbars_dir + \
|
|
||||||
'# Comment: 1 article URI per line\n' + \
|
'# Comment: 1 article URI per line\n' + \
|
||||||
'# (from articles/)\n' + \
|
'# (from articles/)\n' + \
|
||||||
'# not begining with "/"\n' + \
|
'# not begining with "/"\n' + \
|
||||||
|
@ -527,29 +539,30 @@ def create_sidebar(opt, navbars_dir):
|
||||||
if tyto.n == 0: sdb_load = sdb_load_fr
|
if tyto.n == 0: sdb_load = sdb_load_fr
|
||||||
elif tyto.n == 1: sdb_load = sdb_load_en
|
elif tyto.n == 1: sdb_load = sdb_load_en
|
||||||
|
|
||||||
if not opt == 'Remove' and os.path.exists(sidebar_load):
|
ask = ' ├ Use default (empty) sidebar config ? '
|
||||||
ask = ''
|
log = ' ├ Create file: %s'%sidebar_load
|
||||||
ask = input(' ├ Initialize new sidebar ? ')
|
|
||||||
if not ask in ['y', 'Y']:
|
# Create new file, or ask if exists
|
||||||
return
|
ask = ' ├ Use default (empty) sidebar config file ? '
|
||||||
|
log = ' ├ Create file: %s'%sidebar_load
|
||||||
|
|
||||||
|
if os.path.exists(sidebar_load):
|
||||||
|
res = input(ask)
|
||||||
|
if not res in ['y', 'Y']: return
|
||||||
|
|
||||||
tyto.set_file(sidebar_load, 'new', sdb_load)
|
tyto.set_file(sidebar_load, 'new', sdb_load)
|
||||||
print(' ├ Create file: %s'%sidebar_load)
|
print(log)
|
||||||
|
|
||||||
|
|
||||||
#=============================#
|
#=============================#
|
||||||
# navbar load file translated #
|
# navbar load file translated #
|
||||||
#-----------------------------#
|
#-----------------------------#
|
||||||
def create_navbar(opt, navbars_dir):
|
def create_navbar(option):
|
||||||
try: navbar_load
|
|
||||||
except: navbar_load = "%styto.navbar"%navbars_dir
|
|
||||||
|
|
||||||
nav_load_fr = '# Pour : Tyto - Littérateur\n' + \
|
nav_load_fr = '# Pour : Tyto - Littérateur\n' + \
|
||||||
'# Type : fichier texte\n' + \
|
'# Type : fichier texte\n' + \
|
||||||
'# Description : Fichier utilisé par "tyto wip"\n' + \
|
'# Description : Fichier utilisé par "tyto wip"\n' + \
|
||||||
'# (Liste des catégories)\n' + \
|
'# (Liste des catégories)\n' + \
|
||||||
'# Fichier : tyto.navbar\n' + \
|
'# Fichier : %s\n'%navbar_load + \
|
||||||
'# Dossier : %s\n'%navbars_dir + \
|
|
||||||
'# Comment : 1 nom de dossier par ligne *1\n' + \
|
'# Comment : 1 nom de dossier par ligne *1\n' + \
|
||||||
'# (depuis articles/)\n' + \
|
'# (depuis articles/)\n' + \
|
||||||
'# Ne commence pas par "/"\n' + \
|
'# Ne commence pas par "/"\n' + \
|
||||||
|
@ -559,19 +572,18 @@ def create_navbar(opt, navbars_dir):
|
||||||
'# dans le dossier mentionné\n' + \
|
'# dans le dossier mentionné\n' + \
|
||||||
'# - utiliser check et wip dessus\n' + \
|
'# - utiliser check et wip dessus\n' + \
|
||||||
'# Option *1: Pour définir un titre de lien :\n' + \
|
'# Option *1: Pour définir un titre de lien :\n' + \
|
||||||
'# - ajouter "= titre de lien"\n' + \
|
'# - ajouter "# titre de lien"\n' + \
|
||||||
'\n# %s\n'%(15 * "-") +\
|
'\n# %s\n'%(15 * "-") +\
|
||||||
'# Exemples :\n' + \
|
'# Exemples :\n' + \
|
||||||
'# documentation\n' + \
|
'# documentation\n' + \
|
||||||
'# a-propos = Informations concernant ce site\n' + \
|
'# a-propos # Informations concernant ce site\n' + \
|
||||||
'# %s\n\n'%(15 * "-")
|
'# %s\n\n'%(15 * "-")
|
||||||
|
|
||||||
nav_load_en = '# For: Tyto - Littérateur\n' + \
|
nav_load_en = '# For: Tyto - Littérateur\n' + \
|
||||||
'# Type: Text file\n' + \
|
'# Type: Text file\n' + \
|
||||||
'# Description: file used with "tyto wip"\n' + \
|
'# Description: file used with "tyto wip"\n' + \
|
||||||
'# (categories\'s list)\n' + \
|
'# (categories\'s list)\n' + \
|
||||||
'# File: tyto.navbar\n' + \
|
'# File : %s\n'%navbar_load + \
|
||||||
'# Directory: %s\n'%navbars_dir + \
|
|
||||||
'# Comment: 1 folder name per line *1\n' + \
|
'# Comment: 1 folder name per line *1\n' + \
|
||||||
'# (from articles/)\n' + \
|
'# (from articles/)\n' + \
|
||||||
'# not begining with "/"\n' + \
|
'# not begining with "/"\n' + \
|
||||||
|
@ -581,21 +593,23 @@ def create_navbar(opt, navbars_dir):
|
||||||
'# in set folder\n' + \
|
'# in set folder\n' + \
|
||||||
'# - check and wip it\n' + \
|
'# - check and wip it\n' + \
|
||||||
'# Option *1: To define a title link:' + \
|
'# Option *1: To define a title link:' + \
|
||||||
'# - add "= title link"\n' + \
|
'# - add "# title link"\n' + \
|
||||||
'\n# %s\n'%(15 * "-") +\
|
'\n# %s\n'%(15 * "-") +\
|
||||||
'# Examples :\n' + \
|
'# Examples :\n' + \
|
||||||
'# documentation\n' + \
|
'# documentation\n' + \
|
||||||
'# about = infos about this website\n' + \
|
'# about # infos about this website\n' + \
|
||||||
'# %s\n\n'%(15 * "-")
|
'# %s\n\n'%(15 * "-")
|
||||||
|
|
||||||
if tyto.n == 0: nav_load = nav_load_fr
|
if tyto.n == 0: nav_load = nav_load_fr
|
||||||
elif tyto.n == 1: nav_load = nav_load_en
|
elif tyto.n == 1: nav_load = nav_load_en
|
||||||
|
|
||||||
if not opt == 'Remove' and os.path.exists(navbar_load):
|
# Create new file, or ask if exists
|
||||||
ask = ''
|
ask = ' ├ Use default (empty) navbar config file ? '
|
||||||
ask = input(' ├ Initialize new navbar ? ')
|
log = ' ├ Create file: %s'%navbar_load
|
||||||
if not ask in ['y', 'Y']:
|
|
||||||
return
|
if os.path.exists(navbar_load):
|
||||||
|
res = input(ask)
|
||||||
|
if not res in ['y', 'Y']: return
|
||||||
|
|
||||||
tyto.set_file(navbar_load, 'new', nav_load)
|
tyto.set_file(navbar_load, 'new', nav_load)
|
||||||
print(' ├ Create file: %s'%navbar_load)
|
print(log)
|
||||||
|
|
|
@ -16,19 +16,52 @@
|
||||||
#----------------------------------------------------------------------
|
#----------------------------------------------------------------------
|
||||||
|
|
||||||
#**********************************************************************
|
#**********************************************************************
|
||||||
import os
|
import os, sys
|
||||||
|
|
||||||
import tyto
|
import tyto, domain, html
|
||||||
|
|
||||||
# Load domain configuration DB
|
# Load domain configuration DB
|
||||||
exec(open(tyto.domain_conf).read())
|
exec(open(tyto.domain_conf).read())
|
||||||
|
|
||||||
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'
|
||||||
tytoweb = 'https://tyto.echolib.re'
|
Tytogti = 'Dépôt officiel du code source de Tyto - Littérateur'
|
||||||
|
Tytoweb = 'https://tyto.echolib.re'
|
||||||
|
Tytowti = 'Site web officiel du logiciel Tyto - Littérateur'
|
||||||
|
Tytosrc = '(<a href="%s" '%Tytogit + \
|
||||||
|
'title="%s" '%Tytogti + \
|
||||||
|
'id="footer_item_link">Code source</a>)'
|
||||||
|
|
||||||
navbar_file = '%snavbar.html'%srv_wip_tpl
|
navbar_file = '%snavbar.html'%srv_wip_tpl
|
||||||
|
|
||||||
|
#
|
||||||
|
# Manage fies for HTML
|
||||||
|
# (sidebar, metas, footer, navbar)
|
||||||
|
#
|
||||||
|
def manage_configs(target, option):
|
||||||
|
|
||||||
|
args1 = ('metas', 'sidebar', 'footer', 'navbar')
|
||||||
|
args2 = ('-n', '-e', '-R')
|
||||||
|
opts = ('New', 'Edit', 'Remove')
|
||||||
|
|
||||||
|
if target in args1: sys.argv[1] = target
|
||||||
|
elif target and not option: option = target
|
||||||
|
if not sys.argv[1] in args1: tyto.exiting('11', '%s'%str(args1), True)
|
||||||
|
if not option in opts and not option == '-i' and not option in args2:
|
||||||
|
tyto.exiting('11', '%s'%str(args2), True)
|
||||||
|
|
||||||
|
# Getting default file
|
||||||
|
if option == 'New':
|
||||||
|
actions = {
|
||||||
|
'sidebar' : domain.create_sidebar,
|
||||||
|
'navbar' : domain.create_navbar,
|
||||||
|
'metas' : create_user_metas,
|
||||||
|
'footer' : html.create_footer
|
||||||
|
}
|
||||||
|
|
||||||
|
actions[sys.argv[1]](option)
|
||||||
|
|
||||||
|
|
||||||
#==========================#
|
#==========================#
|
||||||
# Load article DB #
|
# Load article DB #
|
||||||
# Start HTML page sections #
|
# Start HTML page sections #
|
||||||
|
@ -49,7 +82,6 @@ def create_metas_page():
|
||||||
# Settings for metas
|
# Settings for metas
|
||||||
#-------------------
|
#-------------------
|
||||||
metas_page = ''
|
metas_page = ''
|
||||||
tab = 4
|
|
||||||
scale = 'width=device-width, initial-scale=1.0'
|
scale = 'width=device-width, initial-scale=1.0'
|
||||||
all_tags = domain_tags + ',' + tags
|
all_tags = domain_tags + ',' + tags
|
||||||
post_url = domain_url + http_uri
|
post_url = domain_url + http_uri
|
||||||
|
@ -61,7 +93,7 @@ def create_metas_page():
|
||||||
sub_uri, rss_file, domain_title, domain_sep, domain_short
|
sub_uri, rss_file, domain_title, domain_sep, domain_short
|
||||||
)
|
)
|
||||||
icon_file = 'favicon.png'
|
icon_file = 'favicon.png'
|
||||||
icon_ref = 'type="image/png" href="%s%s"'%(sub_uri, icon_file)
|
icon_ref = 'type="image/png" href="%stemplate/%s"'%(sub_uri, icon_file)
|
||||||
en_date = tyto.set_en_date(date[0])
|
en_date = tyto.set_en_date(date[0])
|
||||||
relme = '' # External URL in metas (if exists in config domain)
|
relme = '' # External URL in metas (if exists in config domain)
|
||||||
if domain_relme:
|
if domain_relme:
|
||||||
|
@ -69,54 +101,38 @@ def create_metas_page():
|
||||||
domain_relme
|
domain_relme
|
||||||
)
|
)
|
||||||
|
|
||||||
# Check for user metas from wip template/metas.html
|
|
||||||
#--------------------------------------------------
|
|
||||||
metas_file = '%smetas.html'%srv_wip_tpl
|
|
||||||
user_metas = ''
|
|
||||||
metas_used = ('<meta ', '<link ')
|
|
||||||
|
|
||||||
try:
|
|
||||||
user_file = open(metas_file, 'r').read()
|
|
||||||
tyto.exiting("25", 'metas from: %s'%metas_file, False)
|
|
||||||
|
|
||||||
for line in user_file.rsplit('\n'):
|
|
||||||
if line.startswith(metas_used):
|
|
||||||
if user_metas: user_metas = "%s\n%s"%(user_metas, line)
|
|
||||||
else: user_metas = '\n%s'%line
|
|
||||||
user_metas = '%s\n'%user_metas
|
|
||||||
except:
|
|
||||||
tyto.exiting("24", '(metas file): %s'%metas_file, False)
|
|
||||||
|
|
||||||
|
|
||||||
# Set all raw HTML metas
|
# Set all raw HTML metas
|
||||||
#-----------------------
|
#-----------------------
|
||||||
metas = '<meta charset="UTF-8">\n' + \
|
global metas
|
||||||
'<meta name="viewport" content="%s">\n'%scale + \
|
metas = ' <meta charset="UTF-8" />\n' + \
|
||||||
'<meta name=”url” content=”%s”>\n'%domain_url + \
|
' <meta name="viewport" content="%s" />\n'%scale + \
|
||||||
'<meta name="language" content="%s">\n'%domain_lang + \
|
' <meta name=”url” content=”%s” />\n'%domain_url + \
|
||||||
'<meta name="reply-to" content="%s">\n'%domain_mail + \
|
' <meta name="language" content="%s" />\n'%domain_lang + \
|
||||||
'<meta name="copyright" content="%s">\n'%domain_license + \
|
' <meta name="reply-to" content="%s" />\n'%domain_mail + \
|
||||||
'<meta name="generator" content="%s">\n'%Tyto + \
|
' <meta name="copyright" content="%s" />\n'%domain_license + \
|
||||||
'<meta name="title" content="%s">\n'%title + \
|
' <meta name="generator" content="%s" />\n'%Tyto + \
|
||||||
'<meta name="author" content="%s">\n'%author + \
|
' <meta name="title" content="%s" />\n'%title + \
|
||||||
'<meta name="description" content="%s">\n'%about + \
|
' <meta name="author" content="%s" />\n'%author + \
|
||||||
'<meta name="keywords" content="%s">\n'%all_tags + \
|
' <meta name="description" content="%s" />\n'%about + \
|
||||||
'<meta name="search_date" content="%s">\n'%en_date + \
|
' <meta name="keywords" content="%s" />\n'%all_tags + \
|
||||||
|
' <meta name="search_date" content="%s" />\n'%en_date + \
|
||||||
' <link rel="canonical" href="%s" />\n'%post_url + \
|
' <link rel="canonical" href="%s" />\n'%post_url + \
|
||||||
' <link rel="alternate" %s />\n'%(rss_ref) + \
|
' <link rel="alternate" %s />\n'%(rss_ref) + \
|
||||||
'<link rel="stylesheet" %s\n'%css_ref + \
|
' <link rel="stylesheet" %s /\n'%css_ref + \
|
||||||
' <link rel="shortcut icon" %s />'%icon_ref + \
|
' <link rel="shortcut icon" %s />'%icon_ref + \
|
||||||
|
' <!-- Open Graph data -->\n' + \
|
||||||
|
' <meta property="og:site_name" content="%s" />\n'%domain_title + \
|
||||||
|
' <meta property="og:title" content="%s" />\n'%title + \
|
||||||
|
' <meta property="og:type" content="article" />\n' + \
|
||||||
|
' <meta property="og:url" content="%s" />\n'%post_url + \
|
||||||
|
' <meta property="og:description" content="Description Here" />\n' + \
|
||||||
|
' <meta property="og:image" content="" />\n' + \
|
||||||
'%s'%relme + \
|
'%s'%relme + \
|
||||||
user_metas + \
|
'\n<!--# include virtual="/template/metas.html"-->\n' + \
|
||||||
' <title>%s</title>'%title
|
' <title>%s</title>'%title
|
||||||
|
|
||||||
|
|
||||||
# Create HTML tabulation for metas
|
|
||||||
#---------------------------------
|
|
||||||
for line in metas.rsplit('\n'):
|
|
||||||
if metas_page: metas_page = '%s\n%s%s'%(metas_page, tab * ' ', line)
|
|
||||||
else: metas_page = '%s%s'%(tab * ' ', line)
|
|
||||||
|
|
||||||
|
|
||||||
#=======================================#
|
#=======================================#
|
||||||
# Set main page, with all HTML sections #
|
# Set main page, with all HTML sections #
|
||||||
|
@ -136,19 +152,8 @@ def create_main_page(target, article_bottom):
|
||||||
'%sid="site_logo_image">\n'%(15 * " ") + \
|
'%sid="site_logo_image">\n'%(15 * " ") + \
|
||||||
'%s</a>'%(8 * " ")
|
'%s</a>'%(8 * " ")
|
||||||
|
|
||||||
|
|
||||||
# Check for menu bar
|
# Check for menu bar
|
||||||
# Delete file if deactivated in conf
|
create_navbar('-n', navbars_dir)
|
||||||
if domain_menubar:
|
|
||||||
if os.path.exists(navbar_file):
|
|
||||||
tyto.exiting("25", 'menu from: %s'%navbar_file, False)
|
|
||||||
else:
|
|
||||||
tyto.exiting("24", '(menu file): %s'%navbar_file, False)
|
|
||||||
else:
|
|
||||||
if os.path.exists(navbar_file) and os.stat(navbar_file).st_size > 1:
|
|
||||||
tyto.set_file(navbar_file, 'new', '')
|
|
||||||
tyto.exiting("26", 'domain_menubar', False)
|
|
||||||
tyto.exiting('27', 'contents (menu file): %s'%navbar_file, False)
|
|
||||||
|
|
||||||
#-----------------------#
|
#-----------------------#
|
||||||
# Create main HTML Page #
|
# Create main HTML Page #
|
||||||
|
@ -156,7 +161,7 @@ def create_main_page(target, article_bottom):
|
||||||
main_page = '<!Doctype html>\n' + \
|
main_page = '<!Doctype html>\n' + \
|
||||||
'<html lang="%s">\n'%domain_lang + \
|
'<html lang="%s">\n'%domain_lang + \
|
||||||
' <head>\n' + \
|
' <head>\n' + \
|
||||||
'%s\n'%metas_page + \
|
'%s\n'%metas + \
|
||||||
' </head>\n\n' + \
|
' </head>\n\n' + \
|
||||||
' <body>\n' + \
|
' <body>\n' + \
|
||||||
' <header id="header_page">\n' + \
|
' <header id="header_page">\n' + \
|
||||||
|
@ -172,27 +177,31 @@ def create_main_page(target, article_bottom):
|
||||||
' </a>\n' + \
|
' </a>\n' + \
|
||||||
' <p id="site_about">%s</p>\n'%domain_about + \
|
' <p id="site_about">%s</p>\n'%domain_about + \
|
||||||
' </div>\n' + \
|
' </div>\n' + \
|
||||||
'<!--# include virtual="/template/navbar.html"-->' + \
|
'<!--# include virtual="/template/navbar.html"-->\n' + \
|
||||||
' </header>\n' + \
|
' </header>\n' + \
|
||||||
'\n' + \
|
'\n' + \
|
||||||
' <article id="article_main">\n' + \
|
' <article id="article_main">\n' + \
|
||||||
'%s\n'%article_bottom + \
|
'%s\n'%article_bottom + \
|
||||||
' </article>\n' + \
|
' </article>\n' + \
|
||||||
'\n' + \
|
'\n' + \
|
||||||
|
'<!--# include virtual="/template/footer.html"-->\n' + \
|
||||||
' </body>\n' + \
|
' </body>\n' + \
|
||||||
'</html>'
|
'</html>'
|
||||||
|
|
||||||
|
footer_file = '%sfooter.html'%srv_wip_tpl
|
||||||
|
if not os.path.exists(footer_file):
|
||||||
|
tyto.exiting("1", footer_file, True)
|
||||||
|
|
||||||
#====================================#
|
#====================================#
|
||||||
# Create HTML menu from root folders #
|
# Create HTML menu from root folders #
|
||||||
#------------------------------------#
|
#------------------------------------#
|
||||||
def create_navbar():
|
def create_navbar(option, target):
|
||||||
# Conditions to create navbar
|
# Conditions to create navbar
|
||||||
if not domain_menubar:
|
if not domain_menubar:
|
||||||
tyto.set_file(navbar_file, 'new', '')
|
|
||||||
tyto.exiting("26", 'domain_menubar', False)
|
tyto.exiting("26", 'domain_menubar', False)
|
||||||
if os.path.exists(navbar_file) and os.stat(navbar_file).st_size > 1:
|
if os.path.exists(navbar_file) and os.stat(navbar_file).st_size > 1:
|
||||||
tyto.exiting('27', 'contents (menu file): %s'%navbar_file, False)
|
tyto.set_file(navbar_file, 'new', '')
|
||||||
|
tyto.exiting('27', 'contents (navbar): %s'%navbar_file, False)
|
||||||
return
|
return
|
||||||
|
|
||||||
# True in config
|
# True in config
|
||||||
|
@ -208,9 +217,9 @@ def create_navbar():
|
||||||
for line in nav_file.rsplit('\n'):
|
for line in nav_file.rsplit('\n'):
|
||||||
if not line or line.startswith(nolines): continue
|
if not line or line.startswith(nolines): continue
|
||||||
|
|
||||||
if '=' in line:
|
if '#' in line:
|
||||||
direc = line.rsplit('=')[0].rstrip()
|
direc = line.rsplit('#')[0].rstrip()
|
||||||
title = '%stitle="%s"\n'%(15 * ' ', line.rsplit('=')[1].lstrip())
|
title = '%stitle="%s"\n'%(15 * ' ', line.rsplit('#')[1].lstrip())
|
||||||
else:
|
else:
|
||||||
direc = line
|
direc = line
|
||||||
title = ''
|
title = ''
|
||||||
|
@ -232,4 +241,117 @@ def create_navbar():
|
||||||
|
|
||||||
# Close HTML tags
|
# Close HTML tags
|
||||||
menu_html = '\n%s\n%s</ul>\n%s</nav>\n'%(menu_html, 8 * ' ', 6 * ' ')
|
menu_html = '\n%s\n%s</ul>\n%s</nav>\n'%(menu_html, 8 * ' ', 6 * ' ')
|
||||||
tyto.set_file('%snavbar.html'%srv_wip_tpl, 'new', menu_html)
|
tyto.set_file(navbar_file, 'new', menu_html)
|
||||||
|
|
||||||
|
|
||||||
|
#
|
||||||
|
# Create metas.html from tyto.metas.html
|
||||||
|
#
|
||||||
|
def create_user_metas(option):
|
||||||
|
domain.create_metas_file("-i") # Ensure config file exists
|
||||||
|
|
||||||
|
metas_html = '%smetas.html'%srv_wip_tpl
|
||||||
|
user_metas = ''
|
||||||
|
metas_used = ('<meta ', '<link ')
|
||||||
|
log = ' ├ Create file: %s'%metas_html
|
||||||
|
|
||||||
|
try:
|
||||||
|
user_file = open(metas_load, 'r').read()
|
||||||
|
|
||||||
|
for line in user_file.rsplit('\n'):
|
||||||
|
if line.startswith(metas_used):
|
||||||
|
if user_metas: user_metas = "%s\n %s"%(user_metas, line)
|
||||||
|
else: user_metas = ' %s'%line
|
||||||
|
tyto.set_file(metas_html, 'new', user_metas)
|
||||||
|
print(log)
|
||||||
|
except:
|
||||||
|
tyto.exiting("24", '(metas file): %s'%metas_load, False)
|
||||||
|
|
||||||
|
|
||||||
|
#=========================================#
|
||||||
|
# Create generic footer from domain datas #
|
||||||
|
#-----------------------------------------#
|
||||||
|
def create_footer(option):
|
||||||
|
try:
|
||||||
|
tyto.domain_licurl
|
||||||
|
domain_licurl = tyto.domain_licurl
|
||||||
|
except:
|
||||||
|
domain_licurl = "/"
|
||||||
|
|
||||||
|
# Default footer contents
|
||||||
|
footer = '<footer id="footer_page">\n' + \
|
||||||
|
' <div id="footer_infos">\n' + \
|
||||||
|
' <a href="/"\n' + \
|
||||||
|
' title="%s"\n'%(tyto.trans[1][tyto.n]) + \
|
||||||
|
' id="footer_title_link">\n' + \
|
||||||
|
' <h1 id="footer_site_title">%s</h1>\n'%(
|
||||||
|
domain_title) + \
|
||||||
|
' </a>\n' + \
|
||||||
|
' <p id="footer_site_about">%s</p>\n'%(
|
||||||
|
domain_about) + \
|
||||||
|
' </div>\n' + \
|
||||||
|
'\n' + \
|
||||||
|
' <div id="footer_references">\n' + \
|
||||||
|
' <ul> id="footer_items"\n' + \
|
||||||
|
' <li id="fotter_item">\n' + \
|
||||||
|
' <a href="%s"\n'%domain_licurl + \
|
||||||
|
' title="%s %s %s"\n'%(
|
||||||
|
tyto.trans[2][tyto.n],
|
||||||
|
domain_sep, domain_title) + \
|
||||||
|
' id="footer_item_link">%s</a>\n'%(
|
||||||
|
domain_license) + \
|
||||||
|
' </li>\n' + \
|
||||||
|
' <li id="fotter_item">\n' + \
|
||||||
|
' <a href="%s"\n'%Tytoweb + \
|
||||||
|
' title="%s"\n'%Tytowti + \
|
||||||
|
' id="footer_item_link">%s</a> %s\n'%(Tyto, Tytosrc) + \
|
||||||
|
' </li>\n' + \
|
||||||
|
' </ul>\n' + \
|
||||||
|
' </div>\n' + \
|
||||||
|
'</footer>\n'
|
||||||
|
|
||||||
|
|
||||||
|
# Create new file, or ask if exists
|
||||||
|
ask = ' ├ Use default footer.html ? '
|
||||||
|
log = ' ├ Create file: %s'%footer_load
|
||||||
|
|
||||||
|
if os.path.exists(footer_load):
|
||||||
|
if option == '-i': return
|
||||||
|
res = input(ask)
|
||||||
|
if not res in ['y', 'Y']: return
|
||||||
|
|
||||||
|
tyto.set_file(footer_load, 'new', footer)
|
||||||
|
print(log)
|
||||||
|
|
||||||
|
'''
|
||||||
|
' <li id="fotter_item">\n' + \
|
||||||
|
' <a href="%s"\n' + \
|
||||||
|
' title="%s"\n' + \
|
||||||
|
' id="footer_item_link">%s</a>\n'% + \
|
||||||
|
' </li>\n' + \
|
||||||
|
Copyright © 2021-2022
|
||||||
|
|
||||||
|
'''
|
||||||
|
|
||||||
|
#
|
||||||
|
# Create footer.html from tyto.footer.html
|
||||||
|
#
|
||||||
|
def create_user_footer(option):
|
||||||
|
create_footer("-i") # Ensure config file exists
|
||||||
|
|
||||||
|
footer_html = '%sfooter.html'%srv_wip_tpl
|
||||||
|
user_footer = ''
|
||||||
|
noline = ('<!--')
|
||||||
|
log = ' ├ Create file: %s'%footer_html
|
||||||
|
|
||||||
|
try:
|
||||||
|
user_file = open(footer_load, 'r').read()
|
||||||
|
|
||||||
|
for line in user_file.rsplit('\n'):
|
||||||
|
if line.startswith(noline): continue
|
||||||
|
if user_metas: user_metas = "%s\n %s"%(user_metas, line)
|
||||||
|
else: user_metas = ' %s'%line
|
||||||
|
tyto.set_file(footer_html, 'new', user_footer)
|
||||||
|
print(log)
|
||||||
|
except:
|
||||||
|
tyto.exiting("24", '(metas file): %s'%footer_load, False)
|
||||||
|
|
|
@ -39,14 +39,13 @@ def manage_navbars(target, option):
|
||||||
# Initialize new file
|
# Initialize new file
|
||||||
if not target:
|
if not target:
|
||||||
if option == "Remove":
|
if option == "Remove":
|
||||||
actions[sys.argv[1]](opt, navbars_dir)
|
actions[sys.argv[1]](option, navbars_dir)
|
||||||
elif option == 'Edit':
|
elif option == 'Edit':
|
||||||
print(":D Edit %s configuration file:"%sys.argv[1], file)
|
print(":D Edit %s configuration file:"%sys.argv[1], file)
|
||||||
tyto.edit_file(file)
|
tyto.edit_file(file)
|
||||||
elif option == 'New':
|
elif option == 'New':
|
||||||
html.create_navbar()
|
html.create_navbar()
|
||||||
|
|
||||||
|
|
||||||
else:
|
else:
|
||||||
db_exists = tyto.get_db_post(target) # Article exists + has DB ?
|
db_exists = tyto.get_db_post(target) # Article exists + has DB ?
|
||||||
if not db_exists: tyto.exiting("4", '') # Needs database
|
if not db_exists: tyto.exiting("4", '') # Needs database
|
||||||
|
|
|
@ -90,8 +90,9 @@ else: n = 1
|
||||||
|
|
||||||
# Translations French/English
|
# Translations French/English
|
||||||
trans = [
|
trans = [
|
||||||
['À l\'affiche !', 'Featured !' ], #0
|
('À l\'affiche !', 'Featured !'), #0
|
||||||
['Accueil', 'Home'] #1
|
('Accueil', 'Home'), #1
|
||||||
|
('Licence', 'License') #2
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
|
@ -501,6 +502,7 @@ def exiting(nbr, value, out):
|
||||||
'8' : ':< %sNot paired%s: %s'%(CR, CS, value),
|
'8' : ':< %sNot paired%s: %s'%(CR, CS, value),
|
||||||
'9' : ':< Article %shas changed%s. Check it first'%(CR, CS),
|
'9' : ':< Article %shas changed%s. Check it first'%(CR, CS),
|
||||||
'10' : ':< %sUnused "%s"%s in article\'s header'%(CR, value, CS),
|
'10' : ':< %sUnused "%s"%s in article\'s header'%(CR, value, CS),
|
||||||
|
'11' : ':< %sUnused argument%s: %s'%(CR, CS, value),
|
||||||
'20' : ':D %sUp-to-date%s article on: %s'%(CG, CS, value),
|
'20' : ':D %sUp-to-date%s article on: %s'%(CG, CS, value),
|
||||||
'21' : ':D %sValid%s article. Ready to wip'%(CG, CS),
|
'21' : ':D %sValid%s article. Ready to wip'%(CG, CS),
|
||||||
'22' : ':? %sNot paired%s symbols: %s'%(CY, CS, value),
|
'22' : ':? %sNot paired%s symbols: %s'%(CY, CS, value),
|
||||||
|
|
|
@ -87,8 +87,6 @@ def manage_wip(target, option):
|
||||||
# Set Db #
|
# Set Db #
|
||||||
#-------------------#
|
#-------------------#
|
||||||
def wip_article(target):
|
def wip_article(target):
|
||||||
print('Convert')
|
|
||||||
|
|
||||||
# Convert file to strings
|
# Convert file to strings
|
||||||
file_to_string(target)
|
file_to_string(target)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue