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
|
# TODO: This CSS should be moved out of the code
|
||||||
# Items like this that can be different per user should be kept
|
# 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)
|
# in the user's folder and loaded as final CSS, to allow overwrite(s)
|
||||||
|
tlStr += (f"\t<a class=\"timeline-banner hidden-text\" href=\"/users/{nickname}\" "
|
||||||
tlStr += \
|
f"style=\"background-image: url('{usersPath}/{bannerFile}');\">"
|
||||||
'<a class="timeline-banner hidden-text" href="/users/' + nickname + '" title="' + \
|
f"{translate['Switch to profile view']}</a>\n")
|
||||||
translate['Switch to profile view'] + '" alt="' + \
|
|
||||||
translate['Switch to profile view'] + '" style="' + \
|
|
||||||
'background-image: url(\'' + usersPath + '/' + bannerFile + '\');">' + \
|
|
||||||
translate['Switch to profile view'] + '</a>\n'
|
|
||||||
|
|
||||||
|
|
||||||
# Full Row of Buttons
|
# Full Row of Buttons
|
||||||
|
@ -464,7 +460,6 @@ def headerButtonsTimeline(defaultTimeline: str,
|
||||||
"""Returns the header at the top of the timeline, containing
|
"""Returns the header at the top of the timeline, containing
|
||||||
buttons for inbox, outbox, search, calendar, etc
|
buttons for inbox, outbox, search, calendar, etc
|
||||||
"""
|
"""
|
||||||
# TODO: Create menu buttons via loop(s)
|
|
||||||
|
|
||||||
accountDir = baseDir + '/accounts/' + nickname + '@' + domain
|
accountDir = baseDir + '/accounts/' + nickname + '@' + domain
|
||||||
|
|
||||||
|
@ -516,77 +511,31 @@ def headerButtonsTimeline(defaultTimeline: str,
|
||||||
# start of the button header with inbox, outbox, etc
|
# start of the button header with inbox, outbox, etc
|
||||||
# TODO: [rename] containerHeader -> menu (or similar)
|
# 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
|
# if this is a news instance and we are viewing the news timeline
|
||||||
newsHeader = False
|
newsHeader = False
|
||||||
if defaultTimeline == 'tlnews' and boxName == 'tlnews':
|
if defaultTimeline == 'tlnews' and boxName == 'tlnews':
|
||||||
newsHeader = True
|
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 = \
|
isFeaturesTimeline = \
|
||||||
defaultTimeline == 'tlnews' and boxName == 'tlnews'
|
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
|
# TODO: Easiest solution for News instance tab links
|
||||||
if not iconsAsButtons:
|
# - Simply hide the button row
|
||||||
happeningStr += \
|
# - Draw a separate <div> just for News tabs
|
||||||
'<a href="' + usersPath + '/calendar?year=' + \
|
# if newsHeader:
|
||||||
str(now.year) + '?month=' + str(now.month) + \
|
# tlStr += \
|
||||||
'?day=' + str(now.day) + '">' + \
|
# '<a href="' + usersPath + '/inbox">' + \
|
||||||
'<button class="buttonevent">' + \
|
# '<button class="button">' + \
|
||||||
translate['Happening Today'] + '</button></a>'
|
# '<span>' + translate['User'] + '</span></button></a>'
|
||||||
else:
|
# tlStr += \
|
||||||
happeningStr += \
|
# '<a href="' + usersPath + '/editprofile">' + \
|
||||||
'<a href="' + usersPath + '/calendar?year=' + \
|
# '<button class="buttonDesktop">' + \
|
||||||
str(now.year) + '?month=' + str(now.month) + \
|
# '<span>' + translate['Settings'] + '</span></button></a>'
|
||||||
'?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: Group _all_ items that are hidden in 'minimal' mode ?
|
# 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
|
# All menu items default to text buttons
|
||||||
# Add class "icon-button" to overwrite default behaviour
|
# 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
|
# Menu buttons are split into two sections
|
||||||
# - Navigation buttons : Informational pages, e.g. Inbox
|
# - Navigation buttons : Informational pages, e.g. Inbox
|
||||||
# - Action buttons : More clear action, e.g. Search, Create Post
|
# - 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,
|
# 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:
|
# Each dict has:
|
||||||
# - pageRef : the url snippet
|
# - pageRef : the url snippet
|
||||||
# - translationText : text to be displayed
|
# - translationText : text to be displayed
|
||||||
|
@ -625,7 +577,7 @@ def headerButtonsTimeline(defaultTimeline: str,
|
||||||
# - Outbox
|
# - Outbox
|
||||||
# - DM
|
# - DM
|
||||||
# - Replies
|
# - 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
|
# NOTE: "Action" buttons (icons in default Epicyon) are always visible
|
||||||
|
|
||||||
|
@ -691,8 +643,8 @@ def headerButtonsTimeline(defaultTimeline: str,
|
||||||
break
|
break
|
||||||
|
|
||||||
# Generate HTML list
|
# Generate HTML list
|
||||||
navButtonStr = '<div class="navbuttons">\n'
|
navButtonStr = '\t\t<div class="navbuttons">\n'
|
||||||
navButtonStr += '<ul class="menu">\n'
|
navButtonStr += '\t\t\t<ul class="menu">\n'
|
||||||
for name, config in navButtonList:
|
for name, config in navButtonList:
|
||||||
classStr = 'button-test'
|
classStr = 'button-test'
|
||||||
textStr = ''
|
textStr = ''
|
||||||
|
@ -713,12 +665,11 @@ def headerButtonsTimeline(defaultTimeline: str,
|
||||||
classStr += ' button-test-selected'
|
classStr += ' button-test-selected'
|
||||||
textStr += translate[config['translateText']]
|
textStr += translate[config['translateText']]
|
||||||
|
|
||||||
navButtonStr += '<a class="' + classStr + '"' + \
|
navButtonStr += (f"\t\t\t\t<a class=\"{classStr}\" href=\"{usersPath}{config['pageRef']}\">\n"
|
||||||
'href="' + usersPath + config['pageRef'] + '">\n' + \
|
f'\t\t\t\t\t<li>{textStr}</li>\n'
|
||||||
'<li>' + textStr
|
f'\t\t\t\t</a>\n')
|
||||||
navButtonStr += '</li>\n' + \
|
navButtonStr += '\t\t\t</ul>\n\t\t</div>\n'
|
||||||
'</a>\n'
|
|
||||||
navButtonStr += '</ul>\n</div>\n'
|
|
||||||
|
|
||||||
# start of headericons list
|
# start of headericons list
|
||||||
|
|
||||||
|
@ -735,6 +686,12 @@ def headerButtonsTimeline(defaultTimeline: str,
|
||||||
followApprovals = True
|
followApprovals = True
|
||||||
break
|
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:
|
if followApprovals:
|
||||||
actionButtonList.append(('followers',
|
actionButtonList.append(('followers',
|
||||||
{'pageRef': '/followers',
|
{'pageRef': '/followers',
|
||||||
|
@ -742,6 +699,40 @@ def headerButtonsTimeline(defaultTimeline: str,
|
||||||
'iconClass': 'icon-newfollow'}
|
'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
|
# 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
|
# The following produces one button/icon for "new post" dependent on current viewed page
|
||||||
if boxName == 'dm':
|
if boxName == 'dm':
|
||||||
|
@ -773,18 +764,6 @@ def headerButtonsTimeline(defaultTimeline: str,
|
||||||
# 'icon-<type>' is solely used for the CSS to load appropriate icon
|
# 'icon-<type>' is solely used for the CSS to load appropriate icon
|
||||||
actionButtonList[-1][1]['iconClass'] = 'icon-newpost'
|
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',
|
actionButtonList.append(('calendar',
|
||||||
{'pageRef': calendarPath,
|
{'pageRef': calendarPath,
|
||||||
'translateText': 'Calendar',
|
'translateText': 'Calendar',
|
||||||
|
@ -801,8 +780,8 @@ def headerButtonsTimeline(defaultTimeline: str,
|
||||||
'iconClass': 'icon-showhide'}
|
'iconClass': 'icon-showhide'}
|
||||||
))
|
))
|
||||||
|
|
||||||
actionButtonStr = '<div class="actionbuttons">\n'
|
actionButtonStr = '\t\t<div class="actionbuttons">\n'
|
||||||
actionButtonStr += '<ul class="menu">\n'
|
actionButtonStr += '\t\t\t<ul class="menu">\n'
|
||||||
|
|
||||||
# TODO: [rename] 'timelineicon' should maybe be more generic, e.g 'icon-button'
|
# TODO: [rename] 'timelineicon' should maybe be more generic, e.g 'icon-button'
|
||||||
|
|
||||||
|
@ -821,18 +800,16 @@ def headerButtonsTimeline(defaultTimeline: str,
|
||||||
if 'class' in config:
|
if 'class' in config:
|
||||||
classStr += ' ' + config['class']
|
classStr += ' ' + config['class']
|
||||||
|
|
||||||
actionButtonStr += '<a class="' + classStr + '"' + \
|
|
||||||
'href="' + usersPath + config['pageRef'] + '">\n' + \
|
|
||||||
'<li>'
|
|
||||||
if 'highlightLabel' in config:
|
if 'highlightLabel' in config:
|
||||||
actionButtonStr += htmlHighlightLabel(translate[config['translateText']], \
|
textStr = htmlHighlightLabel(translate[config['translateText']], config['highlightLabel'])
|
||||||
config['highlightLabel'])
|
|
||||||
else:
|
else:
|
||||||
actionButtonStr += translate[config['translateText']]
|
textStr = translate[config['translateText']]
|
||||||
actionButtonStr += '</li>\n' + \
|
|
||||||
'</a>\n'
|
|
||||||
|
|
||||||
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
|
# benchmark 5
|
||||||
|
@ -840,41 +817,13 @@ def headerButtonsTimeline(defaultTimeline: str,
|
||||||
if timeDiff > 100:
|
if timeDiff > 100:
|
||||||
print('TIMELINE TIMING ' + boxName + ' 5 = ' + str(timeDiff))
|
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
|
# Compile HTML parts
|
||||||
tlStr += navButtonStr + actionButtonStr + happeningStr
|
tlStr += navButtonStr + actionButtonStr
|
||||||
|
|
||||||
# TODO: Integrate this logic in new approach - if ultimately necessary
|
# End header button section
|
||||||
# if not newsHeader:
|
tlStr += '\t</div>\n'
|
||||||
# tlStr += followApprovals
|
|
||||||
|
|
||||||
# end of the button header with inbox, outbox, etc
|
|
||||||
tlStr += ' </div>\n'
|
|
||||||
return tlStr
|
return tlStr
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue