diff --git a/daemon.py b/daemon.py index 4cc452c21..66a3087be 100644 --- a/daemon.py +++ b/daemon.py @@ -216,6 +216,34 @@ def readFollowList(filename: str) -> None: class PubServer(BaseHTTPRequestHandler): protocol_version = 'HTTP/1.1' + def _isMinimal(self, nickname: str) -> bool: + """Returns true if minimal buttons should be shown + for the given account + """ + accountDir = self.baseDir + '/accounts/' + \ + nickname + '@' + self.server.domain + if not os.path.isdir(accountDir): + return False + minimalFilename = accountDir + '/minimal' + if os.path.isfile(minimalFilename): + return True + return False + + def _setMinimal(self, nickname: str, minimal: bool) -> None: + """Sets whether an account should display minimal buttons + """ + accountDir = self.baseDir + '/accounts/' + \ + nickname + '@' + self.server.domain + if not os.path.isdir(accountDir): + return + minimalFilename = accountDir + '/minimal' + minimalFileExists = os.path.isfile(minimalFilename) + if not minimal and minimalFileExists: + os.remove(minimalFilename) + elif minimal and not minimalFileExists: + with open(minimalFilename, 'w') as fp: + fp.write('\n') + def _sendReplyToQuestion(self, nickname: str, messageId: str, answer: str) -> None: """Sends a reply to a question @@ -1937,6 +1965,23 @@ class PubServer(BaseHTTPRequestHandler): self._benchmarkGETtimings(GETstartTime, GETtimings, 28) + # show or hide buttons in the web interface + if htmlGET and '/users/' in self.path and \ + self.path.endswith('/minimal') and \ + authorized: + nickname = self.path.split('/users/')[1] + if '/' in nickname: + nickname = nickname.split('/')[0] + self._setMinimal(nickname, not self._isMinimal(nickname)) + if not (self.server.mediaInstance or + self.server.blogsInstance): + self.path = '/users/' + nickname + '/inbox' + else: + if self.server.blogsInstance: + self.path = '/users/' + nickname + '/tlblogs' + else: + self.path = '/users/' + nickname + '/tlmedia' + # search for a fediverse address, shared item or emoji # from the web interface by selecting search icon if htmlGET and '/users/' in self.path: @@ -3458,7 +3503,8 @@ class PubServer(BaseHTTPRequestHandler): inboxFeed, self.server.allowDeletion, self.server.httpPrefix, - self.server.projectVersion) + self.server.projectVersion, + self._isMinimal(nickname)) msg = msg.encode('utf-8') self._set_headers('text/html', len(msg), @@ -3548,7 +3594,8 @@ class PubServer(BaseHTTPRequestHandler): inboxDMFeed, self.server.allowDeletion, self.server.httpPrefix, - self.server.projectVersion) + self.server.projectVersion, + self._isMinimal(nickname)) msg = msg.encode('utf-8') self._set_headers('text/html', len(msg), @@ -3637,7 +3684,8 @@ class PubServer(BaseHTTPRequestHandler): inboxRepliesFeed, self.server.allowDeletion, self.server.httpPrefix, - self.server.projectVersion) + self.server.projectVersion, + self._isMinimal(nickname)) msg = msg.encode('utf-8') self._set_headers('text/html', len(msg), @@ -3727,7 +3775,8 @@ class PubServer(BaseHTTPRequestHandler): inboxMediaFeed, self.server.allowDeletion, self.server.httpPrefix, - self.server.projectVersion) + self.server.projectVersion, + self.server._isMinimal(nickname)) msg = msg.encode('utf-8') self._set_headers('text/html', len(msg), @@ -3815,7 +3864,8 @@ class PubServer(BaseHTTPRequestHandler): inboxBlogsFeed, self.server.allowDeletion, self.server.httpPrefix, - self.server.projectVersion) + self.server.projectVersion, + self._isMinimal(nickname)) msg = msg.encode('utf-8') self._set_headers('text/html', len(msg), @@ -4041,7 +4091,8 @@ class PubServer(BaseHTTPRequestHandler): outboxFeed, self.server.allowDeletion, self.server.httpPrefix, - self.server.projectVersion) + self.server.projectVersion, + self._isMinimal(nickname)) msg = msg.encode('utf-8') self._set_headers('text/html', len(msg), diff --git a/translations/ar.json b/translations/ar.json index e8a1fa5d1..492f70721 100644 --- a/translations/ar.json +++ b/translations/ar.json @@ -221,5 +221,6 @@ "Publicly visible post": "مشاركة مرئية بشكل عام", "Your Posts": "منشوراتك", "Git Projects": "مشاريع Git", - "List of project names that you wish to receive git patches for": "قائمة بأسماء المشاريع التي ترغب في تلقي تصحيحات git لها" + "List of project names that you wish to receive git patches for": "قائمة بأسماء المشاريع التي ترغب في تلقي تصحيحات git لها", + "Show/Hide Buttons": "إظهار / إخفاء الأزرار" } diff --git a/translations/ca.json b/translations/ca.json index f9299e6b3..7ea7e65fe 100644 --- a/translations/ca.json +++ b/translations/ca.json @@ -221,5 +221,6 @@ "Publicly visible post": "Publicació visible públicament", "Your Posts": "Les teves publicacions", "Git Projects": "Git Projectes", - "List of project names that you wish to receive git patches for": "Llista de noms de projectes dels quals voleu rebre els pedaços de git" + "List of project names that you wish to receive git patches for": "Llista de noms de projectes dels quals voleu rebre els pedaços de git", + "Show/Hide Buttons": "Mostra / Oculta els botons" } diff --git a/translations/cy.json b/translations/cy.json index 5b2eae407..6133591f7 100644 --- a/translations/cy.json +++ b/translations/cy.json @@ -221,5 +221,6 @@ "Publicly visible post": "Post sy'n weladwy i'r cyhoedd", "Your Posts": "Eich Swyddi", "Git Projects": "Prosiectau Git", - "List of project names that you wish to receive git patches for": "Rhestr o enwau prosiectau yr ydych yn dymuno derbyn darnau git ar eu cyfer" + "List of project names that you wish to receive git patches for": "Rhestr o enwau prosiectau yr ydych yn dymuno derbyn darnau git ar eu cyfer", + "Show/Hide Buttons": "Dangos / Cuddio Botymau" } diff --git a/translations/de.json b/translations/de.json index 1a6ec7653..5ae4bb92d 100644 --- a/translations/de.json +++ b/translations/de.json @@ -221,5 +221,6 @@ "Publicly visible post": "Öffentlich sichtbarer Beitrag", "Your Posts": "Deine Posts", "Git Projects": "Git-Projekte", - "List of project names that you wish to receive git patches for": "Liste der Projektnamen, für die Sie Git-Patches erhalten möchten" + "List of project names that you wish to receive git patches for": "Liste der Projektnamen, für die Sie Git-Patches erhalten möchten", + "Show/Hide Buttons": "Schaltflächen ein- / ausblenden" } diff --git a/translations/en.json b/translations/en.json index d6681c6f6..71aca1bff 100644 --- a/translations/en.json +++ b/translations/en.json @@ -221,5 +221,6 @@ "Publicly visible post": "Publicly visible post", "Your Posts": "Your Posts", "Git Projects": "Git Projects", - "List of project names that you wish to receive git patches for": "List of project names that you wish to receive git patches for" + "List of project names that you wish to receive git patches for": "List of project names that you wish to receive git patches for", + "Show/Hide Buttons": "Show/Hide Buttons" } diff --git a/translations/es.json b/translations/es.json index e326a1749..a2b6288d6 100644 --- a/translations/es.json +++ b/translations/es.json @@ -221,5 +221,6 @@ "Publicly visible post": "Publicación públicamente visible", "Your Posts": "Tus publicaciones", "Git Projects": "Proyectos Git", - "List of project names that you wish to receive git patches for": "Lista de nombres de proyectos para los que desea recibir parches git" + "List of project names that you wish to receive git patches for": "Lista de nombres de proyectos para los que desea recibir parches git", + "Show/Hide Buttons": "Botones Mostrar / Ocultar" } diff --git a/translations/fr.json b/translations/fr.json index 8dd55e155..147361943 100644 --- a/translations/fr.json +++ b/translations/fr.json @@ -221,5 +221,6 @@ "Publicly visible post": "Message publiquement visible", "Your Posts": "Vos publications", "Git Projects": "Projets Git", - "List of project names that you wish to receive git patches for": "Liste des noms de projets pour lesquels vous souhaitez recevoir des correctifs git" + "List of project names that you wish to receive git patches for": "Liste des noms de projets pour lesquels vous souhaitez recevoir des correctifs git", + "Show/Hide Buttons": "Afficher / masquer les boutons" } diff --git a/translations/ga.json b/translations/ga.json index 4d6457159..016e249df 100644 --- a/translations/ga.json +++ b/translations/ga.json @@ -221,5 +221,6 @@ "Publicly visible post": "Post atá infheicthe go poiblí", "Your Posts": "Do Phoist", "Git Projects": "Tionscadail Git", - "List of project names that you wish to receive git patches for": "Liosta d’ainmneacha tionscadail ar mhaith leat paistí git a fháil dóibh" + "List of project names that you wish to receive git patches for": "Liosta d’ainmneacha tionscadail ar mhaith leat paistí git a fháil dóibh", + "Show/Hide Buttons": "Taispeáin / Folaigh Cnaipí" } diff --git a/translations/hi.json b/translations/hi.json index 5bfcac7e4..40836ceda 100644 --- a/translations/hi.json +++ b/translations/hi.json @@ -221,5 +221,6 @@ "Publicly visible post": "सार्वजनिक रूप से दिखाई देने वाली पोस्ट", "Your Posts": "आपके पोस्ट", "Git Projects": "गिट परियोजनाओं", - "List of project names that you wish to receive git patches for": "उन प्रोजेक्ट नामों की सूची, जिनके लिए आप git पैच प्राप्त करना चाहते हैं" + "List of project names that you wish to receive git patches for": "उन प्रोजेक्ट नामों की सूची, जिनके लिए आप git पैच प्राप्त करना चाहते हैं", + "Show/Hide Buttons": "बटन दिखाएँ / छिपाएँ" } diff --git a/translations/it.json b/translations/it.json index d9a8d7d70..8761699be 100644 --- a/translations/it.json +++ b/translations/it.json @@ -221,5 +221,6 @@ "Publicly visible post": "Post pubblicamente visibile", "Your Posts": "I tuoi post", "Git Projects": "Git Projects", - "List of project names that you wish to receive git patches for": "Elenco di nomi di progetti per i quali si desidera ricevere patch git" + "List of project names that you wish to receive git patches for": "Elenco di nomi di progetti per i quali si desidera ricevere patch git", + "Show/Hide Buttons": "Mostra / Nascondi pulsanti" } diff --git a/translations/ja.json b/translations/ja.json index 6c40061b5..784299248 100644 --- a/translations/ja.json +++ b/translations/ja.json @@ -221,5 +221,6 @@ "Publicly visible post": "一般公開の投稿", "Your Posts": "あなたの投稿", "Git Projects": "Gitプロジェクト", - "List of project names that you wish to receive git patches for": "gitパッチを受け取りたいプロジェクト名のリスト" + "List of project names that you wish to receive git patches for": "gitパッチを受け取りたいプロジェクト名のリスト", + "Show/Hide Buttons": "ボタンの表示/非表示" } diff --git a/translations/oc.json b/translations/oc.json index 05972fed0..826c4c3ee 100644 --- a/translations/oc.json +++ b/translations/oc.json @@ -217,5 +217,6 @@ "Publicly visible post": "Publicly visible post", "Your Posts": "Your Posts", "Git Projects": "Git Projects", - "List of project names that you wish to receive git patches for": "List of project names that you wish to receive git patches for" + "List of project names that you wish to receive git patches for": "List of project names that you wish to receive git patches for", + "Show/Hide Buttons": "Show/Hide Buttons" } diff --git a/translations/pt.json b/translations/pt.json index 0b2645c62..57791e6e1 100644 --- a/translations/pt.json +++ b/translations/pt.json @@ -221,5 +221,6 @@ "Publicly visible post": "Postagem publicamente visível", "Your Posts": "Seus posts", "Git Projects": "Projetos Git", - "List of project names that you wish to receive git patches for": "Lista de nomes de projetos para os quais você deseja receber patches git" + "List of project names that you wish to receive git patches for": "Lista de nomes de projetos para os quais você deseja receber patches git", + "Show/Hide Buttons": "Botões Mostrar / Ocultar" } diff --git a/translations/ru.json b/translations/ru.json index 9fa458867..7919cb132 100644 --- a/translations/ru.json +++ b/translations/ru.json @@ -221,5 +221,6 @@ "Publicly visible post": "Публично видимый пост", "Your Posts": "Ваши сообщения", "Git Projects": "Git Projects", - "List of project names that you wish to receive git patches for": "Список имен проектов, для которых вы хотите получать git-патчи" + "List of project names that you wish to receive git patches for": "Список имен проектов, для которых вы хотите получать git-патчи", + "Show/Hide Buttons": "Показать / Скрыть кнопки" } diff --git a/translations/zh.json b/translations/zh.json index 1ad85f699..66c9b5caf 100644 --- a/translations/zh.json +++ b/translations/zh.json @@ -220,5 +220,6 @@ "Publicly visible post": "公开可见的帖子", "Your Posts": "您的帖子", "Git Projects": "Git项目", - "List of project names that you wish to receive git patches for": "您希望收到git补丁的项目名称列表" + "List of project names that you wish to receive git patches for": "您希望收到git补丁的项目名称列表", + "Show/Hide Buttons": "显示/隐藏按钮" } diff --git a/webinterface.py b/webinterface.py index 9dd9b2d76..4fb9851b1 100644 --- a/webinterface.py +++ b/webinterface.py @@ -4150,7 +4150,8 @@ def htmlTimeline(defaultTimeline: str, nickname: str, domain: str, port: int, timelineJson: {}, boxName: str, allowDeletion: bool, httpPrefix: str, projectVersion: str, - manuallyApproveFollowers: bool) -> str: + manuallyApproveFollowers: bool, + minimal: bool) -> str: """Show the timeline as html """ accountDir = baseDir + '/accounts/' + nickname + '@' + domain @@ -4299,22 +4300,25 @@ def htmlTimeline(defaultTimeline: str, break moderationButtonStr = '' - if moderator: + if moderator and not minimal: moderationButtonStr = \ '' - sharesButtonStr = \ - '' + sharesButtonStr = '' + bookmarksButtonStr = '' + if not minimal: + sharesButtonStr = \ + '' - bookmarksButtonStr = \ - '' + bookmarksButtonStr = \ + '' tlStr = htmlHeader(cssFilename, profileStyle) @@ -4398,31 +4402,35 @@ def htmlTimeline(defaultTimeline: str, # typically the media button if defaultTimeline != 'tlmedia': - tlStr += \ - ' ' + if not minimal: + tlStr += \ + ' ' else: - tlStr += \ - ' ' + if not minimal: + tlStr += \ + ' ' # typically the blogs button if defaultTimeline != 'tlblogs': - tlStr += \ - ' ' + if not minimal: + tlStr += \ + ' ' else: - tlStr += \ - ' ' + if not minimal: + tlStr += \ + ' ' tlStr += \ ' ' tlStr += \ - ' ' + translate['Refresh'] + \
+        '/refresh.png' tlStr += followApprovals tlStr += '' @@ -4617,7 +4625,8 @@ def htmlShares(defaultTimeline: str, itemsPerPage, session, baseDir, wfRequest, personCache, nickname, domain, port, None, 'tlshares', allowDeletion, - httpPrefix, projectVersion, manuallyApproveFollowers) + httpPrefix, projectVersion, manuallyApproveFollowers, + False) def htmlInbox(defaultTimeline: str, @@ -4626,7 +4635,8 @@ def htmlInbox(defaultTimeline: str, session, baseDir: str, wfRequest: {}, personCache: {}, nickname: str, domain: str, port: int, inboxJson: {}, allowDeletion: bool, - httpPrefix: str, projectVersion: str) -> str: + httpPrefix: str, projectVersion: str, + minimal: bool) -> str: """Show the inbox as html """ manuallyApproveFollowers = \ @@ -4637,7 +4647,8 @@ def htmlInbox(defaultTimeline: str, itemsPerPage, session, baseDir, wfRequest, personCache, nickname, domain, port, inboxJson, 'inbox', allowDeletion, - httpPrefix, projectVersion, manuallyApproveFollowers) + httpPrefix, projectVersion, manuallyApproveFollowers, + minimal) def htmlBookmarks(defaultTimeline: str, @@ -4646,7 +4657,8 @@ def htmlBookmarks(defaultTimeline: str, session, baseDir: str, wfRequest: {}, personCache: {}, nickname: str, domain: str, port: int, bookmarksJson: {}, allowDeletion: bool, - httpPrefix: str, projectVersion: str) -> str: + httpPrefix: str, projectVersion: str, + minimal: bool) -> str: """Show the bookmarks as html """ manuallyApproveFollowers = \ @@ -4657,7 +4669,8 @@ def htmlBookmarks(defaultTimeline: str, itemsPerPage, session, baseDir, wfRequest, personCache, nickname, domain, port, bookmarksJson, 'tlbookmarks', allowDeletion, - httpPrefix, projectVersion, manuallyApproveFollowers) + httpPrefix, projectVersion, manuallyApproveFollowers, + minimal) def htmlInboxDMs(defaultTimeline: str, @@ -4666,14 +4679,15 @@ def htmlInboxDMs(defaultTimeline: str, session, baseDir: str, wfRequest: {}, personCache: {}, nickname: str, domain: str, port: int, inboxJson: {}, allowDeletion: bool, - httpPrefix: str, projectVersion: str) -> str: + httpPrefix: str, projectVersion: str, + minimal: bool) -> str: """Show the DM timeline as html """ return htmlTimeline(defaultTimeline, recentPostsCache, maxRecentPosts, translate, pageNumber, itemsPerPage, session, baseDir, wfRequest, personCache, nickname, domain, port, inboxJson, 'dm', allowDeletion, - httpPrefix, projectVersion, False) + httpPrefix, projectVersion, False, minimal) def htmlInboxReplies(defaultTimeline: str, @@ -4682,14 +4696,16 @@ def htmlInboxReplies(defaultTimeline: str, session, baseDir: str, wfRequest: {}, personCache: {}, nickname: str, domain: str, port: int, inboxJson: {}, allowDeletion: bool, - httpPrefix: str, projectVersion: str) -> str: + httpPrefix: str, projectVersion: str, + minimal: bool) -> str: """Show the replies timeline as html """ return htmlTimeline(defaultTimeline, recentPostsCache, maxRecentPosts, translate, pageNumber, itemsPerPage, session, baseDir, wfRequest, personCache, nickname, domain, port, inboxJson, 'tlreplies', - allowDeletion, httpPrefix, projectVersion, False) + allowDeletion, httpPrefix, projectVersion, False, + minimal) def htmlInboxMedia(defaultTimeline: str, @@ -4698,14 +4714,16 @@ def htmlInboxMedia(defaultTimeline: str, session, baseDir: str, wfRequest: {}, personCache: {}, nickname: str, domain: str, port: int, inboxJson: {}, allowDeletion: bool, - httpPrefix: str, projectVersion: str) -> str: + httpPrefix: str, projectVersion: str, + minimal: bool) -> str: """Show the media timeline as html """ return htmlTimeline(defaultTimeline, recentPostsCache, maxRecentPosts, translate, pageNumber, itemsPerPage, session, baseDir, wfRequest, personCache, nickname, domain, port, inboxJson, 'tlmedia', - allowDeletion, httpPrefix, projectVersion, False) + allowDeletion, httpPrefix, projectVersion, False, + minimal) def htmlInboxBlogs(defaultTimeline: str, @@ -4714,14 +4732,16 @@ def htmlInboxBlogs(defaultTimeline: str, session, baseDir: str, wfRequest: {}, personCache: {}, nickname: str, domain: str, port: int, inboxJson: {}, allowDeletion: bool, - httpPrefix: str, projectVersion: str) -> str: + httpPrefix: str, projectVersion: str, + minimal: bool) -> str: """Show the blogs timeline as html """ return htmlTimeline(defaultTimeline, recentPostsCache, maxRecentPosts, translate, pageNumber, itemsPerPage, session, baseDir, wfRequest, personCache, nickname, domain, port, inboxJson, 'tlblogs', - allowDeletion, httpPrefix, projectVersion, False) + allowDeletion, httpPrefix, projectVersion, False, + minimal) def htmlModeration(defaultTimeline: str, @@ -4737,7 +4757,7 @@ def htmlModeration(defaultTimeline: str, translate, pageNumber, itemsPerPage, session, baseDir, wfRequest, personCache, nickname, domain, port, inboxJson, 'moderation', - allowDeletion, httpPrefix, projectVersion, True) + allowDeletion, httpPrefix, projectVersion, True, False) def htmlOutbox(defaultTimeline: str, @@ -4746,7 +4766,8 @@ def htmlOutbox(defaultTimeline: str, session, baseDir: str, wfRequest: {}, personCache: {}, nickname: str, domain: str, port: int, outboxJson: {}, allowDeletion: bool, - httpPrefix: str, projectVersion: str) -> str: + httpPrefix: str, projectVersion: str, + minimal: bool) -> str: """Show the Outbox as html """ manuallyApproveFollowers = \ @@ -4756,7 +4777,7 @@ def htmlOutbox(defaultTimeline: str, itemsPerPage, session, baseDir, wfRequest, personCache, nickname, domain, port, outboxJson, 'outbox', allowDeletion, httpPrefix, projectVersion, - manuallyApproveFollowers) + manuallyApproveFollowers, minimal) def htmlIndividualPost(recentPostsCache: {}, maxRecentPosts: int,