2021-12-04 16:59:50 +00:00
|
|
|
__filename__ = "webapp_themeDesigner.py"
|
|
|
|
__author__ = "Bob Mottram"
|
|
|
|
__license__ = "AGPL3+"
|
|
|
|
__version__ = "1.2.0"
|
|
|
|
__maintainer__ = "Bob Mottram"
|
|
|
|
__email__ = "bob@libreserver.org"
|
|
|
|
__status__ = "Production"
|
|
|
|
__module_group__ = "Web Interface"
|
|
|
|
|
|
|
|
import os
|
|
|
|
from utils import loadJson
|
|
|
|
from utils import getConfigParam
|
|
|
|
from webapp_utils import htmlHeaderWithExternalStyle
|
|
|
|
from webapp_utils import htmlFooter
|
2021-12-04 17:35:06 +00:00
|
|
|
from webapp_utils import getBannerFile
|
2021-12-04 16:59:50 +00:00
|
|
|
|
|
|
|
|
|
|
|
def htmlThemeDesigner(cssCache: {}, baseDir: str,
|
|
|
|
nickname: str, domain: str,
|
|
|
|
translate: {}, defaultTimeline: str,
|
2021-12-04 17:35:06 +00:00
|
|
|
themeName: str, accessKeys: {}) -> str:
|
2021-12-04 16:59:50 +00:00
|
|
|
"""Edit theme settings
|
|
|
|
"""
|
2021-12-04 17:22:30 +00:00
|
|
|
themeFilename = baseDir + '/theme/' + themeName + '/theme.json'
|
2021-12-04 16:59:50 +00:00
|
|
|
themeJson = {}
|
|
|
|
if os.path.isfile(themeFilename):
|
|
|
|
themeJson = loadJson(themeFilename)
|
|
|
|
|
|
|
|
themeForm = ''
|
|
|
|
cssFilename = baseDir + '/epicyon-profile.css'
|
|
|
|
if os.path.isfile(baseDir + '/epicyon.css'):
|
|
|
|
cssFilename = baseDir + '/epicyon.css'
|
|
|
|
|
|
|
|
instanceTitle = \
|
|
|
|
getConfigParam(baseDir, 'instanceTitle')
|
|
|
|
themeForm = \
|
|
|
|
htmlHeaderWithExternalStyle(cssFilename, instanceTitle, None)
|
2021-12-04 17:35:06 +00:00
|
|
|
bannerFile, bannerFilename = \
|
|
|
|
getBannerFile(baseDir, nickname, domain, themeName)
|
|
|
|
themeForm += \
|
|
|
|
'<a href="/users/' + nickname + '/' + defaultTimeline + '" ' + \
|
|
|
|
'accesskey="' + accessKeys['menuTimeline'] + '">' + \
|
|
|
|
'<img loading="lazy" class="timeline-banner" ' + \
|
|
|
|
'alt="' + translate['Switch to timeline view'] + '" ' + \
|
|
|
|
'src="/users/' + nickname + '/' + bannerFile + '" /></a>\n'
|
2021-12-04 16:59:50 +00:00
|
|
|
themeForm += '<div class="container">\n'
|
|
|
|
|
|
|
|
themeForm += \
|
|
|
|
' <h1>' + translate['Theme Designer'] + '</h1>\n'
|
|
|
|
|
|
|
|
themeForm += ' <form method="POST" action="' + \
|
|
|
|
'/users/' + nickname + '/changeThemeSettings">\n'
|
|
|
|
|
|
|
|
for variableName, value in themeJson.items():
|
|
|
|
if variableName.endswith('-color') or \
|
|
|
|
variableName.endswith('-text'):
|
|
|
|
themeForm += \
|
|
|
|
'<p><label class="labels">' + \
|
|
|
|
variableName.replace('-', ' ') + '</label>'
|
|
|
|
themeForm += \
|
|
|
|
'<input type="color" name="themeSetting_' + \
|
|
|
|
variableName + '" value="' + str(value) + '"></p>'
|
|
|
|
|
|
|
|
themeForm += ' </form>\n'
|
|
|
|
themeForm += '</div>\n'
|
|
|
|
themeForm += htmlFooter()
|
|
|
|
return themeForm
|