2020-11-10 10:25:21 +00:00
|
|
|
__filename__ = "webapp_tos.py"
|
|
|
|
__author__ = "Bob Mottram"
|
|
|
|
__license__ = "AGPL3+"
|
2021-01-26 10:07:42 +00:00
|
|
|
__version__ = "1.2.0"
|
2020-11-10 10:25:21 +00:00
|
|
|
__maintainer__ = "Bob Mottram"
|
2021-09-10 16:14:50 +00:00
|
|
|
__email__ = "bob@libreserver.org"
|
2020-11-10 10:25:21 +00:00
|
|
|
__status__ = "Production"
|
2021-06-15 15:08:12 +00:00
|
|
|
__module_group__ = "Web Interface"
|
2020-11-10 10:25:21 +00:00
|
|
|
|
|
|
|
import os
|
|
|
|
from shutil import copyfile
|
2021-12-26 14:08:58 +00:00
|
|
|
from utils import get_config_param
|
2021-12-26 10:19:59 +00:00
|
|
|
from utils import local_actor_url
|
2021-12-29 21:55:09 +00:00
|
|
|
from webapp_utils import html_header_with_external_style
|
|
|
|
from webapp_utils import html_footer
|
|
|
|
from markdown import markdown_to_html
|
2020-11-10 10:25:21 +00:00
|
|
|
|
|
|
|
|
2021-12-29 21:55:09 +00:00
|
|
|
def html_terms_of_service(css_cache: {}, base_dir: str,
|
|
|
|
http_prefix: str, domain_full: str) -> str:
|
2020-11-10 10:25:21 +00:00
|
|
|
"""Show the terms of service screen
|
|
|
|
"""
|
2021-12-31 21:18:12 +00:00
|
|
|
admin_nickname = get_config_param(base_dir, 'admin')
|
2021-12-25 16:17:53 +00:00
|
|
|
if not os.path.isfile(base_dir + '/accounts/tos.md'):
|
|
|
|
copyfile(base_dir + '/default_tos.md',
|
|
|
|
base_dir + '/accounts/tos.md')
|
2020-11-10 10:25:21 +00:00
|
|
|
|
2021-12-25 16:17:53 +00:00
|
|
|
if os.path.isfile(base_dir + '/accounts/login-background-custom.jpg'):
|
|
|
|
if not os.path.isfile(base_dir + '/accounts/login-background.jpg'):
|
|
|
|
copyfile(base_dir + '/accounts/login-background-custom.jpg',
|
|
|
|
base_dir + '/accounts/login-background.jpg')
|
2020-11-10 10:25:21 +00:00
|
|
|
|
|
|
|
TOSText = 'Terms of Service go here.'
|
2021-12-25 16:17:53 +00:00
|
|
|
if os.path.isfile(base_dir + '/accounts/tos.md'):
|
|
|
|
with open(base_dir + '/accounts/tos.md', 'r') as file:
|
2021-12-29 21:55:09 +00:00
|
|
|
TOSText = markdown_to_html(file.read())
|
2020-11-10 10:25:21 +00:00
|
|
|
|
|
|
|
TOSForm = ''
|
2021-12-31 21:18:12 +00:00
|
|
|
css_filename = base_dir + '/epicyon-profile.css'
|
2021-12-25 16:17:53 +00:00
|
|
|
if os.path.isfile(base_dir + '/epicyon.css'):
|
2021-12-31 21:18:12 +00:00
|
|
|
css_filename = base_dir + '/epicyon.css'
|
2020-11-10 10:25:21 +00:00
|
|
|
|
2021-01-11 19:46:21 +00:00
|
|
|
instanceTitle = \
|
2021-12-26 14:08:58 +00:00
|
|
|
get_config_param(base_dir, 'instanceTitle')
|
2021-12-31 21:18:12 +00:00
|
|
|
TOSForm = \
|
|
|
|
html_header_with_external_style(css_filename, instanceTitle, None)
|
2020-11-12 17:05:38 +00:00
|
|
|
TOSForm += '<div class="container">' + TOSText + '</div>\n'
|
2021-12-31 21:18:12 +00:00
|
|
|
if admin_nickname:
|
|
|
|
adminActor = local_actor_url(http_prefix, admin_nickname, domain_full)
|
2020-11-12 17:05:38 +00:00
|
|
|
TOSForm += \
|
|
|
|
'<div class="container"><center>\n' + \
|
|
|
|
'<p class="administeredby">Administered by <a href="' + \
|
2021-12-31 21:18:12 +00:00
|
|
|
adminActor + '">' + admin_nickname + '</a></p>\n' + \
|
2020-11-12 17:05:38 +00:00
|
|
|
'</center></div>\n'
|
2021-12-29 21:55:09 +00:00
|
|
|
TOSForm += html_footer()
|
2020-11-10 10:25:21 +00:00
|
|
|
return TOSForm
|