__filename__ = "webapp_profile.py" __author__ = "Bob Mottram" __license__ = "AGPL3+" __version__ = "1.2.0" __maintainer__ = "Bob Mottram" __email__ = "bob@freedombone.net" __status__ = "Production" __module_group__ = "Web Interface" import os from pprint import pprint from utils import hasObjectDict from utils import getOccupationName from utils import getLockedAccount from utils import getFullDomain from utils import isArtist from utils import isDormant from utils import getNicknameFromActor from utils import getDomainFromActor from utils import isSystemAccount from utils import removeHtml from utils import loadJson from utils import getConfigParam from utils import getImageFormats from utils import acctDir from utils import getSupportedLanguages from utils import localActorUrl from languages import getActorLanguages from skills import getSkills from theme import getThemesList from person import personBoxJson from person import getActorJson from person import getPersonAvatarUrl from webfinger import webfingerHandle from posts import parseUserFeed from posts import getPersonBox from donate import getDonationUrl from donate import getWebsite from xmpp import getXmppAddress from matrix import getMatrixAddress from ssb import getSSBAddress from pgp import getEmailAddress from pgp import getPGPfingerprint from pgp import getPGPpubKey from tox import getToxAddress from briar import getBriarAddress from jami import getJamiAddress from cwtch import getCwtchAddress from filters import isFiltered from follow import isFollowerOfPerson from webapp_frontscreen import htmlFrontScreen from webapp_utils import htmlKeyboardNavigation from webapp_utils import htmlHideFromScreenReader from webapp_utils import scheduledPostsExist from webapp_utils import htmlHeaderWithExternalStyle from webapp_utils import htmlHeaderWithPersonMarkup from webapp_utils import htmlFooter from webapp_utils import addEmojiToDisplayName from webapp_utils import getBannerFile from webapp_utils import htmlPostSeparator from webapp_utils import editCheckBox from webapp_utils import editTextField from webapp_utils import editTextArea from webapp_utils import beginEditSection from webapp_utils import endEditSection from blog import getBlogAddress from webapp_post import individualPostAsHtml from webapp_timeline import htmlIndividualShare def htmlProfileAfterSearch(cssCache: {}, recentPostsCache: {}, maxRecentPosts: int, translate: {}, baseDir: str, path: str, httpPrefix: str, nickname: str, domain: str, port: int, profileHandle: str, session, cachedWebfingers: {}, personCache: {}, debug: bool, projectVersion: str, YTReplacementDomain: str, showPublishedDateOnly: bool, defaultTimeline: str, peertubeInstances: [], allowLocalNetworkAccess: bool, themeName: str, accessKeys: {}, systemLanguage: str, maxLikeCount: int, signingPrivateKeyPem: str) -> str: """Show a profile page after a search for a fediverse address """ http = False gnunet = False if httpPrefix == 'http': http = True elif httpPrefix == 'gnunet': gnunet = True profileJson, asHeader = \ getActorJson(domain, profileHandle, http, gnunet, debug, False, signingPrivateKeyPem) if not profileJson: return None personUrl = profileJson['id'] searchDomain, searchPort = getDomainFromActor(personUrl) searchNickname = getNicknameFromActor(personUrl) searchDomainFull = getFullDomain(searchDomain, searchPort) profileStr = '' cssFilename = baseDir + '/epicyon-profile.css' if os.path.isfile(baseDir + '/epicyon.css'): cssFilename = baseDir + '/epicyon.css' avatarUrl = '' if profileJson.get('icon'): if profileJson['icon'].get('url'): avatarUrl = profileJson['icon']['url'] if not avatarUrl: avatarUrl = getPersonAvatarUrl(baseDir, personUrl, personCache, True) displayName = searchNickname if profileJson.get('name'): displayName = profileJson['name'] lockedAccount = getLockedAccount(profileJson) if lockedAccount: displayName += '🔒' movedTo = '' if profileJson.get('movedTo'): movedTo = profileJson['movedTo'] if '"' in movedTo: movedTo = movedTo.split('"')[1] displayName += ' ⌂' followsYou = \ isFollowerOfPerson(baseDir, nickname, domain, searchNickname, searchDomainFull) profileDescription = '' if profileJson.get('summary'): profileDescription = profileJson['summary'] outboxUrl = None if not profileJson.get('outbox'): if debug: pprint(profileJson) print('DEBUG: No outbox found') return None outboxUrl = profileJson['outbox'] # profileBackgroundImage = '' # if profileJson.get('image'): # if profileJson['image'].get('url'): # profileBackgroundImage = profileJson['image']['url'] # url to return to backUrl = path if not backUrl.endswith('/inbox'): backUrl += '/inbox' profileDescriptionShort = profileDescription if '\n' in profileDescription: if len(profileDescription.split('\n')) > 2: profileDescriptionShort = '' else: if '
' in profileDescription: if len(profileDescription.split('
')) > 2: profileDescriptionShort = '' # keep the profile description short if len(profileDescriptionShort) > 256: profileDescriptionShort = '' # remove formatting from profile description used on title avatarDescription = '' if profileJson.get('summary'): if isinstance(profileJson['summary'], str): avatarDescription = \ profileJson['summary'].replace('
', '\n') avatarDescription = avatarDescription.replace('

