Merge branch 'main' of gitlab.com:bashrc2/epicyon

main
Bob Mottram 2021-12-05 23:18:25 +00:00
commit b3018ac972
2 changed files with 115 additions and 25 deletions

View File

@ -2173,7 +2173,24 @@ class PubServer(BaseHTTPRequestHandler):
for fieldStr in fieldsList: for fieldStr in fieldsList:
if '=' not in fieldStr: if '=' not in fieldStr:
continue continue
fields[fieldStr.split('=')[0]] = fieldStr.split('=')[1].strip() fieldValue = fieldStr.split('=')[1].strip()
if not fieldValue:
continue
if fieldValue == 'on':
fieldValue = 'True'
fields[fieldStr.split('=')[0]] = fieldValue
# Check for boolean values which are False.
# These don't come through via themeParams,
# so need to be checked separately
themeFilename = baseDir + '/theme/' + themeName + '/theme.json'
themeJson = loadJson(themeFilename)
if themeJson:
for variableName, value in themeJson.items():
variableName = 'themeSetting_' + variableName
if value.lower() == 'false' or value.lower() == 'true':
if variableName not in fields:
fields[variableName] = 'False'
# get the parameters from the theme designer screen # get the parameters from the theme designer screen
themeDesignerParams = {} themeDesignerParams = {}
@ -2187,6 +2204,33 @@ class PubServer(BaseHTTPRequestHandler):
allowLocalNetworkAccess, allowLocalNetworkAccess,
systemLanguage) systemLanguage)
if 'rss-icon-at-top' in themeDesignerParams:
if themeDesignerParams['rss-icon-at-top'].lower() == 'true':
self.server.rssIconAtTop = True
else:
self.server.rssIconAtTop = False
if 'publish-button-at-top' in themeDesignerParams:
if themeDesignerParams['publish-button-at-top'].lower() == 'true':
self.server.publishButtonAtTop = True
else:
self.server.publishButtonAtTop = False
if 'newswire-publish-icon' in themeDesignerParams:
if themeDesignerParams['newswire-publish-icon'].lower() == 'true':
self.server.showPublishAsIcon = True
else:
self.server.showPublishAsIcon = False
if 'icons-as-buttons' in themeDesignerParams:
if themeDesignerParams['icons-as-buttons'].lower() == 'true':
self.server.iconsAsButtons = True
else:
self.server.iconsAsButtons = False
if 'full-width-timeline-buttons' in themeDesignerParams:
themeValue = themeDesignerParams['full-width-timeline-buttons']
if themeValue.lower() == 'true':
self.server.fullWidthTimelineButtonHeader = True
else:
self.server.fullWidthTimelineButtonHeader = False
# redirect back from theme designer screen # redirect back from theme designer screen
if callingDomain.endswith('.onion') and onionDomain: if callingDomain.endswith('.onion') and onionDomain:
originPathStr = \ originPathStr = \

View File

