diff --git a/daemon.py b/daemon.py index 4dba9f72b..dc1f274bb 100644 --- a/daemon.py +++ b/daemon.py @@ -2173,7 +2173,24 @@ class PubServer(BaseHTTPRequestHandler): for fieldStr in fieldsList: if '=' not in fieldStr: 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 themeDesignerParams = {} @@ -2187,6 +2204,33 @@ class PubServer(BaseHTTPRequestHandler): allowLocalNetworkAccess, 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 if callingDomain.endswith('.onion') and onionDomain: originPathStr = \ diff --git a/webapp_themeDesigner.py b/webapp_themeDesigner.py index 36de7b4da..d2b7b5177 100644 --- a/webapp_themeDesigner.py +++ b/webapp_themeDesigner.py @@ -223,39 +223,85 @@ def htmlThemeDesigner(cssCache: {}, baseDir: str, 'name="submitThemeDesigner" accesskey="' + submitKey + '">' + \ translate['Submit'] + '\n \n' - themeForm += ' \n' - themeForm += ' \n' - themeForm += ' \n' - themeForm += ' \n' - themeForm += ' \n' - themeForm += ' \n' + tableStr = '
\n' + tableStr += ' \n' + tableStr += ' \n' + tableStr += ' \n' + tableStr += ' \n' + tableStr += ' \n' + fontStr = '
\n' + tableStr + colorStr = '
\n' + tableStr + dimensionStr = '
\n' + tableStr + switchStr = '
\n' + tableStr for variableName, value in themeJson.items(): - # only use colors defined as hex - if not value.startswith('#'): - if color_to_hex.get(value): - value = color_to_hex[value] - else: - continue - if variableName.endswith('-color') or \ - variableName.endswith('-text'): + if 'font-size' in variableName: variableNameStr = variableName.replace('-', ' ') - if variableNameStr.endswith(' color'): - variableNameStr = variableNameStr.replace(' color', '') - if variableNameStr.endswith(' bg'): - variableNameStr = variableNameStr.replace(' bg', ' background') - elif variableNameStr.endswith(' fg'): - variableNameStr = variableNameStr.replace(' fg', ' foreground') variableNameStr = variableNameStr.title() - themeForm += \ + fontStr += \ '
' - themeForm += \ + fontStr += \ + '\n' + elif ('-color' in variableName or + '-background' in variableName or + variableName.endswith('-text')): + # only use colors defined as hex + if not value.startswith('#'): + if color_to_hex.get(value): + value = color_to_hex[value] + else: + continue + variableNameStr = variableName.replace('-', ' ') + if ' color' in variableNameStr: + variableNameStr = variableNameStr.replace(' color', '') + if ' bg' in variableNameStr: + variableNameStr = variableNameStr.replace(' bg', ' background') + elif ' fg' in variableNameStr: + variableNameStr = variableNameStr.replace(' fg', ' foreground') + if variableNameStr == 'cw': + variableNameStr = 'content warning' + variableNameStr = variableNameStr.title() + colorStr += \ + ' ' + colorStr += \ '\n' + '" title="' + variableNameStr + '">\n' + elif (('-width' in variableName or + '-height' in variableName) and + (value.lower() != 'true' and value.lower() != 'false')): + variableNameStr = variableName.replace('-', ' ') + variableNameStr = variableNameStr.title() + dimensionStr += \ + ' ' + dimensionStr += \ + '\n' + elif value.title() == 'True' or value.title() == 'False': + variableNameStr = variableName.replace('-', ' ') + variableNameStr = variableNameStr.title() + switchStr += \ + ' ' + checkedStr = '' + if value.title() == 'True': + checkedStr = ' checked' + switchStr += \ + '\n' - themeForm += '

\n' + colorStr += ' \n \n' + fontStr += ' \n \n' + dimensionStr += ' \n \n' + switchStr += ' \n \n' + themeForm += colorStr + fontStr + dimensionStr + switchStr themeForm += ' \n' themeForm += '\n' themeForm += htmlFooter()