', '') avatarDescription = avatarDescription.replace('

', '') if '<' in avatarDescription: avatarDescription = removeHtml(avatarDescription) imageUrl = '' if profileJson.get('image'): if profileJson['image'].get('url'): imageUrl = profileJson['image']['url'] alsoKnownAs = None if profileJson.get('alsoKnownAs'): alsoKnownAs = profileJson['alsoKnownAs'] joinedDate = None if profileJson.get('published'): if 'T' in profileJson['published']: joinedDate = profileJson['published'] profileStr = \ _getProfileHeaderAfterSearch(baseDir, nickname, defaultTimeline, searchNickname, searchDomainFull, translate, displayName, followsYou, profileDescriptionShort, avatarUrl, imageUrl, movedTo, profileJson['id'], alsoKnownAs, accessKeys, joinedDate) domainFull = getFullDomain(domain, port) followIsPermitted = True if not profileJson.get('followers'): # no followers collection specified within actor followIsPermitted = False elif searchNickname == 'news' and searchDomainFull == domainFull: # currently the news actor is not something you can follow followIsPermitted = False elif searchNickname == nickname and searchDomainFull == domainFull: # don't follow yourself! followIsPermitted = False if followIsPermitted: profileStr += \ '
\n' + \ '
\n' + \ '
\n' + \ ' \n' + \ ' \n' + \ ' \n' + \ '
\n' + \ '
\n' + \ '
\n' else: profileStr += \ '
\n' + \ '
\n' + \ '
\n' + \ ' \n' + \ ' \n' + \ '
\n' + \ '
\n' + \ '
\n' userFeed = \ parseUserFeed(signingPrivateKeyPem, session, outboxUrl, asHeader, projectVersion, httpPrefix, domain, debug) if userFeed: i = 0 for item in userFeed: if not item.get('actor'): continue if item['actor'] != personUrl: continue if not item.get('type'): continue if item['type'] != 'Create': continue if not hasObjectDict(item): continue profileStr += \ individualPostAsHtml(signingPrivateKeyPem, True, recentPostsCache, maxRecentPosts, translate, None, baseDir, session, cachedWebfingers, personCache, nickname, domain, port, item, avatarUrl, False, False, httpPrefix, projectVersion, 'inbox', YTReplacementDomain, showPublishedDateOnly, peertubeInstances, allowLocalNetworkAccess, themeName, systemLanguage, maxLikeCount, False, False, False, False, False) i += 1 if i >= 20: break instanceTitle = \ getConfigParam(baseDir, 'instanceTitle') return htmlHeaderWithExternalStyle(cssFilename, instanceTitle) + \ profileStr + htmlFooter() def _getProfileHeader(baseDir: str, httpPrefix: str, nickname: str, domain: str, domainFull: str, translate: {}, defaultTimeline: str, displayName: str, avatarDescription: str, profileDescriptionShort: str, loginButton: str, avatarUrl: str, theme: str, movedTo: str, alsoKnownAs: [], pinnedContent: str, accessKeys: {}, joinedDate: str, occupationName: str) -> str: """The header of the profile screen, containing background image and avatar """ htmlStr = \ '\n\n
\n' + \ ' \n' + \ ' \n' + \ '
\n' + \ ' \n' + \ ' \n' occupationStr = '' if occupationName: occupationStr += \ ' ' + occupationName + '
\n' htmlStr += '

' + displayName + '

\n' + occupationStr htmlStr += \ '

@' + nickname + '@' + domainFull + '
\n' if joinedDate: htmlStr += \ '

' + translate['Joined'] + ' ' + \ joinedDate.split('T')[0] + '
\n' if movedTo: newNickname = getNicknameFromActor(movedTo) newDomain, newPort = getDomainFromActor(movedTo) newDomainFull = getFullDomain(newDomain, newPort) if newNickname and newDomain: htmlStr += \ '

' + translate['New account'] + ': ' + \ '@' + \ newNickname + '@' + newDomainFull + '
\n' elif alsoKnownAs: otherAccountsHtml = \ '

' + translate['Other accounts'] + ': ' actor = localActorUrl(httpPrefix, nickname, domainFull) ctr = 0 if isinstance(alsoKnownAs, list): for altActor in alsoKnownAs: if altActor == actor: continue if ctr > 0: otherAccountsHtml += ' ' ctr += 1 altDomain, altPort = getDomainFromActor(altActor) otherAccountsHtml += \ '' + altDomain + '' elif isinstance(alsoKnownAs, str): if alsoKnownAs != actor: ctr += 1 altDomain, altPort = getDomainFromActor(alsoKnownAs) otherAccountsHtml += \ '' + altDomain + '' otherAccountsHtml += '

\n' if ctr > 0: htmlStr += otherAccountsHtml htmlStr += \ ' ' + \ '' + translate['QR Code'] + \
        '

\n' + \ '

' + profileDescriptionShort + '

\n' + loginButton if pinnedContent: htmlStr += pinnedContent.replace('

', '

📎', 1) htmlStr += \ '

\n' + \ '
\n\n' return htmlStr def _getProfileHeaderAfterSearch(baseDir: str, nickname: str, defaultTimeline: str, searchNickname: str, searchDomainFull: str, translate: {}, displayName: str, followsYou: bool, profileDescriptionShort: str, avatarUrl: str, imageUrl: str, movedTo: str, actor: str, alsoKnownAs: [], accessKeys: {}, joinedDate: str) -> str: """The header of a searched for handle, containing background image and avatar """ htmlStr = \ '\n\n
\n' + \ ' \n' + \ ' \n' + \ '
\n' if avatarUrl: htmlStr += \ ' \n' + \ ' \n' htmlStr += \ '

' + displayName + '

\n' + \ '

@' + searchNickname + '@' + searchDomainFull + '
\n' if joinedDate: htmlStr += '

' + translate['Joined'] + ' ' + \ joinedDate.split('T')[0] + '

\n' if followsYou: htmlStr += '

' + translate['Follows you'] + '

\n' if movedTo: newNickname = getNicknameFromActor(movedTo) newDomain, newPort = getDomainFromActor(movedTo) newDomainFull = getFullDomain(newDomain, newPort) if newNickname and newDomain: newHandle = newNickname + '@' + newDomainFull htmlStr += '

' + translate['New account'] + \ ': @' + newHandle + '

\n' elif alsoKnownAs: otherAccountshtml = \ '

' + translate['Other accounts'] + ': ' ctr = 0 if isinstance(alsoKnownAs, list): for altActor in alsoKnownAs: if altActor == actor: continue if ctr > 0: otherAccountshtml += ' ' ctr += 1 altDomain, altPort = getDomainFromActor(altActor) otherAccountshtml += \ '' + altDomain + '' elif isinstance(alsoKnownAs, str): if alsoKnownAs != actor: ctr += 1 altDomain, altPort = getDomainFromActor(alsoKnownAs) otherAccountshtml += \ '' + altDomain + '' otherAccountshtml += '

\n' if ctr > 0: htmlStr += otherAccountshtml htmlStr += \ '

' + profileDescriptionShort + '

