Have a unified list of themes

main
Bob Mottram 2020-05-28 10:11:21 +01:00
parent 559ce0262d
commit fa6905d850
2 changed files with 25 additions and 23 deletions

View File

@ -11,6 +11,15 @@ from utils import loadJson
from utils import saveJson
def getThemesList() -> []:
"""Returns the list of available themes
Note that these should be capitalized, since they're
also used to create the web interface dropdown list
and to lookup function names
"""
return ('Default', 'Light', 'Purple', 'Hacker', 'HighVis')
def setThemeInConfig(baseDir: str, name: str) -> bool:
configFilename = baseDir + '/config.json'
if not os.path.isfile(configFilename):
@ -263,21 +272,18 @@ def setThemeLight(baseDir: str):
def setTheme(baseDir: str, name: str) -> bool:
result = False
if name == 'purple':
setThemePurple(baseDir)
themes = getThemesList()
for themeName in themes:
if name == themeName.lower():
themeFunctionName = setTheme + themeName
themeFunctionName(baseDir)
result = True
elif name == 'light':
setThemeLight(baseDir)
result = True
elif name == 'hacker':
setThemeHacker(baseDir)
result = True
elif name == 'highvis':
setThemeHighVis(baseDir)
result = True
else:
if not result:
# default
setThemeDefault(baseDir)
result = True
setCustomFont(baseDir)
return result

View File

@ -70,6 +70,7 @@ from happening import thisWeeksEventsCheck
from happening import getCalendarEvents
from happening import getTodaysEvents
from git import isGitPatch
from theme import getThemesList
def getBlogAddress(actorJson: {}) -> str:
@ -1151,20 +1152,15 @@ def htmlEditProfile(translate: {}, baseDir: str, path: str,
'..." style="height:200px">' + moderators + '</textarea>'
moderatorsStr += '</div>'
themes = getThemesList()
themesDropdown = '<div class="container">'
themesDropdown += ' <b>' + translate['Theme'] + '</b><br>'
themesDropdown += ' <select id="themeDropdown" ' + \
'name="themeDropdown" class="theme">'
themesDropdown += ' <option value="default">' + \
translate['Default'] + '</option>'
themesDropdown += ' <option value="light">' + \
translate['Light'] + '</option>'
themesDropdown += ' <option value="purple">' + \
translate['Purple'] + '</option>'
themesDropdown += ' <option value="hacker">' + \
translate['Hacker'] + '</option>'
themesDropdown += ' <option value="highvis">' + \
translate['HighVis'] + '</option>'
for themeName in themes:
themesDropdown += ' <option value="' + \
themeName.lower() + '">' + \
translate[themeName] + '</option>'
themesDropdown += ' </select><br>'
if os.path.isfile(baseDir + '/fonts/custom.woff') or \
os.path.isfile(baseDir + '/fonts/custom.woff2') or \