From e175bb207cd79db4d436dae2649c242792830565 Mon Sep 17 00:00:00 2001 From: Bob Mottram Date: Fri, 23 Apr 2021 18:04:37 +0100 Subject: [PATCH] Key shortcuts on new post screen --- daemon.py | 29 ++++++++++++++++++++++++++--- webapp_create_post.py | 9 ++++++--- 2 files changed, 32 insertions(+), 6 deletions(-) diff --git a/daemon.py b/daemon.py index 965595a98..f506adac0 100644 --- a/daemon.py +++ b/daemon.py @@ -2257,6 +2257,15 @@ class PubServer(BaseHTTPRequestHandler): if debug: print('Sending DM to ' + optionsActor) reportPath = path.replace('/personoptions', '') + '/newdm' + + accessKeys = self.server.accessKeys + if '/users/' in path: + nickname = path.split('/users/')[1] + if '/' in nickname: + nickname = nickname.split('/')[0] + if self.server.keyShortcuts.get(nickname): + accessKeys = self.server.keyShortcuts[nickname] + msg = htmlNewPost(self.server.cssCache, False, self.server.translate, baseDir, @@ -2270,7 +2279,7 @@ class PubServer(BaseHTTPRequestHandler): self.server.defaultTimeline, self.server.newswire, self.server.themeName, - True).encode('utf-8') + True, accessKeys).encode('utf-8') msglen = len(msg) self._set_headers('text/html', msglen, cookie, callingDomain) @@ -2357,6 +2366,15 @@ class PubServer(BaseHTTPRequestHandler): print('Reporting ' + optionsActor) reportPath = \ path.replace('/personoptions', '') + '/newreport' + + accessKeys = self.server.accessKeys + if '/users/' in path: + nickname = path.split('/users/')[1] + if '/' in nickname: + nickname = nickname.split('/')[0] + if self.server.keyShortcuts.get(nickname): + accessKeys = self.server.keyShortcuts[nickname] + msg = htmlNewPost(self.server.cssCache, False, self.server.translate, baseDir, @@ -2369,7 +2387,7 @@ class PubServer(BaseHTTPRequestHandler): self.server.defaultTimeline, self.server.newswire, self.server.themeName, - True).encode('utf-8') + True, accessKeys).encode('utf-8') msglen = len(msg) self._set_headers('text/html', msglen, cookie, callingDomain) @@ -10345,6 +10363,11 @@ class PubServer(BaseHTTPRequestHandler): break if isNewPostEndpoint: nickname = getNicknameFromActor(path) + + accessKeys = self.server.accessKeys + if self.server.keyShortcuts.get(nickname): + accessKeys = self.server.keyShortcuts[nickname] + msg = htmlNewPost(self.server.cssCache, mediaInstance, translate, @@ -10359,7 +10382,7 @@ class PubServer(BaseHTTPRequestHandler): self.server.defaultTimeline, self.server.newswire, self.server.themeName, - noDropDown).encode('utf-8') + noDropDown, accessKeys).encode('utf-8') if not msg: print('Error replying to ' + inReplyToUrl) self._404() diff --git a/webapp_create_post.py b/webapp_create_post.py index c540f49a1..904bcca63 100644 --- a/webapp_create_post.py +++ b/webapp_create_post.py @@ -177,7 +177,8 @@ def htmlNewPost(cssCache: {}, mediaInstance: bool, translate: {}, nickname: str, domain: str, domainFull: str, defaultTimeline: str, newswire: {}, - theme: str, noDropDown: bool) -> str: + theme: str, noDropDown: bool, + accessKeys: {}) -> str: """New post screen """ replyStr = '' @@ -579,7 +580,8 @@ def htmlNewPost(cssCache: {}, mediaInstance: bool, translate: {}, '
\n' + \ '\n' + translate['Switch to timeline view'] + '" ' + \ + 'accesskey="' + accessKeys['menuTimeline'] + '">\n' newPostForm += '\n' + \ '
\n' @@ -693,7 +695,8 @@ def htmlNewPost(cssCache: {}, mediaInstance: bool, translate: {}, newPostForm += \ ' \n' + translate['Submit'] + '" ' + \ + 'accesskey="' + accessKeys['submitButton'] + '">\n' newPostForm += ' \n' newPostForm += '\n'