__filename__ = "webapp_tos.py" __author__ = "Bob Mottram" __license__ = "AGPL3+" __version__ = "1.1.0" __maintainer__ = "Bob Mottram" __email__ = "bob@freedombone.net" __status__ = "Production" import os from shutil import copyfile from utils import getConfigParam from webapp_utils import htmlHeaderWithExternalStyles from webapp_utils import htmlFooter def htmlTermsOfService(cssCache: {}, baseDir: str, httpPrefix: str, domainFull: str) -> str: """Show the terms of service screen """ adminNickname = getConfigParam(baseDir, 'admin') if not os.path.isfile(baseDir + '/accounts/tos.txt'): copyfile(baseDir + '/default_tos.txt', baseDir + '/accounts/tos.txt') if os.path.isfile(baseDir + '/accounts/login-background-custom.jpg'): if not os.path.isfile(baseDir + '/accounts/login-background.jpg'): copyfile(baseDir + '/accounts/login-background-custom.jpg', baseDir + '/accounts/login-background.jpg') TOSText = 'Terms of Service go here.' if os.path.isfile(baseDir + '/accounts/tos.txt'): with open(baseDir + '/accounts/tos.txt', 'r') as file: TOSText = file.read() cssFiles = [] TOSForm = '' cssFiles.append(baseDir + '/epicyon-profile.css') if os.path.isfile(baseDir + '/epicyon.css'): cssFiles[0] = baseDir + '/epicyon.css' # TODO: Clean up and remove this override cssFiles[0] = 'base.css' # Get theme-specific css if exists - must be named '.css' themeName = getConfigParam(baseDir, 'theme') themePath = f'{baseDir}/theme/{themeName}.css' if os.path.isfile(themePath): cssFiles.append('theme/' + themeName + '.css') TOSForm = htmlHeaderWithExternalStyles(cssFiles) TOSForm += '
' + TOSText + '
\n' if adminNickname: adminActor = httpPrefix + '://' + domainFull + \ '/users/' + adminNickname TOSForm += \ '
\n' + \ '

Administered by ' + adminNickname + '

\n' + \ '
\n' TOSForm += htmlFooter() return TOSForm