__filename__ = "webapp_headerbuttons.py" __author__ = "Bob Mottram" __license__ = "AGPL3+" __version__ = "1.1.0" __maintainer__ = "Bob Mottram" __email__ = "bob@freedombone.net" __status__ = "Production" import time from datetime import datetime from happening import todaysEventsCheck from happening import thisWeeksEventsCheck from webapp_utils import htmlHighlightLabel def headerButtonsTimeline(defaultTimeline: str, boxName: str, pageNumber: int, translate: {}, usersPath: str, mediaButton: str, blogsButton: str, newsButton: str, inboxButton: str, dmButton: str, newDM: str, repliesButton: str, newReply: str, minimal: bool, sentButton: str, sharesButtonStr: str, bookmarksButtonStr: str, eventsButtonStr: str, moderationButtonStr: str, newPostButtonStr: str, baseDir: str, nickname: str, domain: str, iconsPath: str, timelineStartTime, newCalendarEvent: bool, calendarPath: str, calendarImage: str, followApprovals: str, iconsAsButtons: bool) -> str: """Returns the header at the top of the timeline, containing buttons for inbox, outbox, search, calendar, etc """ # start of the button header with inbox, outbox, etc tlStr = '
\n' # first button if defaultTimeline == 'tlmedia': tlStr += \ '' elif defaultTimeline == 'tlblogs': tlStr += \ '' elif defaultTimeline == 'tlnews': tlStr += \ '' else: tlStr += \ '' # 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 += \ '' # typically the media button if defaultTimeline != 'tlmedia': if not minimal and not newsHeader: tlStr += \ '' else: if not minimal: tlStr += \ '' isFeaturesTimeline = \ defaultTimeline == 'tlnews' and boxName == 'tlnews' if not isFeaturesTimeline: # typically the blogs button # but may change if this is a blogging oriented instance if defaultTimeline != 'tlblogs': if not minimal and not isFeaturesTimeline: titleStr = translate['Blogs'] if defaultTimeline == 'tlnews': titleStr = translate['Article'] tlStr += \ '' else: if not minimal: tlStr += \ '' # typically the news button # but may change if this is a news oriented instance if defaultTimeline != 'tlnews': tlStr += \ '' else: if not newsHeader: tlStr += \ '' # 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 += \ '' if not newsHeader: # button for the outbox tlStr += \ '' # add other buttons tlStr += \ sharesButtonStr + bookmarksButtonStr + eventsButtonStr + \ moderationButtonStr + happeningStr + newPostButtonStr if not newsHeader: if not iconsAsButtons: # the search icon tlStr += \ '| ' + \
                translate['Search and follow'] + \
                '' else: # the search button tlStr += \ '' # benchmark 5 timeDiff = int((time.time() - timelineStartTime) * 1000) if timeDiff > 100: print('TIMELINE TIMING ' + boxName + ' 5 = ' + str(timeDiff)) # the calendar button if not isFeaturesTimeline: calendarAltText = translate['Calendar'] if newCalendarEvent: # indicate that the calendar icon is highlighted calendarAltText = '*' + calendarAltText + '*' if not iconsAsButtons: tlStr += \ ' | ' + calendarAltText + \
                '\n' else: tlStr += \ '' if not newsHeader: # the show/hide button, for a simpler header appearance if not iconsAsButtons: tlStr += \ ' | ' + translate['Show/Hide Buttons'] + \
                '\n' else: tlStr += \ '' if newsHeader: tlStr += \ '' + \ '' # the newswire button to show right column links if not iconsAsButtons: tlStr += \ '' + \ '| ' + translate['News'] + \
            '' else: # NOTE: deliberately no \n at end of line tlStr += \ '' # the links button to show left column links if not iconsAsButtons: tlStr += \ '' + \ '| ' + translate['Edit Links'] + \
            '' else: # NOTE: deliberately no \n at end of line tlStr += \ '' if newsHeader: tlStr += \ '' + \ '' if not newsHeader: tlStr += followApprovals if not iconsAsButtons: # end of headericons div tlStr += '
' # end of the button header with inbox, outbox, etc tlStr += ' \n' return tlStr