diff --git a/webapp_timeline.py b/webapp_timeline.py index e8e48e05..4a0fe141 100644 --- a/webapp_timeline.py +++ b/webapp_timeline.py @@ -125,13 +125,9 @@ def htmlTimeline(cssCache: {}, defaultTimeline: str, # TODO: This CSS should be moved out of the code # Items like this that can be different per user should be kept # in the user's folder and loaded as final CSS, to allow overwrite(s) - - tlStr += \ - '' + \ - translate['Switch to profile view'] + '\n' + tlStr += (f"\t" + f"{translate['Switch to profile view']}\n") # Full Row of Buttons @@ -464,7 +460,6 @@ def headerButtonsTimeline(defaultTimeline: str, """Returns the header at the top of the timeline, containing buttons for inbox, outbox, search, calendar, etc """ - # TODO: Create menu buttons via loop(s) accountDir = baseDir + '/accounts/' + nickname + '@' + domain @@ -516,77 +511,31 @@ def headerButtonsTimeline(defaultTimeline: str, # start of the button header with inbox, outbox, etc # TODO: [rename] containerHeader -> menu (or similar) - tlStr = '
\n' + tlStr = '\t
\n' + + # TODO: Fix that the following two bools are equivalent + # - Pick one and move on # if this is a news instance and we are viewing the news timeline newsHeader = False if defaultTimeline == 'tlnews' and boxName == 'tlnews': newsHeader = True - -# if not newsHeader: -# tlStr += \ -# '' -# -# tlStr += \ -# '' - isFeaturesTimeline = \ defaultTimeline == 'tlnews' and boxName == 'tlnews' - # TODO: Convert to new approach - append to 'actionButtonList' - # show todays events buttons on the first inbox page - happeningStr = '' - if boxName == 'inbox' and pageNumber == 1: - if todaysEventsCheck(baseDir, nickname, domain): - now = datetime.now() - # happening today button - if not iconsAsButtons: - happeningStr += \ - '' + \ - '' - else: - happeningStr += \ - '' + \ - '' - - # happening this week button - if thisWeeksEventsCheck(baseDir, nickname, domain): - if not iconsAsButtons: - happeningStr += \ - '' - else: - happeningStr += \ - '' - else: - # happening this week button - if thisWeeksEventsCheck(baseDir, nickname, domain): - if not iconsAsButtons: - happeningStr += \ - '' - else: - happeningStr += \ - '' +# TODO: Easiest solution for News instance tab links +# - Simply hide the button row +# - Draw a separate
just for News tabs +# if newsHeader: +# tlStr += \ +# '' + \ +# '' +# tlStr += \ +# '' + \ +# '' # TODO: Group _all_ items that are hidden in 'minimal' mode ? @@ -594,14 +543,17 @@ def headerButtonsTimeline(defaultTimeline: str, # All menu items default to text buttons # Add class "icon-button" to overwrite default behaviour + # NOTE: Currently handled further down in loops over navButtonList and actionButtonList # Menu buttons are split into two sections # - Navigation buttons : Informational pages, e.g. Inbox # - Action buttons : More clear action, e.g. Search, Create Post - # default appearance text; use CSS class(es) to re-styled + # default appearance text; use CSS class(es) to re-style # A list of buttons to be rendered as html, - # each item being a dictionary containing its unique info. + # each item being a tuple containing + # - ref name + # - dictionary of unique config # Each dict has: # - pageRef : the url snippet # - translationText : text to be displayed @@ -625,7 +577,7 @@ def headerButtonsTimeline(defaultTimeline: str, # - Outbox # - DM # - Replies - # - News # TODO: Should this really be even for non-news instances ? + # - News # TODO: Should this be in minimal view? 'Media' and 'Blogs' are not ... # NOTE: "Action" buttons (icons in default Epicyon) are always visible @@ -691,8 +643,8 @@ def headerButtonsTimeline(defaultTimeline: str, break # Generate HTML list - navButtonStr = '\n' + # start of headericons list @@ -735,6 +686,12 @@ def headerButtonsTimeline(defaultTimeline: str, followApprovals = True break + # NOTE: Certain buttons only appear when relevant + + # TODO: Determine if approvals (currently appended at end of actionButtonList) + # and events should be in a separate list; + # e.g. notificationButtonList + # Having its' own
for instance would allow more versatile styling if followApprovals: actionButtonList.append(('followers', {'pageRef': '/followers', @@ -742,6 +699,40 @@ def headerButtonsTimeline(defaultTimeline: str, 'iconClass': 'icon-newfollow'} )) + # Only show todays events buttons on the first inbox page + if boxName == 'inbox' and pageNumber == 1: + if todaysEventsCheck(baseDir, nickname, domain): + now = datetime.now() + todayRef = '/calendar?year=' + str(now.year) + \ + '?month=' + str(now.month) + \ + '?day=' + str(now.day) + actionButtonList.append(('today-event', + {'pageRef': todayRef, + 'translateText': 'Happening Today', + 'class': 'button-event'} + )) + if thisWeeksEventsCheck(baseDir, nickname, domain): + actionButtonList.append(('week-event', + {'pageRef': '/calendar', + 'translateText': 'Happening Today', + 'class': 'button-event'} + )) + + + # NOTE: CSS used to show or hide these based on screen size + actionButtonList.append(('newswire', + {'pageRef': '/newswiremobile', + 'translateText': 'Newswire', + 'class': 'mobile-only', + 'iconClass': 'icon-newswire'} + )) + actionButtonList.append(('links', + {'pageRef': '/linksmobile', + 'translateText': 'Edit Links', + 'class': 'mobile-only', + 'iconClass': 'icon-links'} + )) + # what screen to go to when a new post is created # The following produces one button/icon for "new post" dependent on current viewed page if boxName == 'dm': @@ -773,18 +764,6 @@ def headerButtonsTimeline(defaultTimeline: str, # 'icon-' is solely used for the CSS to load appropriate icon actionButtonList[-1][1]['iconClass'] = 'icon-newpost' - actionButtonList.append(('newswire', - {'pageRef': '/newswiremobile', - 'translateText': 'Newswire', - 'class': 'mobile-only', - 'iconClass': 'icon-newswire'} - )) - actionButtonList.append(('links', - {'pageRef': '/linksmobile', - 'translateText': 'Edit Links', - 'class': 'mobile-only', - 'iconClass': 'icon-links'} - )) actionButtonList.append(('calendar', {'pageRef': calendarPath, 'translateText': 'Calendar', @@ -801,8 +780,8 @@ def headerButtonsTimeline(defaultTimeline: str, 'iconClass': 'icon-showhide'} )) - actionButtonStr = '
\n' - actionButtonStr += '\n\t\t
\n' # benchmark 5 @@ -840,41 +817,13 @@ def headerButtonsTimeline(defaultTimeline: str, if timeDiff > 100: print('TIMELINE TIMING ' + boxName + ' 5 = ' + str(timeDiff)) -# if not newsHeader: -# # the show/hide button, for a simpler header appearance -# if not iconsAsButtons: -# tlStr += \ -# ' | ' + translate['Show/Hide Buttons'] + \
-#                '\n' -# else: -# tlStr += \ -# '' -# else: -# tlStr += \ -# '' + \ -# '' -# tlStr += \ -# '' + \ -# '' # Compile HTML parts - tlStr += navButtonStr + actionButtonStr + happeningStr + tlStr += navButtonStr + actionButtonStr -# TODO: Integrate this logic in new approach - if ultimately necessary -# if not newsHeader: -# tlStr += followApprovals + # End header button section + tlStr += '\t
\n' - # end of the button header with inbox, outbox, etc - tlStr += '
\n' return tlStr