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

View File

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

View File

@ -878,3 +878,15 @@ def getAvatarImageUrl(session,
avatarUrl = postActor + '/avatar.png' avatarUrl = postActor + '/avatar.png'
return avatarUrl 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