@ -223,39 +223,85 @@ def htmlThemeDesigner(cssCache: {}, baseDir: str,
'name="submitThemeDesigner" accesskey="' + submitKey + '">' + \ 'name="submitThemeDesigner" accesskey="' + submitKey + '">' + \
translate['Submit'] + '</button>\n </center>\n' translate['Submit'] + '</button>\n </center>\n'
themeForm += ' <table class="accesskeys">\n' tableStr = ' <table class="accesskeys">\n'
themeForm += ' <colgroup>\n' tableStr += ' <colgroup>\n'
themeForm += ' <col span="1" class="accesskeys-left">\n' tableStr += ' <col span="1" class="accesskeys-left">\n'
themeForm += ' <col span="1" class="accesskeys-center">\n' tableStr += ' <col span="1" class="accesskeys-center">\n'
themeForm += ' </colgroup>\n' tableStr += ' </colgroup>\n'
themeForm += ' <tbody>\n' tableStr += ' <tbody>\n'
fontStr = ' <div class="container">\n' + tableStr
colorStr = ' <div class="container">\n' + tableStr
dimensionStr = ' <div class="container">\n' + tableStr
switchStr = ' <div class="container">\n' + tableStr
for variableName, value in themeJson.items(): for variableName, value in themeJson.items():
if 'font-size' in variableName:
variableNameStr = variableName.replace('-', ' ')
variableNameStr = variableNameStr.title()
fontStr += \
' <tr><td><label class="labels">' + \
variableNameStr + '</label></td>'
fontStr += \
'<td><input type="text" name="themeSetting_' + \
variableName + '" value="' + str(value) + \
'" title="' + variableNameStr + '"></td></tr>\n'
elif ('-color' in variableName or
'-background' in variableName or
variableName.endswith('-text')):
# only use colors defined as hex # only use colors defined as hex
if not value.startswith('#'): if not value.startswith('#'):
if color_to_hex.get(value): if color_to_hex.get(value):
value = color_to_hex[value] value = color_to_hex[value]
else: else:
continue continue
if variableName.endswith('-color') or \
variableName.endswith('-text'):
variableNameStr = variableName.replace('-', ' ') variableNameStr = variableName.replace('-', ' ')
if variableNameStr.endswith(' color'): if ' color' in variableNameStr:
variableNameStr = variableNameStr.replace(' color', '') variableNameStr = variableNameStr.replace(' color', '')
if variableNameStr.endswith(' bg'): if ' bg' in variableNameStr:
variableNameStr = variableNameStr.replace(' bg', ' background') variableNameStr = variableNameStr.replace(' bg', ' background')
elif variableNameStr.endswith(' fg'): elif ' fg' in variableNameStr:
variableNameStr = variableNameStr.replace(' fg', ' foreground') variableNameStr = variableNameStr.replace(' fg', ' foreground')
if variableNameStr == 'cw':
variableNameStr = 'content warning'
variableNameStr = variableNameStr.title() variableNameStr = variableNameStr.title()
themeForm += \ colorStr += \
' <tr><td><label class="labels">' + \ ' <tr><td><label class="labels">' + \
variableNameStr + '</label></td>' variableNameStr + '</label></td>'
themeForm += \ colorStr += \
'<td><input type="color" name="themeSetting_' + \ '<td><input type="color" name="themeSetting_' + \
variableName + '" value="' + str(value) + \ variableName + '" value="' + str(value) + \
'" title="' + variableNameStr + '"></p></td></tr>\n' '" title="' + variableNameStr + '"></td></tr>\n'
elif (('-width' in variableName or
'-height' in variableName) and
(value.lower() != 'true' and value.lower() != 'false')):
variableNameStr = variableName.replace('-', ' ')
variableNameStr = variableNameStr.title()
dimensionStr += \
' <tr><td><label class="labels">' + \
variableNameStr + '</label></td>'
dimensionStr += \
'<td><input type="text" name="themeSetting_' + \
variableName + '" value="' + str(value) + \
'" title="' + variableNameStr + '"></td></tr>\n'
elif value.title() == 'True' or value.title() == 'False':
variableNameStr = variableName.replace('-', ' ')
variableNameStr = variableNameStr.title()
switchStr += \
' <tr><td><label class="labels">' + \
variableNameStr + '</label></td>'
checkedStr = ''
if value.title() == 'True':
checkedStr = ' checked'
switchStr += \
'<td><input type="checkbox" class="profilecheckbox" ' + \
'name="themeSetting_' + variableName + '"' + \
checkedStr + '></td></tr>\n'
themeForm += ' </table>\n' colorStr += ' </table>\n </div>\n'
fontStr += ' </table>\n </div>\n'
dimensionStr += ' </table>\n </div>\n'
switchStr += ' </table>\n </div>\n'
themeForm += colorStr + fontStr + dimensionStr + switchStr
themeForm += ' </form>\n' themeForm += ' </form>\n'
themeForm += '</div>\n' themeForm += '</div>\n'
themeForm += htmlFooter() themeForm += htmlFooter()