diff --git a/daemon.py b/daemon.py index ca8ed0b1..a5f5beb0 100644 --- a/daemon.py +++ b/daemon.py @@ -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 diff --git a/utils.py b/utils.py index 0187f86e..48dbb576 100644 --- a/utils.py +++ b/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: diff --git a/webapp_timeline.py b/webapp_timeline.py index 6f0bfbb1..2536d263 100644 --- a/webapp_timeline.py +++ b/webapp_timeline.py @@ -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 '.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" - f"{translate['News']}\n") - - tlStr += '\n' + tlStr += (f"\t" + f"{translate['News']}\n" + f"\t
\n" + f"\t\t#IndymediaBack\n" + f"\t
\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 += '\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 += '\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 += ' \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 += ' \n' + # center column containing posts tlStr += '
\n' @@ -366,17 +399,18 @@ def htmlTimeline(cssCache: {}, defaultTimeline: str, # end of column-center tlStr += '
\n' - # right column - rightColumnStr = getRightColumnContent(baseDir, nickname, domainFull, - httpPrefix, translate, - moderator, editor, - newswire, positiveVoting, - False, None, True, - showPublishAsIcon, - rssIconAtTop, publishButtonAtTop, - authorized, True) - tlStr += '
' + \ - rightColumnStr + '
\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 += '
' + \ + rightColumnStr + '
\n' _logTimelineTiming(enableTimingLog, timelineStartTime, boxName, '9') diff --git a/webapp_utils.py b/webapp_utils.py index 9daee68e..7be11096 100644 --- a/webapp_utils.py +++ b/webapp_utils.py @@ -528,9 +528,22 @@ def htmlHeaderWithExternalStyle(cssFilename: str, lang='en') -> str: htmlStr += ' \n' htmlStr += ' \n' cssFile = '/' + cssFilename.split('/')[-1] - # TODO: Clean up - default load only one base css file - htmlStr += ' \n' - #htmlStr += ' \n' + htmlStr += ' \n' + htmlStr += ' \n' + htmlStr += ' \n' + htmlStr += ' Epicyon\n' + htmlStr += ' \n' + htmlStr += ' \n' + return htmlStr + +def htmlHeaderWithExternalStyles(cssFiles: [], lang='en') -> str: + htmlStr = '\n' + htmlStr += '\n' + htmlStr += ' \n' + htmlStr += ' \n' + htmlStr += ' \n' + for path in cssFiles: + htmlStr += ' \n' htmlStr += ' \n' htmlStr += ' \n' htmlStr += ' Epicyon\n'