\n'
replyStr = '\n'
# if replying to a non-public post then also make
# this post non-public
if not isPublicPostFromUrl(baseDir, nickname, domain,
inReplyTo):
newPostPath = path
if '?' in newPostPath:
newPostPath = newPostPath.split('?')[0]
if newPostPath.endswith('/newpost'):
path = path.replace('/newpost', '/newfollowers')
elif newPostPath.endswith('/newunlisted'):
path = path.replace('/newunlisted', '/newfollowers')
showPublicOnDropdown = False
else:
newPostText = \
'
' + \
translate['Write your report below.'] + '
\n'
# custom report header with any additional instructions
if os.path.isfile(baseDir + '/accounts/report.txt'):
with open(baseDir + '/accounts/report.txt', 'r') as file:
customReportText = file.read()
if '' not in customReportText:
customReportText = \
'
' + \
customReportText + '
\n'
repStr = '
'
customReportText = \
customReportText.replace('
', repStr)
newPostText += customReportText
idx = 'This message only goes to moderators, even if it ' + \
'mentions other fediverse addresses.'
newPostText += \
'
\n'
citationsSeparator = '#####'
with open(citationsFilename, "r") as f:
citations = f.readlines()
for line in citations:
if citationsSeparator not in line:
continue
sections = line.strip().split(citationsSeparator)
if len(sections) != 3:
continue
title = sections[1]
link = sections[2]
citationsStr += \
'
\n'
# Event posts don't allow replies - they're just an announcement.
# They also have a few more checkboxes
dateAndLocation += \
'\n'
dateAndLocation += \
'
' + \
'
\n'
else:
dateAndLocation += \
'\n'
if not inReplyTo and endpoint != 'newevent':
dateAndLocation += \
'\n'
if endpoint != 'newevent':
dateAndLocation += \
'
\n'
# select a date and time for this post
dateAndLocation += '\n'
dateAndLocation += '\n'
dateAndLocation += '
\n'
else:
dateAndLocation += '
\n'
dateAndLocation += '
\n'
dateAndLocation += \
'
\n'
# select start time for the event
dateAndLocation += '\n'
dateAndLocation += '\n'
dateAndLocation += '
\n'
# select end time for the event
dateAndLocation += \
' \n'
dateAndLocation += '\n'
dateAndLocation += '\n'
dateAndLocation += '\n'
if endpoint == 'newevent':
dateAndLocation += '
\n'
if not defaultTimeline == 'tlfeatures':
newPostForm += (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
newPostForm += (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
# TODO: Better solution - Currently this is a duplicate of list created in 'webapp_timeline.py'
userPages = ['inbox', 'outbox', 'dm', 'tlreplies', 'tlblogs', 'tlmedia', 'tlshares', \
'tlsaves', 'tlevents', 'tlbookmarks', 'moderation', 'search', \
'followers', 'newfollowers', 'newdm', 'newpost', 'newblog', 'newevent']
# Full row "navbar"
if defaultTimeline == 'tlfeatures':
# Show "tab" links instead of standard "buttons"
# NOTE: "inbox" is used as a generic boxName, as with 'User' pages
# 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'
mentionsStr = ''
for m in mentions:
mentionNickname = getNicknameFromActor(m)
if not mentionNickname:
continue
mentionDomain, mentionPort = getDomainFromActor(m)
if not mentionDomain:
continue
if mentionPort:
mentionsHandle = \
'@' + mentionNickname + '@' + \
mentionDomain + ':' + str(mentionPort)
else:
mentionsHandle = '@' + mentionNickname + '@' + mentionDomain
if mentionsHandle not in mentionsStr:
mentionsStr += mentionsHandle + ' '
# build suffixes so that any replies or mentions are
# preserved when switching between scopes
dropdownNewPostSuffix = '/newpost'
dropdownNewBlogSuffix = '/newblog'
dropdownUnlistedSuffix = '/newunlisted'
dropdownFollowersSuffix = '/newfollowers'
dropdownDMSuffix = '/newdm'
dropdownEventSuffix = '/newevent'
dropdownReminderSuffix = '/newreminder'
dropdownReportSuffix = '/newreport'
if inReplyTo or mentions:
dropdownNewPostSuffix = ''
dropdownNewBlogSuffix = ''
dropdownUnlistedSuffix = ''
dropdownFollowersSuffix = ''
dropdownDMSuffix = ''
dropdownEventSuffix = ''
dropdownReminderSuffix = ''
dropdownReportSuffix = ''
if inReplyTo:
dropdownNewPostSuffix += '?replyto=' + inReplyTo
dropdownNewBlogSuffix += '?replyto=' + inReplyTo
dropdownUnlistedSuffix += '?replyto=' + inReplyTo
dropdownFollowersSuffix += '?replyfollowers=' + inReplyTo
dropdownDMSuffix += '?replydm=' + inReplyTo
for mentionedActor in mentions:
dropdownNewPostSuffix += '?mention=' + mentionedActor
dropdownNewBlogSuffix += '?mention=' + mentionedActor
dropdownUnlistedSuffix += '?mention=' + mentionedActor
dropdownFollowersSuffix += '?mention=' + mentionedActor
dropdownDMSuffix += '?mention=' + mentionedActor
dropdownReportSuffix += '?mention=' + mentionedActor
dropDownContent = ''
if not reportUrl and not shareDescription:
dropDownContent = \
_htmlNewPostDropDown(scopeIcon, scopeDescription,
replyStr,
translate,
showPublicOnDropdown,
defaultTimeline,
pathBase,
dropdownNewPostSuffix,
dropdownNewBlogSuffix,
dropdownUnlistedSuffix,
dropdownFollowersSuffix,
dropdownDMSuffix,
dropdownReminderSuffix,
dropdownEventSuffix,
dropdownReportSuffix)
else:
if not shareDescription:
# reporting a post to moderator
mentionsStr = 'Re: ' + reportUrl + '\n\n' + mentionsStr
# TODO: Place form inside a "page" div for 'News' instances
newPostForm += '
\n'
moderator = isModerator(baseDir, nickname)
# TODO: Add "User" links
if defaultTimeline == 'tlfeatures':
# NOTE: It appears that 'endpoint' is effectively 'boxName'
newPostForm += \
headerButtonsTimeline(defaultTimeline, endpoint, pageNumber,
translate, usersPath,
False, moderator,
False,
baseDir, nickname,
domain, None,
True, userPages)
newPostForm += '
\n'
newPostForm += \
'\n'
# Close "main" and "page" div
newPostForm += '
\n
\n'
if not reportUrl:
newPostForm = \
newPostForm.replace('', '')
newPostForm += htmlFooter()
return newPostForm