forked from indymedia/epicyon
Allow for mutliple css files
parent
f922fc338e
commit
b12cf702aa
|
@ -9058,7 +9058,9 @@ class PubServer(BaseHTTPRequestHandler):
|
|||
"""
|
||||
# get the last part of the path
|
||||
# eg. /my/path/file.css becomes file.css
|
||||
if '/' in path:
|
||||
if 'theme/' in path:
|
||||
path = 'theme/' + path.split('/')[-1]
|
||||
elif '/' in path:
|
||||
path = path.split('/')[-1]
|
||||
if os.path.isfile(path):
|
||||
tries = 0
|
||||
|
|
1
utils.py
1
utils.py
|
@ -1282,6 +1282,7 @@ def getCSS(baseDir: str, cssFilename: str, cssCache: {}) -> str:
|
|||
if cssCache.get(cssFilename):
|
||||
if cssCache[cssFilename][0] == lastModified:
|
||||
# file hasn't changed, so return the version in the cache
|
||||
# TODO: Should this simply return 304 to allow user to use local cache?
|
||||
return cssCache[cssFilename][1]
|
||||
|
||||
with open(cssFilename, 'r') as fpCSS:
|
||||
|
|
|
@ -11,11 +11,12 @@ import time
|
|||
from utils import getFullDomain
|
||||
from utils import isEditor
|
||||
from utils import removeIdEnding
|
||||
from utils import getConfigParam
|
||||
from follow import followerApprovalActive
|
||||
from person import isPersonSnoozed
|
||||
from webapp_utils import htmlPostSeparator
|
||||
from webapp_utils import getBannerFile
|
||||
from webapp_utils import htmlHeaderWithExternalStyle
|
||||
from webapp_utils import htmlHeaderWithExternalStyle, htmlHeaderWithExternalStyles
|
||||
from webapp_utils import htmlFooter
|
||||
from webapp_utils import sharesTimelineJson
|
||||
from webapp_utils import htmlHighlightLabel
|
||||
|
@ -77,10 +78,23 @@ def htmlTimeline(cssCache: {}, defaultTimeline: str,
|
|||
if boxName != 'tlmedia':
|
||||
separatorStr = htmlPostSeparator(baseDir, None)
|
||||
|
||||
# the css filename
|
||||
cssFilename = baseDir + '/epicyon-profile.css'
|
||||
cssFiles = []
|
||||
|
||||
# TODO: Clean up - default load only one base css file
|
||||
# default css
|
||||
cssFiles.append(baseDir + '/epicyon-profile.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')
|
||||
|
||||
# filename of the banner shown at the top
|
||||
bannerFile, bannerFilename = \
|
||||
|
@ -111,7 +125,12 @@ def htmlTimeline(cssCache: {}, defaultTimeline: str,
|
|||
if timeDiff > 100:
|
||||
print('TIMELINE TIMING ' + boxName + ' 3 = ' + str(timeDiff))
|
||||
|
||||
tlStr = htmlHeaderWithExternalStyle(cssFilename, profileStyle)
|
||||
tlStr = htmlHeaderWithExternalStyles(cssFiles)
|
||||
|
||||
# benchmark 4
|
||||
timeDiff = int((time.time() - timelineStartTime) * 1000)
|
||||
if timeDiff > 100:
|
||||
print('TIMELINE TIMING ' + boxName + ' 4 = ' + str(timeDiff))
|
||||
|
||||
_logTimelineTiming(enableTimingLog, timelineStartTime, boxName, '4')
|
||||
|
||||
|
@ -134,32 +153,33 @@ def htmlTimeline(cssCache: {}, defaultTimeline: str,
|
|||
else:
|
||||
# TODO: News instances should ignore personalised banners
|
||||
# Currently uses the 'news' actor banner - as it remains unchanged
|
||||
tlStr += (f"\t<a class=\"timeline-banner hidden-text\" href=\"/tlnews\" "
|
||||
f"style=\"background-image: url('/users/news/{bannerFile}');\">"
|
||||
f"{translate['News']}</a>\n")
|
||||
|
||||
tlStr += '</div>\n'
|
||||
tlStr += (f"\t<a class=\"timeline-banner hidden-text\" href=\"/tlnews\">"
|
||||
f"{translate['News']}</a>\n"
|
||||
f"\t<div class=\"title\">\n"
|
||||
f"\t\t<span>#IndymediaBack</span>\n"
|
||||
f"\t</div>\n")
|
||||
|
||||
|
||||
# TODO: Include '/editprofile' link on 'User' page for 'News' instances
|
||||
|
||||
|
||||
# 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 == 'tlnews':
|
||||
# Show "tab" links instead of standard "buttons"
|
||||
tlStr += headerNewsTabs(boxName, translate, usersPath, moderator, baseDir)
|
||||
tlStr += headerNewsTabs(boxName, translate, usersPath, moderator, baseDir, userPages)
|
||||
|
||||
# Close banner div
|
||||
tlStr += '</div>\n'
|
||||
|
||||
# Only show standard "buttons" on 'inbox' page
|
||||
if boxName == 'inbox':
|
||||
tlStr += \
|
||||
headerButtonsTimeline(defaultTimeline, boxName, pageNumber,
|
||||
translate, usersPath,
|
||||
minimal, moderator,
|
||||
manuallyApproveFollowers,
|
||||
baseDir, nickname,
|
||||
domain, timelineStartTime,
|
||||
iconsAsButtons)
|
||||
elif fullWidthTimelineButtonHeader:
|
||||
# Close banner div
|
||||
tlStr += '</div>\n'
|
||||
|
||||
tlStr += \
|
||||
headerButtonsTimeline(defaultTimeline, boxName, pageNumber,
|
||||
translate, usersPath,
|
||||
|
@ -174,14 +194,27 @@ def htmlTimeline(cssCache: {}, defaultTimeline: str,
|
|||
|
||||
domainFull = getFullDomain(domain, port)
|
||||
|
||||
# left column
|
||||
leftColumnStr = \
|
||||
getLeftColumnContent(baseDir, nickname, domainFull,
|
||||
httpPrefix, translate,
|
||||
editor, False, None, rssIconAtTop,
|
||||
True, False)
|
||||
tlStr += ' <div class="section links">\n' + \
|
||||
leftColumnStr + ' </div>\n'
|
||||
# Only show standard "buttons" on 'inbox' page
|
||||
if defaultTimeline == 'tlnews' and boxName in userPages:
|
||||
tlStr += \
|
||||
headerButtonsTimeline(defaultTimeline, boxName, pageNumber,
|
||||
translate, usersPath,
|
||||
minimal, moderator,
|
||||
manuallyApproveFollowers,
|
||||
baseDir, nickname,
|
||||
domain, timelineStartTime,
|
||||
iconsAsButtons, userPages)
|
||||
|
||||
else:
|
||||
# left column
|
||||
leftColumnStr = \
|
||||
getLeftColumnContent(baseDir, nickname, domainFull,
|
||||
httpPrefix, translate, iconsPath,
|
||||
editor, False, None, rssIconAtTop,
|
||||
True, False)
|
||||
tlStr += ' <div class="section links">\n' + \
|
||||
leftColumnStr + ' </div>\n'
|
||||
|
||||
# center column containing posts
|
||||
tlStr += ' <div class="section main">\n'
|
||||
|
||||
|
@ -366,17 +399,18 @@ def htmlTimeline(cssCache: {}, defaultTimeline: str,
|
|||
# end of column-center
|
||||
tlStr += ' </div>\n'
|
||||
|
||||
# right column
|
||||
rightColumnStr = getRightColumnContent(baseDir, nickname, domainFull,
|
||||
httpPrefix, translate,
|
||||
moderator, editor,
|
||||
newswire, positiveVoting,
|
||||
False, None, True,
|
||||
showPublishAsIcon,
|
||||
rssIconAtTop, publishButtonAtTop,
|
||||
authorized, True)
|
||||
tlStr += ' <div class="section newswire">' + \
|
||||
rightColumnStr + ' </div>\n'
|
||||
if defaultTimeline == 'tlnews' and boxName not in userPages:
|
||||
# right column
|
||||
rightColumnStr = getRightColumnContent(baseDir, nickname, domainFull,
|
||||
httpPrefix, translate, iconsPath,
|
||||
moderator, editor,
|
||||
newswire, positiveVoting,
|
||||
False, None, True,
|
||||
showPublishAsIcon,
|
||||
rssIconAtTop, publishButtonAtTop,
|
||||
authorized, True)
|
||||
tlStr += ' <div class="section newswire">' + \
|
||||
rightColumnStr + ' </div>\n'
|
||||
|
||||
_logTimelineTiming(enableTimingLog, timelineStartTime, boxName, '9')
|
||||
|
||||
|
|
|
@ -528,9 +528,22 @@ def htmlHeaderWithExternalStyle(cssFilename: str, lang='en') -> str:
|
|||
htmlStr += ' <meta charset="utf-8">\n'
|
||||
htmlStr += ' <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0">\n'
|
||||
cssFile = '/' + cssFilename.split('/')[-1]
|
||||
# TODO: Clean up - default load only one base css file
|
||||
htmlStr += ' <link rel="stylesheet" href="base.css">\n'
|
||||
#htmlStr += ' <link rel="stylesheet" href="' + cssFile + '">\n'
|
||||
htmlStr += ' <link rel="stylesheet" href="' + cssFile + '">\n'
|
||||
htmlStr += ' <link rel="manifest" href="/manifest.json">\n'
|
||||
htmlStr += ' <meta name="theme-color" content="grey">\n'
|
||||
htmlStr += ' <title>Epicyon</title>\n'
|
||||
htmlStr += ' </head>\n'
|
||||
htmlStr += ' <body>\n'
|
||||
return htmlStr
|
||||
|
||||
def htmlHeaderWithExternalStyles(cssFiles: [], lang='en') -> str:
|
||||
htmlStr = '<!DOCTYPE html>\n'
|
||||
htmlStr += '<html lang="' + lang + '">\n'
|
||||
htmlStr += ' <head>\n'
|
||||
htmlStr += ' <meta charset="utf-8">\n'
|
||||
htmlStr += ' <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0">\n'
|
||||
for path in cssFiles:
|
||||
htmlStr += ' <link rel="stylesheet" href="' + path + '">\n'
|
||||
htmlStr += ' <link rel="manifest" href="/manifest.json">\n'
|
||||
htmlStr += ' <meta name="theme-color" content="grey">\n'
|
||||
htmlStr += ' <title>Epicyon</title>\n'
|
||||
|
|
Loading…
Reference in New Issue