mirror of https://gitlab.com/bashrc2/epicyon
Set theme specific help files when changing theme
parent
18272a101f
commit
b2bece502e
11
daemon.py
11
daemon.py
|
@ -3899,7 +3899,8 @@ class PubServer(BaseHTTPRequestHandler):
|
|||
baseDir: str, httpPrefix: str,
|
||||
domain: str, domainFull: str,
|
||||
onionDomain: str, i2pDomain: str,
|
||||
debug: bool, allowLocalNetworkAccess: bool) -> None:
|
||||
debug: bool, allowLocalNetworkAccess: bool,
|
||||
systemLanguage: str) -> None:
|
||||
"""Updates your user profile after editing via the Edit button
|
||||
on the profile screen
|
||||
"""
|
||||
|
@ -4289,7 +4290,7 @@ class PubServer(BaseHTTPRequestHandler):
|
|||
if fields.get('themeDropdown'):
|
||||
self.server.themeName = fields['themeDropdown']
|
||||
setTheme(baseDir, self.server.themeName, domain,
|
||||
allowLocalNetworkAccess)
|
||||
allowLocalNetworkAccess, systemLanguage)
|
||||
self.server.textModeBanner = \
|
||||
getTextModeBanner(self.server.baseDir)
|
||||
self.server.iconsCache = {}
|
||||
|
@ -4759,7 +4760,8 @@ class PubServer(BaseHTTPRequestHandler):
|
|||
if currTheme:
|
||||
self.server.themeName = currTheme
|
||||
setTheme(baseDir, currTheme, domain,
|
||||
self.server.allowLocalNetworkAccess)
|
||||
self.server.allowLocalNetworkAccess,
|
||||
systemLanguage)
|
||||
self.server.textModeBanner = \
|
||||
getTextModeBanner(self.server.baseDir)
|
||||
self.server.iconsCache = {}
|
||||
|
@ -13543,7 +13545,8 @@ class PubServer(BaseHTTPRequestHandler):
|
|||
self.server.domainFull,
|
||||
self.server.onionDomain,
|
||||
self.server.i2pDomain, self.server.debug,
|
||||
self.server.allowLocalNetworkAccess)
|
||||
self.server.allowLocalNetworkAccess,
|
||||
self.server.systemLanguage)
|
||||
return
|
||||
|
||||
if authorized and self.path.endswith('/linksdata'):
|
||||
|
|
|
@ -2325,7 +2325,8 @@ if YTDomain:
|
|||
if '.' in YTDomain:
|
||||
args.YTReplacementDomain = YTDomain
|
||||
|
||||
if setTheme(baseDir, themeName, domain, args.allowLocalNetworkAccess):
|
||||
if setTheme(baseDir, themeName, domain,
|
||||
args.allowLocalNetworkAccess, args.language):
|
||||
print('Theme set to ' + themeName)
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
|
21
theme.py
21
theme.py
|
@ -50,6 +50,24 @@ def getThemesList(baseDir: str) -> []:
|
|||
return themes
|
||||
|
||||
|
||||
def _copyThemeHelpFiles(baseDir: str, themeName: str,
|
||||
systemLanguage: str) -> None:
|
||||
"""Copies any theme specific help files from the welcome subdirectory
|
||||
"""
|
||||
themeDir = baseDir + '/theme/' + themeName + '/welcome'
|
||||
if not os.path.isdir(themeDir):
|
||||
themeDir = baseDir + '/defaultwelcome'
|
||||
for subdir, dirs, files in os.walk(themeDir):
|
||||
for helpMarkdownFile in files:
|
||||
if helpMarkdownFile.endswith('_' + systemLanguage + '.md'):
|
||||
destHelpMarkdownFile = \
|
||||
helpMarkdownFile.replace('_' + systemLanguage + '.md',
|
||||
'.md')
|
||||
copyfile(themeDir + '/' + helpMarkdownFile,
|
||||
baseDir + '/accounts/' + destHelpMarkdownFile)
|
||||
break
|
||||
|
||||
|
||||
def _setThemeInConfig(baseDir: str, name: str) -> bool:
|
||||
"""Sets the theme with the given name within config.json
|
||||
"""
|
||||
|
@ -642,7 +660,7 @@ def _setClearCacheFlag(baseDir: str) -> None:
|
|||
|
||||
|
||||
def setTheme(baseDir: str, name: str, domain: str,
|
||||
allowLocalNetworkAccess: bool) -> bool:
|
||||
allowLocalNetworkAccess: bool, systemLanguage: str) -> bool:
|
||||
"""Sets the theme with the given name as the current theme
|
||||
"""
|
||||
result = False
|
||||
|
@ -695,6 +713,7 @@ def setTheme(baseDir: str, name: str, domain: str,
|
|||
else:
|
||||
disableGrayscale(baseDir)
|
||||
|
||||
_copyThemeHelpFiles(baseDir, name, systemLanguage)
|
||||
_setThemeInConfig(baseDir, name)
|
||||
_setClearCacheFlag(baseDir)
|
||||
return result
|
||||
|
|
Loading…
Reference in New Issue