footer: user can add CGU + Legals URL in + fill HTML for website description (variable: domain_footer_about in domain.py)

This commit is contained in:
Cyrille L 2023-03-01 10:16:29 +01:00
parent 30c6b82fd4
commit a2b9f94a52
2 changed files with 132 additions and 32 deletions

View File

@ -21,6 +21,15 @@ from datetime import datetime
import os, sys, locale, importlib
import logs, db, tyto, html
#----------------------------------------------------------------------
# Optional
# This variable, if not empty, will be used in website footer
# and will replace defaut content of domain_about
# Put in any HTML you want but,
# note: content is already in <p></p>
#----------------------------------------------------------------------
domain_footer_about = \
'Un petit essai'
#==========================#
# Manage Argument 'domain' #
@ -382,6 +391,46 @@ def create_domain(target):
tyto.set_file(db.domain_conf, False, set_f)
# Legal Notice URL
#-----------------
try: domain_legalurl = db.domain_legalurl
except: domain_legalurl = ''
ask = ''
try:
ask = input(' ├ [Optional] Legal Notice URL ? {%s} '%domain_legalurl)
except KeyboardInterrupt:
print('')
logs.out("255", '', True)
if ask:
if not ask.startswith('http'): logs.out("3", ask, True)
domain_legalurl = ask
set_f = 'domain_legalurl = "%s"'%domain_legalurl
tyto.set_file(db.domain_conf, False, set_f)
# Terms URL
#-----------------
try: domain_termsurl = db.domain_termsurl
except: domain_termsurl = ''
ask = ''
try:
ask = input(' ├ [Optional] Terms of Use URL ? {%s} '%domain_termsurl)
except KeyboardInterrupt:
print('')
logs.out("255", '', True)
if ask:
if not ask.startswith('http'): logs.out("3", ask, True)
domain_legalurl = ask
set_f = 'domain_termsurl = "%s"'%domain_termsurl
tyto.set_file(db.domain_conf, False, set_f)
# CSS Prefix
#-----------
try: domain_css = db.domain_css
@ -792,7 +841,19 @@ def create_footer(option):
tyto.set_file(db.www_footer, 'new', '')
print(' ├ Create empty file: %s'%db.www_footer)
# Default footer contents
# Create new default file, or ask if exists
ask = ' ├ Reset footer configuration file ? '
log = ' ├ Create source file: %s'%db.footer_load
res = ''
if os.path.exists(db.footer_load):
try:
res = input(ask)
except KeyboardInterrupt:
print('')
logs.out("255", '', True)
if not res in ['y', 'Y']: return
# Default footer contents
Tytosrc = '(<a href="%s" '%tyto.Tytogit + \
'title="%s" '%tyto.trans[4][tyto.n] + \
'id="footer_item_link">%s</a>)'%tyto.trans[3][tyto.n]
@ -801,16 +862,51 @@ def create_footer(option):
'title="%s"'%tyto.trans[5][tyto.n] + \
'class="footer_item_link">%s</a> %s'%(tyto.Tyto, Tytosrc)
if db.domain_date == datetime.now().year:
# Show copyright date from creation to now year
print(db.domain_date, datetime.now().year)
if int(db.domain_date) == int(datetime.now().year):
footer_date = db.domain_date
else:
footer_date = '%s - %s'%(db.domain_date, datetime.now().year)
# Simple link to home
domain_home = \
'<a href="/" ' + \
'title="%s" '%(tyto.trans[1][tyto.n]) + \
'id="footer_title_link">%s</a>'%db.domain_title
# Show domain_HTML_about (if not empty), else domain_about
if domain_footer_about: db.domain_about = domain_footer_about
# Links for laws (Terms and legals)
if db.domain_legalurl:
legal_link = \
'<a href="%s" '%db.domain_termsurl + \
'title="%s %s" '%(tyto.trans[16][tyto.n], db.domain_title) + \
'class="footer_item_link">%s</a>'%tyto.trans[16][tyto.n]
if db.domain_termsurl:
terms_link = \
'<a href="%s" '%db.domain_legalurl + \
'title="%s %s" '%(tyto.trans[17][tyto.n], db.domain_title) + \
'class="footer_item_link">%s</a>'%tyto.trans[15][tyto.n]
footer_law = ''
if db.domain_termsurl and db.domain_legalurl:
footer_law = '%s - %s'%(legal_link, terms_link)
elif db.domain_termsurl:
footer_law = terms_link
elif db.domain_legalurl:
footer_law = legal_link
footer_law_link = ''
if footer_law:
footer_law_link = \
' <li class="footer_item">%s: \n'%(tyto.trans[18][tyto.n]) + \
' %s\n'%footer_law + \
' </li>\n'
# Final HTML footer code
footer = \
'<!-- Default <footer> generated by %s\n'%tyto.Tyto + \
' file: /articles/_configs/tyto.footer.html\n' + \
@ -831,6 +927,7 @@ def create_footer(option):
'\n' + \
' <div id="footer_references">\n' + \
' <ul class="footer_items">\n' + \
'%s'%footer_law_link + \
' <li class="footer_item">%s \n'%(tyto.trans[2][tyto.n]) + \
' <a href="%s"\n'%db.domain_licurl + \
' title="%s %s %s"\n'%(
@ -839,35 +936,32 @@ def create_footer(option):
' class="footer_item_link">%s</a>\n'%(
db.domain_license) + \
' </li>\n' + \
' <li class="footer_item">Contact\n' + \
' <a href="mailto:%s"\n'%db.domain_mail + \
' title="%s %s"\n'%(
tyto.trans[13][tyto.n], db.domain_title
) + \
' class="footer_item_link">%s</a>\n'%(
tyto.trans[14][tyto.n]
) + \
' </li>\n' + \
' </ul>\n' + \
' </div>\n' + \
' <div id="footer_cr">\n' + \
' <p>Copyright: %s</p>\n'%footer_date + \
' <div id="footer_credits">\n' + \
' <p>Copyright: %s %s</p>\n'%(footer_date, db.domain_title) + \
' <p>%s %s</p>\n'%(tyto.trans[12][tyto.n], tyto_show) + \
' </div>\n' + \
'</footer>'
# Create new default file, or ask if exists
ask = ' ├ Reset footer configuration file ? '
log = ' ├ Create source file: %s'%db.footer_load
res = ''
if os.path.exists(db.footer_load):
try:
res = input(ask)
except KeyboardInterrupt:
print('')
logs.out("255", '', True)
if not res in ['y', 'Y']: return
tyto.set_file(db.footer_load, 'new', footer)
tyto.create_db_load(db.footer_load, db.footer_load_db)
print(log)
#
# Generic HTML list in footer
"""
' <li class="footer_item">\n' + \
' <a href="%s"\n'%tyto.Tytoweb + \
' title="%s"\n'%tyto.trans[5][tyto.n] + \
' class="footer_item_link">%s</a> %s\n'%(tyto.Tyto, Tytosrc) + \
' </li>\n' + \
' <a href="%s"\n'% + \
' title="%s"\n'% + \
' class="footer_item_link">%s</a> %s\n'%() + \
' </li>\n'
"""

View File

@ -40,19 +40,25 @@ Tytoweb = 'https://tyto.echolib.re'
# Translations French/English
trans = [
('À l\'affiche !', 'Featured !'), #0
('Accueil', 'Home'), #1
('Licence', 'License'), #2
('Code source', 'Source code'),
('À l\'affiche !', 'Featured !'), # 0
('Accueil', 'Home'), # 1
('Licence', 'License'), # 2
('Code source', 'Source code'), # 3
('Dépôt officiel du code source de %s'%Tyto , '%s\'s official source code repository'%Tyto),
('Site web officiel du logiciel libre %s'%Tyto, '%s\'s official website'),
('L\'article', 'The article'),
('écrit par', 'written by'),
('Publié le', 'Published the'), #8 date for section HTML (article_infos)
('à', 'at'), #9 time format
('rédigé le', 'created the'), #10
('À Propos de', 'About'), #11
('Générateur :', 'Generator:')
('L\'article', 'The article'), # 6
('écrit par', 'written by'), # 7
('Publié le', 'Published the'), # 8 date for section HTML (article_infos)
('à', 'at'), # 9 time format
('rédigé le', 'created the'), # 10
('À Propos de', 'About'), # 11
('Générateur :', 'Generator:'), # 12
('Contacter par courriel', 'Contact by mail'), # 13
('Courriel', 'Mail'), # 14
('C.G.U.', 'T.O.U'), # 15
('Mentions légales', 'Legal Notice'), # 16
('Conditions Générales d\'Utilisation', 'Terms of Use'), # 17
('Loi', 'Law') # 18
]