diff --git a/webapp_create_post.py b/webapp_create_post.py index d1614081..da0be76a 100644 --- a/webapp_create_post.py +++ b/webapp_create_post.py @@ -8,13 +8,16 @@ __status__ = "Production" import os from utils import isPublicPostFromUrl +from utils import getConfigParam from utils import getNicknameFromActor from utils import getDomainFromActor from utils import getImageFormats from utils import getMediaFormats from webapp_utils import getBannerFile -from webapp_utils import htmlHeaderWithExternalStyle +from webapp_utils import htmlHeaderWithExternalStyles from webapp_utils import htmlFooter +from webapp_headerbuttons import headerButtonsTimeline, headerNewsTabs +from posts import isModerator def _htmlFollowingDataList(baseDir: str, nickname: str, @@ -250,9 +253,21 @@ def htmlNewPost(cssCache: {}, mediaInstance: bool, translate: {}, newPostText = \ '

' + file.read() + '

\n' - cssFilename = baseDir + '/epicyon-profile.css' + cssFiles = [] + + 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') if '?' in path: path = path.split('?')[0] @@ -555,16 +570,39 @@ def htmlNewPost(cssCache: {}, mediaInstance: bool, translate: {}, dateAndLocation += '\n' dateAndLocation += '\n' - newPostForm = htmlHeaderWithExternalStyle(cssFilename) + newPostForm = htmlHeaderWithExternalStyles(cssFiles) - newPostForm += \ - '
\n' + \ - '\n' - newPostForm += '\n' + \ - '
\n' + usersPath = '/users/' + nickname + + newPostForm += '
\n' + + if not defaultTimeline == 'tlfeatures': + newPostForm += (f"\t" + f"{translate['Switch to timeline view']}\n") + else: + # TODO: News instances should ignore personalised banners + # Currently uses the 'news' actor banner - as it remains unchanged + newPostForm += (f"\t" + f"{translate['Features']}\n" + f"\t
\n" + f"\t\t#IndymediaBack\n" + f"\t
\n") + + # Certain Epciyon pages should only be accessible via the 'User' page for News instances + # TODO: Better solution - Currently this is a duplicate of list created in 'webapp_timeline.py' + userPages = ['inbox', 'outbox', 'dm', 'tlreplies', 'tlblogs', 'tlmedia', 'tlshares', \ + 'tlsaves', 'tlevents', 'tlbookmarks', 'moderation', 'search', \ + 'followers', 'newfollowers', 'newdm', 'newpost', 'newblog', 'newevent'] + + # Full row "navbar" + if defaultTimeline == 'tlfeatures': + # Show "tab" links instead of standard "buttons" + # NOTE: "inbox" is used as a generic boxName, as with 'User' pages + newPostForm += headerNewsTabs('inbox', translate, usersPath, baseDir, userPages) + + # Close banner div + newPostForm += '
\n' mentionsStr = '' for m in mentions: @@ -638,6 +676,24 @@ def htmlNewPost(cssCache: {}, mediaInstance: bool, translate: {}, # reporting a post to moderator mentionsStr = 'Re: ' + reportUrl + '\n\n' + mentionsStr + # TODO: Place form inside a "page" div for 'News' instances + newPostForm += '
\n' + + moderator = isModerator(baseDir, nickname) + + # TODO: Add "User" links + if defaultTimeline == 'tlfeatures': + # NOTE: It appears that 'endpoint' is effectively 'boxName' + newPostForm += \ + headerButtonsTimeline(defaultTimeline, endpoint, pageNumber, + translate, usersPath, + False, moderator, + False, + baseDir, nickname, + domain, None, + True, userPages) + newPostForm += '
\n' + newPostForm += \ '
', '') diff --git a/webapp_headerbuttons.py b/webapp_headerbuttons.py index 4d1d0fbb..9713b0be 100644 --- a/webapp_headerbuttons.py +++ b/webapp_headerbuttons.py @@ -352,9 +352,10 @@ def headerButtonsTimeline(defaultTimeline: str, navIconStr += '\t\t\t\n\t\t
\n' # benchmark 5 - timeDiff = int((time.time() - timelineStartTime) * 1000) - if timeDiff > 100: - print('TIMELINE TIMING ' + boxName + ' 5 = ' + str(timeDiff)) + if timelineStartTime: + timeDiff = int((time.time() - timelineStartTime) * 1000) + if timeDiff > 100: + print('TIMELINE TIMING ' + boxName + ' 5 = ' + str(timeDiff)) # Compile HTML parts diff --git a/webapp_timeline.py b/webapp_timeline.py index 21eff3fe..a867914b 100644 --- a/webapp_timeline.py +++ b/webapp_timeline.py @@ -195,6 +195,8 @@ def htmlTimeline(cssCache: {}, defaultTimeline: str, # Close banner div tlStr += '
\n' + # TODO: Should probably use a more generic class, easier to re-use and help simplify CSS + # NOTE: Related also to class "page" added to 'webapp_create_post.py' # start the timeline tlStr += '
\n'