__filename__ = "webapp_headerbuttons.py" __author__ = "Bob Mottram" __license__ = "AGPL3+" __version__ = "1.1.0" __maintainer__ = "Bob Mottram" __email__ = "bob@freedombone.net" __status__ = "Production" import os 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, featuresButton: 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 == 'tlfeatures': tlStr += \ '' else: tlStr += \ '' # if this is a news instance and we are viewing the news timeline featuresHeader = False if defaultTimeline == 'tlfeatures' and boxName == 'tlfeatures': featuresHeader = True if not featuresHeader: tlStr += \ '' repliesIndexFilename = \ baseDir + '/accounts/' + \ nickname + '@' + domain + '/tlreplies.index' if os.path.isfile(repliesIndexFilename): tlStr += \ '' # typically the media button if defaultTimeline != 'tlmedia': if not minimal and not featuresHeader: tlStr += \ '' else: if not minimal: tlStr += \ '' isFeaturesTimeline = \ defaultTimeline == 'tlfeatures' and boxName == 'tlfeatures' 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 == 'tlfeatures': 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 == 'tlfeatures': if not featuresHeader: 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 featuresHeader: # button for the outbox tlStr += \ '' # add other buttons tlStr += \ sharesButtonStr + bookmarksButtonStr + eventsButtonStr + \ moderationButtonStr + happeningStr + newPostButtonStr if not featuresHeader: 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 featuresHeader: # the show/hide button, for a simpler header appearance if not iconsAsButtons: tlStr += \ ' | ' + translate['Show/Hide Buttons'] + \
                '\n' else: tlStr += \ '' if featuresHeader: 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 featuresHeader: tlStr += \ '' + \ '' if not featuresHeader: tlStr += followApprovals if not iconsAsButtons: # end of headericons div tlStr += '
' # end of the button header with inbox, outbox, etc tlStr += ' \n' return tlStr