forked from indymedia/epicyon
Alter creation of main buttons
- Simplify html generation - Replace use of <button> with <ul>alt-html-css
parent
45c5ff0924
commit
e004327824
|
@ -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 += \
|
||||
'<a class="timeline-banner hidden-text" href="/users/' + nickname + '" title="' + \
|
||||
translate['Switch to profile view'] + '" alt="' + \
|
||||
translate['Switch to profile view'] + '" style="' + \
|
||||
'background-image: url(\'' + usersPath + '/' + bannerFile + '\');">' + \
|
||||
translate['Switch to profile view'] + '</a>\n'
|
||||
tlStr += (f"\t<a class=\"timeline-banner hidden-text\" href=\"/users/{nickname}\" "
|
||||
f"style=\"background-image: url('{usersPath}/{bannerFile}');\">"
|
||||
f"{translate['Switch to profile view']}</a>\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 = '<div class="containerHeader">\n'
|
||||
tlStr = '\t<div class="containerHeader">\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 += \
|
||||
# '<a href="' + usersPath + \
|
||||
# '/dm"><button class="' + dmButton + \
|
||||
# '"><span>' + htmlHighlightLabel(translate['DM'], newDM) + \
|
||||
# '</span></button></a>'
|
||||
#
|
||||
# tlStr += \
|
||||
# '<a href="' + usersPath + '/tlreplies"><button class="' + \
|
||||
# repliesButton + '"><span>' + \
|
||||
# htmlHighlightLabel(translate['Replies'], newReply) + \
|
||||
# '</span></button></a>'
|
||||
|
||||
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 += \
|
||||
'<a href="' + usersPath + '/calendar?year=' + \
|
||||
str(now.year) + '?month=' + str(now.month) + \
|
||||
'?day=' + str(now.day) + '">' + \
|
||||
'<button class="buttonevent">' + \
|
||||
translate['Happening Today'] + '</button></a>'
|
||||
else:
|
||||
happeningStr += \
|
||||
'<a href="' + usersPath + '/calendar?year=' + \
|
||||
str(now.year) + '?month=' + str(now.month) + \
|
||||
'?day=' + str(now.day) + '">' + \
|
||||
'<button class="button">' + \
|
||||
translate['Happening Today'] + '</button></a>'
|
||||
|
||||
# happening this week button
|
||||
if thisWeeksEventsCheck(baseDir, nickname, domain):
|
||||
if not iconsAsButtons:
|
||||
happeningStr += \
|
||||
'<a href="' + usersPath + \
|
||||
'/calendar"><button class="buttonevent">' + \
|
||||
translate['Happening This Week'] + '</button></a>'
|
||||
else:
|
||||
happeningStr += \
|
||||
'<a href="' + usersPath + \
|
||||
'/calendar"><button class="button">' + \
|
||||
translate['Happening This Week'] + '</button></a>'
|
||||
else:
|
||||
# happening this week button
|
||||
if thisWeeksEventsCheck(baseDir, nickname, domain):
|
||||
if not iconsAsButtons:
|
||||
happeningStr += \
|
||||
'<a href="' + usersPath + \
|
||||
'/calendar"><button class="buttonevent">' + \
|
||||
translate['Happening This Week'] + '</button></a>'
|
||||
else:
|
||||
happeningStr += \
|
||||
'<a href="' + usersPath + \
|
||||
'/calendar"><button class="button">' + \
|
||||
translate['Happening This Week'] + '</button></a>'
|
||||
# TODO: Easiest solution for News instance tab links
|
||||
# - Simply hide the button row
|
||||
# - Draw a separate <div> just for News tabs
|
||||
# if newsHeader:
|
||||
# tlStr += \
|
||||
# '<a href="' + usersPath + '/inbox">' + \
|
||||
# '<button class="button">' + \
|
||||
# '<span>' + translate['User'] + '</span></button></a>'
|
||||
# tlStr += \
|
||||
# '<a href="' + usersPath + '/editprofile">' + \
|
||||
# '<button class="buttonDesktop">' + \
|
||||
# '<span>' + translate['Settings'] + '</span></button></a>'
|
||||
|
||||
|
||||
# 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 = '<div class="navbuttons">\n'
|
||||
navButtonStr += '<ul class="menu">\n'
|
||||
navButtonStr = '\t\t<div class="navbuttons">\n'
|
||||
navButtonStr += '\t\t\t<ul class="menu">\n'
|
||||
for name, config in navButtonList:
|
||||
classStr = 'button-test'
|
||||
textStr = ''
|
||||
|
@ -713,12 +665,11 @@ def headerButtonsTimeline(defaultTimeline: str,
|
|||
classStr += ' button-test-selected'
|
||||
textStr += translate[config['translateText']]
|
||||
|
||||
navButtonStr += '<a class="' + classStr + '"' + \
|
||||
'href="' + usersPath + config['pageRef'] + '">\n' + \
|
||||
'<li>' + textStr
|
||||
navButtonStr += '</li>\n' + \
|
||||
'</a>\n'
|
||||
navButtonStr += '</ul>\n</div>\n'
|
||||
navButtonStr += (f"\t\t\t\t<a class=\"{classStr}\" href=\"{usersPath}{config['pageRef']}\">\n"
|
||||
f'\t\t\t\t\t<li>{textStr}</li>\n'
|
||||
f'\t\t\t\t</a>\n')
|
||||
navButtonStr += '\t\t\t</ul>\n\t\t</div>\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 <div> 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-<type>' 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 = '<div class="actionbuttons">\n'
|
||||
actionButtonStr += '<ul class="menu">\n'
|
||||
actionButtonStr = '\t\t<div class="actionbuttons">\n'
|
||||
actionButtonStr += '\t\t\t<ul class="menu">\n'
|
||||
|
||||
# TODO: [rename] 'timelineicon' should maybe be more generic, e.g 'icon-button'
|
||||
|
||||
|
@ -821,18 +800,16 @@ def headerButtonsTimeline(defaultTimeline: str,
|
|||
if 'class' in config:
|
||||
classStr += ' ' + config['class']
|
||||
|
||||
actionButtonStr += '<a class="' + classStr + '"' + \
|
||||
'href="' + usersPath + config['pageRef'] + '">\n' + \
|
||||
'<li>'
|
||||
if 'highlightLabel' in config:
|
||||
actionButtonStr += htmlHighlightLabel(translate[config['translateText']], \
|
||||
config['highlightLabel'])
|
||||
textStr = htmlHighlightLabel(translate[config['translateText']], config['highlightLabel'])
|
||||
else:
|
||||
actionButtonStr += translate[config['translateText']]
|
||||
actionButtonStr += '</li>\n' + \
|
||||
'</a>\n'
|
||||
textStr = translate[config['translateText']]
|
||||
|
||||
actionButtonStr += '</ul>\n</div>\n'
|
||||
actionButtonStr += (f"\t\t\t\t<a class=\"{classStr}\" href=\"{usersPath}{config['pageRef']}\">\n"
|
||||
f'\t\t\t\t\t<li>{textStr}</li>\n'
|
||||
f'\t\t\t\t</a>\n')
|
||||
|
||||
actionButtonStr += '\t\t\t</ul>\n\t\t</div>\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 += \
|
||||
# ' <a class="imageAnchor" href="' + \
|
||||
# usersPath + '/minimal' + \
|
||||
# '"><img loading="lazy" src="/' + iconsDir + \
|
||||
# '/showhide.png" title="' + translate['Show/Hide Buttons'] + \
|
||||
# '" alt="| ' + translate['Show/Hide Buttons'] + \
|
||||
# '" class="timelineicon"/></a>\n'
|
||||
# else:
|
||||
# tlStr += \
|
||||
# '<a href="' + usersPath + '/minimal' + \
|
||||
# '"><button class="button">' + \
|
||||
# '<span>' + translate['Expand'] + \
|
||||
# '</span></button></a>'
|
||||
# else:
|
||||
# tlStr += \
|
||||
# '<a href="' + usersPath + '/inbox">' + \
|
||||
# '<button class="button">' + \
|
||||
# '<span>' + translate['User'] + '</span></button></a>'
|
||||
# tlStr += \
|
||||
# '<a href="' + usersPath + '/editprofile">' + \
|
||||
# '<button class="buttonDesktop">' + \
|
||||
# '<span>' + translate['Settings'] + '</span></button></a>'
|
||||
|
||||
# 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</div>\n'
|
||||
|
||||
# end of the button header with inbox, outbox, etc
|
||||
tlStr += ' </div>\n'
|
||||
return tlStr
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue