From a8063e1c0dd6a433d073d108886e6801e7a6f8fe Mon Sep 17 00:00:00 2001 From: Bob Mottram Date: Thu, 22 Apr 2021 16:06:24 +0100 Subject: [PATCH] Key access to individual timeline posts --- inbox.py | 2 +- webapp_confirm.py | 2 +- webapp_frontscreen.py | 2 +- webapp_post.py | 43 ++++++++++++++++++++++++++++++++----------- webapp_profile.py | 4 ++-- webapp_search.py | 4 ++-- webapp_timeline.py | 5 +++-- 7 files changed, 42 insertions(+), 20 deletions(-) diff --git a/inbox.py b/inbox.py index da64d8f54..747f29936 100644 --- a/inbox.py +++ b/inbox.py @@ -178,7 +178,7 @@ def _inboxStorePostToHtmlCache(recentPostsCache: {}, maxRecentPosts: int, httpPrefix, __version__, boxname, None, showPublishedDateOnly, peertubeInstances, allowLocalNetworkAccess, - themeName, + themeName, 0, not isDM(postJsonObject), True, True, False, True) diff --git a/webapp_confirm.py b/webapp_confirm.py index 346d94893..7442fd6d2 100644 --- a/webapp_confirm.py +++ b/webapp_confirm.py @@ -73,7 +73,7 @@ def htmlConfirmDelete(cssCache: {}, YTReplacementDomain, showPublishedDateOnly, peertubeInstances, allowLocalNetworkAccess, - themeName, + themeName, 0, False, False, False, False, False) deletePostStr += '
' deletePostStr += \ diff --git a/webapp_frontscreen.py b/webapp_frontscreen.py index 0d3d18486..2f725acee 100644 --- a/webapp_frontscreen.py +++ b/webapp_frontscreen.py @@ -72,7 +72,7 @@ def _htmlFrontScreenPosts(recentPostsCache: {}, maxRecentPosts: int, showPublishedDateOnly, peertubeInstances, allowLocalNetworkAccess, - themeName, + themeName, 0, False, False, False, True, False) if postStr: profileStr += postStr + separatorStr diff --git a/webapp_post.py b/webapp_post.py index 4b6fdfba3..18ded1c34 100644 --- a/webapp_post.py +++ b/webapp_post.py @@ -119,7 +119,7 @@ def prepareHtmlPostNickname(nickname: str, postHtml: str) -> str: def preparePostFromHtmlCache(nickname: str, postHtml: str, boxName: str, - pageNumber: int) -> str: + pageNumber: int, accessKeyIndex: int) -> str: """Sets the page number on a cached html post """ # if on the bookmarks timeline then remain there @@ -134,6 +134,19 @@ def preparePostFromHtmlCache(nickname: str, postHtml: str, boxName: str, withPageNumber = postHtml.replace(';-999;', ';' + str(pageNumber) + ';') withPageNumber = withPageNumber.replace('?page=-999', '?page=' + str(pageNumber)) + # replace the key shortcut + for keyIndex in range(10): + keyStr = 'accesskey="' + str(keyIndex) + '"' + if keyStr in withPageNumber: + if accessKeyIndex == 0 or accessKeyIndex > 9: + withPageNumber = \ + withPageNumber.replace(keyStr, '') + else: + withPageNumber = \ + withPageNumber.replace(keyStr, + 'accesskey="' + + str(accessKeyIndex) + '"') + break return prepareHtmlPostNickname(nickname, withPageNumber) @@ -179,7 +192,8 @@ def _getPostFromRecentCache(session, postStartTime, pageNumber: int, recentPostsCache: {}, - maxRecentPosts: int) -> str: + maxRecentPosts: int, + accessKeyIndex: int) -> str: """Attempts to get the html post from the recent posts cache in memory """ if boxName == 'tlmedia': @@ -217,7 +231,8 @@ def _getPostFromRecentCache(session, return None postHtml = \ - preparePostFromHtmlCache(nickname, postHtml, boxName, pageNumber) + preparePostFromHtmlCache(nickname, postHtml, boxName, + pageNumber, accessKeyIndex) updateRecentPostsCache(recentPostsCache, maxRecentPosts, postJsonObject, postHtml) _logPostTiming(enableTimingLog, postStartTime, '3') @@ -1140,7 +1155,7 @@ def individualPostAsHtml(allowDownloads: bool, showPublishedDateOnly: bool, peertubeInstances: [], allowLocalNetworkAccess: bool, - themeName: str, + themeName: str, accessKeyIndex: int, showRepeats=True, showIcons=False, manuallyApprovesFollowers=False, @@ -1199,7 +1214,8 @@ def individualPostAsHtml(allowDownloads: bool, postStartTime, pageNumber, recentPostsCache, - maxRecentPosts) + maxRecentPosts, + accessKeyIndex) if postHtml: return postHtml @@ -1652,8 +1668,13 @@ def individualPostAsHtml(allowDownloads: bool, postHtml = '' if boxName != 'tlmedia': - postHtml = '
\n' + if accessKeyIndex > 0 and accessKeyIndex <= 9: + postHtml = '
\n' + else: + postHtml = '
\n' postHtml += avatarImageInPost postHtml += '
\n' + \ ' ' + titleStr + \ @@ -1732,7 +1753,7 @@ def htmlIndividualPost(cssCache: {}, YTReplacementDomain, showPublishedDateOnly, peertubeInstances, - allowLocalNetworkAccess, themeName, + allowLocalNetworkAccess, themeName, 0, False, authorized, False, False, False) messageId = removeIdEnding(postJsonObject['id']) @@ -1760,7 +1781,7 @@ def htmlIndividualPost(cssCache: {}, showPublishedDateOnly, peertubeInstances, allowLocalNetworkAccess, - themeName, + themeName, 0, False, authorized, False, False, False) + postStr @@ -1791,7 +1812,7 @@ def htmlIndividualPost(cssCache: {}, showPublishedDateOnly, peertubeInstances, allowLocalNetworkAccess, - themeName, + themeName, 0, False, authorized, False, False, False) cssFilename = baseDir + '/epicyon-profile.css' @@ -1833,7 +1854,7 @@ def htmlPostReplies(cssCache: {}, showPublishedDateOnly, peertubeInstances, allowLocalNetworkAccess, - themeName, + themeName, 0, False, False, False, False, False) cssFilename = baseDir + '/epicyon-profile.css' diff --git a/webapp_profile.py b/webapp_profile.py index c9112ae98..9203445b1 100644 --- a/webapp_profile.py +++ b/webapp_profile.py @@ -309,7 +309,7 @@ def htmlProfileAfterSearch(cssCache: {}, YTReplacementDomain, showPublishedDateOnly, peertubeInstances, allowLocalNetworkAccess, - themeName, + themeName, 0, False, False, False, False, False) i += 1 if i >= 20: @@ -916,7 +916,7 @@ def _htmlProfilePosts(recentPostsCache: {}, maxRecentPosts: int, showPublishedDateOnly, peertubeInstances, allowLocalNetworkAccess, - themeName, + themeName, 0, False, False, False, True, False) if postStr: profileStr += postStr + separatorStr diff --git a/webapp_search.py b/webapp_search.py index 048ba1647..ec81d78cf 100644 --- a/webapp_search.py +++ b/webapp_search.py @@ -609,7 +609,7 @@ def htmlHistorySearch(cssCache: {}, translate: {}, baseDir: str, showPublishedDateOnly, peertubeInstances, allowLocalNetworkAccess, - themeName, + themeName, 0, showIndividualPostIcons, showIndividualPostIcons, False, False, False) @@ -782,7 +782,7 @@ def htmlHashtagSearch(cssCache: {}, showPublishedDateOnly, peertubeInstances, allowLocalNetworkAccess, - themeName, + themeName, 0, showRepeats, showIcons, manuallyApprovesFollowers, showPublicOnly, diff --git a/webapp_timeline.py b/webapp_timeline.py index 2298dd019..925ae1da3 100644 --- a/webapp_timeline.py +++ b/webapp_timeline.py @@ -697,7 +697,8 @@ def htmlTimeline(cssCache: {}, defaultTimeline: str, preparePostFromHtmlCache(nickname, currTlStr, boxName, - pageNumber) + pageNumber, + itemCtr) _logTimelineTiming(enableTimingLog, timelineStartTime, boxName, '10') @@ -726,7 +727,7 @@ def htmlTimeline(cssCache: {}, defaultTimeline: str, showPublishedDateOnly, peertubeInstances, allowLocalNetworkAccess, - theme, + theme, itemCtr + 1, boxName != 'dm', showIndividualPostIcons, manuallyApproveFollowers,