__filename__ = "webapp_person_options.py"
__author__ = "Bob Mottram"
__license__ = "AGPL3+"
__version__ = "1.2.0"
__maintainer__ = "Bob Mottram"
__email__ = "bob@libreserver.org"
__status__ = "Production"
__module_group__ = "Web Interface"
import os
from shutil import copyfile
from petnames import getPetName
from person import isPersonSnoozed
from posts import isModerator
from utils import get_full_domain
from utils import getConfigParam
from utils import is_dormant
from utils import removeHtml
from utils import getDomainFromActor
from utils import getNicknameFromActor
from utils import is_featured_writer
from utils import acct_dir
from blocking import isBlocked
from follow import isFollowerOfPerson
from follow import isFollowingActor
from followingCalendar import receivingCalendarEvents
from notifyOnPost import notifyWhenPersonPosts
from webapp_utils import htmlHeaderWithExternalStyle
from webapp_utils import htmlFooter
from webapp_utils import getBrokenLinkSubstitute
from webapp_utils import htmlKeyboardNavigation
def htmlPersonOptions(defaultTimeline: str,
cssCache: {}, translate: {}, base_dir: str,
domain: str, domain_full: str,
originPathStr: str,
optionsActor: str,
optionsProfileUrl: str,
optionsLink: str,
pageNumber: int,
donateUrl: str,
webAddress: str,
xmppAddress: str,
matrixAddress: str,
ssbAddress: str,
blogAddress: str,
toxAddress: str,
briarAddress: str,
jamiAddress: str,
cwtchAddress: str,
EnigmaPubKey: str,
PGPpubKey: str,
PGPfingerprint: str,
emailAddress: str,
dormant_months: int,
backToPath: str,
lockedAccount: bool,
movedTo: str,
alsoKnownAs: [],
text_mode_banner: str,
news_instance: bool,
authorized: bool,
accessKeys: {},
isGroup: bool) -> str:
"""Show options for a person: view/follow/block/report
"""
optionsDomain, optionsPort = getDomainFromActor(optionsActor)
optionsDomainFull = get_full_domain(optionsDomain, optionsPort)
if os.path.isfile(base_dir + '/accounts/options-background-custom.jpg'):
if not os.path.isfile(base_dir + '/accounts/options-background.jpg'):
copyfile(base_dir + '/accounts/options-background.jpg',
base_dir + '/accounts/options-background.jpg')
dormant = False
followStr = 'Follow'
if isGroup:
followStr = 'Join'
blockStr = 'Block'
nickname = None
optionsNickname = None
followsYou = False
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(base_dir, nickname, domain, optionsActor):
followStr = 'Unfollow'
if isGroup:
followStr = 'Leave'
dormant = \
is_dormant(base_dir, nickname, domain, optionsActor,
dormant_months)
optionsNickname = getNicknameFromActor(optionsActor)
optionsDomainFull = get_full_domain(optionsDomain, optionsPort)
followsYou = \
isFollowerOfPerson(base_dir,
nickname, domain,
optionsNickname, optionsDomainFull)
if isBlocked(base_dir, nickname, domain,
optionsNickname, optionsDomainFull):
blockStr = 'Block'
optionsLinkStr = ''
if optionsLink:
optionsLinkStr = \
' \n'
cssFilename = base_dir + '/epicyon-options.css'
if os.path.isfile(base_dir + '/options.css'):
cssFilename = base_dir + '/options.css'
# To snooze, or not to snooze? That is the question
snoozeButtonStr = 'Snooze'
if nickname:
if isPersonSnoozed(base_dir, nickname, domain, optionsActor):
snoozeButtonStr = 'Unsnooze'
donateStr = ''
if donateUrl:
donateStr = \
' \n'
instanceTitle = \
getConfigParam(base_dir, 'instanceTitle')
optionsStr = htmlHeaderWithExternalStyle(cssFilename, instanceTitle, None)
optionsStr += htmlKeyboardNavigation(text_mode_banner, {}, {})
optionsStr += '
\n'
optionsStr += '