2020-11-10 10:25:21 +00:00
|
|
|
__filename__ = "webapp_about.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
|
2021-12-26 14:08:58 +00:00
|
|
|
from utils import get_config_param
|
2021-12-29 21:55:09 +00:00
|
|
|
from webapp_utils import html_header_with_website_markup
|
|
|
|
from webapp_utils import html_footer
|
|
|
|
from markdown import markdown_to_html
|
2020-11-10 10:25:21 +00:00
|
|
|
|
|
|
|
|
2022-07-12 19:03:30 +00:00
|
|
|
def html_about(base_dir: str, http_prefix: str,
|
2021-12-29 21:55:09 +00:00
|
|
|
domain_full: str, onion_domain: str, translate: {},
|
|
|
|
system_language: str) -> str:
|
2020-11-10 10:25:21 +00:00
|
|
|
"""Show the about 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/about.md'):
|
|
|
|
copyfile(base_dir + '/default_about.md',
|
|
|
|
base_dir + '/accounts/about.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
|
|
|
|
2022-01-03 21:21:00 +00:00
|
|
|
about_text = 'Information about this instance goes here.'
|
2021-12-25 16:17:53 +00:00
|
|
|
if os.path.isfile(base_dir + '/accounts/about.md'):
|
2022-06-09 14:46:30 +00:00
|
|
|
with open(base_dir + '/accounts/about.md', 'r',
|
|
|
|
encoding='utf-8') as fp_about:
|
2022-01-03 21:21:00 +00:00
|
|
|
about_text = markdown_to_html(fp_about.read())
|
2020-11-10 10:25:21 +00:00
|
|
|
|
2022-01-03 21:21:00 +00:00
|
|
|
about_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-03 21:21:00 +00:00
|
|
|
instance_title = \
|
2021-12-26 14:08:58 +00:00
|
|
|
get_config_param(base_dir, 'instanceTitle')
|
2022-01-03 21:21:00 +00:00
|
|
|
about_form = \
|
|
|
|
html_header_with_website_markup(css_filename, instance_title,
|
2021-12-29 21:55:09 +00:00
|
|
|
http_prefix, domain_full,
|
|
|
|
system_language)
|
2022-01-03 21:21:00 +00:00
|
|
|
about_form += '<div class="container">' + about_text + '</div>'
|
2021-12-25 20:43:43 +00:00
|
|
|
if onion_domain:
|
2022-01-03 21:21:00 +00:00
|
|
|
about_form += \
|
2020-11-12 17:05:38 +00:00
|
|
|
'<div class="container"><center>\n' + \
|
|
|
|
'<p class="administeredby">' + \
|
2021-12-25 20:43:43 +00:00
|
|
|
'http://' + onion_domain + '</p>\n</center></div>\n'
|
2021-12-31 21:18:12 +00:00
|
|
|
if admin_nickname:
|
2022-01-03 21:21:00 +00:00
|
|
|
admin_actor = '/users/' + admin_nickname
|
|
|
|
about_form += \
|
2020-11-12 17:05:38 +00:00
|
|
|
'<div class="container"><center>\n' + \
|
2021-01-25 20:37:27 +00:00
|
|
|
'<p class="administeredby">' + \
|
|
|
|
translate['Administered by'] + ' <a href="' + \
|
2022-01-03 21:21:00 +00:00
|
|
|
admin_actor + '">' + admin_nickname + '</a>. ' + \
|
2021-01-25 20:37:27 +00:00
|
|
|
translate['Version'] + ' ' + __version__ + \
|
|
|
|
'</p>\n</center></div>\n'
|
2022-01-03 21:21:00 +00:00
|
|
|
about_form += html_footer()
|
|
|
|
return about_form
|