2021-02-25 16:55:40 +00:00
|
|
|
__filename__ = "webapp_welcome_final.py"
|
|
|
|
__author__ = "Bob Mottram"
|
|
|
|
__license__ = "AGPL3+"
|
2022-02-03 13:58:20 +00:00
|
|
|
__version__ = "1.3.0"
|
2021-02-25 16:55:40 +00:00
|
|
|
__maintainer__ = "Bob Mottram"
|
2021-09-10 16:14:50 +00:00
|
|
|
__email__ = "bob@libreserver.org"
|
2021-02-25 16:55:40 +00:00
|
|
|
__status__ = "Production"
|
2021-06-26 11:27:14 +00:00
|
|
|
__module_group__ = "Onboarding"
|
2021-02-25 16:55:40 +00:00
|
|
|
|
|
|
|
import os
|
|
|
|
from shutil import copyfile
|
2021-12-27 15:43:22 +00:00
|
|
|
from utils import remove_html
|
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_external_style
|
|
|
|
from webapp_utils import html_footer
|
|
|
|
from markdown import markdown_to_html
|
2021-02-25 16:55:40 +00:00
|
|
|
|
|
|
|
|
2022-06-01 17:45:59 +00:00
|
|
|
def html_welcome_final(base_dir: str, nickname: str,
|
2021-12-29 21:55:09 +00:00
|
|
|
language: str, translate: {},
|
|
|
|
theme_name: 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
|
2021-12-25 16:17:53 +00:00
|
|
|
if os.path.isfile(base_dir + '/accounts/welcome-background-custom.jpg'):
|
|
|
|
if not os.path.isfile(base_dir + '/accounts/welcome-background.jpg'):
|
|
|
|
copyfile(base_dir + '/accounts/welcome-background-custom.jpg',
|
|
|
|
base_dir + '/accounts/welcome-background.jpg')
|
2021-02-25 16:55:40 +00:00
|
|
|
|
2022-01-04 14:35:14 +00:00
|
|
|
final_text = 'Welcome to Epicyon'
|
|
|
|
final_filename = base_dir + '/accounts/welcome_final.md'
|
|
|
|
if not os.path.isfile(final_filename):
|
|
|
|
default_filename = None
|
2021-12-25 23:35:50 +00:00
|
|
|
if theme_name:
|
2022-01-04 14:35:14 +00:00
|
|
|
default_filename = \
|
2021-12-25 23:35:50 +00:00
|
|
|
base_dir + '/theme/' + theme_name + '/welcome/' + \
|
2021-02-27 10:27:39 +00:00
|
|
|
'final_' + language + '.md'
|
2022-01-04 14:35:14 +00:00
|
|
|
if not os.path.isfile(default_filename):
|
|
|
|
default_filename = None
|
|
|
|
if not default_filename:
|
|
|
|
default_filename = \
|
2021-12-25 16:17:53 +00:00
|
|
|
base_dir + '/defaultwelcome/final_' + language + '.md'
|
2022-01-04 14:35:14 +00:00
|
|
|
if not os.path.isfile(default_filename):
|
|
|
|
default_filename = base_dir + '/defaultwelcome/final_en.md'
|
|
|
|
copyfile(default_filename, final_filename)
|
2021-02-25 22:25:01 +00:00
|
|
|
|
2022-01-04 14:35:14 +00:00
|
|
|
instance_title = \
|
2021-12-26 14:08:58 +00:00
|
|
|
get_config_param(base_dir, 'instanceTitle')
|
2022-01-04 14:35:14 +00:00
|
|
|
if not instance_title:
|
|
|
|
instance_title = 'Epicyon'
|
2021-02-25 22:25:01 +00:00
|
|
|
|
2022-01-04 14:35:14 +00:00
|
|
|
if os.path.isfile(final_filename):
|
|
|
|
with open(final_filename, 'r') as final_file:
|
|
|
|
final_text = final_file.read()
|
|
|
|
final_text = final_text.replace('INSTANCE', instance_title)
|
|
|
|
final_text = markdown_to_html(remove_html(final_text))
|
2021-02-25 16:55:40 +00:00
|
|
|
|
2022-01-04 14:35:14 +00:00
|
|
|
final_form = ''
|
2021-12-31 21:18:12 +00:00
|
|
|
css_filename = base_dir + '/epicyon-welcome.css'
|
2021-12-25 16:17:53 +00:00
|
|
|
if os.path.isfile(base_dir + '/welcome.css'):
|
2021-12-31 21:18:12 +00:00
|
|
|
css_filename = base_dir + '/welcome.css'
|
2021-02-25 16:55:40 +00:00
|
|
|
|
2022-01-04 14:35:14 +00:00
|
|
|
final_form = \
|
|
|
|
html_header_with_external_style(css_filename, instance_title, None)
|
2021-02-25 16:55:40 +00:00
|
|
|
|
2022-01-04 14:35:14 +00:00
|
|
|
final_form += \
|
|
|
|
'<div class="container">' + final_text + '</div>\n' + \
|
2021-02-25 16:55:40 +00:00
|
|
|
'<form enctype="multipart/form-data" method="POST" ' + \
|
|
|
|
'accept-charset="UTF-8" ' + \
|
2021-07-06 12:50:38 +00:00
|
|
|
'action="/users/' + nickname + '/profiledata">\n' + \
|
|
|
|
'<div class="container next">\n' + \
|
2021-02-25 16:55:40 +00:00
|
|
|
' <button type="submit" class="button" ' + \
|
2021-07-06 12:50:38 +00:00
|
|
|
'name="previewAvatar">' + translate['Go Back'] + '</button>\n' + \
|
2021-02-25 16:55:40 +00:00
|
|
|
' <button type="submit" class="button" ' + \
|
2021-07-06 12:50:38 +00:00
|
|
|
'name="welcomeCompleteButton">' + translate['Next'] + '</button>\n' + \
|
|
|
|
'</div>\n'
|
2021-02-25 16:55:40 +00:00
|
|
|
|
2022-01-04 14:35:14 +00:00
|
|
|
final_form += '</form>\n'
|
|
|
|
final_form += html_footer()
|
|
|
|
return final_form
|