html: indev for navbar. Include article in page. domain: add logo, navbar in form
This commit is contained in:
parent
2743cc8c55
commit
aef44c86ef
|
@ -94,9 +94,10 @@ def manage_check(target, option):
|
|||
post_bottom = tyto.protect_article.rsplit('\n')
|
||||
article_bottom = tyto.protect_article
|
||||
|
||||
# Count words in article. Not from quotes, block-codes, icode = 1
|
||||
# Count words in article. Quotes, block-codes, icode = 1 per each
|
||||
post_words = len(article_bottom.strip().split(" "))
|
||||
|
||||
|
||||
# Check for valid contents
|
||||
check_content(post_bottom)
|
||||
post_bottom = article_bottom.rsplit('\n')
|
||||
|
|
|
@ -197,6 +197,17 @@ def create_domain(target, option):
|
|||
'domain_tags = "%s"'%domain_tags)
|
||||
|
||||
|
||||
# Get logo's website
|
||||
#-------------------
|
||||
try: domain_logo = tyto.domain_logo
|
||||
except: domain_logo = 'logo.png'
|
||||
|
||||
ask = ''
|
||||
ask = input(' ├ logo filename ? ("%s") '%domain_logo)
|
||||
tyto.set_file(tyto.domain_conf, False,
|
||||
'domain_logo = "%s"'%domain_logo)
|
||||
|
||||
|
||||
# Get License domain
|
||||
#-------------------
|
||||
try: domain_license = tyto.domain_license
|
||||
|
@ -272,7 +283,22 @@ def create_domain(target, option):
|
|||
tyto.set_file(tyto.domain_conf, False,
|
||||
'domain_relme = "%s"'%domain_relme)
|
||||
|
||||
|
||||
# Activate menu bar from root articles folders ?
|
||||
#-----------------------------------------------
|
||||
try: domain_menubar = tyto.domain_menubar
|
||||
except: domain_menubar = 'False'
|
||||
|
||||
ask = ''
|
||||
ask = input(' ├ Use sub-folders as menu bar ? (%s) '%domain_menubar)
|
||||
|
||||
if ask in ['y', 'Y']: domain_menubar = "True"
|
||||
else: domain_menubar = 'False'
|
||||
|
||||
tyto.set_file(tyto.domain_conf, False,
|
||||
'domain_menubar = %s'%(domain_menubar))
|
||||
|
||||
|
||||
# Sidebar Title
|
||||
#--------------
|
||||
try: sidebar_title = tyto.sidebar_title
|
||||
|
|
|
@ -31,11 +31,11 @@ tytoweb = 'https://tyto.echolib.re'
|
|||
# Load article DB #
|
||||
# Start HTML page sections #
|
||||
#--------------------------#
|
||||
def set_page(post_db):
|
||||
def set_page(post_db, target, article_bottom):
|
||||
exec(open(post_db).read(),globals())
|
||||
|
||||
create_metas_page() # Include metas tags
|
||||
create_main_page() # At last, create main page
|
||||
create_metas_page() # Include metas tags
|
||||
create_main_page(target, article_bottom) # At last, create main page
|
||||
|
||||
|
||||
#============================================#
|
||||
|
@ -119,15 +119,99 @@ def create_metas_page():
|
|||
#=======================================#
|
||||
# Set main page, with all HTML sections #
|
||||
#---------------------------------------#
|
||||
def create_main_page():
|
||||
def create_main_page(target, article_bottom):
|
||||
global main_page
|
||||
|
||||
main_page = '<!doctype html>\n' + \
|
||||
# Create link for website's logo
|
||||
#-------------------------------
|
||||
logo_html = '<a href="/"\n' + \
|
||||
'%stitle="%s %s logo: %s"\n'%(11 * " ",
|
||||
tyto.trans[1][tyto.n], domain_sep, domain_title
|
||||
) + \
|
||||
'%sid="site_logo_link">\n'%(11 * " ") + \
|
||||
'%s<img src=""\n'%(10 * " ") + \
|
||||
'%salt="logo: %s">\n'%(15 * " ", domain_title) + \
|
||||
'%sid="site_logo_image">\n'%(15 * " ") + \
|
||||
'%s</a>'%(8 * " ")
|
||||
|
||||
#------------------------------------#
|
||||
# Create HTML menu from root folders #
|
||||
#------------------------------------#
|
||||
menu_html = ''
|
||||
|
||||
# Conditions to create navbar
|
||||
#----------------------------
|
||||
# True in config
|
||||
if domain_menubar:
|
||||
# Filter these directories
|
||||
nodirs = ('files', 'images', 'sidebar')
|
||||
|
||||
# Open HTML tags
|
||||
menu_html = '%s<nav id="site_menu">\n'%(6 * ' ') + \
|
||||
'%s<ul id="site_menu_items">'%(8 * ' ')
|
||||
articles_dirs = os.listdir(tyto.domain_articles)
|
||||
# Create folder links (d) in navbar
|
||||
for d in articles_dirs:
|
||||
d_uri = os.path.join(domain_articles, d)
|
||||
|
||||
# Check if d is a directory
|
||||
if not os.path.isdir(d_uri): continue
|
||||
# Filter unwanted
|
||||
|
||||
if d.startswith(nodirs): continue
|
||||
|
||||
# Must have index.* in d directory
|
||||
items_indir = os.listdir(d_uri)
|
||||
print(">>>", items_indir)
|
||||
index = True
|
||||
for item in items_indir:
|
||||
if item.startswith('index.'):
|
||||
|
||||
break
|
||||
else: index = False
|
||||
if not index: continue
|
||||
|
||||
|
||||
# Add link to HTML structure
|
||||
menu_item = '\n%s<li class="site_menu_item">'%(10 * ' ') + \
|
||||
'<a class="site_menu_link" href="/%s/">%s</a>'%(
|
||||
d, d
|
||||
) + \
|
||||
'</li>'
|
||||
menu_html = '%s%s'%(menu_html, menu_item)
|
||||
|
||||
# Close HTML tags
|
||||
menu_html = '\n%s\n%s</ul>\n%s</nav>\n'%(menu_html, 8 * ' ', 6 * ' ')
|
||||
|
||||
|
||||
#-----------------------#
|
||||
# Create main HTML Page #
|
||||
#-----------------------#
|
||||
main_page = '<!Doctype html>\n' + \
|
||||
'<html lang="%s">\n'%domain_lang + \
|
||||
' <head>\n' + \
|
||||
'%s\n'%metas_page + \
|
||||
' </head>\n\n' + \
|
||||
' <body>\n' + \
|
||||
'%s\n' + \
|
||||
' <header id="header_page">\n' + \
|
||||
' <div id="site_logo">\n' + \
|
||||
' %s\n'%logo_html + \
|
||||
' </div>\n' + \
|
||||
'\n' + \
|
||||
' <div id="site_infos">\n' + \
|
||||
' <a href="/"\n' + \
|
||||
' title="%s"\n'%(tyto.trans[1][tyto.n]) + \
|
||||
' id="site_link">\n' + \
|
||||
' <h1 id="site_title">%s</h1>\n'%domain_title + \
|
||||
' </a>\n' + \
|
||||
' <p id="site_about">%s</p>\n'%domain_about + \
|
||||
' </div>\n' + \
|
||||
'%s'%menu_html + \
|
||||
' </header>\n' + \
|
||||
'\n' + \
|
||||
' <article id="article_main">\n' + \
|
||||
'%s\n'%article_bottom + \
|
||||
' </article>\n' + \
|
||||
'\n' + \
|
||||
' </body>\n' + \
|
||||
'</html>'
|
||||
|
|
|
@ -90,8 +90,9 @@ else: n = 1
|
|||
|
||||
# Translations French/English
|
||||
trans = [
|
||||
['À l\'affiche !', 'Featured !' ]
|
||||
]
|
||||
['À l\'affiche !', 'Featured !' ], #0
|
||||
['Accueil', 'Home'] #1
|
||||
]
|
||||
|
||||
|
||||
# Set all tags used in article's header
|
||||
|
|
|
@ -118,10 +118,10 @@ def wip_article(target):
|
|||
wip_tabs() # make HTML tabulations
|
||||
|
||||
# Result (temp display)
|
||||
print(article_bottom)
|
||||
#print(article_bottom)
|
||||
|
||||
# Get article DB in html.py
|
||||
html.set_page(post_db)
|
||||
html.set_page(post_db, target, article_bottom)
|
||||
print(html.main_page)
|
||||
|
||||
# Replace in DB hash_wip and date_wip
|
||||
|
@ -629,7 +629,7 @@ def wip_raws(target):
|
|||
def wip_tabs():
|
||||
global article_bottom
|
||||
article_temp = ''
|
||||
tab = tab_start = 8 # From <article> tag
|
||||
tab = tab_start = 2 # From <article> tag
|
||||
indiv = False
|
||||
|
||||
for line in article_bottom.rsplit('\n'):
|
||||
|
|
Loading…
Reference in New Issue