From 7d60cdacb20339bb154b720500d4526600e9f3bb Mon Sep 17 00:00:00 2001
From: OMN
Date: Sat, 12 Dec 2020 19:38:38 +0000
Subject: [PATCH] Quick fixes
- Usage of headerNewsTabs()
- Remove 'Login' button from newswire column
- Display front page correctly when not logged in
- Add multi/themed CSS to front page and edit profile page
- Show site banner on profile edit page
- Include edit profile in "user pages" list
---
webapp_column_left.py | 2 +-
webapp_column_right.py | 18 ++++----
webapp_create_post.py | 7 ++-
webapp_frontscreen.py | 102 ++++++++++++++++++++++++++---------------
webapp_profile.py | 85 ++++++++++++++++++++++++++++++----
webapp_timeline.py | 7 +--
6 files changed, 158 insertions(+), 63 deletions(-)
diff --git a/webapp_column_left.py b/webapp_column_left.py
index f4a9dcb1..ab92f0bf 100644
--- a/webapp_column_left.py
+++ b/webapp_column_left.py
@@ -306,7 +306,7 @@ def htmlLinksMobile(cssCache: {}, baseDir: str,
# Full row "navbar"
if defaultTimeline == 'tlfeatures':
# Show "tab" links instead of standard "buttons"
- htmlStr += headerNewsTabs('linksmobile', translate, usersPath, baseDir, userPages)
+ htmlStr += headerNewsTabs('linksmobile', translate, usersPath, baseDir, authorized, userPages)
# Close banner div
htmlStr += '\n'
diff --git a/webapp_column_right.py b/webapp_column_right.py
index 5effe409..41a32858 100644
--- a/webapp_column_right.py
+++ b/webapp_column_right.py
@@ -61,6 +61,7 @@ def getRightColumnContent(baseDir: str, nickname: str, domainFull: str,
if ':' in domain:
domain = domain.split(':')
+ publishButtonStr = None
if authorized:
# only show the publish button if logged in, otherwise replace it with
# a login button
@@ -70,15 +71,16 @@ def getRightColumnContent(baseDir: str, nickname: str, domainFull: str,
'title="' + translate['Publish a news article'] + '">' + \
'\n'
- else:
- # if not logged in then replace the publish button with
- # a login button
- publishButtonStr = \
- ' \n'
+# NOTE: Removed from this fork as is handled by 'htmlFooter' in webapp_utils.py
+# else:
+# # if not logged in then replace the publish button with
+# # a login button
+# publishButtonStr = \
+# ' \n'
# show publish button at the top if needed
- if publishButtonAtTop:
+ if publishButtonStr and publishButtonAtTop:
htmlStr += '
' + publishButtonStr + '
'
editImageClass = ''
@@ -477,7 +479,7 @@ def htmlNewswireMobile(cssCache: {}, baseDir: str, nickname: str,
# Full row "navbar"
if defaultTimeline == 'tlfeatures':
# Show "tab" links instead of standard "buttons"
- htmlStr += headerNewsTabs('newswiremobile', translate, usersPath, baseDir, userPages)
+ htmlStr += headerNewsTabs('newswiremobile', translate, usersPath, baseDir, authorized, userPages)
# Close banner div
htmlStr += '\n'
diff --git a/webapp_create_post.py b/webapp_create_post.py
index da0be76a..36ddd295 100644
--- a/webapp_create_post.py
+++ b/webapp_create_post.py
@@ -599,7 +599,10 @@ def htmlNewPost(cssCache: {}, mediaInstance: bool, translate: {},
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)
+ # 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'
@@ -798,7 +801,7 @@ def htmlNewPost(cssCache: {}, mediaInstance: bool, translate: {},
newPostForm += ' \n'
newPostForm += '\n'
- # Close "section" and "page" div
+ # Close "main" and "page" div
newPostForm += '\n\n'
if not reportUrl:
diff --git a/webapp_frontscreen.py b/webapp_frontscreen.py
index adfb0b24..daf4f274 100644
--- a/webapp_frontscreen.py
+++ b/webapp_frontscreen.py
@@ -9,12 +9,14 @@ __status__ = "Production"
import os
from utils import isSystemAccount
from utils import getDomainFromActor
+from utils import getConfigParam
from person import personBoxJson
-from webapp_utils import htmlHeaderWithExternalStyle
+from webapp_utils import htmlHeaderWithExternalStyles
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
from webapp_column_left import getLeftColumnContent
from webapp_column_right import getRightColumnContent
from webapp_post import individualPostAsHtml
@@ -106,41 +108,61 @@ def htmlFrontScreen(rssIconAtTop: bool,
if port:
domainFull = domain + ':' + str(port)
- loginButton = headerButtonsFrontScreen(translate, nickname,
- 'features', authorized,
- iconsAsButtons)
-
# If this is the news account then show a different banner
- bannerFile, bannerFilename = \
- getBannerFile(baseDir, nickname, domain, theme)
- profileHeaderStr = \
- '\n'
- if loginButton:
- 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'
+
+ # 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'
+ profileHeaderStr += '
\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'
+
+ # TODO: Place form inside a "page" div for 'News' instances
+ # NOTE: Duplicate of code from webapp_create_post.py
+ editProfileForm += '