diff --git a/webapp_frontscreen.py b/webapp_frontscreen.py new file mode 100644 index 000000000..a4e7b1b22 --- /dev/null +++ b/webapp_frontscreen.py @@ -0,0 +1,243 @@ +__filename__ = "webapp_frontscreen.py" +__author__ = "Bob Mottram" +__license__ = "AGPL3+" +__version__ = "1.1.0" +__maintainer__ = "Bob Mottram" +__email__ = "bob@freedombone.net" +__status__ = "Production" + +import os +from utils import isSystemAccount +from utils import getDomainFromActor +from person import personBoxJson +from webapp_utils import htmlHeaderWithExternalStyle +from webapp_utils import htmlFooter +from webapp_utils import getIconsWebPath +from webapp_utils import getBannerFile +from webapp_utils import htmlPostSeparator +from webapp_column_left import getLeftColumnContent +from webapp_column_right import getRightColumnContent +from webapp_post import individualPostAsHtml + + +def headerButtonsFrontScreen(translate: {}, + nickname: str, boxName: str, + authorized: bool, + iconsAsButtons: bool, + iconsPath: bool) -> str: + """Returns the header buttons for the front page of a news instance + """ + headerStr = '' + if nickname == 'news': + buttonFeatures = 'buttonMobile' + buttonNewswire = 'buttonMobile' + buttonLinks = 'buttonMobile' + if boxName == 'features': + buttonFeatures = 'buttonselected' + elif boxName == 'newswire': + buttonNewswire = 'buttonselected' + elif boxName == 'links': + buttonLinks = 'buttonselected' + + headerStr += \ + ' ' + \ + '' + if not authorized: + headerStr += \ + ' ' + \ + '' + if iconsAsButtons: + headerStr += \ + ' ' + \ + '' + headerStr += \ + ' ' + \ + '' + else: + headerStr += \ + ' ' + \ + '\n' + headerStr += \ + ' ' + \ + '\n' + else: + if not authorized: + headerStr += \ + ' ' + \ + '' + + if headerStr: + headerStr = \ + '\n
\n' + iconsPath = getIconsWebPath(baseDir) + profileHeaderStr += \ + getLeftColumnContent(baseDir, 'news', domainFull, + httpPrefix, translate, + iconsPath, False, + False, None, rssIconAtTop, True, + True) + profileHeaderStr += ' | \n' + profileHeaderStr += '\n' + + profileStr = profileHeaderStr + + cssFilename = baseDir + '/epicyon-profile.css' + if os.path.isfile(baseDir + '/epicyon.css'): + cssFilename = baseDir + '/epicyon.css' + + licenseStr = '' + bannerFile, bannerFilename = \ + getBannerFile(baseDir, nickname, domain) + profileStr += \ + htmlFrontScreenPosts(recentPostsCache, maxRecentPosts, + translate, + baseDir, httpPrefix, + nickname, domain, port, + session, wfRequest, personCache, + projectVersion, + YTReplacementDomain, + showPublishedDateOnly) + licenseStr + + # Footer which is only used for system accounts + profileFooterStr = ' | \n' + profileFooterStr += '\n' + iconsPath = getIconsWebPath(baseDir) + profileFooterStr += \ + getRightColumnContent(baseDir, 'news', domainFull, + httpPrefix, translate, + iconsPath, False, False, + newswire, False, + False, None, False, False, + False, True, authorized, True) + profileFooterStr += ' | \n' + profileFooterStr += '
\n' - iconsPath = getIconsWebPath(baseDir) - profileHeaderStr += \ - getLeftColumnContent(baseDir, 'news', domainFull, - httpPrefix, translate, - iconsPath, False, - False, None, rssIconAtTop, True, - True) - profileHeaderStr += ' | \n' - profileHeaderStr += '\n'
- else:
- avatarUrl = profileJson['icon']['url']
- profileHeaderStr = \
- getProfileHeader(baseDir, nickname, domain,
- domainFull, translate, iconsPath,
- defaultTimeline, displayName,
- avatarDescription,
- profileDescriptionShort,
- loginButton, avatarUrl)
+ avatarUrl = profileJson['icon']['url']
+ profileHeaderStr = \
+ getProfileHeader(baseDir, nickname, domain,
+ domainFull, translate, iconsPath,
+ defaultTimeline, displayName,
+ avatarDescription,
+ profileDescriptionShort,
+ loginButton, avatarUrl)
profileStr = profileHeaderStr + donateSection
- if not isSystemAccount(nickname):
- profileStr += ' \n'
- profileStr += ' '
+ profileStr += '\n'
+ profileStr += ' '
profileStr += followApprovalsSection
@@ -623,87 +602,55 @@ def htmlProfile(rssIconAtTop: bool,
if os.path.isfile(baseDir + '/epicyon.css'):
cssFilename = baseDir + '/epicyon.css'
- if isSystemAccount(nickname):
- licenseStr = ''
- bannerFile, bannerFilename = \
- getBannerFile(baseDir, nickname, domain)
+ licenseStr = \
+ '' + \
+ ''
+
+ if selected == 'posts':
profileStr += \
- htmlFrontScreenPosts(recentPostsCache, maxRecentPosts,
- translate,
- baseDir, httpPrefix,
- nickname, domain, port,
- session, wfRequest, personCache,
- projectVersion,
- YTReplacementDomain,
- showPublishedDateOnly) + licenseStr
- else:
- licenseStr = \
- '' + \
- ''
-
- if selected == 'posts':
- profileStr += \
- htmlProfilePosts(recentPostsCache, maxRecentPosts,
- translate,
- baseDir, httpPrefix, authorized,
- nickname, domain, port,
- session, wfRequest, personCache,
- projectVersion,
- YTReplacementDomain,
- showPublishedDateOnly) + licenseStr
- elif selected == 'following':
- profileStr += \
- htmlProfileFollowing(translate, baseDir, httpPrefix,
- authorized, nickname,
- domain, port, session,
- wfRequest, personCache, extraJson,
- projectVersion, ["unfollow"], selected,
- usersPath, pageNumber, maxItemsPerPage)
- elif selected == 'followers':
- profileStr += \
- htmlProfileFollowing(translate, baseDir, httpPrefix,
- authorized, nickname,
- domain, port, session,
- wfRequest, personCache, extraJson,
- projectVersion, ["block"],
- selected, usersPath, pageNumber,
- maxItemsPerPage)
- elif selected == 'roles':
- profileStr += \
- htmlProfileRoles(translate, nickname, domainFull,
- extraJson)
- elif selected == 'skills':
- profileStr += \
- htmlProfileSkills(translate, nickname, domainFull, extraJson)
- elif selected == 'shares':
- profileStr += \
- htmlProfileShares(actor, translate,
- nickname, domainFull,
- extraJson) + licenseStr
-
- # Footer which is only used for system accounts
- profileFooterStr = ''
- if isSystemAccount(nickname):
- profileFooterStr = ' | \n'
- profileFooterStr += ' \n' - iconsPath = getIconsWebPath(baseDir) - profileFooterStr += \ - getRightColumnContent(baseDir, 'news', domainFull, - httpPrefix, translate, - iconsPath, False, False, - newswire, False, - False, None, False, False, - False, True, authorized, True) - profileFooterStr += ' | \n' - profileFooterStr += '