forked from indymedia/epicyon
Have a unified list of themes
parent
559ce0262d
commit
fa6905d850
32
theme.py
32
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
|
||||
|
|
|
@ -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 \
|
||||
|
|
Loading…
Reference in New Issue