Defining news themes

merge-requests/30/head
Bob Mottram 2021-02-27 11:44:50 +00:00
parent e4b3a22264
commit 99163d66e8
4 changed files with 29 additions and 8 deletions

View File

@ -239,6 +239,7 @@ from cache import checkForChangedActor
from cache import storePersonInCache from cache import storePersonInCache
from cache import getPersonFromCache from cache import getPersonFromCache
from httpsig import verifyPostHeaders from httpsig import verifyPostHeaders
from theme import isNewsThemeName
from theme import getTextModeBanner from theme import getTextModeBanner
from theme import setNewsAvatar from theme import setNewsAvatar
from theme import setTheme from theme import setTheme
@ -4227,6 +4228,11 @@ class PubServer(BaseHTTPRequestHandler):
"mediaInstance", "mediaInstance",
self.server.mediaInstance) self.server.mediaInstance)
# is this a news theme?
if isNewsThemeName(self.server.baseDir,
self.server.themeName):
fields['newsInstance'] = 'on'
# change news instance status # change news instance status
if fields.get('newsInstance'): if fields.get('newsInstance'):
self.server.newsInstance = False self.server.newsInstance = False
@ -14274,14 +14280,6 @@ def runDaemon(brochMode: bool,
httpd.i2pDomain = i2pDomain httpd.i2pDomain = i2pDomain
httpd.mediaInstance = mediaInstance httpd.mediaInstance = mediaInstance
httpd.blogsInstance = blogsInstance 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 # load translations dictionary
httpd.translate = {} httpd.translate = {}
@ -14445,6 +14443,18 @@ def runDaemon(brochMode: bool,
httpd.themeName = getConfigParam(baseDir, 'theme') httpd.themeName = getConfigParam(baseDir, 'theme')
if not httpd.themeName: if not httpd.themeName:
httpd.themeName = 'default' 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, setNewsAvatar(baseDir,
httpd.themeName, httpd.themeName,
httpPrefix, httpPrefix,

View File

@ -23,6 +23,15 @@ def _getThemeFiles() -> []:
'welcome.css') '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) -> []: def getThemesList(baseDir: str) -> []:
"""Returns the list of available themes """Returns the list of available themes
Note that these should be capitalized, since they're Note that these should be capitalized, since they're

View File

@ -0,0 +1 @@

View File

@ -0,0 +1 @@