From 5343c38ff28005d8aa11a5881c6c05458a2e4da0 Mon Sep 17 00:00:00 2001 From: Bob Mottram Date: Thu, 22 Apr 2021 12:51:19 +0100 Subject: [PATCH] Key shortcuts --- webapp_calendar.py | 6 +++++- webapp_login.py | 2 +- webapp_person_options.py | 2 +- webapp_profile.py | 21 +++++++++++++++++++-- webapp_search.py | 2 +- webapp_timeline.py | 20 ++++++++++++++++++-- webapp_utils.py | 8 ++++++-- 7 files changed, 51 insertions(+), 10 deletions(-) diff --git a/webapp_calendar.py b/webapp_calendar.py index 8ba1500cc..4a5c7abb3 100644 --- a/webapp_calendar.py +++ b/webapp_calendar.py @@ -456,7 +456,11 @@ def htmlCalendar(personCache: {}, cssCache: {}, translate: {}, htmlHideFromScreenReader('←') + ' ' + translate['Previous month'] navLinks[prevMonthStr] = calActor + '/calendar?year=' + str(prevYear) + \ '?month=' + str(prevMonthNumber) + # TODO + navAccessKeys = { + } screenReaderCal = \ - htmlKeyboardNavigation(textModeBanner, navLinks, monthName) + htmlKeyboardNavigation(textModeBanner, navLinks, navAccessKeys, + monthName) return headerStr + screenReaderCal + calendarStr + htmlFooter() diff --git a/webapp_login.py b/webapp_login.py index e488d5f46..9e5fa6206 100644 --- a/webapp_login.py +++ b/webapp_login.py @@ -84,7 +84,7 @@ def htmlLogin(cssCache: {}, translate: {}, copyfile(baseDir + '/img/login.png', loginImageFilename) textModeLogo = getTextModeLogo(baseDir) - textModeLogoHtml = htmlKeyboardNavigation(textModeLogo, {}) + textModeLogoHtml = htmlKeyboardNavigation(textModeLogo, {}, {}) if os.path.isfile(baseDir + '/accounts/login-background-custom.jpg'): if not os.path.isfile(baseDir + '/accounts/login-background.jpg'): diff --git a/webapp_person_options.py b/webapp_person_options.py index dc9ccbf04..8019a87c1 100644 --- a/webapp_person_options.py +++ b/webapp_person_options.py @@ -119,7 +119,7 @@ def htmlPersonOptions(defaultTimeline: str, instanceTitle = \ getConfigParam(baseDir, 'instanceTitle') optionsStr = htmlHeaderWithExternalStyle(cssFilename, instanceTitle) - optionsStr += htmlKeyboardNavigation(textModeBanner, {}) + optionsStr += htmlKeyboardNavigation(textModeBanner, {}, {}) optionsStr += '

\n' optionsStr += '
\n' optionsStr += '
\n' diff --git a/webapp_profile.py b/webapp_profile.py index 0f252853e..5f371e0a5 100644 --- a/webapp_profile.py +++ b/webapp_profile.py @@ -755,7 +755,19 @@ def htmlProfile(rssIconAtTop: bool, menuShares: userPathStr + '/shares#timeline', menuLogout: '/logout' } - profileStr = htmlKeyboardNavigation(textModeBanner, navLinks) + navAccessKeys = { + menuTimeline: 't', + menuEdit: 'e', + menuFollowing: 'f', + menuFollowers: 'g', + menuRoles: 'o', + menuSkills: 's', + menuShares: 'h', + menuLogout: 'x' + } + profileStr = htmlKeyboardNavigation(textModeBanner, + navLinks, navAccessKeys, + navAccessKeys) profileStr += profileHeaderStr + donateSection profileStr += '
\n' @@ -1471,7 +1483,12 @@ def htmlEditProfile(cssCache: {}, translate: {}, baseDir: str, path: str, menuProfile: userPathStr, menuTimeline: userTimalineStr } - editProfileForm += htmlKeyboardNavigation(textModeBanner, navLinks) + navAccessKeys = { + menuProfile: 'p', + menuTimeline: 't' + } + editProfileForm += htmlKeyboardNavigation(textModeBanner, + navLinks, navAccessKeys) # top banner editProfileForm += \ diff --git a/webapp_search.py b/webapp_search.py index 16f548266..048ba1647 100644 --- a/webapp_search.py +++ b/webapp_search.py @@ -342,7 +342,7 @@ def htmlSearch(cssCache: {}, translate: {}, searchBannerFile, searchBannerFilename = \ getSearchBannerFile(baseDir, searchNickname, domain, theme) - textModeBannerStr = htmlKeyboardNavigation(textModeBanner, {}) + textModeBannerStr = htmlKeyboardNavigation(textModeBanner, {}, {}) if textModeBannerStr is None: textModeBannerStr = '' diff --git a/webapp_timeline.py b/webapp_timeline.py index 129085978..0d76fed0e 100644 --- a/webapp_timeline.py +++ b/webapp_timeline.py @@ -479,10 +479,26 @@ def htmlTimeline(cssCache: {}, defaultTimeline: str, menuNewswire: usersPath + '/newswiremobile', menuLinks: usersPath + '/linksmobile' } + navAccessKeys = { + menuProfile: 'p', + menuInbox: 'i', + menuSearch: '/', + menuNewPost: 'n', + menuCalendar: 'c', + menuDM: 'm', + menuReplies: 'r', + menuOutbox: 'o', + menuBookmarks: 'k', + menuShares: 's', + menuBlogs: 'b', + menuNewswire: 'w', + menuLinks: 'l' + } if moderator: navLinks[menuModeration] = usersPath + '/moderation#modtimeline' - tlStr += htmlKeyboardNavigation(textModeBanner, navLinks, None, - usersPath, translate, followApprovals) + tlStr += htmlKeyboardNavigation(textModeBanner, navLinks, navAccessKeys, + None, usersPath, translate, + followApprovals) # banner and row of buttons tlStr += \ diff --git a/webapp_utils.py b/webapp_utils.py index c3cbcfc56..d154d8a51 100644 --- a/webapp_utils.py +++ b/webapp_utils.py @@ -1114,7 +1114,7 @@ def htmlHideFromScreenReader(htmlStr: str) -> str: return '' -def htmlKeyboardNavigation(banner: str, links: {}, +def htmlKeyboardNavigation(banner: str, links: {}, accessKeys: {}, subHeading=None, usersPath=None, translate=None, followApprovals=False) -> str: @@ -1138,8 +1138,12 @@ def htmlKeyboardNavigation(banner: str, links: {}, # show the list of links for title, url in links.items(): + accessKeyStr = '' + if accessKeys.get(title): + accessKeyStr = 'accesskey="' + accessKeys[title] + '"' + htmlStr += '
  • \n' htmlStr += '
    \n' return htmlStr