| 
									
										
										
										
											2020-11-09 22:44:03 +00:00
										 |  |  | __filename__ = "webapp_person_options.py" | 
					
						
							|  |  |  | __author__ = "Bob Mottram" | 
					
						
							|  |  |  | __license__ = "AGPL3+" | 
					
						
							| 
									
										
										
										
											2021-01-26 10:07:42 +00:00
										 |  |  | __version__ = "1.2.0" | 
					
						
							| 
									
										
										
										
											2020-11-09 22:44:03 +00:00
										 |  |  | __maintainer__ = "Bob Mottram" | 
					
						
							|  |  |  | __email__ = "bob@freedombone.net" | 
					
						
							|  |  |  | __status__ = "Production" | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | import os | 
					
						
							|  |  |  | from shutil import copyfile | 
					
						
							|  |  |  | from petnames import getPetName | 
					
						
							|  |  |  | from person import isPersonSnoozed | 
					
						
							|  |  |  | from posts import isModerator | 
					
						
							| 
									
										
										
										
											2020-12-16 11:19:16 +00:00
										 |  |  | from utils import getFullDomain | 
					
						
							| 
									
										
										
										
											2020-12-17 09:50:04 +00:00
										 |  |  | from utils import getConfigParam | 
					
						
							| 
									
										
										
										
											2020-12-13 12:57:57 +00:00
										 |  |  | from utils import isDormant | 
					
						
							| 
									
										
										
										
											2020-12-12 15:36:44 +00:00
										 |  |  | from utils import removeHtml | 
					
						
							| 
									
										
										
										
											2020-11-09 22:44:03 +00:00
										 |  |  | from utils import getDomainFromActor | 
					
						
							|  |  |  | from utils import getNicknameFromActor | 
					
						
							| 
									
										
										
										
											2021-02-13 11:37:02 +00:00
										 |  |  | from utils import isFeaturedWriter | 
					
						
							| 
									
										
										
										
											2020-11-09 22:44:03 +00:00
										 |  |  | from blocking import isBlocked | 
					
						
							| 
									
										
										
										
											2021-01-02 11:37:24 +00:00
										 |  |  | from follow import isFollowerOfPerson | 
					
						
							| 
									
										
										
										
											2020-11-09 22:44:03 +00:00
										 |  |  | from follow import isFollowingActor | 
					
						
							|  |  |  | from followingCalendar import receivingCalendarEvents | 
					
						
							| 
									
										
										
										
											2020-11-12 17:05:38 +00:00
										 |  |  | from webapp_utils import htmlHeaderWithExternalStyle | 
					
						
							| 
									
										
										
										
											2020-11-09 22:44:03 +00:00
										 |  |  | from webapp_utils import htmlFooter | 
					
						
							| 
									
										
										
										
											2020-12-12 10:38:48 +00:00
										 |  |  | from webapp_utils import getBrokenLinkSubstitute | 
					
						
							| 
									
										
										
										
											2021-02-12 19:29:10 +00:00
										 |  |  | from webapp_utils import htmlKeyboardNavigation | 
					
						
							| 
									
										
										
										
											2020-11-09 22:44:03 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-11-10 20:44:38 +00:00
										 |  |  | def htmlPersonOptions(defaultTimeline: str, | 
					
						
							|  |  |  |                       cssCache: {}, translate: {}, baseDir: str, | 
					
						
							| 
									
										
										
										
											2020-11-09 22:44:03 +00:00
										 |  |  |                       domain: str, domainFull: str, | 
					
						
							|  |  |  |                       originPathStr: str, | 
					
						
							|  |  |  |                       optionsActor: str, | 
					
						
							|  |  |  |                       optionsProfileUrl: str, | 
					
						
							|  |  |  |                       optionsLink: str, | 
					
						
							|  |  |  |                       pageNumber: int, | 
					
						
							|  |  |  |                       donateUrl: str, | 
					
						
							|  |  |  |                       xmppAddress: str, | 
					
						
							|  |  |  |                       matrixAddress: str, | 
					
						
							|  |  |  |                       ssbAddress: str, | 
					
						
							|  |  |  |                       blogAddress: str, | 
					
						
							|  |  |  |                       toxAddress: str, | 
					
						
							| 
									
										
										
										
											2020-12-24 16:48:03 +00:00
										 |  |  |                       briarAddress: str, | 
					
						
							| 
									
										
										
										
											2020-11-29 12:50:41 +00:00
										 |  |  |                       jamiAddress: str, | 
					
						
							| 
									
										
										
										
											2020-11-09 22:44:03 +00:00
										 |  |  |                       PGPpubKey: str, | 
					
						
							|  |  |  |                       PGPfingerprint: str, | 
					
						
							| 
									
										
										
										
											2020-12-13 12:57:57 +00:00
										 |  |  |                       emailAddress: str, | 
					
						
							| 
									
										
										
										
											2020-12-20 13:54:54 +00:00
										 |  |  |                       dormantMonths: int, | 
					
						
							| 
									
										
										
										
											2021-01-02 11:06:08 +00:00
										 |  |  |                       backToPath: str, | 
					
						
							| 
									
										
										
										
											2021-01-12 11:08:54 +00:00
										 |  |  |                       lockedAccount: bool, | 
					
						
							| 
									
										
										
										
											2021-01-22 20:35:14 +00:00
										 |  |  |                       movedTo: str, | 
					
						
							| 
									
										
										
										
											2021-02-12 19:29:10 +00:00
										 |  |  |                       alsoKnownAs: [], | 
					
						
							| 
									
										
										
										
											2021-02-13 11:37:02 +00:00
										 |  |  |                       textModeBanner: str, | 
					
						
							| 
									
										
										
										
											2021-02-23 17:29:22 +00:00
										 |  |  |                       newsInstance: bool, | 
					
						
							|  |  |  |                       authorized: bool) -> str: | 
					
						
							| 
									
										
										
										
											2020-11-09 22:44:03 +00:00
										 |  |  |     """Show options for a person: view/follow/block/report
 | 
					
						
							|  |  |  |     """
 | 
					
						
							|  |  |  |     optionsDomain, optionsPort = getDomainFromActor(optionsActor) | 
					
						
							| 
									
										
										
										
											2020-12-16 11:19:16 +00:00
										 |  |  |     optionsDomainFull = getFullDomain(optionsDomain, optionsPort) | 
					
						
							| 
									
										
										
										
											2020-11-09 22:44:03 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  |     if os.path.isfile(baseDir + '/accounts/options-background-custom.jpg'): | 
					
						
							|  |  |  |         if not os.path.isfile(baseDir + '/accounts/options-background.jpg'): | 
					
						
							|  |  |  |             copyfile(baseDir + '/accounts/options-background.jpg', | 
					
						
							|  |  |  |                      baseDir + '/accounts/options-background.jpg') | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-12-13 12:57:57 +00:00
										 |  |  |     dormant = False | 
					
						
							| 
									
										
										
										
											2020-11-09 22:44:03 +00:00
										 |  |  |     followStr = 'Follow' | 
					
						
							|  |  |  |     blockStr = 'Block' | 
					
						
							|  |  |  |     nickname = None | 
					
						
							|  |  |  |     optionsNickname = None | 
					
						
							| 
									
										
										
										
											2021-01-02 11:37:24 +00:00
										 |  |  |     followsYou = False | 
					
						
							| 
									
										
										
										
											2020-11-09 22:44:03 +00:00
										 |  |  |     if originPathStr.startswith('/users/'): | 
					
						
							|  |  |  |         nickname = originPathStr.split('/users/')[1] | 
					
						
							|  |  |  |         if '/' in nickname: | 
					
						
							|  |  |  |             nickname = nickname.split('/')[0] | 
					
						
							|  |  |  |         if '?' in nickname: | 
					
						
							|  |  |  |             nickname = nickname.split('?')[0] | 
					
						
							|  |  |  |         followerDomain, followerPort = getDomainFromActor(optionsActor) | 
					
						
							|  |  |  |         if isFollowingActor(baseDir, nickname, domain, optionsActor): | 
					
						
							|  |  |  |             followStr = 'Unfollow' | 
					
						
							| 
									
										
										
										
											2020-12-13 12:57:57 +00:00
										 |  |  |             dormant = \ | 
					
						
							|  |  |  |                 isDormant(baseDir, nickname, domain, optionsActor, | 
					
						
							|  |  |  |                           dormantMonths) | 
					
						
							| 
									
										
										
										
											2020-11-09 22:44:03 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  |         optionsNickname = getNicknameFromActor(optionsActor) | 
					
						
							| 
									
										
										
										
											2020-12-16 11:19:16 +00:00
										 |  |  |         optionsDomainFull = getFullDomain(optionsDomain, optionsPort) | 
					
						
							| 
									
										
										
										
											2021-01-02 11:37:24 +00:00
										 |  |  |         followsYou = \ | 
					
						
							|  |  |  |             isFollowerOfPerson(baseDir, | 
					
						
							|  |  |  |                                nickname, domain, | 
					
						
							|  |  |  |                                optionsNickname, optionsDomainFull) | 
					
						
							| 
									
										
										
										
											2020-11-09 22:44:03 +00:00
										 |  |  |         if isBlocked(baseDir, nickname, domain, | 
					
						
							|  |  |  |                      optionsNickname, optionsDomainFull): | 
					
						
							|  |  |  |             blockStr = 'Block' | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     optionsLinkStr = '' | 
					
						
							|  |  |  |     if optionsLink: | 
					
						
							|  |  |  |         optionsLinkStr = \ | 
					
						
							|  |  |  |             '    <input type="hidden" name="postUrl" value="' + \ | 
					
						
							|  |  |  |             optionsLink + '">\n' | 
					
						
							|  |  |  |     cssFilename = baseDir + '/epicyon-options.css' | 
					
						
							|  |  |  |     if os.path.isfile(baseDir + '/options.css'): | 
					
						
							|  |  |  |         cssFilename = baseDir + '/options.css' | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     # To snooze, or not to snooze? That is the question | 
					
						
							|  |  |  |     snoozeButtonStr = 'Snooze' | 
					
						
							|  |  |  |     if nickname: | 
					
						
							|  |  |  |         if isPersonSnoozed(baseDir, nickname, domain, optionsActor): | 
					
						
							|  |  |  |             snoozeButtonStr = 'Unsnooze' | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     donateStr = '' | 
					
						
							|  |  |  |     if donateUrl: | 
					
						
							|  |  |  |         donateStr = \ | 
					
						
							|  |  |  |             '    <a href="' + donateUrl + \ | 
					
						
							| 
									
										
										
										
											2021-02-12 19:30:22 +00:00
										 |  |  |             ' tabindex="-1""><button class="button" name="submitDonate">' + \ | 
					
						
							| 
									
										
										
										
											2020-11-09 22:44:03 +00:00
										 |  |  |             translate['Donate'] + '</button></a>\n' | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-01-11 19:46:21 +00:00
										 |  |  |     instanceTitle = \ | 
					
						
							|  |  |  |         getConfigParam(baseDir, 'instanceTitle') | 
					
						
							|  |  |  |     optionsStr = htmlHeaderWithExternalStyle(cssFilename, instanceTitle) | 
					
						
							| 
									
										
										
										
											2021-02-12 19:29:10 +00:00
										 |  |  |     optionsStr += htmlKeyboardNavigation(textModeBanner, {}) | 
					
						
							| 
									
										
										
										
											2020-11-09 22:44:03 +00:00
										 |  |  |     optionsStr += '<br><br>\n' | 
					
						
							|  |  |  |     optionsStr += '<div class="options">\n' | 
					
						
							|  |  |  |     optionsStr += '  <div class="optionsAvatar">\n' | 
					
						
							|  |  |  |     optionsStr += '  <center>\n' | 
					
						
							|  |  |  |     optionsStr += '  <a href="' + optionsActor + '">\n' | 
					
						
							|  |  |  |     optionsStr += '  <img loading="lazy" src="' + optionsProfileUrl + \ | 
					
						
							| 
									
										
										
										
											2021-02-01 20:03:07 +00:00
										 |  |  |         '" alt="" ' + getBrokenLinkSubstitute() + '/></a>\n' | 
					
						
							| 
									
										
										
										
											2020-11-09 22:44:03 +00:00
										 |  |  |     handle = getNicknameFromActor(optionsActor) + '@' + optionsDomain | 
					
						
							| 
									
										
										
										
											2020-12-13 12:57:57 +00:00
										 |  |  |     handleShown = handle | 
					
						
							| 
									
										
										
										
											2021-01-02 11:06:08 +00:00
										 |  |  |     if lockedAccount: | 
					
						
							|  |  |  |         handleShown += '🔒' | 
					
						
							| 
									
										
										
										
											2021-01-12 11:08:54 +00:00
										 |  |  |     if movedTo: | 
					
						
							|  |  |  |         handleShown += ' ⌂' | 
					
						
							| 
									
										
										
										
											2020-12-13 12:57:57 +00:00
										 |  |  |     if dormant: | 
					
						
							| 
									
										
										
										
											2020-12-13 13:43:09 +00:00
										 |  |  |         handleShown += ' 💤' | 
					
						
							| 
									
										
										
										
											2020-11-09 22:44:03 +00:00
										 |  |  |     optionsStr += \ | 
					
						
							|  |  |  |         '  <p class="optionsText">' + translate['Options for'] + \ | 
					
						
							| 
									
										
										
										
											2020-12-13 12:57:57 +00:00
										 |  |  |         ' @' + handleShown + '</p>\n' | 
					
						
							| 
									
										
										
										
											2021-01-02 11:37:24 +00:00
										 |  |  |     if followsYou: | 
					
						
							|  |  |  |         optionsStr += \ | 
					
						
							|  |  |  |             '  <p class="optionsText">' + translate['Follows you'] + '</p>\n' | 
					
						
							| 
									
										
										
										
											2021-01-12 11:08:54 +00:00
										 |  |  |     if movedTo: | 
					
						
							|  |  |  |         newNickname = getNicknameFromActor(movedTo) | 
					
						
							|  |  |  |         newDomain, newPort = getDomainFromActor(movedTo) | 
					
						
							|  |  |  |         if newNickname and newDomain: | 
					
						
							|  |  |  |             newHandle = newNickname + '@' + newDomain | 
					
						
							|  |  |  |             optionsStr += \ | 
					
						
							|  |  |  |                 '  <p class="optionsText">' + \ | 
					
						
							|  |  |  |                 translate['New account'] + \ | 
					
						
							| 
									
										
										
										
											2021-01-12 13:18:08 +00:00
										 |  |  |                 ': <a href="' + movedTo + '">@' + newHandle + '</a></p>\n' | 
					
						
							| 
									
										
										
										
											2021-01-22 20:35:14 +00:00
										 |  |  |     elif alsoKnownAs: | 
					
						
							| 
									
										
										
										
											2021-01-23 10:03:50 +00:00
										 |  |  |         otherAccountsHtml = \ | 
					
						
							| 
									
										
										
										
											2021-01-22 20:35:14 +00:00
										 |  |  |             '  <p class="optionsText">' + \ | 
					
						
							|  |  |  |             translate['Other accounts'] + ': ' | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-01-23 10:03:50 +00:00
										 |  |  |         ctr = 0 | 
					
						
							| 
									
										
										
										
											2021-01-22 20:35:14 +00:00
										 |  |  |         if isinstance(alsoKnownAs, list): | 
					
						
							|  |  |  |             for altActor in alsoKnownAs: | 
					
						
							| 
									
										
										
										
											2021-01-23 10:03:50 +00:00
										 |  |  |                 if altActor == optionsActor: | 
					
						
							|  |  |  |                     continue | 
					
						
							| 
									
										
										
										
											2021-01-22 20:35:14 +00:00
										 |  |  |                 if ctr > 0: | 
					
						
							| 
									
										
										
										
											2021-01-23 10:03:50 +00:00
										 |  |  |                     otherAccountsHtml += ' ' | 
					
						
							| 
									
										
										
										
											2021-01-22 20:35:14 +00:00
										 |  |  |                 ctr += 1 | 
					
						
							|  |  |  |                 altDomain, altPort = getDomainFromActor(altActor) | 
					
						
							| 
									
										
										
										
											2021-01-23 10:03:50 +00:00
										 |  |  |                 otherAccountsHtml += \ | 
					
						
							| 
									
										
										
										
											2021-01-22 20:35:14 +00:00
										 |  |  |                     '<a href="' + altActor + '">' + altDomain + '</a>' | 
					
						
							|  |  |  |         elif isinstance(alsoKnownAs, str): | 
					
						
							| 
									
										
										
										
											2021-01-23 10:03:50 +00:00
										 |  |  |             if alsoKnownAs != optionsActor: | 
					
						
							|  |  |  |                 ctr += 1 | 
					
						
							|  |  |  |                 altDomain, altPort = getDomainFromActor(alsoKnownAs) | 
					
						
							|  |  |  |                 otherAccountsHtml += \ | 
					
						
							|  |  |  |                     '<a href="' + alsoKnownAs + '">' + altDomain + '</a>' | 
					
						
							|  |  |  |         otherAccountsHtml += '</p>\n' | 
					
						
							|  |  |  |         if ctr > 0: | 
					
						
							|  |  |  |             optionsStr += otherAccountsHtml | 
					
						
							| 
									
										
										
										
											2020-11-09 22:44:03 +00:00
										 |  |  |     if emailAddress: | 
					
						
							|  |  |  |         optionsStr += \ | 
					
						
							|  |  |  |             '<p class="imText">' + translate['Email'] + \ | 
					
						
							|  |  |  |             ': <a href="mailto:' + \ | 
					
						
							| 
									
										
										
										
											2020-12-12 15:36:44 +00:00
										 |  |  |             emailAddress + '">' + removeHtml(emailAddress) + '</a></p>\n' | 
					
						
							| 
									
										
										
										
											2020-11-09 22:44:03 +00:00
										 |  |  |     if xmppAddress: | 
					
						
							|  |  |  |         optionsStr += \ | 
					
						
							|  |  |  |             '<p class="imText">' + translate['XMPP'] + \ | 
					
						
							| 
									
										
										
										
											2020-12-12 15:36:44 +00:00
										 |  |  |             ': <a href="xmpp:' + removeHtml(xmppAddress) + '">' + \ | 
					
						
							| 
									
										
										
										
											2020-11-09 22:44:03 +00:00
										 |  |  |             xmppAddress + '</a></p>\n' | 
					
						
							|  |  |  |     if matrixAddress: | 
					
						
							|  |  |  |         optionsStr += \ | 
					
						
							|  |  |  |             '<p class="imText">' + translate['Matrix'] + ': ' + \ | 
					
						
							| 
									
										
										
										
											2020-12-12 15:36:44 +00:00
										 |  |  |             removeHtml(matrixAddress) + '</p>\n' | 
					
						
							| 
									
										
										
										
											2020-11-09 22:44:03 +00:00
										 |  |  |     if ssbAddress: | 
					
						
							|  |  |  |         optionsStr += \ | 
					
						
							| 
									
										
										
										
											2020-12-12 15:36:44 +00:00
										 |  |  |             '<p class="imText">SSB: ' + removeHtml(ssbAddress) + '</p>\n' | 
					
						
							| 
									
										
										
										
											2020-11-09 22:44:03 +00:00
										 |  |  |     if blogAddress: | 
					
						
							|  |  |  |         optionsStr += \ | 
					
						
							| 
									
										
										
										
											2020-12-12 15:36:44 +00:00
										 |  |  |             '<p class="imText">Blog: <a href="' + \ | 
					
						
							|  |  |  |             removeHtml(blogAddress) + '">' + \ | 
					
						
							|  |  |  |             removeHtml(blogAddress) + '</a></p>\n' | 
					
						
							| 
									
										
										
										
											2020-11-09 22:44:03 +00:00
										 |  |  |     if toxAddress: | 
					
						
							|  |  |  |         optionsStr += \ | 
					
						
							| 
									
										
										
										
											2020-12-12 15:36:44 +00:00
										 |  |  |             '<p class="imText">Tox: ' + removeHtml(toxAddress) + '</p>\n' | 
					
						
							| 
									
										
										
										
											2020-12-24 16:48:03 +00:00
										 |  |  |     if briarAddress: | 
					
						
							| 
									
										
										
										
											2020-12-24 17:11:18 +00:00
										 |  |  |         if briarAddress.startswith('briar://'): | 
					
						
							|  |  |  |             optionsStr += \ | 
					
						
							|  |  |  |                 '<p class="imText">' + \ | 
					
						
							|  |  |  |                 removeHtml(briarAddress) + '</p>\n' | 
					
						
							|  |  |  |         else: | 
					
						
							|  |  |  |             optionsStr += \ | 
					
						
							|  |  |  |                 '<p class="imText">briar://' + \ | 
					
						
							|  |  |  |                 removeHtml(briarAddress) + '</p>\n' | 
					
						
							| 
									
										
										
										
											2020-11-29 12:50:41 +00:00
										 |  |  |     if jamiAddress: | 
					
						
							|  |  |  |         optionsStr += \ | 
					
						
							| 
									
										
										
										
											2020-12-12 15:36:44 +00:00
										 |  |  |             '<p class="imText">Jami: ' + removeHtml(jamiAddress) + '</p>\n' | 
					
						
							| 
									
										
										
										
											2020-11-09 22:44:03 +00:00
										 |  |  |     if PGPfingerprint: | 
					
						
							|  |  |  |         optionsStr += '<p class="pgp">PGP: ' + \ | 
					
						
							| 
									
										
										
										
											2020-12-12 15:36:44 +00:00
										 |  |  |             removeHtml(PGPfingerprint).replace('\n', '<br>') + '</p>\n' | 
					
						
							| 
									
										
										
										
											2020-11-09 22:44:03 +00:00
										 |  |  |     if PGPpubKey: | 
					
						
							|  |  |  |         optionsStr += '<p class="pgp">' + \ | 
					
						
							| 
									
										
										
										
											2020-12-12 15:36:44 +00:00
										 |  |  |             removeHtml(PGPpubKey).replace('\n', '<br>') + '</p>\n' | 
					
						
							| 
									
										
										
										
											2020-11-09 22:44:03 +00:00
										 |  |  |     optionsStr += '  <form method="POST" action="' + \ | 
					
						
							|  |  |  |         originPathStr + '/personoptions">\n' | 
					
						
							|  |  |  |     optionsStr += '    <input type="hidden" name="pageNumber" value="' + \ | 
					
						
							|  |  |  |         str(pageNumber) + '">\n' | 
					
						
							|  |  |  |     optionsStr += '    <input type="hidden" name="actor" value="' + \ | 
					
						
							|  |  |  |         optionsActor + '">\n' | 
					
						
							|  |  |  |     optionsStr += '    <input type="hidden" name="avatarUrl" value="' + \ | 
					
						
							|  |  |  |         optionsProfileUrl + '">\n' | 
					
						
							| 
									
										
										
										
											2021-02-23 17:29:22 +00:00
										 |  |  |     if authorized: | 
					
						
							| 
									
										
										
										
											2021-02-23 17:51:48 +00:00
										 |  |  |         if originPathStr == '/users/' + nickname: | 
					
						
							|  |  |  |             if optionsNickname: | 
					
						
							|  |  |  |                 handle = optionsNickname + '@' + optionsDomainFull | 
					
						
							|  |  |  |                 petname = getPetName(baseDir, nickname, domain, handle) | 
					
						
							|  |  |  |                 optionsStr += \ | 
					
						
							|  |  |  |                     '    ' + translate['Petname'] + ': \n' + \ | 
					
						
							|  |  |  |                     '    <input type="text" name="optionpetname" value="' + \ | 
					
						
							|  |  |  |                     petname + '">\n' \ | 
					
						
							|  |  |  |                     '    <button type="submit" class="buttonsmall" ' + \ | 
					
						
							|  |  |  |                     'name="submitPetname">' + \ | 
					
						
							|  |  |  |                     translate['Submit'] + '</button><br>\n' | 
					
						
							| 
									
										
										
										
											2020-11-09 22:44:03 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-02-23 17:51:48 +00:00
										 |  |  |             # checkbox for receiving calendar events | 
					
						
							|  |  |  |             if isFollowingActor(baseDir, nickname, domain, optionsActor): | 
					
						
							| 
									
										
										
										
											2021-02-23 17:29:22 +00:00
										 |  |  |                 checkboxStr = \ | 
					
						
							|  |  |  |                     '    <input type="checkbox" ' + \ | 
					
						
							| 
									
										
										
										
											2021-02-23 17:51:48 +00:00
										 |  |  |                     'class="profilecheckbox" name="onCalendar" checked> ' + \ | 
					
						
							|  |  |  |                     translate['Receive calendar events from this account'] + \ | 
					
						
							| 
									
										
										
										
											2021-02-23 17:29:22 +00:00
										 |  |  |                     '\n    <button type="submit" class="buttonsmall" ' + \ | 
					
						
							| 
									
										
										
										
											2021-02-23 17:51:48 +00:00
										 |  |  |                     'name="submitOnCalendar">' + \ | 
					
						
							| 
									
										
										
										
											2021-02-23 17:29:22 +00:00
										 |  |  |                     translate['Submit'] + '</button><br>\n' | 
					
						
							| 
									
										
										
										
											2021-02-23 17:51:48 +00:00
										 |  |  |                 if not receivingCalendarEvents(baseDir, nickname, domain, | 
					
						
							|  |  |  |                                                optionsNickname, | 
					
						
							|  |  |  |                                                optionsDomainFull): | 
					
						
							| 
									
										
										
										
											2021-02-23 17:29:22 +00:00
										 |  |  |                     checkboxStr = checkboxStr.replace(' checked>', '>') | 
					
						
							|  |  |  |                 optionsStr += checkboxStr | 
					
						
							| 
									
										
										
										
											2020-12-17 14:25:00 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-02-23 17:51:48 +00:00
										 |  |  |             # checkbox for permission to post to newswire | 
					
						
							|  |  |  |             newswirePostsPermitted = False | 
					
						
							|  |  |  |             if optionsDomainFull == domainFull: | 
					
						
							|  |  |  |                 adminNickname = getConfigParam(baseDir, 'admin') | 
					
						
							|  |  |  |                 if (nickname == adminNickname or | 
					
						
							|  |  |  |                     (isModerator(baseDir, nickname) and | 
					
						
							|  |  |  |                      not isModerator(baseDir, optionsNickname))): | 
					
						
							|  |  |  |                     newswireBlockedFilename = \ | 
					
						
							|  |  |  |                         baseDir + '/accounts/' + \ | 
					
						
							|  |  |  |                         optionsNickname + '@' + optionsDomain + '/.nonewswire' | 
					
						
							|  |  |  |                     checkboxStr = \ | 
					
						
							|  |  |  |                         '    <input type="checkbox" ' + \ | 
					
						
							|  |  |  |                         'class="profilecheckbox" ' + \ | 
					
						
							|  |  |  |                         'name="postsToNews" checked> ' + \ | 
					
						
							|  |  |  |                         translate['Allow news posts'] + \ | 
					
						
							|  |  |  |                         '\n    <button type="submit" class="buttonsmall" ' + \ | 
					
						
							|  |  |  |                         'name="submitPostToNews">' + \ | 
					
						
							|  |  |  |                         translate['Submit'] + '</button><br>\n' | 
					
						
							|  |  |  |                     if os.path.isfile(newswireBlockedFilename): | 
					
						
							|  |  |  |                         checkboxStr = checkboxStr.replace(' checked>', '>') | 
					
						
							|  |  |  |                     else: | 
					
						
							|  |  |  |                         newswirePostsPermitted = True | 
					
						
							|  |  |  |                     optionsStr += checkboxStr | 
					
						
							| 
									
										
										
										
											2021-02-13 11:37:02 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-02-23 17:51:48 +00:00
										 |  |  |             # whether blogs created by this account are moderated on | 
					
						
							|  |  |  |             # the newswire | 
					
						
							|  |  |  |             if newswirePostsPermitted: | 
					
						
							|  |  |  |                 moderatedFilename = \ | 
					
						
							|  |  |  |                     baseDir + '/accounts/' + \ | 
					
						
							|  |  |  |                     optionsNickname + '@' + \ | 
					
						
							|  |  |  |                     optionsDomain + '/.newswiremoderated' | 
					
						
							| 
									
										
										
										
											2021-02-23 17:29:22 +00:00
										 |  |  |                 checkboxStr = \ | 
					
						
							|  |  |  |                     '    <input type="checkbox" ' + \ | 
					
						
							| 
									
										
										
										
											2021-02-23 17:51:48 +00:00
										 |  |  |                     'class="profilecheckbox" name="modNewsPosts" checked> ' + \ | 
					
						
							|  |  |  |                     translate['News posts are moderated'] + \ | 
					
						
							| 
									
										
										
										
											2021-02-23 17:29:22 +00:00
										 |  |  |                     '\n    <button type="submit" class="buttonsmall" ' + \ | 
					
						
							| 
									
										
										
										
											2021-02-23 17:51:48 +00:00
										 |  |  |                     'name="submitModNewsPosts">' + \ | 
					
						
							| 
									
										
										
										
											2021-02-23 17:29:22 +00:00
										 |  |  |                     translate['Submit'] + '</button><br>\n' | 
					
						
							| 
									
										
										
										
											2021-02-23 17:51:48 +00:00
										 |  |  |                 if not os.path.isfile(moderatedFilename): | 
					
						
							| 
									
										
										
										
											2021-02-23 17:29:22 +00:00
										 |  |  |                     checkboxStr = checkboxStr.replace(' checked>', '>') | 
					
						
							|  |  |  |                 optionsStr += checkboxStr | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-02-23 17:51:48 +00:00
										 |  |  |             # checkbox for permission to post to featured articles | 
					
						
							|  |  |  |             if newsInstance and optionsDomainFull == domainFull: | 
					
						
							|  |  |  |                 adminNickname = getConfigParam(baseDir, 'admin') | 
					
						
							|  |  |  |                 if (nickname == adminNickname or | 
					
						
							|  |  |  |                     (isModerator(baseDir, nickname) and | 
					
						
							|  |  |  |                      not isModerator(baseDir, optionsNickname))): | 
					
						
							|  |  |  |                     checkboxStr = \ | 
					
						
							|  |  |  |                         '    <input type="checkbox" ' + \ | 
					
						
							|  |  |  |                         'class="profilecheckbox" ' + \ | 
					
						
							|  |  |  |                         'name="postsToFeatures" checked> ' + \ | 
					
						
							|  |  |  |                         translate['Featured writer'] + \ | 
					
						
							|  |  |  |                         '\n    <button type="submit" class="buttonsmall" ' + \ | 
					
						
							|  |  |  |                         'name="submitPostToFeatures">' + \ | 
					
						
							|  |  |  |                         translate['Submit'] + '</button><br>\n' | 
					
						
							|  |  |  |                     if not isFeaturedWriter(baseDir, optionsNickname, | 
					
						
							|  |  |  |                                             optionsDomain): | 
					
						
							|  |  |  |                         checkboxStr = checkboxStr.replace(' checked>', '>') | 
					
						
							|  |  |  |                     optionsStr += checkboxStr | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-11-09 22:44:03 +00:00
										 |  |  |     optionsStr += optionsLinkStr | 
					
						
							| 
									
										
										
										
											2020-11-10 20:40:19 +00:00
										 |  |  |     backPath = '/' | 
					
						
							|  |  |  |     if nickname: | 
					
						
							| 
									
										
										
										
											2020-11-10 20:44:38 +00:00
										 |  |  |         backPath = '/users/' + nickname + '/' + defaultTimeline | 
					
						
							| 
									
										
										
										
											2020-12-20 13:54:54 +00:00
										 |  |  |         if 'moderation' in backToPath: | 
					
						
							|  |  |  |             backPath = '/users/' + nickname + '/moderation' | 
					
						
							| 
									
										
										
										
											2021-02-23 17:59:56 +00:00
										 |  |  |     if authorized and originPathStr == '/users/' + nickname: | 
					
						
							| 
									
										
										
										
											2021-02-23 17:58:52 +00:00
										 |  |  |         optionsStr += \ | 
					
						
							|  |  |  |             '    <a href="' + backPath + '"><button type="button" ' + \ | 
					
						
							|  |  |  |             'class="buttonIcon" name="submitBack">' + translate['Go Back'] + \ | 
					
						
							|  |  |  |             '</button></a>\n' | 
					
						
							|  |  |  |     else: | 
					
						
							|  |  |  |         optionsStr += \ | 
					
						
							|  |  |  |             '    <a href="' + originPathStr + '"><button type="button" ' + \ | 
					
						
							|  |  |  |             'class="buttonIcon" name="submitBack">' + translate['Go Back'] + \ | 
					
						
							|  |  |  |             '</button></a>\n' | 
					
						
							| 
									
										
										
										
											2021-02-23 17:29:22 +00:00
										 |  |  |     if authorized: | 
					
						
							|  |  |  |         optionsStr += \ | 
					
						
							|  |  |  |             '    <button type="submit" class="button" name="submitView">' + \ | 
					
						
							|  |  |  |             translate['View'] + '</button>\n' | 
					
						
							| 
									
										
										
										
											2020-11-09 22:44:03 +00:00
										 |  |  |     optionsStr += donateStr | 
					
						
							| 
									
										
										
										
											2021-02-23 17:29:22 +00:00
										 |  |  |     if authorized: | 
					
						
							|  |  |  |         optionsStr += \ | 
					
						
							|  |  |  |             '    <button type="submit" class="button" name="submit' + \ | 
					
						
							|  |  |  |             followStr + '">' + translate[followStr] + '</button>\n' | 
					
						
							|  |  |  |         optionsStr += \ | 
					
						
							|  |  |  |             '    <button type="submit" class="button" name="submit' + \ | 
					
						
							|  |  |  |             blockStr + '">' + translate[blockStr] + '</button>\n' | 
					
						
							|  |  |  |         optionsStr += \ | 
					
						
							|  |  |  |             '    <button type="submit" class="button" name="submitDM">' + \ | 
					
						
							|  |  |  |             translate['DM'] + '</button>\n' | 
					
						
							|  |  |  |         optionsStr += \ | 
					
						
							|  |  |  |             '    <button type="submit" class="button" name="submit' + \ | 
					
						
							|  |  |  |             snoozeButtonStr + '">' + translate[snoozeButtonStr] + \ | 
					
						
							|  |  |  |             '</button>\n' | 
					
						
							| 
									
										
										
										
											2020-12-16 18:04:32 +00:00
										 |  |  |         optionsStr += \ | 
					
						
							| 
									
										
										
										
											2020-12-16 18:24:04 +00:00
										 |  |  |             '    <button type="submit" class="button" ' + \ | 
					
						
							| 
									
										
										
										
											2021-02-23 17:29:22 +00:00
										 |  |  |             'name="submitReport">' + translate['Report'] + '</button>\n' | 
					
						
							| 
									
										
										
										
											2020-11-09 22:44:03 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-02-23 17:29:22 +00:00
										 |  |  |         if isModerator(baseDir, nickname): | 
					
						
							|  |  |  |             optionsStr += \ | 
					
						
							|  |  |  |                 '    <button type="submit" class="button" ' + \ | 
					
						
							|  |  |  |                 'name="submitPersonInfo">' + \ | 
					
						
							|  |  |  |                 translate['Info'] + '</button>\n' | 
					
						
							| 
									
										
										
										
											2020-11-09 22:44:03 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-02-23 17:29:22 +00:00
										 |  |  |         personNotes = '' | 
					
						
							| 
									
										
										
										
											2021-02-23 17:45:53 +00:00
										 |  |  |         if originPathStr == '/users/' + nickname: | 
					
						
							| 
									
										
										
										
											2021-02-23 17:35:26 +00:00
										 |  |  |             personNotesFilename = \ | 
					
						
							|  |  |  |                 baseDir + '/accounts/' + nickname + '@' + domain + \ | 
					
						
							|  |  |  |                 '/notes/' + handle + '.txt' | 
					
						
							|  |  |  |             if os.path.isfile(personNotesFilename): | 
					
						
							|  |  |  |                 with open(personNotesFilename, 'r') as fp: | 
					
						
							|  |  |  |                     personNotes = fp.read() | 
					
						
							| 
									
										
										
										
											2021-02-23 17:29:22 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  |         optionsStr += \ | 
					
						
							|  |  |  |             '    <br><br>' + translate['Notes'] + ': \n' | 
					
						
							|  |  |  |         optionsStr += '    <button type="submit" class="buttonsmall" ' + \ | 
					
						
							|  |  |  |             'name="submitPersonNotes">' + \ | 
					
						
							|  |  |  |             translate['Submit'] + '</button><br>\n' | 
					
						
							|  |  |  |         optionsStr += \ | 
					
						
							|  |  |  |             '    <textarea id="message" ' + \ | 
					
						
							| 
									
										
										
										
											2021-02-28 14:26:04 +00:00
										 |  |  |             'name="optionnotes" style="height:400px" spellcheck="true">' + \ | 
					
						
							| 
									
										
										
										
											2021-02-23 17:29:22 +00:00
										 |  |  |             personNotes + '</textarea>\n' | 
					
						
							| 
									
										
										
										
											2020-11-09 22:44:03 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  |     optionsStr += '  </form>\n' | 
					
						
							|  |  |  |     optionsStr += '</center>\n' | 
					
						
							|  |  |  |     optionsStr += '</div>\n' | 
					
						
							|  |  |  |     optionsStr += '</div>\n' | 
					
						
							|  |  |  |     optionsStr += htmlFooter() | 
					
						
							|  |  |  |     return optionsStr |