forked from indymedia/epicyon
Alter HTML generation; add mulitple/themed CSS
parent
0d36569a27
commit
bd0c75ed7b
|
@ -9,14 +9,17 @@ __status__ = "Production"
|
||||||
import os
|
import os
|
||||||
from utils import getConfigParam
|
from utils import getConfigParam
|
||||||
from utils import getNicknameFromActor
|
from utils import getNicknameFromActor
|
||||||
from utils import isEditor
|
from posts import isEditor
|
||||||
|
from posts import isModerator
|
||||||
from webapp_utils import sharesTimelineJson
|
from webapp_utils import sharesTimelineJson
|
||||||
from webapp_utils import htmlPostSeparator
|
from webapp_utils import htmlPostSeparator
|
||||||
from webapp_utils import getLeftImageFile
|
from webapp_utils import getLeftImageFile
|
||||||
from webapp_utils import headerButtonsFrontScreen
|
from webapp_utils import headerButtonsFrontScreen
|
||||||
from webapp_utils import htmlHeaderWithExternalStyle
|
from webapp_utils import getIconsWebPath
|
||||||
|
from webapp_utils import htmlHeaderWithExternalStyle, htmlHeaderWithExternalStyles
|
||||||
from webapp_utils import htmlFooter
|
from webapp_utils import htmlFooter
|
||||||
from webapp_utils import getBannerFile
|
from webapp_utils import getBannerFile
|
||||||
|
from webapp_headerbuttons import headerNewsTabs
|
||||||
|
|
||||||
|
|
||||||
def _linksExist(baseDir: str) -> bool:
|
def _linksExist(baseDir: str) -> bool:
|
||||||
|
@ -90,15 +93,12 @@ def getLeftColumnContent(baseDir: str, nickname: str, domainFull: str,
|
||||||
'<button class="cancelbtn">' + \
|
'<button class="cancelbtn">' + \
|
||||||
translate['Go Back'] + '</button></a>\n'
|
translate['Go Back'] + '</button></a>\n'
|
||||||
|
|
||||||
if (editor or rssIconAtTop) and not showHeaderImage:
|
if (editor or rssIconAtTop):
|
||||||
htmlStr += '<div class="columnIcons">'
|
htmlStr += '<div class="columnIcons">'
|
||||||
|
|
||||||
if editImageClass == 'leftColEdit':
|
if editImageClass == 'leftColEdit':
|
||||||
htmlStr += '\n <center>\n'
|
htmlStr += '\n <center>\n'
|
||||||
|
|
||||||
if editor or rssIconAtTop:
|
|
||||||
htmlStr += ' <div class="leftColIcons">\n'
|
|
||||||
|
|
||||||
if editor:
|
if editor:
|
||||||
# show the edit icon
|
# show the edit icon
|
||||||
htmlStr += \
|
htmlStr += \
|
||||||
|
@ -131,13 +131,10 @@ def getLeftColumnContent(baseDir: str, nickname: str, domainFull: str,
|
||||||
if rssIconAtTop:
|
if rssIconAtTop:
|
||||||
htmlStr += rssIconStr
|
htmlStr += rssIconStr
|
||||||
|
|
||||||
if editor or rssIconAtTop:
|
|
||||||
htmlStr += ' </div>\n'
|
|
||||||
|
|
||||||
if editImageClass == 'leftColEdit':
|
if editImageClass == 'leftColEdit':
|
||||||
htmlStr += ' </center>\n'
|
htmlStr += ' </center>\n'
|
||||||
|
|
||||||
if (editor or rssIconAtTop) and not showHeaderImage:
|
if (editor or rssIconAtTop):
|
||||||
htmlStr += '</div><br>'
|
htmlStr += '</div><br>'
|
||||||
|
|
||||||
# if showHeaderImage:
|
# if showHeaderImage:
|
||||||
|
@ -249,28 +246,70 @@ def htmlLinksMobile(cssCache: {}, baseDir: str,
|
||||||
"""
|
"""
|
||||||
htmlStr = ''
|
htmlStr = ''
|
||||||
|
|
||||||
|
cssFiles = []
|
||||||
|
|
||||||
# the css filename
|
# the css filename
|
||||||
cssFilename = baseDir + '/epicyon-profile.css'
|
cssFiles.append(baseDir + '/epicyon-profile.css')
|
||||||
if os.path.isfile(baseDir + '/epicyon.css'):
|
if os.path.isfile(baseDir + '/epicyon.css'):
|
||||||
cssFilename = baseDir + '/epicyon.css'
|
cssFiles[0] = baseDir + '/epicyon.css'
|
||||||
|
|
||||||
|
# TODO: Clean up and remove this override
|
||||||
|
cssFiles[0] = 'base.css'
|
||||||
|
|
||||||
|
# Get theme-specific css if exists - must be named '<theme-name>.css'
|
||||||
|
themeName = getConfigParam(baseDir, 'theme')
|
||||||
|
|
||||||
|
themePath = f'{baseDir}/theme/{themeName}.css'
|
||||||
|
if os.path.isfile(themePath):
|
||||||
|
cssFiles.append('theme/' + themeName + '.css')
|
||||||
|
|
||||||
# is the user a site editor?
|
# is the user a site editor?
|
||||||
if nickname == 'news':
|
if nickname == 'news':
|
||||||
editor = False
|
editor = False
|
||||||
|
moderator = False
|
||||||
else:
|
else:
|
||||||
|
# is the user a moderator?
|
||||||
|
moderator = isModerator(baseDir, nickname)
|
||||||
|
|
||||||
|
# is the user a site editor?
|
||||||
editor = isEditor(baseDir, nickname)
|
editor = isEditor(baseDir, nickname)
|
||||||
|
|
||||||
domain = domainFull
|
domain = domainFull
|
||||||
if ':' in domain:
|
if ':' in domain:
|
||||||
domain = domain.split(':')[0]
|
domain = domain.split(':')[0]
|
||||||
|
|
||||||
htmlStr = htmlHeaderWithExternalStyle(cssFilename)
|
htmlStr = htmlHeaderWithExternalStyles(cssFiles)
|
||||||
bannerFile, bannerFilename = \
|
|
||||||
getBannerFile(baseDir, nickname, domain, theme)
|
bannerFile, bannerFilename = getBannerFile(baseDir, nickname, domain)
|
||||||
htmlStr += \
|
usersPath = '/users/' + nickname
|
||||||
'<a href="/users/' + nickname + '/' + defaultTimeline + '">' + \
|
|
||||||
'<img loading="lazy" class="timeline-banner" ' + \
|
htmlStr += '<div class="header">\n'
|
||||||
'src="/users/' + nickname + '/' + bannerFile + '" /></a>\n'
|
|
||||||
|
if not defaultTimeline == 'tlfeatures':
|
||||||
|
htmlStr += (f"\t<a class=\"timeline-banner hidden-text\" href=\"/users/{nickname}/{defaultTimeline}\" "
|
||||||
|
f"style=\"background-image: url('{usersPath}/{bannerFile}');\">"
|
||||||
|
f"{translate['Switch to profile view']}</a>\n")
|
||||||
|
else:
|
||||||
|
# TODO: News instances should ignore personalised banners
|
||||||
|
# Currently uses the 'news' actor banner - as it remains unchanged
|
||||||
|
htmlStr += (f"\t<a class=\"timeline-banner hidden-text\" href=\"/users/{nickname}/tlfeatures\">"
|
||||||
|
f"{translate['Features']}</a>\n"
|
||||||
|
f"\t<div class=\"title\">\n"
|
||||||
|
f"\t\t<span>#IndymediaBack</span>\n"
|
||||||
|
f"\t</div>\n")
|
||||||
|
|
||||||
|
# Certain Epciyon pages should only be accessible via the 'User' page for News instances
|
||||||
|
userPages = ['inbox', 'outbox', 'dm', 'tlreplies', 'tlblogs', 'tlmedia', 'tlshares', \
|
||||||
|
'tlsaves', 'tlevents', 'tlbookmarks', 'moderation', 'search', \
|
||||||
|
'followers', 'newfollowers']
|
||||||
|
|
||||||
|
# Full row "navbar"
|
||||||
|
if defaultTimeline == 'tlfeatures':
|
||||||
|
# Show "tab" links instead of standard "buttons"
|
||||||
|
htmlStr += headerNewsTabs('linksmobile', translate, usersPath, baseDir, userPages)
|
||||||
|
|
||||||
|
# Close banner div
|
||||||
|
htmlStr += '</div>\n'
|
||||||
|
|
||||||
htmlStr += '<div class="col-left-mobile">\n'
|
htmlStr += '<div class="col-left-mobile">\n'
|
||||||
htmlStr += '<center>' + \
|
htmlStr += '<center>' + \
|
||||||
|
|
|
@ -17,11 +17,14 @@ from utils import getNicknameFromActor
|
||||||
from utils import isEditor
|
from utils import isEditor
|
||||||
from posts import isModerator
|
from posts import isModerator
|
||||||
from webapp_utils import getRightImageFile
|
from webapp_utils import getRightImageFile
|
||||||
from webapp_utils import htmlHeaderWithExternalStyle
|
from webapp_utils import getImageFile
|
||||||
|
from webapp_utils import htmlHeaderWithExternalStyle, htmlHeaderWithExternalStyles
|
||||||
from webapp_utils import htmlFooter
|
from webapp_utils import htmlFooter
|
||||||
from webapp_utils import getBannerFile
|
from webapp_utils import getBannerFile
|
||||||
from webapp_utils import htmlPostSeparator
|
from webapp_utils import htmlPostSeparator
|
||||||
from webapp_utils import headerButtonsFrontScreen
|
from webapp_utils import headerButtonsFrontScreen
|
||||||
|
from webapp_utils import getIconsWebPath
|
||||||
|
from webapp_headerbuttons import headerNewsTabs
|
||||||
|
|
||||||
|
|
||||||
def _votesIndicator(totalVotes: int, positiveVoting: bool) -> str:
|
def _votesIndicator(totalVotes: int, positiveVoting: bool) -> str:
|
||||||
|
@ -417,10 +420,22 @@ def htmlNewswireMobile(cssCache: {}, baseDir: str, nickname: str,
|
||||||
"""
|
"""
|
||||||
htmlStr = ''
|
htmlStr = ''
|
||||||
|
|
||||||
|
cssFiles = []
|
||||||
|
|
||||||
# the css filename
|
# the css filename
|
||||||
cssFilename = baseDir + '/epicyon-profile.css'
|
cssFiles.append(baseDir + '/epicyon-profile.css')
|
||||||
if os.path.isfile(baseDir + '/epicyon.css'):
|
if os.path.isfile(baseDir + '/epicyon.css'):
|
||||||
cssFilename = baseDir + '/epicyon.css'
|
cssFiles[0] = baseDir + '/epicyon.css'
|
||||||
|
|
||||||
|
# TODO: Clean up and remove this override
|
||||||
|
cssFiles[0] = 'base.css'
|
||||||
|
|
||||||
|
# Get theme-specific css if exists - must be named '<theme-name>.css'
|
||||||
|
themeName = getConfigParam(baseDir, 'theme')
|
||||||
|
|
||||||
|
themePath = f'{baseDir}/theme/{themeName}.css'
|
||||||
|
if os.path.isfile(themePath):
|
||||||
|
cssFiles.append('theme/' + themeName + '.css')
|
||||||
|
|
||||||
if nickname == 'news':
|
if nickname == 'news':
|
||||||
editor = False
|
editor = False
|
||||||
|
@ -434,14 +449,38 @@ def htmlNewswireMobile(cssCache: {}, baseDir: str, nickname: str,
|
||||||
|
|
||||||
showPublishButton = editor
|
showPublishButton = editor
|
||||||
|
|
||||||
htmlStr = htmlHeaderWithExternalStyle(cssFilename)
|
htmlStr = htmlHeaderWithExternalStyles(cssFiles)
|
||||||
|
|
||||||
bannerFile, bannerFilename = \
|
bannerFile, bannerFilename = getBannerFile(baseDir, nickname, domain)
|
||||||
getBannerFile(baseDir, nickname, domain, theme)
|
usersPath = '/users/' + nickname
|
||||||
htmlStr += \
|
|
||||||
'<a href="/users/' + nickname + '/' + defaultTimeline + '">' + \
|
htmlStr += '<div class="header">\n'
|
||||||
'<img loading="lazy" class="timeline-banner" ' + \
|
|
||||||
'src="/users/' + nickname + '/' + bannerFile + '" /></a>\n'
|
if not defaultTimeline == 'tlfeatures':
|
||||||
|
htmlStr += (f"\t<a class=\"timeline-banner hidden-text\" href=\"/users/{nickname}/{defaultTimeline}\" "
|
||||||
|
f"style=\"background-image: url('{usersPath}/{bannerFile}');\">"
|
||||||
|
f"{translate['Switch to profile view']}</a>\n")
|
||||||
|
else:
|
||||||
|
# TODO: News instances should ignore personalised banners
|
||||||
|
# Currently uses the 'news' actor banner - as it remains unchanged
|
||||||
|
htmlStr += (f"\t<a class=\"timeline-banner hidden-text\" href=\"/users/{nickname}/tlfeatures\">"
|
||||||
|
f"{translate['Features']}</a>\n"
|
||||||
|
f"\t<div class=\"title\">\n"
|
||||||
|
f"\t\t<span>#IndymediaBack</span>\n"
|
||||||
|
f"\t</div>\n")
|
||||||
|
|
||||||
|
# Certain Epciyon pages should only be accessible via the 'User' page for News instances
|
||||||
|
userPages = ['inbox', 'outbox', 'dm', 'tlreplies', 'tlblogs', 'tlmedia', 'tlshares', \
|
||||||
|
'tlsaves', 'tlevents', 'tlbookmarks', 'moderation', 'search', \
|
||||||
|
'followers', 'newfollowers']
|
||||||
|
|
||||||
|
# Full row "navbar"
|
||||||
|
if defaultTimeline == 'tlfeatures':
|
||||||
|
# Show "tab" links instead of standard "buttons"
|
||||||
|
htmlStr += headerNewsTabs('newswiremobile', translate, usersPath, baseDir, userPages)
|
||||||
|
|
||||||
|
# Close banner div
|
||||||
|
htmlStr += '</div>\n'
|
||||||
|
|
||||||
htmlStr += '<div class="col-right-mobile">\n'
|
htmlStr += '<div class="col-right-mobile">\n'
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue