From 67a3ef538f3dd0591f31fa2fb293196694a14ece Mon Sep 17 00:00:00 2001 From: Bob Mottram Date: Sat, 24 Oct 2020 18:44:41 +0100 Subject: [PATCH] Add option for timeline button header full screen width --- daemon.py | 60 +++++++++++++++++++++------ epicyon.py | 15 ++++++- tests.py | 6 +-- webinterface.py | 106 ++++++++++++++++++++++++++++++++---------------- 4 files changed, 136 insertions(+), 51 deletions(-) diff --git a/daemon.py b/daemon.py index d4203d43..d3f3d30e 100644 --- a/daemon.py +++ b/daemon.py @@ -6431,6 +6431,8 @@ class PubServer(BaseHTTPRequestHandler): GETtimings, 'show status done', 'show inbox page') + fullWidthTimelineButtonHeader = \ + self.server.fullWidthTimelineButtonHeader msg = htmlInbox(defaultTimeline, recentPostsCache, maxRecentPosts, @@ -6452,7 +6454,8 @@ class PubServer(BaseHTTPRequestHandler): self.server.showPublishedDateOnly, self.server.newswire, self.server.positiveVoting, - self.server.showPublishAsIcon) + self.server.showPublishAsIcon, + fullWidthTimelineButtonHeader) if GETstartTime: self._benchmarkGETtimings(GETstartTime, GETtimings, 'show status done', @@ -6545,6 +6548,8 @@ class PubServer(BaseHTTPRequestHandler): 0, self.server.positiveVoting, self.server.votingTimeMins) + fullWidthTimelineButtonHeader = \ + self.server.fullWidthTimelineButtonHeader msg = \ htmlInboxDMs(self.server.defaultTimeline, self.server.recentPostsCache, @@ -6567,7 +6572,8 @@ class PubServer(BaseHTTPRequestHandler): self.server.showPublishedDateOnly, self.server.newswire, self.server.positiveVoting, - self.server.showPublishAsIcon) + self.server.showPublishAsIcon, + fullWidthTimelineButtonHeader) msg = msg.encode('utf-8') self._set_headers('text/html', len(msg), cookie, callingDomain) @@ -6653,6 +6659,8 @@ class PubServer(BaseHTTPRequestHandler): True, 0, self.server.positiveVoting, self.server.votingTimeMins) + fullWidthTimelineButtonHeader = \ + self.server.fullWidthTimelineButtonHeader msg = \ htmlInboxReplies(self.server.defaultTimeline, self.server.recentPostsCache, @@ -6675,7 +6683,8 @@ class PubServer(BaseHTTPRequestHandler): self.server.showPublishedDateOnly, self.server.newswire, self.server.positiveVoting, - self.server.showPublishAsIcon) + self.server.showPublishAsIcon, + fullWidthTimelineButtonHeader) msg = msg.encode('utf-8') self._set_headers('text/html', len(msg), cookie, callingDomain) @@ -6761,6 +6770,8 @@ class PubServer(BaseHTTPRequestHandler): True, 0, self.server.positiveVoting, self.server.votingTimeMins) + fullWidthTimelineButtonHeader = \ + self.server.fullWidthTimelineButtonHeader msg = \ htmlInboxMedia(self.server.defaultTimeline, self.server.recentPostsCache, @@ -6783,7 +6794,8 @@ class PubServer(BaseHTTPRequestHandler): self.server.showPublishedDateOnly, self.server.newswire, self.server.positiveVoting, - self.server.showPublishAsIcon) + self.server.showPublishAsIcon, + fullWidthTimelineButtonHeader) msg = msg.encode('utf-8') self._set_headers('text/html', len(msg), cookie, callingDomain) @@ -6869,6 +6881,8 @@ class PubServer(BaseHTTPRequestHandler): True, 0, self.server.positiveVoting, self.server.votingTimeMins) + fullWidthTimelineButtonHeader = \ + self.server.fullWidthTimelineButtonHeader msg = \ htmlInboxBlogs(self.server.defaultTimeline, self.server.recentPostsCache, @@ -6891,7 +6905,8 @@ class PubServer(BaseHTTPRequestHandler): self.server.showPublishedDateOnly, self.server.newswire, self.server.positiveVoting, - self.server.showPublishAsIcon) + self.server.showPublishAsIcon, + fullWidthTimelineButtonHeader) msg = msg.encode('utf-8') self._set_headers('text/html', len(msg), cookie, callingDomain) @@ -6985,6 +7000,8 @@ class PubServer(BaseHTTPRequestHandler): currNickname = currNickname.split('/')[0] moderator = isModerator(baseDir, currNickname) editor = isEditor(baseDir, currNickname) + fullWidthTimelineButtonHeader = \ + self.server.fullWidthTimelineButtonHeader msg = \ htmlInboxNews(self.server.defaultTimeline, self.server.recentPostsCache, @@ -7008,7 +7025,8 @@ class PubServer(BaseHTTPRequestHandler): self.server.newswire, moderator, editor, self.server.positiveVoting, - self.server.showPublishAsIcon) + self.server.showPublishAsIcon, + fullWidthTimelineButtonHeader) msg = msg.encode('utf-8') self._set_headers('text/html', len(msg), cookie, callingDomain) @@ -7086,7 +7104,8 @@ class PubServer(BaseHTTPRequestHandler): self.server.showPublishedDateOnly, self.server.newswire, self.server.positiveVoting, - self.server.showPublishAsIcon) + self.server.showPublishAsIcon, + self.server.fullWidthTimelineButtonHeader) msg = msg.encode('utf-8') self._set_headers('text/html', len(msg), cookie, callingDomain) @@ -7156,6 +7175,8 @@ class PubServer(BaseHTTPRequestHandler): authorized, 0, self.server.positiveVoting, self.server.votingTimeMins) + fullWidthTimelineButtonHeader = \ + self.server.fullWidthTimelineButtonHeader msg = \ htmlBookmarks(self.server.defaultTimeline, self.server.recentPostsCache, @@ -7178,7 +7199,8 @@ class PubServer(BaseHTTPRequestHandler): self.server.showPublishedDateOnly, self.server.newswire, self.server.positiveVoting, - self.server.showPublishAsIcon) + self.server.showPublishAsIcon, + fullWidthTimelineButtonHeader) msg = msg.encode('utf-8') self._set_headers('text/html', len(msg), cookie, callingDomain) @@ -7267,6 +7289,8 @@ class PubServer(BaseHTTPRequestHandler): authorized, 0, self.server.positiveVoting, self.server.votingTimeMins) + fullWidthTimelineButtonHeader = \ + self.server.fullWidthTimelineButtonHeader msg = \ htmlEvents(self.server.defaultTimeline, self.server.recentPostsCache, @@ -7289,7 +7313,8 @@ class PubServer(BaseHTTPRequestHandler): self.server.showPublishedDateOnly, self.server.newswire, self.server.positiveVoting, - self.server.showPublishAsIcon) + self.server.showPublishAsIcon, + fullWidthTimelineButtonHeader) msg = msg.encode('utf-8') self._set_headers('text/html', len(msg), cookie, callingDomain) @@ -7370,6 +7395,8 @@ class PubServer(BaseHTTPRequestHandler): self.server.newswireVotesThreshold, self.server.positiveVoting, self.server.votingTimeMins) + fullWidthTimelineButtonHeader = \ + self.server.fullWidthTimelineButtonHeader msg = \ htmlOutbox(self.server.defaultTimeline, self.server.recentPostsCache, @@ -7392,7 +7419,8 @@ class PubServer(BaseHTTPRequestHandler): self.server.showPublishedDateOnly, self.server.newswire, self.server.positiveVoting, - self.server.showPublishAsIcon) + self.server.showPublishAsIcon, + fullWidthTimelineButtonHeader) msg = msg.encode('utf-8') self._set_headers('text/html', len(msg), cookie, callingDomain) @@ -7464,6 +7492,8 @@ class PubServer(BaseHTTPRequestHandler): True, 0, self.server.positiveVoting, self.server.votingTimeMins) + fullWidthTimelineButtonHeader = \ + self.server.fullWidthTimelineButtonHeader msg = \ htmlModeration(self.server.defaultTimeline, self.server.recentPostsCache, @@ -7485,7 +7515,8 @@ class PubServer(BaseHTTPRequestHandler): self.server.showPublishedDateOnly, self.server.newswire, self.server.positiveVoting, - self.server.showPublishAsIcon) + self.server.showPublishAsIcon, + fullWidthTimelineButtonHeader) msg = msg.encode('utf-8') self._set_headers('text/html', len(msg), cookie, callingDomain) @@ -12001,7 +12032,8 @@ def loadTokens(baseDir: str, tokensDict: {}, tokensLookup: {}) -> None: tokensLookup[token] = nickname -def runDaemon(showPublishAsIcon: bool, +def runDaemon(fullWidthTimelineButtonHeader: bool, + showPublishAsIcon: bool, maxFollowers: int, allowNewsFollowers: bool, maxNewsPosts: int, @@ -12161,6 +12193,10 @@ def runDaemon(showPublishAsIcon: bool, # newswire, or a 'Publish' button httpd.showPublishAsIcon = showPublishAsIcon + # Whether to show the timeline header containing inbox, outbox + # calendar, etc as the full width of the screen or not + httpd.fullWidthTimelineButtonHeader = fullWidthTimelineButtonHeader + if registration == 'open': httpd.registration = True else: diff --git a/epicyon.py b/epicyon.py index f2c2e97e..c77565ef 100644 --- a/epicyon.py +++ b/epicyon.py @@ -215,6 +215,13 @@ parser.add_argument("--showPublishAsIcon", const=True, default=True, help="Whether to show newswire publish " + "as an icon or a button") +parser.add_argument("--fullWidthTimelineButtonHeader", + dest='fullWidthTimelineButtonHeader', + type=str2bool, nargs='?', + const=True, default=False, + help="Whether to show the timeline " + + "button header containing inbox and outbox " + + "as the full width of the screen") parser.add_argument("--allowNewsFollowers", dest='allowNewsFollowers', type=str2bool, nargs='?', @@ -1996,6 +2003,11 @@ showPublishAsIcon = \ if showPublishAsIcon is not None: args.showPublishAsIcon = bool(showPublishAsIcon) +fullWidthTimelineButtonHeader = \ + getConfigParam(baseDir, 'fullWidthTimelineButtonHeader') +if fullWidthTimelineButtonHeader is not None: + args.fullWidthTimelineButtonHeader = bool(fullWidthTimelineButtonHeader) + YTDomain = getConfigParam(baseDir, 'youtubedomain') if YTDomain: if '://' in YTDomain: @@ -2009,7 +2021,8 @@ if setTheme(baseDir, themeName, domain): print('Theme set to ' + themeName) if __name__ == "__main__": - runDaemon(args.showPublishAsIcon, + runDaemon(args.fullWidthTimelineButtonHeader, + args.showPublishAsIcon, args.maxFollowers, args.allowNewsFollowers, args.maxNewsPosts, diff --git a/tests.py b/tests.py index dd72ef8d..8966bddc 100644 --- a/tests.py +++ b/tests.py @@ -290,7 +290,7 @@ def createServerAlice(path: str, domain: str, port: int, onionDomain = None i2pDomain = None print('Server running: Alice') - runDaemon(True, 10, False, 0, 100, 1024, 5, False, + runDaemon(False, True, 10, False, 0, 100, 1024, 5, False, 0, False, 1, False, False, False, 5, True, True, 'en', __version__, "instanceId", False, path, domain, @@ -354,7 +354,7 @@ def createServerBob(path: str, domain: str, port: int, onionDomain = None i2pDomain = None print('Server running: Bob') - runDaemon(True, 10, False, 0, 100, 1024, 5, False, 0, + runDaemon(False, True, 10, False, 0, 100, 1024, 5, False, 0, False, 1, False, False, False, 5, True, True, 'en', __version__, "instanceId", False, path, domain, @@ -392,7 +392,7 @@ def createServerEve(path: str, domain: str, port: int, federationList: [], onionDomain = None i2pDomain = None print('Server running: Eve') - runDaemon(True, 10, False, 0, 100, 1024, 5, False, 0, + runDaemon(False, True, 10, False, 0, 100, 1024, 5, False, 0, False, 1, False, False, False, 5, True, True, 'en', __version__, "instanceId", False, path, domain, diff --git a/webinterface.py b/webinterface.py index e89ec92c..fa9d5183 100644 --- a/webinterface.py +++ b/webinterface.py @@ -6144,7 +6144,8 @@ def htmlTimeline(defaultTimeline: str, newswire: {}, moderator: bool, editor: bool, positiveVoting: bool, - showPublishAsIcon: bool) -> str: + showPublishAsIcon: bool, + fullWidthTimelineButtonHeader: bool) -> str: """Show the timeline as html """ timelineStartTime = time.time() @@ -6418,6 +6419,20 @@ def htmlTimeline(defaultTimeline: str, tlStr += '
' tlStr += '
\n\n' + if fullWidthTimelineButtonHeader: + tlStr += \ + getTimelineButtonHeader(defaultTimeline, boxName, pageNumber, + translate, usersPath, mediaButton, + blogsButton, newsButton, inboxButton, + dmButton, newDM, repliesButton, + newReply, minimal, sentButton, + sharesButtonStr, bookmarksButtonStr, + eventsButtonStr, moderationButtonStr, + newPostButtonStr, baseDir, nickname, + domain, iconsDir, timelineStartTime, + newCalendarEvent, calendarPath, + calendarImage, followApprovals) + # start the timeline tlStr += '\n' tlStr += ' \n' @@ -6443,18 +6458,19 @@ def htmlTimeline(defaultTimeline: str, # center column containing posts tlStr += '
\n' - tlStr += \ - getTimelineButtonHeader(defaultTimeline, boxName, pageNumber, - translate, usersPath, mediaButton, - blogsButton, newsButton, inboxButton, - dmButton, newDM, repliesButton, - newReply, minimal, sentButton, - sharesButtonStr, bookmarksButtonStr, - eventsButtonStr, moderationButtonStr, - newPostButtonStr, baseDir, nickname, - domain, iconsDir, timelineStartTime, - newCalendarEvent, calendarPath, - calendarImage, followApprovals) + if not fullWidthTimelineButtonHeader: + tlStr += \ + getTimelineButtonHeader(defaultTimeline, boxName, pageNumber, + translate, usersPath, mediaButton, + blogsButton, newsButton, inboxButton, + dmButton, newDM, repliesButton, + newReply, minimal, sentButton, + sharesButtonStr, bookmarksButtonStr, + eventsButtonStr, moderationButtonStr, + newPostButtonStr, baseDir, nickname, + domain, iconsDir, timelineStartTime, + newCalendarEvent, calendarPath, + calendarImage, followApprovals) # second row of buttons for moderator actions if moderator and boxName == 'moderation': @@ -6666,7 +6682,8 @@ def htmlShares(defaultTimeline: str, YTReplacementDomain: str, showPublishedDateOnly: bool, newswire: {}, positiveVoting: bool, - showPublishAsIcon: bool) -> str: + showPublishAsIcon: bool, + fullWidthTimelineButtonHeader: bool) -> str: """Show the shares timeline as html """ manuallyApproveFollowers = \ @@ -6681,7 +6698,8 @@ def htmlShares(defaultTimeline: str, False, YTReplacementDomain, showPublishedDateOnly, newswire, False, False, - positiveVoting, showPublishAsIcon) + positiveVoting, showPublishAsIcon, + fullWidthTimelineButtonHeader) def htmlInbox(defaultTimeline: str, @@ -6694,7 +6712,8 @@ def htmlInbox(defaultTimeline: str, minimal: bool, YTReplacementDomain: str, showPublishedDateOnly: bool, newswire: {}, positiveVoting: bool, - showPublishAsIcon: bool) -> str: + showPublishAsIcon: bool, + fullWidthTimelineButtonHeader: bool) -> str: """Show the inbox as html """ manuallyApproveFollowers = \ @@ -6709,7 +6728,8 @@ def htmlInbox(defaultTimeline: str, minimal, YTReplacementDomain, showPublishedDateOnly, newswire, False, False, - positiveVoting, showPublishAsIcon) + positiveVoting, showPublishAsIcon, + fullWidthTimelineButtonHeader) def htmlBookmarks(defaultTimeline: str, @@ -6722,7 +6742,8 @@ def htmlBookmarks(defaultTimeline: str, minimal: bool, YTReplacementDomain: str, showPublishedDateOnly: bool, newswire: {}, positiveVoting: bool, - showPublishAsIcon: bool) -> str: + showPublishAsIcon: bool, + fullWidthTimelineButtonHeader: bool) -> str: """Show the bookmarks as html """ manuallyApproveFollowers = \ @@ -6737,7 +6758,8 @@ def htmlBookmarks(defaultTimeline: str, minimal, YTReplacementDomain, showPublishedDateOnly, newswire, False, False, - positiveVoting, showPublishAsIcon) + positiveVoting, showPublishAsIcon, + fullWidthTimelineButtonHeader) def htmlEvents(defaultTimeline: str, @@ -6750,7 +6772,8 @@ def htmlEvents(defaultTimeline: str, minimal: bool, YTReplacementDomain: str, showPublishedDateOnly: bool, newswire: {}, positiveVoting: bool, - showPublishAsIcon: bool) -> str: + showPublishAsIcon: bool, + fullWidthTimelineButtonHeader: bool) -> str: """Show the events as html """ manuallyApproveFollowers = \ @@ -6765,7 +6788,8 @@ def htmlEvents(defaultTimeline: str, minimal, YTReplacementDomain, showPublishedDateOnly, newswire, False, False, - positiveVoting, showPublishAsIcon) + positiveVoting, showPublishAsIcon, + fullWidthTimelineButtonHeader) def htmlInboxDMs(defaultTimeline: str, @@ -6778,7 +6802,8 @@ def htmlInboxDMs(defaultTimeline: str, minimal: bool, YTReplacementDomain: str, showPublishedDateOnly: bool, newswire: {}, positiveVoting: bool, - showPublishAsIcon: bool) -> str: + showPublishAsIcon: bool, + fullWidthTimelineButtonHeader: bool) -> str: """Show the DM timeline as html """ return htmlTimeline(defaultTimeline, recentPostsCache, maxRecentPosts, @@ -6788,7 +6813,8 @@ def htmlInboxDMs(defaultTimeline: str, httpPrefix, projectVersion, False, minimal, YTReplacementDomain, showPublishedDateOnly, newswire, False, False, positiveVoting, - showPublishAsIcon) + showPublishAsIcon, + fullWidthTimelineButtonHeader) def htmlInboxReplies(defaultTimeline: str, @@ -6801,7 +6827,8 @@ def htmlInboxReplies(defaultTimeline: str, minimal: bool, YTReplacementDomain: str, showPublishedDateOnly: bool, newswire: {}, positiveVoting: bool, - showPublishAsIcon: bool) -> str: + showPublishAsIcon: bool, + fullWidthTimelineButtonHeader: bool) -> str: """Show the replies timeline as html """ return htmlTimeline(defaultTimeline, recentPostsCache, maxRecentPosts, @@ -6812,7 +6839,8 @@ def htmlInboxReplies(defaultTimeline: str, minimal, YTReplacementDomain, showPublishedDateOnly, newswire, False, False, - positiveVoting, showPublishAsIcon) + positiveVoting, showPublishAsIcon, + fullWidthTimelineButtonHeader) def htmlInboxMedia(defaultTimeline: str, @@ -6825,7 +6853,8 @@ def htmlInboxMedia(defaultTimeline: str, minimal: bool, YTReplacementDomain: str, showPublishedDateOnly: bool, newswire: {}, positiveVoting: bool, - showPublishAsIcon: bool) -> str: + showPublishAsIcon: bool, + fullWidthTimelineButtonHeader: bool) -> str: """Show the media timeline as html """ return htmlTimeline(defaultTimeline, recentPostsCache, maxRecentPosts, @@ -6836,7 +6865,8 @@ def htmlInboxMedia(defaultTimeline: str, minimal, YTReplacementDomain, showPublishedDateOnly, newswire, False, False, - positiveVoting, showPublishAsIcon) + positiveVoting, showPublishAsIcon, + fullWidthTimelineButtonHeader) def htmlInboxBlogs(defaultTimeline: str, @@ -6849,7 +6879,8 @@ def htmlInboxBlogs(defaultTimeline: str, minimal: bool, YTReplacementDomain: str, showPublishedDateOnly: bool, newswire: {}, positiveVoting: bool, - showPublishAsIcon: bool) -> str: + showPublishAsIcon: bool, + fullWidthTimelineButtonHeader: bool) -> str: """Show the blogs timeline as html """ return htmlTimeline(defaultTimeline, recentPostsCache, maxRecentPosts, @@ -6860,7 +6891,8 @@ def htmlInboxBlogs(defaultTimeline: str, minimal, YTReplacementDomain, showPublishedDateOnly, newswire, False, False, - positiveVoting, showPublishAsIcon) + positiveVoting, showPublishAsIcon, + fullWidthTimelineButtonHeader) def htmlInboxNews(defaultTimeline: str, @@ -6873,7 +6905,8 @@ def htmlInboxNews(defaultTimeline: str, minimal: bool, YTReplacementDomain: str, showPublishedDateOnly: bool, newswire: {}, moderator: bool, editor: bool, - positiveVoting: bool, showPublishAsIcon: bool) -> str: + positiveVoting: bool, showPublishAsIcon: bool, + fullWidthTimelineButtonHeader: bool) -> str: """Show the news timeline as html """ return htmlTimeline(defaultTimeline, recentPostsCache, maxRecentPosts, @@ -6884,7 +6917,8 @@ def htmlInboxNews(defaultTimeline: str, minimal, YTReplacementDomain, showPublishedDateOnly, newswire, moderator, editor, - positiveVoting, showPublishAsIcon) + positiveVoting, showPublishAsIcon, + fullWidthTimelineButtonHeader) def htmlModeration(defaultTimeline: str, @@ -6897,7 +6931,8 @@ def htmlModeration(defaultTimeline: str, YTReplacementDomain: str, showPublishedDateOnly: bool, newswire: {}, positiveVoting: bool, - showPublishAsIcon: bool) -> str: + showPublishAsIcon: bool, + fullWidthTimelineButtonHeader: bool) -> str: """Show the moderation feed as html """ return htmlTimeline(defaultTimeline, recentPostsCache, maxRecentPosts, @@ -6907,7 +6942,7 @@ def htmlModeration(defaultTimeline: str, allowDeletion, httpPrefix, projectVersion, True, False, YTReplacementDomain, showPublishedDateOnly, newswire, False, False, positiveVoting, - showPublishAsIcon) + showPublishAsIcon, fullWidthTimelineButtonHeader) def htmlOutbox(defaultTimeline: str, @@ -6920,7 +6955,8 @@ def htmlOutbox(defaultTimeline: str, minimal: bool, YTReplacementDomain: str, showPublishedDateOnly: bool, newswire: {}, positiveVoting: bool, - showPublishAsIcon: bool) -> str: + showPublishAsIcon: bool, + fullWidthTimelineButtonHeader: bool) -> str: """Show the Outbox as html """ manuallyApproveFollowers = \ @@ -6933,7 +6969,7 @@ def htmlOutbox(defaultTimeline: str, manuallyApproveFollowers, minimal, YTReplacementDomain, showPublishedDateOnly, newswire, False, False, positiveVoting, - showPublishAsIcon) + showPublishAsIcon, fullWidthTimelineButtonHeader) def htmlIndividualPost(recentPostsCache: {}, maxRecentPosts: int,