html: progress on HTML page build
This commit is contained in:
parent
7945f5473f
commit
9d8d54d5d4
|
@ -55,9 +55,6 @@ def post_IDs(file_post):
|
|||
print(':< Unused argument file')
|
||||
sys.exit(1)
|
||||
|
||||
# Set HTML file from file_post
|
||||
file_html = file_post.replace('.tyto','.html')
|
||||
|
||||
# Check if file exists or exit
|
||||
global post_uri
|
||||
post_uri = '%s%s'%(domain.domain_articles, file_post)
|
||||
|
@ -65,6 +62,16 @@ def post_IDs(file_post):
|
|||
print(':< Unused file: %s'%post_uri)
|
||||
sys.exit(1)
|
||||
|
||||
|
||||
global post_url
|
||||
# Set HTML file from file_post
|
||||
file_html = file_post.replace('.tyto','.html')
|
||||
if file_html.endswith('index.html'):
|
||||
file_html = file_html.remplace('index.html', '')
|
||||
post_url = '%s%s/%s'%(
|
||||
domain.domain_protocol, domain.domain_name, file_html
|
||||
)
|
||||
|
||||
# From argument file_post
|
||||
# Set WEB link prefix. Count / in uri
|
||||
global weburi
|
||||
|
@ -1172,6 +1179,7 @@ def create_DB(post_db):
|
|||
'post_ID = "%s"'%curr_post_ID,
|
||||
'post_db = "%s"'%post_db,
|
||||
'post_tmp = "%s"'%post_tmp,
|
||||
'post_url = "%s"'%post_url,
|
||||
'\n# Article Status',
|
||||
'post_chk = ("%s","%s")'%(hash_chk,time_chk),
|
||||
'post_wip = ("%s","%s")'%(hash_wip,time_wip),
|
||||
|
|
|
@ -78,9 +78,10 @@ except:
|
|||
#===========================#
|
||||
# Append new line to a file #
|
||||
#---------------------------#
|
||||
def append_f(f,line_val):
|
||||
def append_f(f, line_val):
|
||||
file = open(f, "a")
|
||||
file.write('%s\n'%line_val)
|
||||
file.close()
|
||||
|
||||
#======================================#
|
||||
# Just a generic exit #
|
||||
|
@ -107,18 +108,12 @@ def exiting(process,out,msg):
|
|||
#==========================#-------------------------------------------
|
||||
def manage_domain(Domain, Opt):
|
||||
if not Opt:
|
||||
try:
|
||||
# No option: get domain and print it
|
||||
print('\n',datas_domain)
|
||||
except:
|
||||
sys.exit(0)
|
||||
try: print('\n',datas_domain) # No option: get domain and print it
|
||||
except: sys.exit(0)
|
||||
|
||||
elif Opt == 'New':
|
||||
try:
|
||||
# Domain NAME is defined in CLI
|
||||
set_domain = Domain
|
||||
except:
|
||||
set_domain = ''
|
||||
try: set_domain = Domain # Domain NAME is defined in CLI
|
||||
except: set_domain = ''
|
||||
|
||||
add_domain(set_domain)
|
||||
|
||||
|
@ -133,9 +128,9 @@ def manage_domain(Domain, Opt):
|
|||
# Compare before and after domain conf file
|
||||
new_conf_ID = check.get_filesum(domain_conf,True)
|
||||
if not old_conf_ID == new_conf_ID:
|
||||
exiting('root',2,':D Updated domain configuration file.')
|
||||
exiting('root', 2, ':D Updated domain configuration file.')
|
||||
else:
|
||||
exiting('root',2,':D Unchanged domain configuration file.')
|
||||
exiting('root', 2, ':D Unchanged domain configuration file.')
|
||||
else:
|
||||
sys.exit(0)
|
||||
|
||||
|
@ -147,8 +142,7 @@ def manage_domain(Domain, Opt):
|
|||
#-----------------------------------#----------------------------------
|
||||
def add_domain(set_domain):
|
||||
# Exit if a domain already exists
|
||||
if domain_active:
|
||||
sys.exit(0)
|
||||
if domain_active: sys.exit(0)
|
||||
|
||||
global temp_domain
|
||||
temp_domain = '%s/tyto_domain.tmp'%curr_dir
|
||||
|
@ -189,6 +183,7 @@ def add_domain(set_domain):
|
|||
post_temp = file.read()
|
||||
for line in post_temp.split('\n'):
|
||||
print(' │ %s'%line)
|
||||
file.close()
|
||||
|
||||
# Ask to confirm to write activation domain
|
||||
print(' ├─────────────────────────────')
|
||||
|
@ -196,7 +191,25 @@ def add_domain(set_domain):
|
|||
if confirm in ['y', 'Y']:
|
||||
create_domain()
|
||||
else:
|
||||
exiting('form',1,'')
|
||||
exiting('form', 1, '')
|
||||
|
||||
#==============#
|
||||
# Get protocol #
|
||||
#--------------#
|
||||
def get_protocol(set_domain):
|
||||
global domain_protocol
|
||||
domain_protocol = ''
|
||||
|
||||
# check protocol https, http
|
||||
if set_domain.startswith('https://'): domain_protocol = 'https://'
|
||||
elif set_domain.startswith('http://') : domain_protocol = 'http://'
|
||||
|
||||
if domain_protocol:
|
||||
set_domain = set_domain.replace(domain_protocol,"")
|
||||
else:
|
||||
confirm = input(' ├ Use "https" ? ')
|
||||
if confirm in ['y', 'Y']: domain_protocol = 'https://'
|
||||
else : domain_protocol = 'http://'
|
||||
|
||||
#==============================#
|
||||
# If domain name is set in CLI #
|
||||
|
@ -204,6 +217,9 @@ def add_domain(set_domain):
|
|||
#------------------------------#
|
||||
def domain_input_confirn(set_domain):
|
||||
global domain_name
|
||||
|
||||
get_protocol(set_domain)
|
||||
|
||||
confirm = input(' ├ Add Domain (%s) here ? '%set_domain)
|
||||
if confirm in ['y', 'Y']:
|
||||
# Check if domain already registred
|
||||
|
@ -211,20 +227,25 @@ def domain_input_confirn(set_domain):
|
|||
if isdomain in domains_db:
|
||||
dom_folder = globals().get(isdomain,False)
|
||||
if dom_folder and not dom_folder == curr_dir:
|
||||
exiting('root',2,'\n:/ Domain exists in %s'%dom_folder)
|
||||
exiting('root', 2, '\n:/ Domain exists in %s'%dom_folder)
|
||||
domain_name = set_domain
|
||||
else:
|
||||
exiting('root',1,'')
|
||||
exiting('root', 1, '')
|
||||
|
||||
#=====================#
|
||||
# Add new domain_name #
|
||||
#---------------------#
|
||||
def domain_input():
|
||||
global domain_name
|
||||
global domain_name, domain_protocol
|
||||
set_domain = input(' ├ Enter Domain Name: ')
|
||||
|
||||
if not set_domain: exiting('root', 1, '')
|
||||
else : domain_name = set_domain
|
||||
|
||||
domain_protocol = ''
|
||||
get_protocol(set_domain)
|
||||
|
||||
|
||||
#====================#
|
||||
# Domain FORM #
|
||||
# domain_name is set #
|
||||
|
@ -241,6 +262,7 @@ def domain_form():
|
|||
|
||||
# Add settings from domain name before starting form
|
||||
append_f(temp_domain,'domain_name = "%s"'%domain_name)
|
||||
append_f(temp_domain,'domain_protocol = "%s"'%domain_protocol)
|
||||
append_f(temp_domain,'domain_conf = "%s"'%conf_domain)
|
||||
append_f(temp_domain,'domain_db = "%s"'%domain_db)
|
||||
append_f(temp_domain,'domain_logs = "%s"'%domain_logs)
|
||||
|
|
|
@ -23,10 +23,25 @@ def html_main_page():
|
|||
post_db = exec(open(check.curr_post_db).read(),globals())
|
||||
|
||||
# Metas in HTML page
|
||||
#-------------------
|
||||
scale = 'width=device-width, initial-scale=1.0'
|
||||
visit = '3 days'
|
||||
title = '%s %s %s'%(post_title, domain.sep_titles, domain.domain_title)
|
||||
tags = '%s,%s'%(domain.domain_tags, post_tags)
|
||||
icon = '/template/favicon.png'
|
||||
f_css = '/template/styles.css'
|
||||
f_rss = '/rss.xml'
|
||||
i_rss = 'RSS 2.0, %s %s %s'%(
|
||||
domain.domain_title, domain.sep_titles, domain.domain_name
|
||||
)
|
||||
|
||||
# External URL in metas (if exists)
|
||||
if domain.domain_exturl:
|
||||
relme = '<link rel="me" type="text/html" href="%s">\n'%(
|
||||
domain.domain_exturl
|
||||
)
|
||||
else:
|
||||
relme = ''
|
||||
|
||||
metas = '<meta charset="UTF-8" />\n' + \
|
||||
'<meta name="viewport" content="%s">\n'%scale + \
|
||||
|
@ -42,7 +57,72 @@ def html_main_page():
|
|||
'<meta name="description" content="%s">\n'%post_about + \
|
||||
'<meta name="keywords" content="%s">\n'%tags + \
|
||||
'<meta name="search_date" content="%s">\n'%post_date + \
|
||||
'<title>%s</title>\n'%title
|
||||
'<link rel="canonical" href="%s" />\n'%post_url + \
|
||||
'<link rel="alternate" type="application/rss+xml" href="%s" title="%s" />\n'%(f_rss, i_rss) + \
|
||||
'<link rel="stylesheet" media="screen" href="%s" />\n'%f_css + \
|
||||
'<link rel="shortcut icon" type="image/png" href="%s" />\n'%icon + \
|
||||
'%s'%relme + \
|
||||
'<title>%s</title>'%title
|
||||
|
||||
print(metas)
|
||||
# header in HTML page
|
||||
#--------------------
|
||||
headers = '<header class="%s">\n'%domain.domain_css + \
|
||||
' <div id="logo-header">\n' + \
|
||||
' <a id="logo-link" href="/">\n' + \
|
||||
' <img id="%s_logo"\n'%domain.domain_css + \
|
||||
' src="/template/%s"\n'%domain.domain_logo + \
|
||||
' alt="Logo: %s"\n'%domain.domain_title + \
|
||||
' title="Logo: %s" />\n'%domain.domain_title + \
|
||||
' </a>\n' + \
|
||||
' </div>\n' + \
|
||||
' <div id="site-infos">\n' + \
|
||||
' <h1 id="site-name">\n' + \
|
||||
' <a id="site-link"\n' + \
|
||||
' href="/"\n' + \
|
||||
' title="%s %s %s">%s</a>\n'%(
|
||||
domain.domain_title,
|
||||
domain.sep_titles,
|
||||
domain.domain_name,
|
||||
domain.domain_title
|
||||
) + \
|
||||
' </h1>\n' + \
|
||||
' <h2 id="site-about">%s</h2>\n'%domain.domain_about + \
|
||||
' </div>\n' + \
|
||||
'</header>\n'
|
||||
|
||||
# Article (in section, including aside)
|
||||
articles = '<section id="wrapper">\n' + \
|
||||
' <article id="article_%s" class="%s">\n'%(
|
||||
post_ID, domain.domain_css
|
||||
) + \
|
||||
' <div id="metas">\n' + \
|
||||
' <p>\n' + \
|
||||
' <span id="%s">%s</span>\n'%(post_author, post_author) + \
|
||||
' <span id="sep"> - </span>\n' + \
|
||||
' <span id="date">%s</span>\n'%post_date + \
|
||||
' </p>\n' + \
|
||||
' </div>'
|
||||
|
||||
# Create full page
|
||||
#-----------------
|
||||
page = '<!DOCTYPE html>\n' + \
|
||||
' <html lang="%s">\n'%domain.domain_lang + \
|
||||
' <head>'
|
||||
|
||||
# Add tab metas in page
|
||||
for meta in metas.rsplit('\n'):
|
||||
page = '%s\n%s%s'%(page, 6*' ', meta)
|
||||
|
||||
page = '%s\n%s</head>\n'%(page, 4*' ') + \
|
||||
'%s\n <body id="%s" class="%s">'%(4*' ', post_ID, domain.domain_css)
|
||||
|
||||
# Add tab header in page
|
||||
for header in headers.rsplit('\n'):
|
||||
page = '%s\n%s%s'%(page, 6*' ', header)
|
||||
|
||||
# Add tab article in page
|
||||
for article in articles.rsplit('\n'):
|
||||
page = '%s\n%s%s'%(page, 6*' ', article)
|
||||
|
||||
print(page)
|
||||
|
||||
|
|
Loading…
Reference in New Issue