Key access to individual timeline posts

merge-requests/30/head
Bob Mottram 2021-04-22 16:06:24 +01:00
parent b4a26ef2ab
commit a8063e1c0d
7 changed files with 42 additions and 20 deletions

View File

@ -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)

View File

@ -73,7 +73,7 @@ def htmlConfirmDelete(cssCache: {},
YTReplacementDomain,
showPublishedDateOnly,
peertubeInstances, allowLocalNetworkAccess,
themeName,
themeName, 0,
False, False, False, False, False)
deletePostStr += '<center>'
deletePostStr += \

View File

@ -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

View File

@ -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 = ' <div id="' + timelinePostBookmark + \
'" class="' + containerClass + '">\n'
if accessKeyIndex > 0 and accessKeyIndex <= 9:
postHtml = ' <div id="' + timelinePostBookmark + \
'" class="' + containerClass + \
'" accesskey="' + str(accessKeyIndex) + '">\n'
else:
postHtml = ' <div id="' + timelinePostBookmark + \
'" class="' + containerClass + '">\n'
postHtml += avatarImageInPost
postHtml += ' <div class="post-title">\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'

View File

@ -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

View File

@ -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,

View File

@ -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,