\n' + \ '
\n' + \ '
\n\n' return htmlStr def htmlProfile(signingPrivateKeyPem: str, rssIconAtTop: bool, cssCache: {}, iconsAsButtons: bool, defaultTimeline: str, recentPostsCache: {}, maxRecentPosts: int, translate: {}, projectVersion: str, baseDir: str, httpPrefix: str, authorized: bool, profileJson: {}, selected: str, session, cachedWebfingers: {}, personCache: {}, YTReplacementDomain: str, showPublishedDateOnly: bool, newswire: {}, theme: str, dormantMonths: int, peertubeInstances: [], allowLocalNetworkAccess: bool, textModeBanner: str, debug: bool, accessKeys: {}, city: str, systemLanguage: str, maxLikeCount: int, sharedItemsFederatedDomains: [], extraJson: {} = None, pageNumber: int = None, maxItemsPerPage: int = None) -> str: """Show the profile page as html """ nickname = profileJson['preferredUsername'] if not nickname: return "" if isSystemAccount(nickname): return htmlFrontScreen(signingPrivateKeyPem, rssIconAtTop, cssCache, iconsAsButtons, defaultTimeline, recentPostsCache, maxRecentPosts, translate, projectVersion, baseDir, httpPrefix, authorized, profileJson, selected, session, cachedWebfingers, personCache, YTReplacementDomain, showPublishedDateOnly, newswire, theme, extraJson, allowLocalNetworkAccess, accessKeys, systemLanguage, maxLikeCount, sharedItemsFederatedDomains, pageNumber, maxItemsPerPage) domain, port = getDomainFromActor(profileJson['id']) if not domain: return "" displayName = \ addEmojiToDisplayName(baseDir, httpPrefix, nickname, domain, profileJson['name'], True) domainFull = getFullDomain(domain, port) profileDescription = \ addEmojiToDisplayName(baseDir, httpPrefix, nickname, domain, profileJson['summary'], False) postsButton = 'button' followingButton = 'button' followersButton = 'button' rolesButton = 'button' skillsButton = 'button' sharesButton = 'button' wantedButton = 'button' if selected == 'posts': postsButton = 'buttonselected' elif selected == 'following': followingButton = 'buttonselected' elif selected == 'followers': followersButton = 'buttonselected' elif selected == 'roles': rolesButton = 'buttonselected' elif selected == 'skills': skillsButton = 'buttonselected' elif selected == 'shares': sharesButton = 'buttonselected' elif selected == 'wanted': wantedButton = 'buttonselected' loginButton = '' followApprovalsSection = '' followApprovals = False editProfileStr = '' logoutStr = '' actor = profileJson['id'] usersPath = '/users/' + actor.split('/users/')[1] donateSection = '' donateUrl = getDonationUrl(profileJson) websiteUrl = getWebsite(profileJson, translate) blogAddress = getBlogAddress(profileJson) PGPpubKey = getPGPpubKey(profileJson) PGPfingerprint = getPGPfingerprint(profileJson) emailAddress = getEmailAddress(profileJson) xmppAddress = getXmppAddress(profileJson) matrixAddress = getMatrixAddress(profileJson) ssbAddress = getSSBAddress(profileJson) toxAddress = getToxAddress(profileJson) briarAddress = getBriarAddress(profileJson) jamiAddress = getJamiAddress(profileJson) cwtchAddress = getCwtchAddress(profileJson) if donateUrl or websiteUrl or xmppAddress or matrixAddress or \ ssbAddress or toxAddress or briarAddress or \ jamiAddress or cwtchAddress or PGPpubKey or \ PGPfingerprint or emailAddress: donateSection = '
\n' donateSection += '
\n' if donateUrl and not isSystemAccount(nickname): donateSection += \ '

\n' if websiteUrl: donateSection += \ '

' + translate['Website'] + ': ' + websiteUrl + '

\n' if emailAddress: donateSection += \ '

' + translate['Email'] + ': ' + emailAddress + '

\n' if blogAddress: donateSection += \ '

Blog: ' + blogAddress + '

\n' if xmppAddress: donateSection += \ '

' + translate['XMPP'] + ': ' + xmppAddress + '

\n' if matrixAddress: donateSection += \ '

' + translate['Matrix'] + ': ' + matrixAddress + '

\n' if ssbAddress: donateSection += \ '

SSB:

\n' if toxAddress: donateSection += \ '

Tox:

\n' if briarAddress: if briarAddress.startswith('briar://'): donateSection += \ '

\n' else: donateSection += \ '

briar://

\n' if jamiAddress: donateSection += \ '

Jami:

\n' if cwtchAddress: donateSection += \ '

Cwtch:

