Continue refactoring for News instances

alt-html-css
Admin 2020-11-19 10:49:18 +00:00
parent 685959b976
commit 226996c042
1 changed files with 90 additions and 35 deletions

View File

@ -122,16 +122,44 @@ def htmlTimeline(cssCache: {}, defaultTimeline: str,
# Banner and "profile toggle" link
tlStr += '<div class="header">\n'
# TODO: This CSS should be moved out of the code
# Items like this that can be different per user should be kept
# in the user's folder and loaded as final CSS, to allow overwrite(s)
tlStr += (f"\t<a class=\"timeline-banner hidden-text\" href=\"/users/{nickname}\" "
f"style=\"background-image: url('{usersPath}/{bannerFile}');\">"
f"{translate['Switch to profile view']}</a>\n")
if not newsHeader:
tlStr += (f"\t<a class=\"timeline-banner hidden-text\" href=\"/users/{nickname}\" "
f"style=\"background-image: url('{usersPath}/{bannerFile}');\">"
f"{translate['Switch to profile view']}</a>\n")
else:
# TODO: News instances should ignore personalised banners
# Currently uses the 'news' actor banner - as it remains unchanged
tlStr += (f"\t<a class=\"timeline-banner hidden-text\" href=\"/tlnews\" "
f"style=\"background-image: url('/users/news/{bannerFile}');\">"
f"{translate['News']}</a>\n")
tlStr += '</div>\n'
# Full Row of Buttons
if fullWidthTimelineButtonHeader:
# TODO: Include '/editprofile' link on 'User' page for 'News' instances
# Full row "navbar"
if defaultTimeline == 'tlnews':
# Show "tab" links instead of standard "buttons"
tlStr += headerNewsTabs(boxName, translate, usersPath, moderator, baseDir)
# Only show standard "buttons" on 'inbox' page
if boxName == 'inbox':
tlStr += \
headerButtonsTimeline(defaultTimeline, boxName, pageNumber,
translate, usersPath,
minimal, moderator,
manuallyApproveFollowers,
baseDir, nickname,
domain, timelineStartTime,
iconsAsButtons)
elif fullWidthTimelineButtonHeader:
tlStr += \
headerButtonsTimeline(defaultTimeline, boxName, pageNumber,
translate, usersPath,
@ -152,12 +180,12 @@ def htmlTimeline(cssCache: {}, defaultTimeline: str,
httpPrefix, translate,
editor, False, None, rssIconAtTop,
True, False)
tlStr += ' <div class="col-left">\n' + \
tlStr += ' <div class="section links">\n' + \
leftColumnStr + ' </div>\n'
# center column containing posts
tlStr += ' <div class="col-center">\n'
tlStr += ' <div class="section main">\n'
if not fullWidthTimelineButtonHeader:
if not defaultTimeline == 'tlnews' and not fullWidthTimelineButtonHeader:
tlStr += \
headerButtonsTimeline(defaultTimeline, boxName, pageNumber,
translate, usersPath,
@ -347,7 +375,7 @@ def htmlTimeline(cssCache: {}, defaultTimeline: str,
showPublishAsIcon,
rssIconAtTop, publishButtonAtTop,
authorized, True)
tlStr += ' <div class="col-right">' + \
tlStr += ' <div class="section newswire">' + \
rightColumnStr + ' </div>\n'
_logTimelineTiming(enableTimingLog, timelineStartTime, boxName, '9')
@ -524,30 +552,6 @@ def headerButtonsTimeline(defaultTimeline: str,
tlStr = '\t<div class="containerHeader">\n'
# TODO: Fix that the following two bools are equivalent
# - Pick one and move on
# if this is a news instance and we are viewing the news timeline
newsHeader = False
if defaultTimeline == 'tlnews' and boxName == 'tlnews':
newsHeader = True
isFeaturesTimeline = \
defaultTimeline == 'tlnews' and boxName == 'tlnews'
# TODO: Easiest solution for News instance tab links
# - Simply hide the button row
# - Draw a separate <div> just for News tabs
# if newsHeader:
# tlStr += \
# '<a href="' + usersPath + '/inbox">' + \
# '<button class="button">' + \
# '<span>' + translate['User'] + '</span></button></a>'
# tlStr += \
# '<a href="' + usersPath + '/editprofile">' + \
# '<button class="buttonDesktop">' + \
# '<span>' + translate['Settings'] + '</span></button></a>'
# TODO: Group _all_ items that are hidden in 'minimal' mode ?
# - Are there others elsewhere in the code ?
@ -654,7 +658,7 @@ def headerButtonsTimeline(defaultTimeline: str,
# Generate HTML list
navButtonStr = '\t\t<div class="navbuttons">\n'
navButtonStr += '\t\t\t<ul class="menu">\n'
navButtonStr += '\t\t\t<ul class="button-bar">\n'
for name, config in navButtonList:
classStr = 'button-test'
textStr = ''
@ -791,7 +795,7 @@ def headerButtonsTimeline(defaultTimeline: str,
))
actionButtonStr = '\t\t<div class="actionbuttons">\n'
actionButtonStr += '\t\t\t<ul class="menu">\n'
actionButtonStr += '\t\t\t<ul class="button-bar">\n'
# TODO: [rename] 'timelineicon' should maybe be more generic, e.g 'icon-button'
@ -837,6 +841,57 @@ def headerButtonsTimeline(defaultTimeline: str,
return tlStr
def headerNewsTabs(boxName: str,
translate: {},
usersPath: str,
moderator: bool,
baseDir: str) -> str:
navTabList = []
navTabList.append(('tlnews',
{'pageRef': '/tlnews',
'translateText': 'Features'}
))
navTabList.append(('newswiremobile',
{'pageRef': '/newswiremobile',
'translateText': 'News'}
))
navTabList.append(('calendar',
{'pageRef': '/calendar',
'translateText': 'Calendar'}
))
navTabList.append(('linksmobile',
{'pageRef': '/linksmobile',
'translateText': 'Links'}
))
navTabList.append(('inbox',
{'pageRef': '/inbox',
'translateText': 'User'}
))
navStr = '\t\t<div class="navtabs">\n'
navStr += '\t\t\t<ul>\n'
for name, config in navTabList:
classStr = ''
if name == boxName:
classStr = 'tab-highlight'
if 'class' in config:
classStr += ' ' + config['class']
textStr = translate[config['translateText']]
navStr += (f"\t\t\t\t<a class=\"{classStr}\" href=\"{usersPath}{config['pageRef']}\">\n"
f'\t\t\t\t\t<li>{textStr}</li>\n'
f'\t\t\t\t</a>\n')
navStr += '\t\t\t</ul>\n\t\t</div>\n'
return navStr
def htmlShares(cssCache: {}, defaultTimeline: str,
recentPostsCache: {}, maxRecentPosts: int,
translate: {}, pageNumber: int, itemsPerPage: int,