HTML: set customizable metas.html from form
This commit is contained in:
parent
aa99f32c46
commit
173eb7027f
|
@ -356,15 +356,11 @@ def create_domain(target, option):
|
|||
|
||||
# Activate Domain
|
||||
#----------------
|
||||
tyto.set_file(tyto.domain_conf, False,
|
||||
'\ndomain_active = True')
|
||||
tyto.set_file(tyto.domain_conf, False, '\ndomain_active = True')
|
||||
|
||||
# Load config
|
||||
exec(open(tyto.domain_conf).read(),globals())
|
||||
|
||||
# Create sidebar
|
||||
create_sidebar(option, sidebar_dir)
|
||||
|
||||
# Create folders from configuration file
|
||||
folders = (
|
||||
srv_wip_tpl, srv_wip_images, srv_wip_files,
|
||||
|
@ -380,12 +376,64 @@ def create_domain(target, option):
|
|||
if not os.makedirs(folder, exist_ok=True):
|
||||
print(' │ Exists directory: %s'%folder)
|
||||
|
||||
# Create tyto.sidebar and metas.html
|
||||
print(' │')
|
||||
create_sidebar(option, sidebar_dir)
|
||||
create_metas_file(srv_wip_tpl)
|
||||
|
||||
print(' │')
|
||||
print(' ├──────────────────────────────────────┐')
|
||||
print(' │ Domain is ready. Have fun, writers ! │')
|
||||
print(' └──────────────────────────────────────┘')
|
||||
|
||||
|
||||
#========================================#
|
||||
# Create metas.html with default content #
|
||||
#----------------------------------------#
|
||||
def create_metas_file(srv_wip_tpl):
|
||||
metas_file = '%smetas.html'%srv_wip_tpl
|
||||
if os.path.exists(metas_file):
|
||||
ask = ''
|
||||
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' + \
|
||||
'\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' + \
|
||||
'\n' + \
|
||||
'<meta name="robots" content="all">\n' + \
|
||||
'<meta name="medium" content="website">\n' + \
|
||||
'<meta name="revisit-after" content="3 days">'
|
||||
|
||||
tyto.set_file(metas_file, True, metas_tags)
|
||||
print(' ├ Create file: %s'%metas_file)
|
||||
print(' │ ! Check this file, before starting !')
|
||||
|
||||
|
||||
#==============================#
|
||||
# sidebar load file translated #
|
||||
#------------------------------#
|
||||
|
@ -431,5 +479,4 @@ def create_sidebar(opt, sidebar_dir):
|
|||
return
|
||||
|
||||
tyto.set_file(sidebar_load, 'new', sdb_load)
|
||||
|
||||
print(' ├ Create new file: %s'%sidebar_load)
|
||||
print(' ├ Create file: %s'%sidebar_load)
|
||||
|
|
|
@ -49,7 +49,6 @@ def create_metas_page():
|
|||
metas_page = ''
|
||||
tab = 4
|
||||
scale = 'width=device-width, initial-scale=1.0'
|
||||
visit = '3 days'
|
||||
all_tags = domain_tags + ',' + tags
|
||||
post_url = domain_url + http_uri
|
||||
css_file = 'template/style.css'
|
||||
|
@ -72,25 +71,26 @@ def create_metas_page():
|
|||
#--------------------------------------------------
|
||||
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('<meta '):
|
||||
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:
|
||||
pass
|
||||
tyto.exiting("24", '(metas file): %s'%metas_file, False)
|
||||
|
||||
|
||||
# Set all raw HTML metas
|
||||
#-----------------------
|
||||
metas = '<meta charset="UTF-8">\n' + \
|
||||
'<meta name="viewport" content="%s">\n'%scale + \
|
||||
'<meta name=”url” content=”%s”>\n'%domain_url + \
|
||||
'<meta name="robots" content="all">\n' + \
|
||||
'<meta name="medium" content="website">\n' + \
|
||||
'<meta name="revisit-after" content="%s">\n'%visit + \
|
||||
'<meta name="language" content="%s">\n'%domain_lang + \
|
||||
'<meta name="reply-to" content="%s">\n'%domain_mail + \
|
||||
'<meta name="copyright" content="%s">\n'%domain_license + \
|
||||
|
|
|
@ -503,7 +503,7 @@ def exiting(nbr, value, out):
|
|||
'21' : ':D %sValid%s article. Ready to wip'%(CG, CS),
|
||||
'22' : ':? %sNot paired%s symbols: %s'%(CY, CS, value),
|
||||
'23' : ':? %sCorrupted database%s: %s'%(CY, CS, value),
|
||||
'24' : ':? %sfile missing%s (wip article): %s'%(CY, CS, value),
|
||||
'24' : ':? %sfile missing%s %s'%(CY, CS, value),
|
||||
'25' : ':D Add contents %s'%value,
|
||||
'255' : ':| Maybe later...'
|
||||
}
|
||||
|
|
|
@ -45,7 +45,7 @@ def manage_wip(target, option):
|
|||
wip_article(target)
|
||||
else:
|
||||
if not os.path.exists(wip_uri):
|
||||
tyto.exiting("24", wip_uri, False)
|
||||
tyto.exiting("24", '(wip article): %s'%wip_uri, False)
|
||||
wip_article(target)
|
||||
else:
|
||||
tyto.exiting("20", date_wip, True)
|
||||
|
|
Loading…
Reference in New Issue