forked from indymedia/epicyon
Have a unified list of themes
parent
559ce0262d
commit
fa6905d850
30
theme.py
30
theme.py
|
@ -11,6 +11,15 @@ from utils import loadJson
|
||||||
from utils import saveJson
|
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:
|
def setThemeInConfig(baseDir: str, name: str) -> bool:
|
||||||
configFilename = baseDir + '/config.json'
|
configFilename = baseDir + '/config.json'
|
||||||
if not os.path.isfile(configFilename):
|
if not os.path.isfile(configFilename):
|
||||||
|
@ -263,21 +272,18 @@ def setThemeLight(baseDir: str):
|
||||||
|
|
||||||
def setTheme(baseDir: str, name: str) -> bool:
|
def setTheme(baseDir: str, name: str) -> bool:
|
||||||
result = False
|
result = False
|
||||||
if name == 'purple':
|
|
||||||
setThemePurple(baseDir)
|
themes = getThemesList()
|
||||||
|
for themeName in themes:
|
||||||
|
if name == themeName.lower():
|
||||||
|
themeFunctionName = setTheme + themeName
|
||||||
|
themeFunctionName(baseDir)
|
||||||
result = True
|
result = True
|
||||||
elif name == 'light':
|
|
||||||
setThemeLight(baseDir)
|
if not result:
|
||||||
result = True
|
|
||||||
elif name == 'hacker':
|
|
||||||
setThemeHacker(baseDir)
|
|
||||||
result = True
|
|
||||||
elif name == 'highvis':
|
|
||||||
setThemeHighVis(baseDir)
|
|
||||||
result = True
|
|
||||||
else:
|
|
||||||
# default
|
# default
|
||||||
setThemeDefault(baseDir)
|
setThemeDefault(baseDir)
|
||||||
result = True
|
result = True
|
||||||
|
|
||||||
setCustomFont(baseDir)
|
setCustomFont(baseDir)
|
||||||
return result
|
return result
|
||||||
|
|
|
@ -70,6 +70,7 @@ from happening import thisWeeksEventsCheck
|
||||||
from happening import getCalendarEvents
|
from happening import getCalendarEvents
|
||||||
from happening import getTodaysEvents
|
from happening import getTodaysEvents
|
||||||
from git import isGitPatch
|
from git import isGitPatch
|
||||||
|
from theme import getThemesList
|
||||||
|
|
||||||
|
|
||||||
def getBlogAddress(actorJson: {}) -> str:
|
def getBlogAddress(actorJson: {}) -> str:
|
||||||
|
@ -1151,20 +1152,15 @@ def htmlEditProfile(translate: {}, baseDir: str, path: str,
|
||||||
'..." style="height:200px">' + moderators + '</textarea>'
|
'..." style="height:200px">' + moderators + '</textarea>'
|
||||||
moderatorsStr += '</div>'
|
moderatorsStr += '</div>'
|
||||||
|
|
||||||
|
themes = getThemesList()
|
||||||
themesDropdown = '<div class="container">'
|
themesDropdown = '<div class="container">'
|
||||||
themesDropdown += ' <b>' + translate['Theme'] + '</b><br>'
|
themesDropdown += ' <b>' + translate['Theme'] + '</b><br>'
|
||||||
themesDropdown += ' <select id="themeDropdown" ' + \
|
themesDropdown += ' <select id="themeDropdown" ' + \
|
||||||
'name="themeDropdown" class="theme">'
|
'name="themeDropdown" class="theme">'
|
||||||
themesDropdown += ' <option value="default">' + \
|
for themeName in themes:
|
||||||
translate['Default'] + '</option>'
|
themesDropdown += ' <option value="' + \
|
||||||
themesDropdown += ' <option value="light">' + \
|
themeName.lower() + '">' + \
|
||||||
translate['Light'] + '</option>'
|
translate[themeName] + '</option>'
|
||||||
themesDropdown += ' <option value="purple">' + \
|
|
||||||
translate['Purple'] + '</option>'
|
|
||||||
themesDropdown += ' <option value="hacker">' + \
|
|
||||||
translate['Hacker'] + '</option>'
|
|
||||||
themesDropdown += ' <option value="highvis">' + \
|
|
||||||
translate['HighVis'] + '</option>'
|
|
||||||
themesDropdown += ' </select><br>'
|
themesDropdown += ' </select><br>'
|
||||||
if os.path.isfile(baseDir + '/fonts/custom.woff') or \
|
if os.path.isfile(baseDir + '/fonts/custom.woff') or \
|
||||||
os.path.isfile(baseDir + '/fonts/custom.woff2') or \
|
os.path.isfile(baseDir + '/fonts/custom.woff2') or \
|
||||||
|
|
Loading…
Reference in New Issue