diff --git a/theme.py b/theme.py index 883df247..aa4ed353 100644 --- a/theme.py +++ b/theme.py @@ -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) - result = True - elif name == 'light': - setThemeLight(baseDir) - result = True - elif name == 'hacker': - setThemeHacker(baseDir) - result = True - elif name == 'highvis': - setThemeHighVis(baseDir) - result = True - else: + + themes = getThemesList() + for themeName in themes: + if name == themeName.lower(): + themeFunctionName = setTheme + themeName + themeFunctionName(baseDir) + result = True + + if not result: # default setThemeDefault(baseDir) result = True + setCustomFont(baseDir) return result diff --git a/webinterface.py b/webinterface.py index 99ff06a5..a2088f2d 100644 --- a/webinterface.py +++ b/webinterface.py @@ -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 + '' moderatorsStr += '' + themes = getThemesList() themesDropdown = '
' themesDropdown += ' ' + translate['Theme'] + '
' themesDropdown += '
' if os.path.isfile(baseDir + '/fonts/custom.woff') or \ os.path.isfile(baseDir + '/fonts/custom.woff2') or \