From a08f3d2cd7d83744a842dfc014d89f9159afa640 Mon Sep 17 00:00:00 2001 From: Bob Mottram Date: Wed, 9 Dec 2020 12:29:56 +0000 Subject: [PATCH] Icons web path --- daemon.py | 18 +++++++++++++----- webapp_utils.py | 13 +++++++------ 2 files changed, 20 insertions(+), 11 deletions(-) diff --git a/daemon.py b/daemon.py index f6085fc1b..66621de3f 100644 --- a/daemon.py +++ b/daemon.py @@ -3823,9 +3823,8 @@ class PubServer(BaseHTTPRequestHandler): # change theme if fields.get('themeDropdown'): - setTheme(baseDir, - fields['themeDropdown'], - domain, + self.themeName = fields['themeDropdown'] + setTheme(baseDir, self.themeName, domain, allowLocalNetworkAccess) self.server.showPublishAsIcon = \ getConfigParam(self.server.baseDir, @@ -4197,6 +4196,7 @@ class PubServer(BaseHTTPRequestHandler): '.etag') currTheme = getTheme(baseDir) if currTheme: + self.themeName = currTheme setTheme(baseDir, currTheme, domain, self.server.allowLocalNetworkAccess) self.server.showPublishAsIcon = \ @@ -5060,8 +5060,11 @@ class PubServer(BaseHTTPRequestHandler): if path.endswith('.png'): mediaStr = path.split('/icons/')[1] if '/' not in mediaStr: - theme = 'default' - iconFilename = mediaStr + if not self.themeName: + theme = 'default' + else: + theme = self.themeName + iconFilename = mediaStr else: theme = mediaStr.split('/')[0] iconFilename = mediaStr.split('/')[1] @@ -13113,6 +13116,11 @@ def runDaemon(maxNewswirePosts: int, else: httpd.thrPostsQueue.start() + # get the current theme + httpd.themeName = getConfigParam(baseDir, 'theme') + if not httpd.themeName: + httpd.themeName = 'default' + print('Creating expire thread for shared items') httpd.thrSharesExpire = \ threadWithTrace(target=runSharesExpire, diff --git a/webapp_utils.py b/webapp_utils.py index 40bee5c39..4aa599148 100644 --- a/webapp_utils.py +++ b/webapp_utils.py @@ -393,12 +393,13 @@ def getPersonAvatarUrl(baseDir: str, personUrl: str, personCache: {}, def getIconsWebPath(baseDir: str) -> str: """Returns the web path where icons exist """ - iconsPath = 'icons' - theme = getConfigParam(baseDir, 'theme') - if theme: - if os.path.isdir(baseDir + '/theme/' + theme + '/icons'): - iconsPath = 'icons/' + theme - return iconsPath + return 'icons' +# iconsPath = 'icons' +# theme = getConfigParam(baseDir, 'theme') +# if theme: +# if os.path.isdir(baseDir + '/theme/' + theme + '/icons'): +# iconsPath = 'icons/' + theme +# return iconsPath def scheduledPostsExist(baseDir: str, nickname: str, domain: str) -> bool: