diff --git a/webapp_column_left.py b/webapp_column_left.py index dbbdad6c..4f9e33d0 100644 --- a/webapp_column_left.py +++ b/webapp_column_left.py @@ -16,9 +16,9 @@ from webapp_utils import htmlPostSeparator from webapp_utils import getLeftImageFile from webapp_utils import headerButtonsFrontScreen from webapp_utils import htmlHeaderWithExternalStyle, htmlHeaderWithExternalStyles +from webapp_utils import htmlHeaderBanner from webapp_utils import htmlFooter from webapp_utils import getBannerFile -from webapp_headerbuttons import headerNewsTabs def _linksExist(baseDir: str) -> bool: @@ -282,33 +282,13 @@ def htmlLinksMobile(cssCache: {}, baseDir: str, bannerFile, bannerFilename = getBannerFile(baseDir, nickname, domain) usersPath = '/users/' + nickname - htmlStr += '
\n' - - if not defaultTimeline == 'tlfeatures': - htmlStr += (f"\t" - f"{translate['Switch to profile view']}\n") - else: - # TODO: News instances should ignore personalised banners - # Currently uses the 'news' actor banner - as it remains unchanged - htmlStr += (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 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, authorized, userPages) - - # Close banner div - htmlStr += '
\n' + htmlStr += htmlHeaderBanner(defaultTimeline, 'linksmobile', baseDir, usersPath, + authorized, translate, userPages, bannerFile) htmlStr += '
\n' htmlStr += '
' + \ diff --git a/webapp_column_right.py b/webapp_column_right.py index c5fd6e6c..d5bbcba5 100644 --- a/webapp_column_right.py +++ b/webapp_column_right.py @@ -19,11 +19,11 @@ from posts import isModerator from webapp_utils import getRightImageFile from webapp_utils import getImageFile from webapp_utils import htmlHeaderWithExternalStyle, htmlHeaderWithExternalStyles +from webapp_utils import htmlHeaderBanner from webapp_utils import htmlFooter from webapp_utils import getBannerFile from webapp_utils import htmlPostSeparator from webapp_utils import headerButtonsFrontScreen -from webapp_headerbuttons import headerNewsTabs def _votesIndicator(totalVotes: int, positiveVoting: bool) -> str: @@ -218,6 +218,8 @@ def _htmlNewswire(baseDir: str, newswire: {}, nickname: str, moderator: bool, continue dateShown = publishedDate.strftime("%Y-%m-%d %H:%M") + #print(f'[DEBUG] mod: {moderator}\ndata: {item}') # DEBUG + dateStrLink = dateStr.replace('T', ' ') dateStrLink = dateStrLink.replace('Z', '') url = item[1] @@ -455,33 +457,13 @@ def htmlNewswireMobile(cssCache: {}, baseDir: str, nickname: str, bannerFile, bannerFilename = getBannerFile(baseDir, nickname, domain) usersPath = '/users/' + nickname - htmlStr += '
\n' - - if not defaultTimeline == 'tlfeatures': - htmlStr += (f"\t" - f"{translate['Switch to profile view']}\n") - else: - # TODO: News instances should ignore personalised banners - # Currently uses the 'news' actor banner - as it remains unchanged - htmlStr += (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 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, authorized, userPages) - - # Close banner div - htmlStr += '
\n' + htmlStr += htmlHeaderBanner(defaultTimeline, 'newswiremobile', baseDir, usersPath, + authorized, translate, userPages, bannerFile) htmlStr += '
\n' diff --git a/webapp_create_post.py b/webapp_create_post.py index 36ddd295..a2ac21f7 100644 --- a/webapp_create_post.py +++ b/webapp_create_post.py @@ -15,8 +15,9 @@ from utils import getImageFormats from utils import getMediaFormats from webapp_utils import getBannerFile from webapp_utils import htmlHeaderWithExternalStyles +from webapp_utils import htmlHeaderBanner from webapp_utils import htmlFooter -from webapp_headerbuttons import headerButtonsTimeline, headerNewsTabs +from webapp_headerbuttons import headerButtonsTimeline from posts import isModerator @@ -574,38 +575,16 @@ def htmlNewPost(cssCache: {}, mediaInstance: bool, translate: {}, 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 - # NOTE: It should be "safe" to assume that this code would not be running, - # unless the user was already deemed 'authorized', - # thus allowing us to pass True directly - newPostForm += headerNewsTabs('inbox', translate, usersPath, baseDir, True, userPages) - - # Close banner div - newPostForm += '
\n' + # 'authorized' is assumed to be True if this function is being called + # TODO: Confirm this assumption + newPostForm += htmlHeaderBanner(defaultTimeline, 'inbox', baseDir, usersPath, + True, translate, userPages, bannerFile) mentionsStr = '' for m in mentions: diff --git a/webapp_frontscreen.py b/webapp_frontscreen.py index 802885c8..2b93861f 100644 --- a/webapp_frontscreen.py +++ b/webapp_frontscreen.py @@ -12,11 +12,10 @@ from utils import getDomainFromActor from utils import getConfigParam from person import personBoxJson from webapp_utils import htmlHeaderWithExternalStyles -from webapp_utils import htmlFooter +from webapp_utils import htmlHeaderBanner, htmlFooter from webapp_utils import getBannerFile from webapp_utils import htmlPostSeparator from webapp_utils import headerButtonsFrontScreen -from webapp_headerbuttons import headerNewsTabs from webapp_column_left import getLeftColumnContent from webapp_column_right import getRightColumnContent from webapp_post import individualPostAsHtml @@ -111,21 +110,9 @@ def htmlFrontScreen(rssIconAtTop: bool, # If this is the news account then show a different banner bannerFile, bannerFilename = getBannerFile(baseDir, nickname, domain) - profileHeaderStr = '
\n' - - # TODO: News instances should ignore personalised banners - # Currently uses the 'news' actor banner - as it remains unchanged - profileHeaderStr += (f"\t" - f"{translate['Features']}\n" - f"\t
\n" - f"\t\t#IndymediaBack\n" - f"\t
\n") - - # Show "tab" links instead of standard "buttons" - profileHeaderStr += headerNewsTabs('tlfeatures', translate, '/users/news', baseDir, authorized, None) - - # Close banner div - profileHeaderStr += '
\n' + # NOTE: This currently more-or-less assumes being run only if 'news' instance + profileHeaderStr = htmlHeaderBanner(defaultTimeline, 'frontpage', baseDir, '/users/news', + authorized, translate, None, bannerFile); # 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' @@ -164,8 +151,11 @@ def htmlFrontScreen(rssIconAtTop: bool, profileStr += '
\n' licenseStr = '' - bannerFile, bannerFilename = \ - getBannerFile(baseDir, nickname, domain, theme) + +# NOTE: Redundant +# bannerFile, bannerFilename = \ +# getBannerFile(baseDir, nickname, domain) + profileStr += \ _htmlFrontScreenPosts(recentPostsCache, maxRecentPosts, translate, diff --git a/webapp_headerbuttons.py b/webapp_headerbuttons.py index fea632a6..8e7799fe 100644 --- a/webapp_headerbuttons.py +++ b/webapp_headerbuttons.py @@ -361,61 +361,3 @@ def headerButtonsTimeline(defaultTimeline: str, tlStr += '\t
\n' return tlStr - - -def headerNewsTabs(boxName: str, - translate: {}, - usersPath: str, - baseDir: str, - authorized: bool, - userPages: []) -> str: - navTabList = [] - - 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\n' - - return navStr diff --git a/webapp_profile.py b/webapp_profile.py index 2f87e7d2..fd60171f 100644 --- a/webapp_profile.py +++ b/webapp_profile.py @@ -44,6 +44,7 @@ from webapp_frontscreen import htmlFrontScreen from webapp_utils import scheduledPostsExist from webapp_utils import getPersonAvatarUrl from webapp_utils import htmlHeaderWithExternalStyle, htmlHeaderWithExternalStyles +from webapp_utils import htmlHeaderBanner from webapp_utils import htmlFooter from webapp_utils import addEmojiToDisplayName from webapp_utils import getBannerFile @@ -51,7 +52,7 @@ from webapp_utils import htmlPostSeparator from webapp_utils import getBlogAddress from webapp_post import individualPostAsHtml from webapp_timeline import htmlIndividualShare -from webapp_headerbuttons import headerButtonsTimeline, headerNewsTabs +from webapp_headerbuttons import headerButtonsTimeline def htmlProfileAfterSearch(cssCache: {}, @@ -1205,37 +1206,15 @@ def htmlEditProfile(cssCache: {}, translate: {}, baseDir: str, path: str, usersPath = '/users/' + nickname - # top banner - editProfileForm += '
\n' - - if not defaultTimeline == 'tlfeatures': - editProfileForm += (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 - editProfileForm += (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 userPages = ['inbox', 'outbox', 'dm', 'tlreplies', 'tlblogs', 'tlmedia', 'tlshares', \ 'tlsaves', 'tlevents', 'tlbookmarks', 'moderation', 'search', \ 'followers', 'newfollowers', 'newdm', 'newpost', 'newblog', 'newevent', 'editprofile'] - # Full row "navbar" - if defaultTimeline == 'tlfeatures': - # Show "tab" links instead of standard "buttons" - # NOTE: It should be "safe" to assume that this code would not be running, - # unless the user was already deemed 'authorized', - # thus allowing us to pass True directly - editProfileForm += headerNewsTabs('editprofile', translate, usersPath, baseDir, True, userPages) - - # Close banner div - editProfileForm += '
\n' + # Safe to assume this function would not be called if user was not authorized + # TODO: Confirm this assumption + editProfileForm += htmlHeaderBanner(defaultTimeline, 'editprofile', baseDir, usersPath, + True, translate, userPages, bannerFile) # TODO: Place form inside a "page" div for 'News' instances # NOTE: Duplicate of code from webapp_create_post.py diff --git a/webapp_timeline.py b/webapp_timeline.py index 3d0607f9..b2c63f91 100644 --- a/webapp_timeline.py +++ b/webapp_timeline.py @@ -17,14 +17,14 @@ from person import isPersonSnoozed from webapp_utils import htmlPostSeparator from webapp_utils import getBannerFile from webapp_utils import htmlHeaderWithExternalStyle, htmlHeaderWithExternalStyles -from webapp_utils import htmlFooter +from webapp_utils import htmlHeaderBanner, htmlFooter from webapp_utils import sharesTimelineJson from webapp_utils import htmlHighlightLabel from webapp_post import preparePostFromHtmlCache from webapp_post import individualPostAsHtml from webapp_column_left import getLeftColumnContent from webapp_column_right import getRightColumnContent -from webapp_headerbuttons import headerButtonsTimeline, headerNewsTabs +from webapp_headerbuttons import headerButtonsTimeline from posts import isModerator @@ -141,45 +141,18 @@ def htmlTimeline(cssCache: {}, defaultTimeline: str, if defaultTimeline == 'tlfeatures':# and boxName == 'tlfeatures': newsHeader = True - # Banner and "profile toggle" link - - tlStr += '
\n' - - # TODO: This CSS should be moved out of the code - # Items like this that can be different per user should be kept - # in the user's folder and loaded as final CSS, to allow overwrite(s) - if not newsHeader: - tlStr += (f"\t" - f"{translate['Switch to profile view']}\n") - else: - # TODO: News instances should ignore personalised banners - # Currently uses the 'news' actor banner - as it remains unchanged - tlStr += (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: The 'new...' pages appear to require handling elsewhere userPages = ['inbox', 'outbox', 'dm', 'tlreplies', 'tlblogs', 'tlmedia', 'tlshares', \ 'tlsaves', 'tlevents', 'tlbookmarks', 'moderation', 'search', \ 'followers', 'newfollowers', 'newdm', 'newpost', 'newblog', 'newevent', 'editprofile'] - # Full row "navbar" - if defaultTimeline == 'tlfeatures': - # Show "tab" links instead of standard "buttons" - tlStr += headerNewsTabs(boxName, translate, usersPath, baseDir, authorized, userPages) + # Banner and "profile toggle" link - # Close banner div - tlStr += '
\n' - - elif fullWidthTimelineButtonHeader: - # Close banner div - tlStr += '
\n' + tlStr += htmlHeaderBanner(defaultTimeline, boxName, baseDir, usersPath, + authorized, translate, userPages, bannerFile); + if not newsHeader and fullWidthTimelineButtonHeader: tlStr += \ headerButtonsTimeline(defaultTimeline, boxName, pageNumber, translate, usersPath, @@ -188,9 +161,6 @@ def htmlTimeline(cssCache: {}, defaultTimeline: str, baseDir, nickname, domain, timelineStartTime, iconsAsButtons, userPages) - else: - # 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' diff --git a/webapp_utils.py b/webapp_utils.py index d10df9b5..053246ea 100644 --- a/webapp_utils.py +++ b/webapp_utils.py @@ -19,6 +19,7 @@ from cache import getPersonFromCache from cache import storePersonInCache from content import addHtmlTags from content import replaceEmojiFromTags +from webapp_headernewstabs import headerNewsTabs def getBrokenLinkSubstitute() -> str: @@ -552,6 +553,58 @@ def htmlHeaderWithExternalStyles(cssFiles: [], lang='en') -> str: return htmlStr +# TODO: Determine if bannerFile should really only be determined here +def htmlHeaderBanner(defaultTimeline, boxName, + baseDir, usersPath, authorized, + translate, userPages, + bannerFile) -> str: + + newsHeader = False + if defaultTimeline == 'tlfeatures' or \ + (defaultTimeline == 'inbox' and boxName == 'frontpage'): + newsHeader = True + + # Banner and "profile toggle" link + + bannerStr = '
\n' + + # TODO: This CSS should be moved out of the code + # Items like this that can be different per user should be kept + # in the user's folder and loaded as final CSS, to allow overwrite(s) + # This needs further thought + if not newsHeader: + bannerStr += (f"\t" + f"{translate['Switch to profile view']}\n") + else: + # TODO: News instances should ignore personalised banners + # Currently uses the 'news' actor banner - as it remains unchanged + # More sensible location would be within each theme directory + # e.g. as 'banner_news.png' to keep with existing naming convention + bannerStr += (f"\t" + f"{translate['Features']}\n" + f"\t
\n" + f"\t\t#IndymediaBack\n" + f"\t
\n") + +# TODO: Should this be "global" for importers of this module? +# # Certain Epciyon pages should only be accessible via the 'User' page for News instances +# # TODO: The 'new...' pages appear to require handling elsewhere +# userPages = ['inbox', 'outbox', 'dm', 'tlreplies', 'tlblogs', 'tlmedia', 'tlshares', \ +# 'tlsaves', 'tlevents', 'tlbookmarks', 'moderation', 'search', \ +# 'followers', 'newfollowers', 'newdm', 'newpost', 'newblog', 'newevent', 'editprofile'] + + # Full row "navbar" + if newsHeader: + # Show "tab" links instead of standard "buttons" + bannerStr += headerNewsTabs(boxName, translate, usersPath, baseDir, authorized, userPages) + + # Close banner div + bannerStr += '
\n' + + return bannerStr + + def htmlFooter() -> str: htmlStr = '