Separate variable

merge-requests/30/head
Bob Mottram 2021-02-05 17:05:53 +00:00
parent 49610cae66
commit 1e49b3e352
3 changed files with 37 additions and 40 deletions

View File

@ -40,6 +40,7 @@ from jami import getJamiAddress
from filters import isFiltered
from follow import isFollowerOfPerson
from webapp_frontscreen import htmlFrontScreen
from webapp_utils import htmlKeyboardNavigation
from webapp_utils import scheduledPostsExist
from webapp_utils import getPersonAvatarUrl
from webapp_utils import htmlHeaderWithExternalStyle
@ -708,21 +709,15 @@ def htmlProfile(rssIconAtTop: bool,
pinnedContent)
# keyboard navigation
profileStr = \
'<div class="transparent">' + \
'<label class="transparent">' + \
'<a href="/users/' + nickname + '/' + defaultTimeline + '">' + \
translate['Switch to timeline view'] + '</a></label> | ' + \
'<label class="transparent">' + \
'<a href="/users/' + nickname + '/editprofile">' + \
translate['Edit'] + '</a></label> | ' + \
'<label class="transparent">' + \
'<a class="skip-main" href="#buttonheader">' + \
translate['Skip to timeline'] + '</a></label> | ' + \
'<label class="transparent">' + \
'<a href="/logout">' + \
translate['Logout'] + '</a></label>' + \
'</div>\n'
userPathStr = '/users/' + nickname
userTimelineStr = '/users/' + nickname + '/' + defaultTimeline,
navLinks = {
translate['Switch to timeline view']: userTimelineStr,
translate['Edit']: userPathStr + '/editprofile',
translate['Skip to timeline']: '#buttonheader',
translate['Logout']: '/logout'
}
profileStr = htmlKeyboardNavigation(navLinks)
profileStr += profileHeaderStr + donateSection
profileStr += '<div class="container" id="buttonheader">\n'
@ -1339,15 +1334,13 @@ def htmlEditProfile(cssCache: {}, translate: {}, baseDir: str, path: str,
editProfileForm = htmlHeaderWithExternalStyle(cssFilename, instanceTitle)
# keyboard navigation
editProfileForm += \
'<div class="transparent">' + \
'<label class="transparent">' + \
'<a href="/users/' + nickname + '">' + \
translate['Switch to profile view'] + '</a></label> | ' + \
'<label class="transparent">' + \
'<a href="/users/' + nickname + '/' + defaultTimeline + '">' + \
translate['Switch to timeline view'] + '</a></label>' + \
'</div>\n'
userPathStr = '/users/' + nickname
userTimalineStr = '/users/' + nickname + '/' + defaultTimeline
navLinks = {
translate['Switch to profile view']: userPathStr,
translate['Switch to timeline view']: userTimalineStr
}
editProfileForm += htmlKeyboardNavigation(navLinks)
# top banner
editProfileForm += \

View File

@ -14,6 +14,7 @@ from utils import isEditor
from utils import removeIdEnding
from follow import followerApprovalActive
from person import isPersonSnoozed
from webapp_utils import htmlKeyboardNavigation
from webapp_utils import htmlPostSeparator
from webapp_utils import getBannerFile
from webapp_utils import htmlHeaderWithExternalStyle
@ -364,22 +365,13 @@ def htmlTimeline(cssCache: {}, defaultTimeline: str,
translate['Post'] + '</span></button></a>'
# keyboard navigation
tlStr += \
'<div class="transparent">' + \
'<label class="transparent">' + \
'<a href="/users/' + nickname + '">' + \
translate['Switch to profile view'] + '</a></label> | ' + \
'<label class="transparent">' + \
'<a class="skip-main" href="' + usersPath + '/' + boxName + \
'#timeline">' + \
translate['Skip to timeline'] + '</a></label> | ' + \
'<label class="transparent">' + \
'<a class="skip-newswire" href="#newswire">' + \
translate['Skip to Newswire'] + '</a></label> | ' + \
'<label class="transparent">' + \
'<a class="skip-links" href="#links">' + \
translate['Skip to Links'] + '</a></label>' + \
'</div>\n'
navLinks = {
translate['Switch to profile view']: '/users/' + nickname,
translate['Skip to timeline']: usersPath + '/' + boxName + '#timeline',
translate['Skip to Newswire']: '#newswire',
translate['Skip to Links']: '#links'
}
tlStr += htmlKeyboardNavigation(navLinks)
# banner and row of buttons
tlStr += \

View File

@ -878,3 +878,15 @@ def getAvatarImageUrl(session,
avatarUrl = postActor + '/avatar.png'
return avatarUrl
def htmlKeyboardNavigation(links: {}) -> str:
"""Given a set of links return the html for keyboard navigation
"""
htmlStr = '<div class="transparent">'
for title, url in links.items():
htmlStr += '<label class="transparent">' + \
'<a href="' + url + '">' + \
title + '</a></label> | '
htmlStr += '</div>'
return htmlStr