Minimize web interface clutter

main
Bob Mottram 2020-05-23 15:23:56 +01:00
parent 5a99ce9aae
commit 46b1f6311b
17 changed files with 157 additions and 70 deletions

View File

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

View File

@ -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": "إظهار / إخفاء الأزرار"
}

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -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 dainmneacha tionscadail ar mhaith leat paistí git a fháil dóibh"
"List of project names that you wish to receive git patches for": "Liosta dainmneacha tionscadail ar mhaith leat paistí git a fháil dóibh",
"Show/Hide Buttons": "Taispeáin / Folaigh Cnaipí"
}

View File

@ -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": "बटन दिखाएँ / छिपाएँ"
}

View File

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

View File

@ -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": "ボタンの表示/非表示"
}

View File

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

View File

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

View File

@ -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": "Показать / Скрыть кнопки"
}

View File

@ -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": "显示/隐藏按钮"
}

View File

@ -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 = \
'<a href="' + usersPath + \
'/moderation"><button class="' + \
moderationButton + '"><span>' + \
translate['Mod'] + ' </span></button></a>'
sharesButtonStr = \
'<a href="' + usersPath + '/tlshares"><button class="' + \
sharesButton + '"><span>' + translate['Shares'] + \
' </span></button></a>'
sharesButtonStr = ''
bookmarksButtonStr = ''
if not minimal:
sharesButtonStr = \
'<a href="' + usersPath + '/tlshares"><button class="' + \
sharesButton + '"><span>' + translate['Shares'] + \
' </span></button></a>'
bookmarksButtonStr = \
'<a href="' + usersPath + '/tlbookmarks"><button class="' + \
bookmarksButton + '"><span>' + translate['Bookmarks'] + \
' </span></button></a>'
bookmarksButtonStr = \
'<a href="' + usersPath + '/tlbookmarks"><button class="' + \
bookmarksButton + '"><span>' + translate['Bookmarks'] + \
' </span></button></a>'
tlStr = htmlHeader(cssFilename, profileStyle)
@ -4398,31 +4402,35 @@ def htmlTimeline(defaultTimeline: str,
# typically the media button
if defaultTimeline != 'tlmedia':
tlStr += \
' <a href="' + usersPath + \
'/tlmedia"><button class="' + \
mediaButton + '"><span>' + translate['Media'] + \
'</span></button></a>'
if not minimal:
tlStr += \
' <a href="' + usersPath + \
'/tlmedia"><button class="' + \
mediaButton + '"><span>' + translate['Media'] + \
'</span></button></a>'
else:
tlStr += \
' <a href="' + usersPath + \
'/inbox"><button class="' + \
inboxButton+'"><span>' + translate['Inbox'] + \
'</span></button></a>'
if not minimal:
tlStr += \
' <a href="' + usersPath + \
'/inbox"><button class="' + \
inboxButton+'"><span>' + translate['Inbox'] + \
'</span></button></a>'
# typically the blogs button
if defaultTimeline != 'tlblogs':
tlStr += \
' <a href="' + usersPath + \
'/tlblogs"><button class="' + \
blogsButton + '"><span>' + translate['Blogs'] + \
'</span></button></a>'
if not minimal:
tlStr += \
' <a href="' + usersPath + \
'/tlblogs"><button class="' + \
blogsButton + '"><span>' + translate['Blogs'] + \
'</span></button></a>'
else:
tlStr += \
' <a href="' + usersPath + \
'/inbox"><button class="' + \
inboxButton + '"><span>' + translate['Inbox'] + \
'</span></button></a>'
if not minimal:
tlStr += \
' <a href="' + usersPath + \
'/inbox"><button class="' + \
inboxButton + '"><span>' + translate['Inbox'] + \
'</span></button></a>'
tlStr += \
' <a href="' + usersPath + \
@ -4445,10 +4453,10 @@ def htmlTimeline(defaultTimeline: str,
'" alt="' + translate['Calendar'] + \
'" class="timelineicon"/></a>'
tlStr += \
' <a href="' + usersPath + '/' + boxName + \
' <a href="' + usersPath + '/minimal' + \
'"><img loading="lazy" src="/' + iconsDir + \
'/refresh.png" title="' + translate['Refresh'] + \
'" alt="' + translate['Refresh'] + \
'/refresh.png" title="' + translate['Show/Hide Buttons'] + \
'" alt="' + translate['Show/Hide Buttons'] + \
'" class="timelineicon"/></a>'
tlStr += followApprovals
tlStr += '</div>'
@ -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,