From 1e49b3e352dfd11d81742f1d69f8f8b2b7b77bf4 Mon Sep 17 00:00:00 2001 From: Bob Mottram Date: Fri, 5 Feb 2021 17:05:53 +0000 Subject: [PATCH] Separate variable --- webapp_profile.py | 41 +++++++++++++++++------------------------ webapp_timeline.py | 24 ++++++++---------------- webapp_utils.py | 12 ++++++++++++ 3 files changed, 37 insertions(+), 40 deletions(-) diff --git a/webapp_profile.py b/webapp_profile.py index 5be20f6e0..0a5aef3ef 100644 --- a/webapp_profile.py +++ b/webapp_profile.py @@ -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 = \ - '
' + \ - ' | ' + \ - ' | ' + \ - ' | ' + \ - '' + \ - '
\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 += '
\n' @@ -1339,15 +1334,13 @@ def htmlEditProfile(cssCache: {}, translate: {}, baseDir: str, path: str, editProfileForm = htmlHeaderWithExternalStyle(cssFilename, instanceTitle) # keyboard navigation - editProfileForm += \ - '\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 += \ diff --git a/webapp_timeline.py b/webapp_timeline.py index 112348ee2..371e52924 100644 --- a/webapp_timeline.py +++ b/webapp_timeline.py @@ -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'] + '' # keyboard navigation - tlStr += \ - '\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 += \ diff --git a/webapp_utils.py b/webapp_utils.py index 1531c912f..bbf124f50 100644 --- a/webapp_utils.py +++ b/webapp_utils.py @@ -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 = '
' + for title, url in links.items(): + htmlStr += ' | ' + htmlStr += '
' + return htmlStr