\n' if PGPfingerprint: donateSection += \ '

PGP: ' + \ PGPfingerprint.replace('\n', '
') + '

\n' if PGPpubKey: donateSection += \ '

' + PGPpubKey.replace('\n', '
') + '

\n' donateSection += '
\n' donateSection += '
\n' if authorized: editProfileStr = \ '' + \ '| ' + translate['Edit'] + '\n' logoutStr = \ '' + \ '| ' + translate['Logout'] + \
            '\n' # are there any follow requests? followRequestsFilename = \ acctDir(baseDir, nickname, domain) + '/followrequests.txt' if os.path.isfile(followRequestsFilename): with open(followRequestsFilename, 'r') as f: for line in f: if len(line) > 0: followApprovals = True followersButton = 'buttonhighlighted' if selected == 'followers': followersButton = 'buttonselectedhighlighted' break if selected == 'followers': if followApprovals: with open(followRequestsFilename, 'r') as f: for followerHandle in f: if len(line) > 0: if '://' in followerHandle: followerActor = followerHandle else: nick = followerHandle.split('@')[0] dom = followerHandle.split('@')[1] followerActor = \ localActorUrl(httpPrefix, nick, dom) basePath = '/users/' + nickname followApprovalsSection += '
' followApprovalsSection += \ '' followApprovalsSection += \ '' + \ followerHandle + '' followApprovalsSection += \ '' followApprovalsSection += \ '

' followApprovalsSection += \ '' followApprovalsSection += \ '' followApprovalsSection += '
' profileDescriptionShort = profileDescription if '\n' in profileDescription: if len(profileDescription.split('\n')) > 2: profileDescriptionShort = '' else: if '
' in profileDescription: if len(profileDescription.split('
')) > 2: profileDescriptionShort = '' profileDescription = profileDescription.replace('
', '\n') # keep the profile description short if len(profileDescriptionShort) > 256: profileDescriptionShort = '' # remove formatting from profile description used on title avatarDescription = '' if profileJson.get('summary'): avatarDescription = profileJson['summary'].replace('
', '\n') avatarDescription = avatarDescription.replace('

', '') avatarDescription = avatarDescription.replace('

