2020-11-10 10:25:21 +00:00
|
|
|
__filename__ = "webapp_tos.py"
|
|
|
|
__author__ = "Bob Mottram"
|
|
|
|
__license__ = "AGPL3+"
|
2024-01-21 19:01:20 +00:00
|
|
|
__version__ = "1.5.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
|
2024-05-12 12:35:26 +00:00
|
|
|
from utils import data_dir
|
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
|
|
|
|
|
|
|
|
2022-06-01 17:45:59 +00:00
|
|
|
def html_terms_of_service(base_dir: str,
|
2021-12-29 21:55:09 +00:00
|
|
|
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')
|
2024-05-12 12:35:26 +00:00
|
|
|
dir_str = data_dir(base_dir)
|
|
|
|
if not os.path.isfile(dir_str + '/tos.md'):
|
2021-12-25 16:17:53 +00:00
|
|
|
copyfile(base_dir + '/default_tos.md',
|
2024-05-12 12:35:26 +00:00
|
|
|
dir_str + '/tos.md')
|
2020-11-10 10:25:21 +00:00
|
|
|
|
2024-05-12 12:35:26 +00:00
|
|
|
if os.path.isfile(dir_str + '/login-background-custom.jpg'):
|
|
|
|
if not os.path.isfile(dir_str + '/login-background.jpg'):
|
|
|
|
copyfile(dir_str + '/login-background-custom.jpg',
|
|
|
|
dir_str + '/login-background.jpg')
|
2020-11-10 10:25:21 +00:00
|
|
|
|
2022-01-04 13:35:50 +00:00
|
|
|
tos_text = 'Terms of Service go here.'
|
2024-05-12 12:35:26 +00:00
|
|
|
if os.path.isfile(dir_str + '/tos.md'):
|
2024-07-13 20:27:19 +00:00
|
|
|
try:
|
2024-07-16 12:20:58 +00:00
|
|
|
with open(dir_str + '/tos.md', 'r', encoding='utf-8') as fp_tos:
|
|
|
|
tos_text = markdown_to_html(fp_tos.read())
|
2024-07-13 20:27:19 +00:00
|
|
|
except OSError:
|
|
|
|
print('EX: html_terms_of_service unable to read ' +
|
|
|
|
dir_str + '/tos.md')
|
2020-11-10 10:25:21 +00:00
|
|
|
|
2022-01-04 13:35:50 +00:00
|
|
|
tos_form = ''
|
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
|
|
|
|
2022-01-04 13:35:50 +00:00
|
|
|
instance_title = \
|
2021-12-26 14:08:58 +00:00
|
|
|
get_config_param(base_dir, 'instanceTitle')
|
2022-01-04 13:35:50 +00:00
|
|
|
tos_form = \
|
|
|
|
html_header_with_external_style(css_filename, instance_title, None)
|
|
|
|
tos_form += '<div class="container">' + tos_text + '</div>\n'
|
2021-12-31 21:18:12 +00:00
|
|
|
if admin_nickname:
|
2022-01-04 13:35:50 +00:00
|
|
|
admin_actor = local_actor_url(http_prefix, admin_nickname, domain_full)
|
|
|
|
tos_form += \
|
2020-11-12 17:05:38 +00:00
|
|
|
'<div class="container"><center>\n' + \
|
|
|
|
'<p class="administeredby">Administered by <a href="' + \
|
2022-01-04 13:35:50 +00:00
|
|
|
admin_actor + '">' + admin_nickname + '</a></p>\n' + \
|
2020-11-12 17:05:38 +00:00
|
|
|
'</center></div>\n'
|
2022-01-04 13:35:50 +00:00
|
|
|
tos_form += html_footer()
|
|
|
|
return tos_form
|