diff --git a/daemon.py b/daemon.py index ef1f8c3cd..7cfc0fc2f 100644 --- a/daemon.py +++ b/daemon.py @@ -239,6 +239,7 @@ from cache import checkForChangedActor from cache import storePersonInCache from cache import getPersonFromCache from httpsig import verifyPostHeaders +from theme import isNewsThemeName from theme import getTextModeBanner from theme import setNewsAvatar from theme import setTheme @@ -4227,6 +4228,11 @@ class PubServer(BaseHTTPRequestHandler): "mediaInstance", self.server.mediaInstance) + # is this a news theme? + if isNewsThemeName(self.server.baseDir, + self.server.themeName): + fields['newsInstance'] = 'on' + # change news instance status if fields.get('newsInstance'): self.server.newsInstance = False @@ -14274,14 +14280,6 @@ def runDaemon(brochMode: bool, httpd.i2pDomain = i2pDomain httpd.mediaInstance = mediaInstance httpd.blogsInstance = blogsInstance - httpd.newsInstance = newsInstance - httpd.defaultTimeline = 'inbox' - if mediaInstance: - httpd.defaultTimeline = 'tlmedia' - if blogsInstance: - httpd.defaultTimeline = 'tlblogs' - if newsInstance: - httpd.defaultTimeline = 'tlfeatures' # load translations dictionary httpd.translate = {} @@ -14445,6 +14443,18 @@ def runDaemon(brochMode: bool, httpd.themeName = getConfigParam(baseDir, 'theme') if not httpd.themeName: httpd.themeName = 'default' + if isNewsThemeName(baseDir, httpd.themeName): + newsInstance = True + + httpd.newsInstance = newsInstance + httpd.defaultTimeline = 'inbox' + if mediaInstance: + httpd.defaultTimeline = 'tlmedia' + if blogsInstance: + httpd.defaultTimeline = 'tlblogs' + if newsInstance: + httpd.defaultTimeline = 'tlfeatures' + setNewsAvatar(baseDir, httpd.themeName, httpPrefix, diff --git a/theme.py b/theme.py index 008d0a7f3..9a4800380 100644 --- a/theme.py +++ b/theme.py @@ -23,6 +23,15 @@ def _getThemeFiles() -> []: 'welcome.css') +def isNewsThemeName(baseDir: str, themeName: str) -> bool: + """Returns true if the given theme is a news instance + """ + themeDir = baseDir + '/theme/' + themeName + if os.path.isfile(themeDir + '/is_news_instance'): + return True + return False + + def getThemesList(baseDir: str) -> []: """Returns the list of available themes Note that these should be capitalized, since they're diff --git a/theme/indymediaclassic/is_news_instance b/theme/indymediaclassic/is_news_instance new file mode 100644 index 000000000..0519ecba6 --- /dev/null +++ b/theme/indymediaclassic/is_news_instance @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/theme/indymediamodern/is_news_instance b/theme/indymediamodern/is_news_instance new file mode 100644 index 000000000..0519ecba6 --- /dev/null +++ b/theme/indymediamodern/is_news_instance @@ -0,0 +1 @@ + \ No newline at end of file