', '') movedTo = '' if profileJson.get('movedTo'): movedTo = profileJson['movedTo'] if '"' in movedTo: movedTo = movedTo.split('"')[1] alsoKnownAs = None if profileJson.get('alsoKnownAs'): alsoKnownAs = profileJson['alsoKnownAs'] joinedDate = None if profileJson.get('published'): if 'T' in profileJson['published']: joinedDate = profileJson['published'] occupationName = None if profileJson.get('hasOccupation'): occupationName = getOccupationName(profileJson) avatarUrl = profileJson['icon']['url'] # use alternate path for local avatars to avoid any caching issues if '://' + domainFull + '/accounts/avatars/' in avatarUrl: avatarUrl = \ avatarUrl.replace('://' + domainFull + '/accounts/avatars/', '://' + domainFull + '/users/') # get pinned post content accountDir = acctDir(baseDir, nickname, domain) pinnedFilename = accountDir + '/pinToProfile.txt' pinnedContent = None if os.path.isfile(pinnedFilename): with open(pinnedFilename, 'r') as pinFile: pinnedContent = pinFile.read() profileHeaderStr = \ _getProfileHeader(baseDir, httpPrefix, nickname, domain, domainFull, translate, defaultTimeline, displayName, avatarDescription, profileDescriptionShort, loginButton, avatarUrl, theme, movedTo, alsoKnownAs, pinnedContent, accessKeys, joinedDate, occupationName) # keyboard navigation userPathStr = '/users/' + nickname deft = defaultTimeline menuTimeline = \ htmlHideFromScreenReader('🏠') + ' ' + \ translate['Switch to timeline view'] menuEdit = \ htmlHideFromScreenReader('✍') + ' ' + translate['Edit'] menuFollowing = \ htmlHideFromScreenReader('👥') + ' ' + translate['Following'] menuFollowers = \ htmlHideFromScreenReader('👪') + ' ' + translate['Followers'] menuRoles = \ htmlHideFromScreenReader('🤚') + ' ' + translate['Roles'] menuSkills = \ htmlHideFromScreenReader('🛠') + ' ' + translate['Skills'] menuLogout = \ htmlHideFromScreenReader('❎') + ' ' + translate['Logout'] navLinks = { menuTimeline: userPathStr + '/' + deft, menuEdit: userPathStr + '/editprofile', menuFollowing: userPathStr + '/following#timeline', menuFollowers: userPathStr + '/followers#timeline', menuRoles: userPathStr + '/roles#timeline', menuSkills: userPathStr + '/skills#timeline', menuLogout: '/logout' } navAccessKeys = {} for variableName, key in accessKeys.items(): if not locals().get(variableName): continue navAccessKeys[locals()[variableName]] = key profileStr = htmlKeyboardNavigation(textModeBanner, navLinks, navAccessKeys) profileStr += profileHeaderStr + donateSection profileStr += '
\n' profileStr += '
' profileStr += \ ' ' profileStr += \ ' ' + \ '' profileStr += \ ' ' + \ '' profileStr += \ ' ' + \ '' profileStr += \ ' ' + \ '' # profileStr += \ # ' ' + \ # '' # profileStr += \ # ' ' + \ # '' profileStr += logoutStr + editProfileStr profileStr += '
' profileStr += '
' # start of #timeline profileStr += '
\n' profileStr += followApprovalsSection cssFilename = baseDir + '/epicyon-profile.css' if os.path.isfile(baseDir + '/epicyon.css'): cssFilename = baseDir + '/epicyon.css' licenseStr = \ '' + \ '' + \
        translate['Get the source code'] + '' if selected == 'posts': profileStr += \ _htmlProfilePosts(recentPostsCache, maxRecentPosts, translate, baseDir, httpPrefix, authorized, nickname, domain, port, session, cachedWebfingers, personCache, projectVersion, YTReplacementDomain, showPublishedDateOnly, peertubeInstances, allowLocalNetworkAccess, theme, systemLanguage, maxLikeCount, signingPrivateKeyPem) + licenseStr elif selected == 'following': profileStr += \ _htmlProfileFollowing(translate, baseDir, httpPrefix, authorized, nickname, domain, port, session, cachedWebfingers, personCache, extraJson, projectVersion, ["unfollow"], selected, usersPath, pageNumber, maxItemsPerPage, dormantMonths, debug, signingPrivateKeyPem) elif selected == 'followers': profileStr += \ _htmlProfileFollowing(translate, baseDir, httpPrefix, authorized, nickname, domain, port, session, cachedWebfingers, personCache, extraJson, projectVersion, ["block"], selected, usersPath, pageNumber, maxItemsPerPage, dormantMonths, debug, signingPrivateKeyPem) 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, 'shares') + licenseStr # elif selected == 'wanted': # profileStr += \ # _htmlProfileShares(actor, translate, # nickname, domainFull, # extraJson, 'wanted') + licenseStr # end of #timeline profileStr += '
' instanceTitle = \ getConfigParam(baseDir, 'instanceTitle') profileStr = \ htmlHeaderWithPersonMarkup(cssFilename, instanceTitle, profileJson, city) + \ profileStr + htmlFooter() return profileStr def _htmlProfilePosts(recentPostsCache: {}, maxRecentPosts: int, translate: {}, baseDir: str, httpPrefix: str, authorized: bool, nickname: str, domain: str, port: int, session, cachedWebfingers: {}, personCache: {}, projectVersion: str, YTReplacementDomain: str, showPublishedDateOnly: bool, peertubeInstances: [], allowLocalNetworkAccess: bool, themeName: str, systemLanguage: str, maxLikeCount: int, signingPrivateKeyPem: str) -> str: """Shows posts on the profile screen These should only be public posts """ separatorStr = htmlPostSeparator(baseDir, None) profileStr = '' maxItems = 4 ctr = 0 currPage = 1 boxName = 'outbox' while ctr < maxItems and currPage < 4: outboxFeedPathStr = \ '/users/' + nickname + '/' + boxName + '?page=' + \ str(currPage) outboxFeed = \ personBoxJson({}, session, baseDir, domain, port, outboxFeedPathStr, httpPrefix, 10, boxName, authorized, 0, False, 0) if not outboxFeed: break if len(outboxFeed['orderedItems']) == 0: break for item in outboxFeed['orderedItems']: if item['type'] == 'Create': postStr = \ individualPostAsHtml(signingPrivateKeyPem, True, recentPostsCache, maxRecentPosts, translate, None, baseDir, session, cachedWebfingers, personCache, nickname, domain, port, item, None, True, False, httpPrefix, projectVersion, 'inbox', YTReplacementDomain, showPublishedDateOnly, peertubeInstances, allowLocalNetworkAccess, themeName, systemLanguage, maxLikeCount, False, False, False, True, False) if postStr: profileStr += postStr + separatorStr ctr += 1 if ctr >= maxItems: break currPage += 1 return profileStr def _htmlProfileFollowing(translate: {}, baseDir: str, httpPrefix: str, authorized: bool, nickname: str, domain: str, port: int, session, cachedWebfingers: {}, personCache: {}, followingJson: {}, projectVersion: str, buttons: [], feedName: str, actor: str, pageNumber: int, maxItemsPerPage: int, dormantMonths: int, debug: bool, signingPrivateKeyPem: str) -> str: """Shows following on the profile screen """ profileStr = '' if authorized and pageNumber: if authorized and pageNumber > 1: # page up arrow profileStr += \ '
\n' + \ ' ' + \
                translate['Page up'] + '\n' + \ '
