epicyon/webapp_headernewstabs.py

71 lines
1.9 KiB
Python

__filename__ = "webapp_headernewstabs.py"
__author__ = "Bob Mottram"
__license__ = "AGPL3+"
__version__ = "1.1.0"
__maintainer__ = "Bob Mottram"
__email__ = "bob@freedombone.net"
__status__ = "Production"
def headerNewsTabs(boxName: str,
translate: {},
usersPath: str,
baseDir: str,
authorized: bool,
userPages: []) -> str:
navTabList = []
navTabList.append(('home',
{'pageRef': '/',
'translateText': 'Home'}
))
navTabList.append(('tlfeatures',
{'pageRef': '/tlfeatures',
'translateText': 'Features'}
))
navTabList.append(('newswiremobile',
{'pageRef': '/newswiremobile',
'translateText': 'Newswire',
'class': 'tab-news'}
))
# navTabList.append(('calendar',
# {'pageRef': '/calendar',
# 'translateText': 'Calendar'}
# ))
navTabList.append(('linksmobile',
{'pageRef': '/linksmobile',
'translateText': 'Links',
'class': 'tab-links'}
))
if authorized:
navTabList.append(('inbox',
{'pageRef': '/inbox',
'translateText': 'User'}
))
navStr = '\t\t<div class="section navtabs">\n'
navStr += '\t\t\t<ul>\n'
for name, config in navTabList:
classStr = ''
if name == boxName:
classStr = 'tab-highlight'
elif name == 'inbox' and userPages and boxName in userPages:
classStr = 'tab-highlight'
if 'class' in config:
classStr += ' ' + config['class']
textStr = translate[config['translateText']]
navStr += (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')
navStr += '\t\t\t</ul>\n\t\t</div>\n'
return navStr