epicyon/webapp_welcome_final.py

83 lines
3.1 KiB
Python
Raw Normal View History

2021-02-25 16:55:40 +00:00
__filename__ = "webapp_welcome_final.py"
__author__ = "Bob Mottram"
__license__ = "AGPL3+"
__version__ = "1.2.0"
__maintainer__ = "Bob Mottram"
__email__ = "bob@freedombone.net"
__status__ = "Production"
2021-06-15 15:08:12 +00:00
__module_group__ = "Web Interface"
2021-02-25 16:55:40 +00:00
import os
from shutil import copyfile
2021-02-25 19:15:04 +00:00
from utils import removeHtml
2021-02-25 16:55:40 +00:00
from utils import getConfigParam
from webapp_utils import htmlHeaderWithExternalStyle
from webapp_utils import htmlFooter
from webapp_utils import markdownToHtml
def htmlWelcomeFinal(baseDir: str, nickname: str, domain: str,
httpPrefix: str, domainFull: str,
2021-02-27 10:27:39 +00:00
language: str, translate: {},
themeName: str) -> str:
2021-02-25 16:55:40 +00:00
"""Returns the final welcome screen after first login
"""
# set a custom background for the welcome screen
if os.path.isfile(baseDir + '/accounts/welcome-background-custom.jpg'):
if not os.path.isfile(baseDir + '/accounts/welcome-background.jpg'):
copyfile(baseDir + '/accounts/welcome-background-custom.jpg',
baseDir + '/accounts/welcome-background.jpg')
finalText = 'Welcome to Epicyon'
finalFilename = baseDir + '/accounts/welcome_final.md'
if not os.path.isfile(finalFilename):
2021-02-27 10:27:39 +00:00
defaultFilename = None
if themeName:
defaultFilename = \
baseDir + '/theme/' + themeName + '/welcome/' + \
'final_' + language + '.md'
if not os.path.isfile(defaultFilename):
defaultFilename = None
if not defaultFilename:
defaultFilename = \
baseDir + '/defaultwelcome/final_' + language + '.md'
2021-02-25 16:55:40 +00:00
if not os.path.isfile(defaultFilename):
defaultFilename = baseDir + '/defaultwelcome/final_en.md'
copyfile(defaultFilename, finalFilename)
instanceTitle = \
getConfigParam(baseDir, 'instanceTitle')
if not instanceTitle:
instanceTitle = 'Epicyon'
2021-02-25 16:55:40 +00:00
if os.path.isfile(finalFilename):
with open(finalFilename, 'r') as finalFile:
finalText = finalFile.read()
finalText = finalText.replace('INSTANCE', instanceTitle)
finalText = markdownToHtml(removeHtml(finalText))
2021-02-25 16:55:40 +00:00
finalForm = ''
cssFilename = baseDir + '/epicyon-welcome.css'
if os.path.isfile(baseDir + '/welcome.css'):
cssFilename = baseDir + '/welcome.css'
finalForm = htmlHeaderWithExternalStyle(cssFilename, instanceTitle)
finalForm += '<div class="container">' + finalText + '</div>\n'
finalForm += \
'<form enctype="multipart/form-data" method="POST" ' + \
'accept-charset="UTF-8" ' + \
'action="/users/' + nickname + '/profiledata">\n'
finalForm += '<div class="container next">\n'
finalForm += \
' <button type="submit" class="button" ' + \
'name="previewAvatar">' + translate['Go Back'] + '</button>\n'
finalForm += \
' <button type="submit" class="button" ' + \
'name="welcomeCompleteButton">' + translate['Next'] + '</button>\n'
finalForm += '</div>\n'
finalForm += '</form>\n'
finalForm += htmlFooter()
return finalForm