\n' for followingActor in followingJson['orderedItems']: # is this a dormant followed account? dormant = False if authorized and feedName == 'following': dormant = \ isDormant(baseDir, nickname, domain, followingActor, dormantMonths) profileStr += \ _individualFollowAsHtml(signingPrivateKeyPem, translate, baseDir, session, cachedWebfingers, personCache, domain, followingActor, authorized, nickname, httpPrefix, projectVersion, dormant, debug, buttons) if authorized and maxItemsPerPage and pageNumber: if len(followingJson['orderedItems']) >= maxItemsPerPage: # page down arrow profileStr += \ '
\n' + \ ' ' + \
                translate['Page down'] + '\n' + \ '
\n' return profileStr def _htmlProfileRoles(translate: {}, nickname: str, domain: str, rolesList: []) -> str: """Shows roles on the profile screen """ profileStr = '' profileStr += \ '
\n
\n' for role in rolesList: if translate.get(role): profileStr += '

' + translate[role] + '

\n' else: profileStr += '

' + role + '

\n' profileStr += '
\n' if len(profileStr) == 0: profileStr += \ '

@' + nickname + '@' + domain + ' has no roles assigned

\n' else: profileStr = '
' + profileStr + '
\n' return profileStr def _htmlProfileSkills(translate: {}, nickname: str, domain: str, skillsJson: {}) -> str: """Shows skills on the profile screen """ profileStr = '' for skill, level in skillsJson.items(): profileStr += \ '
' + skill + \ '
\n
\n' if len(profileStr) > 0: profileStr = '
' + \ profileStr + '
\n' return profileStr def _htmlProfileShares(actor: str, translate: {}, nickname: str, domain: str, sharesJson: {}, sharesFileType: str) -> str: """Shows shares on the profile screen """ profileStr = '' for item in sharesJson['orderedItems']: profileStr += htmlIndividualShare(domain, item['shareId'], actor, item, translate, False, False, sharesFileType) if len(profileStr) > 0: profileStr = '
' + profileStr + '
\n' return profileStr def _grayscaleEnabled(baseDir: str) -> bool: """Is grayscale UI enabled? """ return os.path.isfile(baseDir + '/accounts/.grayscale') def _htmlThemesDropdown(baseDir: str, translate: {}) -> str: """Returns the html for theme selection dropdown """ # Themes section themes = getThemesList(baseDir) themesDropdown = '
\n' grayscale = _grayscaleEnabled(baseDir) themesDropdown += \ editCheckBox(translate['Grayscale'], 'grayscale', grayscale) themesDropdown += '
' if os.path.isfile(baseDir + '/fonts/custom.woff') or \ os.path.isfile(baseDir + '/fonts/custom.woff2') or \ os.path.isfile(baseDir + '/fonts/custom.otf') or \ os.path.isfile(baseDir + '/fonts/custom.ttf'): themesDropdown += \ editCheckBox(translate['Remove the custom font'], 'removeCustomFont', False) themeName = getConfigParam(baseDir, 'theme') themesDropdown = \ themesDropdown.replace('