Load the text mode banner

merge-requests/16/head
Bob Mottram 2021-02-05 19:50:09 +00:00
parent f3ce5cb492
commit 715b69bafb
3 changed files with 19 additions and 2 deletions

View File

@ -230,6 +230,7 @@ from media import removeMetaData
from cache import storePersonInCache
from cache import getPersonFromCache
from httpsig import verifyPostHeaders
from theme import getTextModeBanner
from theme import setNewsAvatar
from theme import setTheme
from theme import getTheme
@ -4171,6 +4172,8 @@ class PubServer(BaseHTTPRequestHandler):
self.server.themeName = fields['themeDropdown']
setTheme(baseDir, self.server.themeName, domain,
allowLocalNetworkAccess)
self.server.textModeBanner = \
getTextModeBanner(self.server.baseDir)
self.server.iconsCache = {}
self.server.fontsCache = {}
self.server.showPublishAsIcon = \
@ -4620,6 +4623,8 @@ class PubServer(BaseHTTPRequestHandler):
self.server.themeName = currTheme
setTheme(baseDir, currTheme, domain,
self.server.allowLocalNetworkAccess)
self.server.textModeBanner = \
getTextModeBanner(self.server.baseDir)
self.server.iconsCache = {}
self.server.fontsCache = {}
self.server.showPublishAsIcon = \
@ -13880,7 +13885,7 @@ def runDaemon(verifyAllSignatures: bool,
return False
# ASCII/ANSI text banner used in shell browsers, such as Lynx
httpd.textModeBanner = None
httpd.textModeBanner = getTextModeBanner(baseDir)
httpd.unitTest = unitTest
httpd.allowLocalNetworkAccess = allowLocalNetworkAccess

View File

@ -422,6 +422,18 @@ def _setThemeFonts(baseDir: str, themeName: str) -> None:
break
def getTextModeBanner(baseDir: str) -> str:
"""Returns the banner used for shell browsers, like Lynx
"""
textModeBannerFilename = baseDir + '/accounts/banner.txt'
if os.path.isfile(textModeBannerFilename):
with open(textModeBannerFilename, 'r') as fp:
bannerStr = fp.read()
if bannerStr:
return bannerStr.replace('\n', '<br>')
return None
def _setThemeImages(baseDir: str, name: str) -> None:
"""Changes the profile background image
and banner to the defaults

View File

@ -888,7 +888,7 @@ def htmlKeyboardNavigation(banner: str, links: {},
htmlStr = '<div class="transparent"><ul>'
if banner:
htmlStr += banner.replace('\n', '<br>') + '<br>'
htmlStr += banner + '<br>'
# show new follower approvals
if usersPath and translate and followApprovals: