From ae44a8814468a2805b1f1b942513520d7d9f93d7 Mon Sep 17 00:00:00 2001 From: Bob Mottram Date: Thu, 22 Apr 2021 22:46:02 +0100 Subject: [PATCH] Key shortcuts screen --- daemon.py | 192 ++++++++++++++++++++++++++++++++++++++----- translations/ar.json | 25 +++++- translations/ca.json | 25 +++++- translations/cy.json | 25 +++++- translations/de.json | 25 +++++- translations/en.json | 25 +++++- translations/es.json | 25 +++++- translations/fr.json | 25 +++++- translations/ga.json | 25 +++++- translations/hi.json | 25 +++++- translations/it.json | 25 +++++- translations/ja.json | 25 +++++- translations/ku.json | 25 +++++- translations/oc.json | 25 +++++- translations/pt.json | 25 +++++- translations/ru.json | 25 +++++- translations/zh.json | 25 +++++- webapp_accesskeys.py | 95 +++++++++++++++++++++ 18 files changed, 651 insertions(+), 36 deletions(-) create mode 100644 webapp_accesskeys.py diff --git a/daemon.py b/daemon.py index 42ac87698..b6c63bf77 100644 --- a/daemon.py +++ b/daemon.py @@ -134,6 +134,8 @@ from webapp_utils import getBlogAddress from webapp_calendar import htmlCalendarDeleteConfirm from webapp_calendar import htmlCalendar from webapp_about import htmlAbout +from webapp_accesskeys import htmlAccessKeys +from webapp_accesskeys import loadAccessKeysForAccounts from webapp_confirm import htmlConfirmDelete from webapp_confirm import htmlConfirmRemoveSharedItem from webapp_confirm import htmlConfirmUnblock @@ -7342,6 +7344,11 @@ class PubServer(BaseHTTPRequestHandler): self.server.YTReplacementDomain iconsAsButtons = \ self.server.iconsAsButtons + + accessKeys = self.server.accessKeys + if self.server.keyShortcuts.get(nickname): + accessKeys = self.server.keyShortcuts[nickname] + msg = \ htmlProfile(self.server.rssIconAtTop, self.server.cssCache, @@ -7365,7 +7372,7 @@ class PubServer(BaseHTTPRequestHandler): self.server.allowLocalNetworkAccess, self.server.textModeBanner, self.server.debug, - self.server.accessKeys, + accessKeys, actorJson['roles'], None, None) msg = msg.encode('utf-8') @@ -7432,6 +7439,10 @@ class PubServer(BaseHTTPRequestHandler): self.server.iconsAsButtons allowLocalNetworkAccess = \ self.server.allowLocalNetworkAccess + accessKeys = self.server.accessKeys + if self.server.keyShortcuts.get(nickname): + accessKeys = \ + self.server.keyShortcuts[nickname] msg = \ htmlProfile(self.server.rssIconAtTop, self.server.cssCache, @@ -7455,7 +7466,7 @@ class PubServer(BaseHTTPRequestHandler): allowLocalNetworkAccess, self.server.textModeBanner, self.server.debug, - self.server.accessKeys, + accessKeys, actorJson['skills'], None, None) msg = msg.encode('utf-8') @@ -7823,6 +7834,12 @@ class PubServer(BaseHTTPRequestHandler): fullWidthTimelineButtonHeader = \ self.server.fullWidthTimelineButtonHeader minimalNick = self._isMinimal(nickname) + + accessKeys = self.server.accessKeys + if self.server.keyShortcuts.get(nickname): + accessKeys = \ + self.server.keyShortcuts[nickname] + msg = htmlInbox(self.server.cssCache, defaultTimeline, recentPostsCache, @@ -7855,7 +7872,7 @@ class PubServer(BaseHTTPRequestHandler): self.server.peertubeInstances, self.server.allowLocalNetworkAccess, self.server.textModeBanner, - self.server.accessKeys) + accessKeys) if GETstartTime: self._benchmarkGETtimings(GETstartTime, GETtimings, 'show status done', @@ -7953,6 +7970,12 @@ class PubServer(BaseHTTPRequestHandler): fullWidthTimelineButtonHeader = \ self.server.fullWidthTimelineButtonHeader minimalNick = self._isMinimal(nickname) + + accessKeys = self.server.accessKeys + if self.server.keyShortcuts.get(nickname): + accessKeys = \ + self.server.keyShortcuts[nickname] + msg = \ htmlInboxDMs(self.server.cssCache, self.server.defaultTimeline, @@ -7985,7 +8008,7 @@ class PubServer(BaseHTTPRequestHandler): self.server.peertubeInstances, self.server.allowLocalNetworkAccess, self.server.textModeBanner, - self.server.accessKeys) + accessKeys) msg = msg.encode('utf-8') msglen = len(msg) self._set_headers('text/html', msglen, @@ -8076,6 +8099,12 @@ class PubServer(BaseHTTPRequestHandler): fullWidthTimelineButtonHeader = \ self.server.fullWidthTimelineButtonHeader minimalNick = self._isMinimal(nickname) + + accessKeys = self.server.accessKeys + if self.server.keyShortcuts.get(nickname): + accessKeys = \ + self.server.keyShortcuts[nickname] + msg = \ htmlInboxReplies(self.server.cssCache, self.server.defaultTimeline, @@ -8108,7 +8137,7 @@ class PubServer(BaseHTTPRequestHandler): self.server.peertubeInstances, self.server.allowLocalNetworkAccess, self.server.textModeBanner, - self.server.accessKeys) + accessKeys) msg = msg.encode('utf-8') msglen = len(msg) self._set_headers('text/html', msglen, @@ -8199,6 +8228,12 @@ class PubServer(BaseHTTPRequestHandler): fullWidthTimelineButtonHeader = \ self.server.fullWidthTimelineButtonHeader minimalNick = self._isMinimal(nickname) + + accessKeys = self.server.accessKeys + if self.server.keyShortcuts.get(nickname): + accessKeys = \ + self.server.keyShortcuts[nickname] + msg = \ htmlInboxMedia(self.server.cssCache, self.server.defaultTimeline, @@ -8232,7 +8267,7 @@ class PubServer(BaseHTTPRequestHandler): self.server.peertubeInstances, self.server.allowLocalNetworkAccess, self.server.textModeBanner, - self.server.accessKeys) + accessKeys) msg = msg.encode('utf-8') msglen = len(msg) self._set_headers('text/html', msglen, @@ -8323,6 +8358,12 @@ class PubServer(BaseHTTPRequestHandler): fullWidthTimelineButtonHeader = \ self.server.fullWidthTimelineButtonHeader minimalNick = self._isMinimal(nickname) + + accessKeys = self.server.accessKeys + if self.server.keyShortcuts.get(nickname): + accessKeys = \ + self.server.keyShortcuts[nickname] + msg = \ htmlInboxBlogs(self.server.cssCache, self.server.defaultTimeline, @@ -8356,7 +8397,7 @@ class PubServer(BaseHTTPRequestHandler): self.server.peertubeInstances, self.server.allowLocalNetworkAccess, self.server.textModeBanner, - self.server.accessKeys) + accessKeys) msg = msg.encode('utf-8') msglen = len(msg) self._set_headers('text/html', msglen, @@ -8455,6 +8496,12 @@ class PubServer(BaseHTTPRequestHandler): fullWidthTimelineButtonHeader = \ self.server.fullWidthTimelineButtonHeader minimalNick = self._isMinimal(nickname) + + accessKeys = self.server.accessKeys + if self.server.keyShortcuts.get(nickname): + accessKeys = \ + self.server.keyShortcuts[nickname] + msg = \ htmlInboxNews(self.server.cssCache, self.server.defaultTimeline, @@ -8489,7 +8536,7 @@ class PubServer(BaseHTTPRequestHandler): self.server.peertubeInstances, self.server.allowLocalNetworkAccess, self.server.textModeBanner, - self.server.accessKeys) + accessKeys) msg = msg.encode('utf-8') msglen = len(msg) self._set_headers('text/html', msglen, @@ -8585,6 +8632,12 @@ class PubServer(BaseHTTPRequestHandler): fullWidthTimelineButtonHeader = \ self.server.fullWidthTimelineButtonHeader minimalNick = self._isMinimal(nickname) + + accessKeys = self.server.accessKeys + if self.server.keyShortcuts.get(nickname): + accessKeys = \ + self.server.keyShortcuts[nickname] + msg = \ htmlInboxFeatures(self.server.cssCache, self.server.defaultTimeline, @@ -8618,7 +8671,7 @@ class PubServer(BaseHTTPRequestHandler): self.server.peertubeInstances, self.server.allowLocalNetworkAccess, self.server.textModeBanner, - self.server.accessKeys) + accessKeys) msg = msg.encode('utf-8') msglen = len(msg) self._set_headers('text/html', msglen, @@ -8678,6 +8731,12 @@ class PubServer(BaseHTTPRequestHandler): pageNumber = int(pageNumber) else: pageNumber = 1 + + accessKeys = self.server.accessKeys + if self.server.keyShortcuts.get(nickname): + accessKeys = \ + self.server.keyShortcuts[nickname] + msg = \ htmlShares(self.server.cssCache, self.server.defaultTimeline, @@ -8708,7 +8767,7 @@ class PubServer(BaseHTTPRequestHandler): self.server.peertubeInstances, self.server.allowLocalNetworkAccess, self.server.textModeBanner, - self.server.accessKeys) + accessKeys) msg = msg.encode('utf-8') msglen = len(msg) self._set_headers('text/html', msglen, @@ -8782,6 +8841,12 @@ class PubServer(BaseHTTPRequestHandler): fullWidthTimelineButtonHeader = \ self.server.fullWidthTimelineButtonHeader minimalNick = self._isMinimal(nickname) + + accessKeys = self.server.accessKeys + if self.server.keyShortcuts.get(nickname): + accessKeys = \ + self.server.keyShortcuts[nickname] + msg = \ htmlBookmarks(self.server.cssCache, self.server.defaultTimeline, @@ -8815,7 +8880,7 @@ class PubServer(BaseHTTPRequestHandler): self.server.peertubeInstances, self.server.allowLocalNetworkAccess, self.server.textModeBanner, - self.server.accessKeys) + accessKeys) msg = msg.encode('utf-8') msglen = len(msg) self._set_headers('text/html', msglen, @@ -8909,6 +8974,12 @@ class PubServer(BaseHTTPRequestHandler): fullWidthTimelineButtonHeader = \ self.server.fullWidthTimelineButtonHeader minimalNick = self._isMinimal(nickname) + + accessKeys = self.server.accessKeys + if self.server.keyShortcuts.get(nickname): + accessKeys = \ + self.server.keyShortcuts[nickname] + msg = \ htmlEvents(self.server.cssCache, self.server.defaultTimeline, @@ -8942,7 +9013,7 @@ class PubServer(BaseHTTPRequestHandler): self.server.peertubeInstances, self.server.allowLocalNetworkAccess, self.server.textModeBanner, - self.server.accessKeys) + accessKeys) msg = msg.encode('utf-8') msglen = len(msg) self._set_headers('text/html', msglen, @@ -9028,6 +9099,12 @@ class PubServer(BaseHTTPRequestHandler): fullWidthTimelineButtonHeader = \ self.server.fullWidthTimelineButtonHeader minimalNick = self._isMinimal(nickname) + + accessKeys = self.server.accessKeys + if self.server.keyShortcuts.get(nickname): + accessKeys = \ + self.server.keyShortcuts[nickname] + msg = \ htmlOutbox(self.server.cssCache, self.server.defaultTimeline, @@ -9061,7 +9138,7 @@ class PubServer(BaseHTTPRequestHandler): self.server.peertubeInstances, self.server.allowLocalNetworkAccess, self.server.textModeBanner, - self.server.accessKeys) + accessKeys) msg = msg.encode('utf-8') msglen = len(msg) self._set_headers('text/html', msglen, @@ -9138,6 +9215,12 @@ class PubServer(BaseHTTPRequestHandler): fullWidthTimelineButtonHeader = \ self.server.fullWidthTimelineButtonHeader moderationActionStr = '' + + accessKeys = self.server.accessKeys + if self.server.keyShortcuts.get(nickname): + accessKeys = \ + self.server.keyShortcuts[nickname] + msg = \ htmlModeration(self.server.cssCache, self.server.defaultTimeline, @@ -9170,7 +9253,7 @@ class PubServer(BaseHTTPRequestHandler): self.server.peertubeInstances, self.server.allowLocalNetworkAccess, self.server.textModeBanner, - self.server.accessKeys) + accessKeys) msg = msg.encode('utf-8') msglen = len(msg) self._set_headers('text/html', msglen, @@ -9249,6 +9332,16 @@ class PubServer(BaseHTTPRequestHandler): self._404() self.server.GETbusy = False return True + + 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 = \ htmlProfile(self.server.rssIconAtTop, self.server.cssCache, @@ -9273,7 +9366,7 @@ class PubServer(BaseHTTPRequestHandler): self.server.allowLocalNetworkAccess, self.server.textModeBanner, self.server.debug, - self.server.accessKeys, + accessKeys, shares, pageNumber, sharesPerPage) msg = msg.encode('utf-8') @@ -9350,6 +9443,15 @@ class PubServer(BaseHTTPRequestHandler): self.server.GETbusy = False return True + 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 = \ htmlProfile(self.server.rssIconAtTop, self.server.cssCache, @@ -9374,7 +9476,7 @@ class PubServer(BaseHTTPRequestHandler): self.server.allowLocalNetworkAccess, self.server.textModeBanner, self.server.debug, - self.server.accessKeys, + accessKeys, following, pageNumber, followsPerPage).encode('utf-8') @@ -9449,6 +9551,16 @@ class PubServer(BaseHTTPRequestHandler): self._404() self.server.GETbusy = False return True + + 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 = \ htmlProfile(self.server.rssIconAtTop, self.server.cssCache, @@ -9474,7 +9586,7 @@ class PubServer(BaseHTTPRequestHandler): self.server.allowLocalNetworkAccess, self.server.textModeBanner, self.server.debug, - self.server.accessKeys, + accessKeys, followers, pageNumber, followsPerPage).encode('utf-8') @@ -9572,6 +9684,16 @@ class PubServer(BaseHTTPRequestHandler): self._404() self.server.GETbusy = False return True + + 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 = \ htmlProfile(self.server.rssIconAtTop, self.server.cssCache, @@ -9597,7 +9719,7 @@ class PubServer(BaseHTTPRequestHandler): self.server.allowLocalNetworkAccess, self.server.textModeBanner, self.server.debug, - self.server.accessKeys, + accessKeys, None, None).encode('utf-8') msglen = len(msg) self._set_headers('text/html', msglen, @@ -11015,6 +11137,33 @@ class PubServer(BaseHTTPRequestHandler): 'show about screen') return + if htmlGET and usersInPath and authorized and \ + self.path.endswith('/accesskeys'): + nickname = self.path.split('/users/')[1] + if '/' in nickname: + nickname = nickname.split('/')[0] + + accessKeys = self.server.accessKeys + if self.server.keyShortcuts.get(nickname): + accessKeys = \ + self.server.keyShortcuts[nickname] + + msg = \ + htmlAccessKeys(self.server.cssCache, + self.server.baseDir, + nickname, self.server.domain, + self.server.translate, + accessKeys, + self.server.accessKeys) + msg = msg.encode('utf-8') + msglen = len(msg) + self._login_headers('text/html', msglen, callingDomain) + self._write(msg) + self._benchmarkGETtimings(GETstartTime, GETtimings, + 'following accounts done', + 'show accesskeys screen') + return + self._benchmarkGETtimings(GETstartTime, GETtimings, 'following accounts done', 'show about screen done') @@ -14507,7 +14656,7 @@ def runDaemon(brochMode: bool, 'menuDM': 'd', 'menuReplies': 'r', 'menuOutbox': 's', - 'menuBookmarks': 'k', + 'menuBookmarks': 'q', 'menuShares': 'h', 'menuBlogs': 'b', 'menuNewswire': 'w', @@ -14517,8 +14666,11 @@ def runDaemon(brochMode: bool, 'menuFollowers': 'g', 'menuRoles': 'o', 'menuSkills': 'a', - 'menuLogout': 'x' + 'menuLogout': 'x', + 'menuKeys': 'k' } + httpd.keyShortcuts = {} + loadAccessKeysForAccounts(baseDir, httpd.keyShortcuts) httpd.unitTest = unitTest httpd.allowLocalNetworkAccess = allowLocalNetworkAccess diff --git a/translations/ar.json b/translations/ar.json index 1d924ac55..527b0608f 100644 --- a/translations/ar.json +++ b/translations/ar.json @@ -403,5 +403,28 @@ "shocked": "صدمت", "Encrypted": "مشفر", "Direct Message permitted instances": "الرسالة المباشرة المسموح بها", - "Direct messages are always allowed from these instances.": "الرسائل المباشرة مسموح بها دائما من هذه المثيلات." + "Direct messages are always allowed from these instances.": "الرسائل المباشرة مسموح بها دائما من هذه المثيلات.", + "Key Shortcuts": "الاختصارات الرئيسية", + "menuTimeline": "عرض الجدول الزمني", + "menuEdit": "يحرر", + "menuProfile": "عرض الملف الشخصي", + "menuInbox": "صندوق الوارد", + "menuSearch": "البحث / المتتالية", + "menuNewPost": "منشور جديد", + "menuCalendar": "تقويم", + "menuDM": "رسالة مباشرة", + "menuReplies": "الردود", + "menuOutbox": "مرسل", + "menuBookmarks": "إشارات مرجعية", + "menuShares": "البنود المشتركة", + "menuBlogs": "المدونات", + "menuNewswire": "Newswire", + "menuLinks": "روابط انترنت", + "menuModeration": "الاعتدال", + "menuFollowing": "التالية", + "menuFollowers": "متابعون", + "menuRoles": "أدوار", + "menuSkills": "مهارات", + "menuLogout": "تسجيل خروج", + "menuKeys": "الاختصارات الرئيسية" } diff --git a/translations/ca.json b/translations/ca.json index 47487a6f6..619b96bb7 100644 --- a/translations/ca.json +++ b/translations/ca.json @@ -403,5 +403,28 @@ "shocked": "sorprès", "Encrypted": "Xifrat", "Direct Message permitted instances": "Instàncies permeses del missatge directe", - "Direct messages are always allowed from these instances.": "Els missatges directes sempre estan permesos d'aquests casos." + "Direct messages are always allowed from these instances.": "Els missatges directes sempre estan permesos d'aquests casos.", + "Key Shortcuts": "Dreceres clau", + "menuTimeline": "Vista de la línia de temps", + "menuEdit": "Preprarar una edició", + "menuProfile": "Vista de perfil", + "menuInbox": "Capa inferior", + "menuSearch": "Cerca / Segueix", + "menuNewPost": "Nou missatge", + "menuCalendar": "Calendari", + "menuDM": "Missatges directes", + "menuReplies": "Resum", + "menuOutbox": "Present", + "menuBookmarks": "Adreces d'interès", + "menuShares": "Articles compartits", + "menuBlogs": "Blocs", + "menuNewswire": "Newswire", + "menuLinks": "Enllaços web", + "menuModeration": "Moderació", + "menuFollowing": "Proper", + "menuFollowers": "Seguidors", + "menuRoles": "Rols", + "menuSkills": "Habilitats", + "menuLogout": "Tancar sessió", + "menuKeys": "Dreceres clau" } diff --git a/translations/cy.json b/translations/cy.json index fe5c966be..e0c3f167e 100644 --- a/translations/cy.json +++ b/translations/cy.json @@ -403,5 +403,28 @@ "shocked": "sioc", "Encrypted": "Amgryptio", "Direct Message permitted instances": "Achosion a ganiateir negeseuon uniongyrchol", - "Direct messages are always allowed from these instances.": "Caniateir negeseuon uniongyrchol bob amser o'r achosion hyn." + "Direct messages are always allowed from these instances.": "Caniateir negeseuon uniongyrchol bob amser o'r achosion hyn.", + "Key Shortcuts": "Llwybrau byr allweddol", + "menuTimeline": "View View", + "menuEdit": "Golygaf", + "menuProfile": "Gweld Proffil", + "menuInbox": "Mewnflwch", + "menuSearch": "Chwilio / Dilyn", + "menuNewPost": "Swydd newydd", + "menuCalendar": "Galendr", + "menuDM": "Negeseuon Uniongyrchol", + "menuReplies": "Atebion", + "menuOutbox": "Hanfon", + "menuBookmarks": "Nodau tudalen", + "menuShares": "Eitemau a Rennir", + "menuBlogs": "Blogiau", + "menuNewswire": "Newswire", + "menuLinks": "Cysylltiadau", + "menuModeration": "Safoniad", + "menuFollowing": "Ddilynol", + "menuFollowers": "Ddilynwyr", + "menuRoles": "Rolau", + "menuSkills": "Medrau", + "menuLogout": "Allgofnodi", + "menuKeys": "Llwybrau byr allweddol" } diff --git a/translations/de.json b/translations/de.json index 70099d937..70427d027 100644 --- a/translations/de.json +++ b/translations/de.json @@ -403,5 +403,28 @@ "shocked": "schockiert", "Encrypted": "Verschlüsselt", "Direct Message permitted instances": "Direktnachricht erlaubte Instanzen", - "Direct messages are always allowed from these instances.": "Direkte Nachrichten sind in diesen Fällen immer zulässig." + "Direct messages are always allowed from these instances.": "Direkte Nachrichten sind in diesen Fällen immer zulässig.", + "Key Shortcuts": "Schlüsselverknüpfungen", + "menuTimeline": "Timeline-Ansicht", + "menuEdit": "Bearbeiten", + "menuProfile": "Profilansicht", + "menuInbox": "Inbox", + "menuSearch": "Suche / Folgen", + "menuNewPost": "Neuer Beitrag", + "menuCalendar": "Kalender", + "menuDM": "Direkte Nachrichten", + "menuReplies": "Antworten", + "menuOutbox": "Geschickt", + "menuBookmarks": "Lesezeichen", + "menuShares": "Gemeinsame Artikel", + "menuBlogs": "Blogs", + "menuNewswire": "Newswire", + "menuLinks": "Web-Links", + "menuModeration": "Mäßigung", + "menuFollowing": "Folgen", + "menuFollowers": "Anhänger", + "menuRoles": "Rollen", + "menuSkills": "Kompetenzen", + "menuLogout": "Ausloggen", + "menuKeys": "Schlüsselverknüpfungen" } diff --git a/translations/en.json b/translations/en.json index 328038954..c9ef9a103 100644 --- a/translations/en.json +++ b/translations/en.json @@ -403,5 +403,28 @@ "shocked": "shocked", "Encrypted": "Encrypted", "Direct Message permitted instances": "Direct Message permitted instances", - "Direct messages are always allowed from these instances.": "Direct messages are always allowed from these instances." + "Direct messages are always allowed from these instances.": "Direct messages are always allowed from these instances.", + "Key Shortcuts": "Key Shortcuts", + "menuTimeline": "Timeline view", + "menuEdit": "Edit", + "menuProfile": "Profile view", + "menuInbox": "Inbox", + "menuSearch": "Search/follow", + "menuNewPost": "New post", + "menuCalendar": "Calendar", + "menuDM": "Direct Messages", + "menuReplies": "Replies", + "menuOutbox": "Sent", + "menuBookmarks": "Bookmarks", + "menuShares": "Shared items", + "menuBlogs": "Blogs", + "menuNewswire": "Newswire", + "menuLinks": "Links", + "menuModeration": "Moderation", + "menuFollowing": "Following", + "menuFollowers": "Followers", + "menuRoles": "Roles", + "menuSkills": "Skills", + "menuLogout": "Logout", + "menuKeys": "Key Shortcuts" } diff --git a/translations/es.json b/translations/es.json index c2f3a2e74..29068b653 100644 --- a/translations/es.json +++ b/translations/es.json @@ -403,5 +403,28 @@ "shocked": "conmocionada", "Encrypted": "Cifrada", "Direct Message permitted instances": "Mensaje directo permitido instancias", - "Direct messages are always allowed from these instances.": "Los mensajes directos siempre están permitidos de estas instancias." + "Direct messages are always allowed from these instances.": "Los mensajes directos siempre están permitidos de estas instancias.", + "Key Shortcuts": "Atajos clave", + "menuTimeline": "Vista de la línea de tiempo", + "menuEdit": "Editar", + "menuProfile": "Vista del perfil", + "menuInbox": "Bandeja de entrada", + "menuSearch": "Búsqueda / Seguir", + "menuNewPost": "Nueva publicación", + "menuCalendar": "Calendario", + "menuDM": "Mensajes directos", + "menuReplies": "Respuestas", + "menuOutbox": "Enviada", + "menuBookmarks": "Marcadores", + "menuShares": "Artículos compartidos", + "menuBlogs": "Blogs", + "menuNewswire": "Newswire", + "menuLinks": "Enlaces web", + "menuModeration": "Moderación", + "menuFollowing": "Siguiente", + "menuFollowers": "De seguidores", + "menuRoles": "Roles", + "menuSkills": "Habilidades", + "menuLogout": "Cerrar sesión", + "menuKeys": "Atajos clave" } diff --git a/translations/fr.json b/translations/fr.json index 68d246462..42e0c1a4b 100644 --- a/translations/fr.json +++ b/translations/fr.json @@ -403,5 +403,28 @@ "shocked": "sous le choc", "Encrypted": "Crypté", "Direct Message permitted instances": "Message direct des instances autorisées", - "Direct messages are always allowed from these instances.": "Les messages directs sont toujours autorisés dans ces instances." + "Direct messages are always allowed from these instances.": "Les messages directs sont toujours autorisés dans ces instances.", + "Key Shortcuts": "Raccourcis clés", + "menuTimeline": "Vue de la chronologie", + "menuEdit": "Éditer", + "menuProfile": "Voir", + "menuInbox": "Boîte de réception", + "menuSearch": "Rechercher / suivre", + "menuNewPost": "Nouveau poste", + "menuCalendar": "Calendrier", + "menuDM": "Messages directs", + "menuReplies": "réponses", + "menuOutbox": "Envoyée", + "menuBookmarks": "Favoris", + "menuShares": "Articles partagés", + "menuBlogs": "Blogs", + "menuNewswire": "Newswire", + "menuLinks": "Liens web", + "menuModeration": "Modération", + "menuFollowing": "Suivante", + "menuFollowers": "Suiveuses", + "menuRoles": "Les rôles", + "menuSkills": "Compétences", + "menuLogout": "Se déconnecter", + "menuKeys": "Raccourcis clés" } diff --git a/translations/ga.json b/translations/ga.json index c8c8d8911..82ddab85a 100644 --- a/translations/ga.json +++ b/translations/ga.json @@ -403,5 +403,28 @@ "shocked": "ionadh", "Encrypted": "Criptithe", "Direct Message permitted instances": "Ceadaíonn teachtaireacht dhíreach cásanna", - "Direct messages are always allowed from these instances.": "Ceadaítear teachtaireachtaí díreacha i gcónaí ó na cásanna seo." + "Direct messages are always allowed from these instances.": "Ceadaítear teachtaireachtaí díreacha i gcónaí ó na cásanna seo.", + "Key Shortcuts": "Príomh-aicearraí", + "menuTimeline": "Amlíne View", + "menuEdit": "Eagarthóireacht a dhéanamh ar", + "menuProfile": "Dearcadh próifíle", + "menuInbox": "Bosca isteach", + "menuSearch": "Cuardaigh / Lean", + "menuNewPost": "Post nua", + "menuCalendar": "Caileandar", + "menuDM": "Teachtaireachtaí díreacha", + "menuReplies": "Freagraí", + "menuOutbox": "Seoltar", + "menuBookmarks": "Leabharmharcanna", + "menuShares": "Míreanna Comhroinnte", + "menuBlogs": "Blaganna", + "menuNewswire": "Newswire", + "menuLinks": "Naisc Ghréasáin", + "menuModeration": "Modhnóireacht a dhéanamh ar", + "menuFollowing": "Lucht tacaíochta", + "menuFollowers": "Leanúna", + "menuRoles": "Róil", + "menuSkills": "Scileanna", + "menuLogout": "Logáil Amach", + "menuKeys": "Príomh-aicearraí" } diff --git a/translations/hi.json b/translations/hi.json index b36a7ad2a..853b74725 100644 --- a/translations/hi.json +++ b/translations/hi.json @@ -403,5 +403,28 @@ "shocked": "हैरान", "Encrypted": "को गोपित", "Direct Message permitted instances": "प्रत्यक्ष संदेश अनुमत उदाहरण", - "Direct messages are always allowed from these instances.": "इन उदाहरणों से प्रत्यक्ष संदेश हमेशा अनुमति देते हैं।" + "Direct messages are always allowed from these instances.": "इन उदाहरणों से प्रत्यक्ष संदेश हमेशा अनुमति देते हैं।", + "Key Shortcuts": "कुंजी शॉर्टकट", + "menuTimeline": "समयरेखा दृश्य", + "menuEdit": "संपादित करें", + "menuProfile": "प्रोफ़ाइल दृश्य", + "menuInbox": "इनबॉक्स", + "menuSearch": "खोज / अनुसरण करें", + "menuNewPost": "नई पोस्ट", + "menuCalendar": "पंचांग", + "menuDM": "सीधे संदेश", + "menuReplies": "जवाब", + "menuOutbox": "भेज दिया", + "menuBookmarks": "बुकमार्क", + "menuShares": "साझा आइटम", + "menuBlogs": "ब्लॉग", + "menuNewswire": "न्यूज़वायर", + "menuLinks": "वेब लिंक", + "menuModeration": "संयम", + "menuFollowing": "निम्नलिखित", + "menuFollowers": "समर्थक", + "menuRoles": "भूमिकाएँ", + "menuSkills": "कौशल", + "menuLogout": "लॉग आउट", + "menuKeys": "कुंजी शॉर्टकट" } diff --git a/translations/it.json b/translations/it.json index f540050d6..b7bee1906 100644 --- a/translations/it.json +++ b/translations/it.json @@ -403,5 +403,28 @@ "shocked": "scioccata", "Encrypted": "Crittografato", "Direct Message permitted instances": "Messaggio diretto istanze consentite", - "Direct messages are always allowed from these instances.": "I messaggi diretti sono sempre ammessi da questi casi." + "Direct messages are always allowed from these instances.": "I messaggi diretti sono sempre ammessi da questi casi.", + "Key Shortcuts": "Scorciatoie chiave", + "menuTimeline": "Vista della cronologia", + "menuEdit": "Modificare", + "menuProfile": "Visualizzazione del profilo", + "menuInbox": "Posta in arrivo", + "menuSearch": "Cerca / Segui", + "menuNewPost": "Nuovo post.", + "menuCalendar": "Calendario", + "menuDM": "Messaggi diretti", + "menuReplies": "Risposte", + "menuOutbox": "Inviata", + "menuBookmarks": "Segnalibri", + "menuShares": "Articoli condivisi", + "menuBlogs": "Blog", + "menuNewswire": "Newswire", + "menuLinks": "Link internet", + "menuModeration": "Moderazione", + "menuFollowing": "A seguire", + "menuFollowers": "Seguaci", + "menuRoles": "Ruoli", + "menuSkills": "Competenze", + "menuLogout": "Disconnettersi", + "menuKeys": "Scorciatoie chiave" } diff --git a/translations/ja.json b/translations/ja.json index 8b129146e..50273899d 100644 --- a/translations/ja.json +++ b/translations/ja.json @@ -403,5 +403,28 @@ "shocked": "ショックを受けた", "Encrypted": "暗号化", "Direct Message permitted instances": "直接メッセージ許可インスタンス", - "Direct messages are always allowed from these instances.": "直接メッセージは常にこれらのインスタンスから許可されています。" + "Direct messages are always allowed from these instances.": "直接メッセージは常にこれらのインスタンスから許可されています。", + "Key Shortcuts": "キーショートカット", + "menuTimeline": "タイムラインビュー", + "menuEdit": "編集する", + "menuProfile": "プロファイルビュー", + "menuInbox": "受信箱", + "menuSearch": "検索/フォロー", + "menuNewPost": "新しい投稿", + "menuCalendar": "カレンダー", + "menuDM": "ダイレクトメッセージ", + "menuReplies": "返信", + "menuOutbox": "送り返した", + "menuBookmarks": "ブックマーク", + "menuShares": "共有アイテム", + "menuBlogs": "ブログ", + "menuNewswire": "ニューワイヤー", + "menuLinks": "Webリンク", + "menuModeration": "節度", + "menuFollowing": "以下", + "menuFollowers": "フォロワー", + "menuRoles": "役割", + "menuSkills": "スキル", + "menuLogout": "ログアウト", + "menuKeys": "キーショートカット" } diff --git a/translations/ku.json b/translations/ku.json index 86f856b8f..2595c9dea 100644 --- a/translations/ku.json +++ b/translations/ku.json @@ -403,5 +403,28 @@ "shocked": "şok kirin", "Encrypted": "Encîfre kirin", "Direct Message permitted instances": "Peyama rasterast destûrê", - "Direct messages are always allowed from these instances.": "Peyamên rasterast her gav ji van deman têne destûr kirin." + "Direct messages are always allowed from these instances.": "Peyamên rasterast her gav ji van deman têne destûr kirin.", + "Key Shortcuts": "Kurteyên Key", + "menuTimeline": "Dîtina Timeline", + "menuEdit": "Weşandin", + "menuProfile": "View Profîl", + "menuInbox": "Inbott", + "menuSearch": "Lêgerîn / bişopîne", + "menuNewPost": "Peyama nû", + "menuCalendar": "Salname", + "menuDM": "Peyamên rasterast", + "menuReplies": "Bersiv", + "menuOutbox": "Şandin", + "menuBookmarks": "Emîrê", + "menuShares": "Tiştên parvekirî", + "menuBlogs": "Blogs", + "menuNewswire": "Newswire", + "menuLinks": "Girêdanên malperê", + "menuModeration": "Nermbûn", + "menuFollowing": "Pêketînî", + "menuFollowers": "Followers", + "menuRoles": "Roles", + "menuSkills": "Şarezayên", + "menuLogout": "Derkeve", + "menuKeys": "Kurteyên Key" } diff --git a/translations/oc.json b/translations/oc.json index 370cc90dc..adc35439b 100644 --- a/translations/oc.json +++ b/translations/oc.json @@ -399,5 +399,28 @@ "shocked": "shocked", "Encrypted": "Encrypted", "Direct Message permitted instances": "Direct Message permitted instances", - "Direct messages are always allowed from these instances.": "Direct messages are always allowed from these instances." + "Direct messages are always allowed from these instances.": "Direct messages are always allowed from these instances.", + "Key Shortcuts": "Key Shortcuts", + "menuTimeline": "Timeline view", + "menuEdit": "Edit", + "menuProfile": "Profile view", + "menuInbox": "Inbox", + "menuSearch": "Search/follow", + "menuNewPost": "New post", + "menuCalendar": "Calendar", + "menuDM": "Direct Messages", + "menuReplies": "Replies", + "menuOutbox": "Sent", + "menuBookmarks": "Bookmarks", + "menuShares": "Shared items", + "menuBlogs": "Blogs", + "menuNewswire": "Newswire", + "menuLinks": "Links", + "menuModeration": "Moderation", + "menuFollowing": "Following", + "menuFollowers": "Followers", + "menuRoles": "Roles", + "menuSkills": "Skills", + "menuLogout": "Logout", + "menuKeys": "Key Shortcuts" } diff --git a/translations/pt.json b/translations/pt.json index 5ed9a87c3..7e58dc8c5 100644 --- a/translations/pt.json +++ b/translations/pt.json @@ -403,5 +403,28 @@ "shocked": "chocada", "Encrypted": "Criptografada", "Direct Message permitted instances": "Mensagens diretas permitidas instâncias", - "Direct messages are always allowed from these instances.": "Mensagens diretas são sempre permitidas a partir dessas instâncias." + "Direct messages are always allowed from these instances.": "Mensagens diretas são sempre permitidas a partir dessas instâncias.", + "Key Shortcuts": "Atalhos-chave", + "menuTimeline": "Vista da linha do tempo", + "menuEdit": "Editar", + "menuProfile": "Vista de perfil", + "menuInbox": "Caixa de entrada", + "menuSearch": "Pesquisa / Siga", + "menuNewPost": "Nova postagem", + "menuCalendar": "Calendário", + "menuDM": "Mensagens diretas", + "menuReplies": "Respostas", + "menuOutbox": "Enviei", + "menuBookmarks": "Favoritas", + "menuShares": "Itens compartilhados", + "menuBlogs": "Blogs", + "menuNewswire": "Newswire", + "menuLinks": "Links da Web", + "menuModeration": "Moderação", + "menuFollowing": "Seguindo", + "menuFollowers": "Seguidoras", + "menuRoles": "Papéis", + "menuSkills": "Habilidades", + "menuLogout": "Sair", + "menuKeys": "Atalhos-chave" } diff --git a/translations/ru.json b/translations/ru.json index 924356521..6e6e4102a 100644 --- a/translations/ru.json +++ b/translations/ru.json @@ -403,5 +403,28 @@ "shocked": "потрясенный", "Encrypted": "Зашифрованный", "Direct Message permitted instances": "Прямое сообщение разрешено экземпляры", - "Direct messages are always allowed from these instances.": "Прямые сообщения всегда допускаются из этих экземпляров." + "Direct messages are always allowed from these instances.": "Прямые сообщения всегда допускаются из этих экземпляров.", + "Key Shortcuts": "Клавичные ярлыки", + "menuTimeline": "Сроки зрения", + "menuEdit": "Редактировать", + "menuProfile": "вид профиля", + "menuInbox": "Входящие", + "menuSearch": "Поиск / следующее", + "menuNewPost": "Новый пост", + "menuCalendar": "Календарь", + "menuDM": "Прямые сообщения", + "menuReplies": "Отвечает", + "menuOutbox": "Отправил", + "menuBookmarks": "Закладки", + "menuShares": "Общие предметы", + "menuBlogs": "Блоги", + "menuNewswire": "Новобранец", + "menuLinks": "веб ссылки", + "menuModeration": "На модерации", + "menuFollowing": "Следующий", + "menuFollowers": "Подписчики", + "menuRoles": "Роли", + "menuSkills": "Навыки и умения", + "menuLogout": "Выйти", + "menuKeys": "Клавичные ярлыки" } diff --git a/translations/zh.json b/translations/zh.json index 5d566eb8e..38e8ce523 100644 --- a/translations/zh.json +++ b/translations/zh.json @@ -403,5 +403,28 @@ "shocked": "震惊的", "Encrypted": "加密的", "Direct Message permitted instances": "直接留言允许实例", - "Direct messages are always allowed from these instances.": "这些实例始终允许直接消息。" + "Direct messages are always allowed from these instances.": "这些实例始终允许直接消息。", + "Key Shortcuts": "关键捷径", + "menuTimeline": "时间表视图", + "menuEdit": "编辑", + "menuProfile": "个人资料视图", + "menuInbox": "收件箱", + "menuSearch": "搜索/关注", + "menuNewPost": "最新帖子", + "menuCalendar": "日历", + "menuDM": "直接留言", + "menuReplies": "答案", + "menuOutbox": "发送", + "menuBookmarks": "书签", + "menuShares": "共享项目", + "menuBlogs": "博客", + "menuNewswire": "新闻界.", + "menuLinks": "网页链接", + "menuModeration": "适度", + "menuFollowing": "下列的", + "menuFollowers": "追随者", + "menuRoles": "角色", + "menuSkills": "技能", + "menuLogout": "登出", + "menuKeys": "关键捷径" } diff --git a/webapp_accesskeys.py b/webapp_accesskeys.py new file mode 100644 index 000000000..466e3023e --- /dev/null +++ b/webapp_accesskeys.py @@ -0,0 +1,95 @@ +__filename__ = "webapp_accesskeys.py" +__author__ = "Bob Mottram" +__license__ = "AGPL3+" +__version__ = "1.2.0" +__maintainer__ = "Bob Mottram" +__email__ = "bob@freedombone.net" +__status__ = "Production" + +import os +from utils import loadJson +from utils import getConfigParam +from webapp_utils import htmlHeaderWithExternalStyle +from webapp_utils import htmlFooter + + +def loadAccessKeysForAccounts(baseDir: str, keyShortcuts: {}) -> None: + """Loads key shortcuts for each account + """ + for subdir, dirs, files in os.walk(baseDir + '/accounts'): + for acct in dirs: + if '@' not in acct: + continue + if 'inbox@' in acct or 'news@' in acct: + continue + accountDir = os.path.join(baseDir + '/accounts', acct) + accessKeysFilename = accountDir + '/accessKeys.json' + if not os.path.isfile(accessKeysFilename): + continue + nickname = acct.split('@')[0] + accessKeys = loadJson(accessKeysFilename) + if accessKeys: + keyShortcuts[nickname] = accessKeys + break + + +def htmlAccessKeys(cssCache: {}, baseDir: str, + nickname: str, domain: str, + translate: {}, accessKeys: {}, + defaultAccessKeys: {}) -> str: + """Show and edit key shortcuts + """ + accessKeysFilename = \ + baseDir + '/accounts/' + nickname + '@' + domain + '/accessKeys.json' + if os.path.isfile(accessKeysFilename): + accessKeysFromFile = loadJson(accessKeysFilename) + if accessKeysFromFile: + accessKeys = accessKeysFromFile + + accessKeysForm = '' + cssFilename = baseDir + '/epicyon-profile.css' + if os.path.isfile(baseDir + '/epicyon.css'): + cssFilename = baseDir + '/epicyon.css' + + instanceTitle = \ + getConfigParam(baseDir, 'instanceTitle') + accessKeysForm = htmlHeaderWithExternalStyle(cssFilename, instanceTitle) + accessKeysForm += '
\n' + + accessKeysForm += \ + '

' + translate['Key Shortcuts'] + '

\n' + + accessKeysForm += '
\n' + + accessKeysForm += \ + '
' + \ + '
\n' + + accessKeysForm += ' \n' + accessKeysForm += ' \n' + accessKeysForm += ' \n' + accessKeysForm += ' \n' + accessKeysForm += ' \n' + accessKeysForm += ' \n' + + for variableName, key in defaultAccessKeys.items(): + if not translate.get(variableName): + continue + keyStr = '' + keyStr += \ + '' + if accessKeys.get(variableName): + key = accessKeys[variableName] + keyStr += \ + '' + + accessKeysForm += ' \n' + accessKeysForm += '
' + keyStr = '
\n' + accessKeysForm += '
\n' + accessKeysForm += '
\n' + accessKeysForm += htmlFooter() + return accessKeysForm