2020-11-09 22:44:03 +00:00
|
|
|
__filename__ = "webapp_person_options.py"
|
|
|
|
__author__ = "Bob Mottram"
|
|
|
|
__license__ = "AGPL3+"
|
2022-02-03 13:58:20 +00:00
|
|
|
__version__ = "1.3.0"
|
2020-11-09 22:44:03 +00:00
|
|
|
__maintainer__ = "Bob Mottram"
|
2021-09-10 16:14:50 +00:00
|
|
|
__email__ = "bob@libreserver.org"
|
2020-11-09 22:44:03 +00:00
|
|
|
__status__ = "Production"
|
2021-06-15 15:08:12 +00:00
|
|
|
__module_group__ = "Web Interface"
|
2020-11-09 22:44:03 +00:00
|
|
|
|
|
|
|
import os
|
|
|
|
from shutil import copyfile
|
2021-12-29 21:55:09 +00:00
|
|
|
from petnames import get_pet_name
|
|
|
|
from person import is_person_snoozed
|
2021-12-28 19:33:29 +00:00
|
|
|
from posts import is_moderator
|
2021-12-26 12:45:03 +00:00
|
|
|
from utils import get_full_domain
|
2021-12-26 14:08:58 +00:00
|
|
|
from utils import get_config_param
|
2021-12-26 12:54:51 +00:00
|
|
|
from utils import is_dormant
|
2021-12-27 15:43:22 +00:00
|
|
|
from utils import remove_html
|
2021-12-27 19:05:25 +00:00
|
|
|
from utils import get_domain_from_actor
|
2021-12-27 22:19:18 +00:00
|
|
|
from utils import get_nickname_from_actor
|
2021-12-26 12:07:40 +00:00
|
|
|
from utils import is_featured_writer
|
2021-12-26 12:02:29 +00:00
|
|
|
from utils import acct_dir
|
2021-12-29 21:55:09 +00:00
|
|
|
from blocking import is_blocked
|
|
|
|
from follow import is_follower_of_person
|
2021-12-28 20:32:11 +00:00
|
|
|
from follow import is_following_actor
|
2021-12-29 21:55:09 +00:00
|
|
|
from followingCalendar import receiving_calendar_events
|
|
|
|
from notifyOnPost import notify_when_person_posts
|
|
|
|
from webapp_utils import html_header_with_external_style
|
|
|
|
from webapp_utils import html_footer
|
|
|
|
from webapp_utils import get_broken_link_substitute
|
|
|
|
from webapp_utils import html_keyboard_navigation
|
2020-11-09 22:44:03 +00:00
|
|
|
|
|
|
|
|
2021-12-31 23:50:29 +00:00
|
|
|
def html_person_options(default_timeline: str,
|
2021-12-29 21:55:09 +00:00
|
|
|
css_cache: {}, translate: {}, base_dir: str,
|
|
|
|
domain: str, domain_full: str,
|
2022-01-04 10:33:30 +00:00
|
|
|
origin_path_str: str,
|
|
|
|
options_actor: str,
|
|
|
|
options_profile_url: str,
|
|
|
|
options_link: str,
|
|
|
|
page_number: int,
|
2021-12-31 18:11:17 +00:00
|
|
|
donate_url: str,
|
2022-01-04 10:33:30 +00:00
|
|
|
web_address: str,
|
2021-12-31 18:11:17 +00:00
|
|
|
xmpp_address: str,
|
|
|
|
matrix_address: str,
|
|
|
|
ssb_address: str,
|
|
|
|
blog_address: str,
|
|
|
|
tox_address: str,
|
|
|
|
briar_address: str,
|
|
|
|
jami_address: str,
|
2021-12-30 20:48:38 +00:00
|
|
|
cwtch_address: str,
|
2021-12-31 18:11:17 +00:00
|
|
|
enigma_pub_key: str,
|
|
|
|
pgp_pub_key: str,
|
|
|
|
pgp_fingerprint: str,
|
|
|
|
email_address: str,
|
2021-12-29 21:55:09 +00:00
|
|
|
dormant_months: int,
|
2022-01-04 10:33:30 +00:00
|
|
|
back_to_path: str,
|
|
|
|
locked_account: bool,
|
|
|
|
moved_to: str,
|
|
|
|
also_known_as: [],
|
2021-12-29 21:55:09 +00:00
|
|
|
text_mode_banner: str,
|
|
|
|
news_instance: bool,
|
|
|
|
authorized: bool,
|
2021-12-31 21:18:12 +00:00
|
|
|
access_keys: {},
|
2022-01-04 10:33:30 +00:00
|
|
|
is_group: bool) -> str:
|
2020-11-09 22:44:03 +00:00
|
|
|
"""Show options for a person: view/follow/block/report
|
|
|
|
"""
|
2022-01-04 10:33:30 +00:00
|
|
|
options_domain, options_port = get_domain_from_actor(options_actor)
|
2022-03-23 22:49:37 +00:00
|
|
|
if not options_domain:
|
|
|
|
return None
|
2022-01-04 10:33:30 +00:00
|
|
|
options_domain_full = get_full_domain(options_domain, options_port)
|
2020-11-09 22:44:03 +00:00
|
|
|
|
2021-12-25 16:17:53 +00:00
|
|
|
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')
|
2020-11-09 22:44:03 +00:00
|
|
|
|
2020-12-13 12:57:57 +00:00
|
|
|
dormant = False
|
2022-01-04 10:33:30 +00:00
|
|
|
follow_str = 'Follow'
|
|
|
|
if is_group:
|
|
|
|
follow_str = 'Join'
|
|
|
|
block_str = 'Block'
|
2020-11-09 22:44:03 +00:00
|
|
|
nickname = None
|
2022-01-04 10:33:30 +00:00
|
|
|
options_nickname = None
|
|
|
|
follows_you = False
|
|
|
|
if origin_path_str.startswith('/users/'):
|
|
|
|
nickname = origin_path_str.split('/users/')[1]
|
2020-11-09 22:44:03 +00:00
|
|
|
if '/' in nickname:
|
|
|
|
nickname = nickname.split('/')[0]
|
|
|
|
if '?' in nickname:
|
|
|
|
nickname = nickname.split('?')[0]
|
2022-01-04 10:33:30 +00:00
|
|
|
# follower_domain, follower_port = get_domain_from_actor(options_actor)
|
|
|
|
if is_following_actor(base_dir, nickname, domain, options_actor):
|
|
|
|
follow_str = 'Unfollow'
|
|
|
|
if is_group:
|
|
|
|
follow_str = 'Leave'
|
2020-12-13 12:57:57 +00:00
|
|
|
dormant = \
|
2022-01-04 10:33:30 +00:00
|
|
|
is_dormant(base_dir, nickname, domain, options_actor,
|
2021-12-26 12:54:51 +00:00
|
|
|
dormant_months)
|
2020-11-09 22:44:03 +00:00
|
|
|
|
2022-01-04 10:33:30 +00:00
|
|
|
options_nickname = get_nickname_from_actor(options_actor)
|
2022-03-23 23:59:29 +00:00
|
|
|
if not options_nickname:
|
|
|
|
return None
|
2022-01-04 10:33:30 +00:00
|
|
|
options_domain_full = get_full_domain(options_domain, options_port)
|
|
|
|
follows_you = \
|
2021-12-29 21:55:09 +00:00
|
|
|
is_follower_of_person(base_dir,
|
|
|
|
nickname, domain,
|
2022-01-04 10:33:30 +00:00
|
|
|
options_nickname, options_domain_full)
|
2021-12-29 21:55:09 +00:00
|
|
|
if is_blocked(base_dir, nickname, domain,
|
2022-01-04 10:33:30 +00:00
|
|
|
options_nickname, options_domain_full):
|
|
|
|
block_str = 'Block'
|
2020-11-09 22:44:03 +00:00
|
|
|
|
2022-01-04 10:33:30 +00:00
|
|
|
options_link_str = ''
|
|
|
|
if options_link:
|
|
|
|
options_link_str = \
|
2020-11-09 22:44:03 +00:00
|
|
|
' <input type="hidden" name="postUrl" value="' + \
|
2022-01-04 10:33:30 +00:00
|
|
|
options_link + '">\n'
|
2021-12-31 21:18:12 +00:00
|
|
|
css_filename = base_dir + '/epicyon-options.css'
|
2021-12-25 16:17:53 +00:00
|
|
|
if os.path.isfile(base_dir + '/options.css'):
|
2021-12-31 21:18:12 +00:00
|
|
|
css_filename = base_dir + '/options.css'
|
2020-11-09 22:44:03 +00:00
|
|
|
|
|
|
|
# To snooze, or not to snooze? That is the question
|
2022-01-04 10:33:30 +00:00
|
|
|
snooze_button_str = 'Snooze'
|
2020-11-09 22:44:03 +00:00
|
|
|
if nickname:
|
2022-01-04 10:33:30 +00:00
|
|
|
if is_person_snoozed(base_dir, nickname, domain, options_actor):
|
|
|
|
snooze_button_str = 'Unsnooze'
|
2020-11-09 22:44:03 +00:00
|
|
|
|
2022-01-04 10:33:30 +00:00
|
|
|
donate_str = ''
|
2021-12-31 18:11:17 +00:00
|
|
|
if donate_url:
|
2022-01-04 10:33:30 +00:00
|
|
|
donate_str = \
|
2021-12-31 18:11:17 +00:00
|
|
|
' <a href="' + donate_url + \
|
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'
|
|
|
|
|
2022-01-04 10:33:30 +00:00
|
|
|
instance_title = \
|
2021-12-26 14:08:58 +00:00
|
|
|
get_config_param(base_dir, 'instanceTitle')
|
2022-01-04 10:33:30 +00:00
|
|
|
options_str = \
|
|
|
|
html_header_with_external_style(css_filename, instance_title, None)
|
|
|
|
options_str += html_keyboard_navigation(text_mode_banner, {}, {})
|
|
|
|
options_str += '<br><br>\n'
|
|
|
|
options_str += '<div class="options">\n'
|
|
|
|
options_str += ' <div class="optionsAvatar">\n'
|
|
|
|
options_str += ' <center>\n'
|
|
|
|
options_str += ' <a href="' + options_actor + '">\n'
|
|
|
|
options_str += ' <img loading="lazy" src="' + options_profile_url + \
|
2021-12-29 21:55:09 +00:00
|
|
|
'" alt="" ' + get_broken_link_substitute() + '/></a>\n'
|
2022-03-23 23:59:29 +00:00
|
|
|
handle_nick = get_nickname_from_actor(options_actor)
|
|
|
|
if not handle_nick:
|
|
|
|
return None
|
|
|
|
handle = handle_nick + '@' + options_domain
|
2022-01-04 10:33:30 +00:00
|
|
|
handle_shown = handle
|
|
|
|
if locked_account:
|
|
|
|
handle_shown += '🔒'
|
|
|
|
if moved_to:
|
|
|
|
handle_shown += ' ⌂'
|
2020-12-13 12:57:57 +00:00
|
|
|
if dormant:
|
2022-01-04 10:33:30 +00:00
|
|
|
handle_shown += ' 💤'
|
|
|
|
options_str += \
|
2020-11-09 22:44:03 +00:00
|
|
|
' <p class="optionsText">' + translate['Options for'] + \
|
2022-01-04 10:33:30 +00:00
|
|
|
' @' + handle_shown + '</p>\n'
|
2022-03-23 22:43:19 +00:00
|
|
|
if follows_you and authorized:
|
2022-01-04 10:33:30 +00:00
|
|
|
options_str += \
|
2021-01-02 11:37:24 +00:00
|
|
|
' <p class="optionsText">' + translate['Follows you'] + '</p>\n'
|
2022-01-04 10:33:30 +00:00
|
|
|
if moved_to:
|
|
|
|
new_nickname = get_nickname_from_actor(moved_to)
|
|
|
|
new_domain, _ = get_domain_from_actor(moved_to)
|
|
|
|
if new_nickname and new_domain:
|
|
|
|
new_handle = new_nickname + '@' + new_domain
|
|
|
|
options_str += \
|
2021-01-12 11:08:54 +00:00
|
|
|
' <p class="optionsText">' + \
|
|
|
|
translate['New account'] + \
|
2022-01-04 10:33:30 +00:00
|
|
|
': <a href="' + moved_to + '">@' + new_handle + '</a></p>\n'
|
|
|
|
elif also_known_as:
|
|
|
|
other_accounts_html = \
|
2021-01-22 20:35:14 +00:00
|
|
|
' <p class="optionsText">' + \
|
|
|
|
translate['Other accounts'] + ': '
|
|
|
|
|
2021-01-23 10:03:50 +00:00
|
|
|
ctr = 0
|
2022-01-04 10:33:30 +00:00
|
|
|
if isinstance(also_known_as, list):
|
|
|
|
for alt_actor in also_known_as:
|
|
|
|
if alt_actor == options_actor:
|
2021-01-23 10:03:50 +00:00
|
|
|
continue
|
2021-01-22 20:35:14 +00:00
|
|
|
if ctr > 0:
|
2022-01-04 10:33:30 +00:00
|
|
|
other_accounts_html += ' '
|
2021-01-22 20:35:14 +00:00
|
|
|
ctr += 1
|
2022-01-04 10:33:30 +00:00
|
|
|
alt_domain, _ = get_domain_from_actor(alt_actor)
|
|
|
|
other_accounts_html += \
|
|
|
|
'<a href="' + alt_actor + '">' + alt_domain + '</a>'
|
|
|
|
elif isinstance(also_known_as, str):
|
|
|
|
if also_known_as != options_actor:
|
2021-01-23 10:03:50 +00:00
|
|
|
ctr += 1
|
2022-01-04 10:33:30 +00:00
|
|
|
alt_domain, _ = get_domain_from_actor(also_known_as)
|
|
|
|
other_accounts_html += \
|
|
|
|
'<a href="' + also_known_as + '">' + alt_domain + '</a>'
|
|
|
|
other_accounts_html += '</p>\n'
|
2021-01-23 10:03:50 +00:00
|
|
|
if ctr > 0:
|
2022-01-04 10:33:30 +00:00
|
|
|
options_str += other_accounts_html
|
2021-12-31 18:11:17 +00:00
|
|
|
if email_address:
|
2022-01-04 10:33:30 +00:00
|
|
|
options_str += \
|
2020-11-09 22:44:03 +00:00
|
|
|
'<p class="imText">' + translate['Email'] + \
|
|
|
|
': <a href="mailto:' + \
|
2021-12-31 18:11:17 +00:00
|
|
|
email_address + '">' + remove_html(email_address) + '</a></p>\n'
|
2022-01-04 10:36:04 +00:00
|
|
|
if web_address:
|
|
|
|
options_str += \
|
|
|
|
'<p class="imText">🌐 ' + \
|
|
|
|
'<a href="' + remove_html(web_address) + '">' + \
|
|
|
|
web_address + '</a></p>\n'
|
2021-12-31 18:11:17 +00:00
|
|
|
if xmpp_address:
|
2022-01-04 10:33:30 +00:00
|
|
|
options_str += \
|
2020-11-09 22:44:03 +00:00
|
|
|
'<p class="imText">' + translate['XMPP'] + \
|
2021-12-31 18:11:17 +00:00
|
|
|
': <a href="xmpp:' + remove_html(xmpp_address) + '">' + \
|
|
|
|
xmpp_address + '</a></p>\n'
|
|
|
|
if matrix_address:
|
2022-01-04 10:33:30 +00:00
|
|
|
options_str += \
|
2020-11-09 22:44:03 +00:00
|
|
|
'<p class="imText">' + translate['Matrix'] + ': ' + \
|
2021-12-31 18:11:17 +00:00
|
|
|
remove_html(matrix_address) + '</p>\n'
|
|
|
|
if ssb_address:
|
2022-01-04 10:33:30 +00:00
|
|
|
options_str += \
|
2021-12-31 18:11:17 +00:00
|
|
|
'<p class="imText">SSB: ' + remove_html(ssb_address) + '</p>\n'
|
|
|
|
if blog_address:
|
2022-01-04 10:33:30 +00:00
|
|
|
options_str += \
|
2020-12-12 15:36:44 +00:00
|
|
|
'<p class="imText">Blog: <a href="' + \
|
2021-12-31 18:11:17 +00:00
|
|
|
remove_html(blog_address) + '">' + \
|
|
|
|
remove_html(blog_address) + '</a></p>\n'
|
|
|
|
if tox_address:
|
2022-01-04 10:33:30 +00:00
|
|
|
options_str += \
|
2021-12-31 18:11:17 +00:00
|
|
|
'<p class="imText">Tox: ' + remove_html(tox_address) + '</p>\n'
|
|
|
|
if briar_address:
|
|
|
|
if briar_address.startswith('briar://'):
|
2022-01-04 10:33:30 +00:00
|
|
|
options_str += \
|
2020-12-24 17:11:18 +00:00
|
|
|
'<p class="imText">' + \
|
2021-12-31 18:11:17 +00:00
|
|
|
remove_html(briar_address) + '</p>\n'
|
2020-12-24 17:11:18 +00:00
|
|
|
else:
|
2022-01-04 10:33:30 +00:00
|
|
|
options_str += \
|
2020-12-24 17:11:18 +00:00
|
|
|
'<p class="imText">briar://' + \
|
2021-12-31 18:11:17 +00:00
|
|
|
remove_html(briar_address) + '</p>\n'
|
|
|
|
if jami_address:
|
2022-01-04 10:33:30 +00:00
|
|
|
options_str += \
|
2021-12-31 18:11:17 +00:00
|
|
|
'<p class="imText">Jami: ' + remove_html(jami_address) + '</p>\n'
|
2021-12-30 20:48:38 +00:00
|
|
|
if cwtch_address:
|
2022-01-04 10:33:30 +00:00
|
|
|
options_str += \
|
2021-12-30 20:48:38 +00:00
|
|
|
'<p class="imText">Cwtch: ' + remove_html(cwtch_address) + '</p>\n'
|
2021-12-31 18:11:17 +00:00
|
|
|
if enigma_pub_key:
|
2022-01-04 10:33:30 +00:00
|
|
|
options_str += \
|
2021-12-31 18:11:17 +00:00
|
|
|
'<p class="imText">Enigma: ' + \
|
|
|
|
remove_html(enigma_pub_key) + '</p>\n'
|
|
|
|
if pgp_fingerprint:
|
2022-01-04 10:33:30 +00:00
|
|
|
options_str += '<p class="pgp">PGP: ' + \
|
2021-12-31 18:11:17 +00:00
|
|
|
remove_html(pgp_fingerprint).replace('\n', '<br>') + '</p>\n'
|
|
|
|
if pgp_pub_key:
|
2022-01-04 10:33:30 +00:00
|
|
|
options_str += '<p class="pgp">' + \
|
2021-12-31 18:11:17 +00:00
|
|
|
remove_html(pgp_pub_key).replace('\n', '<br>') + '</p>\n'
|
2022-01-04 10:33:30 +00:00
|
|
|
options_str += ' <form method="POST" action="' + \
|
|
|
|
origin_path_str + '/personoptions">\n'
|
|
|
|
options_str += ' <input type="hidden" name="pageNumber" value="' + \
|
|
|
|
str(page_number) + '">\n'
|
|
|
|
options_str += ' <input type="hidden" name="actor" value="' + \
|
|
|
|
options_actor + '">\n'
|
|
|
|
options_str += ' <input type="hidden" name="avatarUrl" value="' + \
|
|
|
|
options_profile_url + '">\n'
|
2021-02-23 17:29:22 +00:00
|
|
|
if authorized:
|
2022-01-04 10:33:30 +00:00
|
|
|
if origin_path_str == '/users/' + nickname:
|
|
|
|
if options_nickname:
|
|
|
|
# handle = options_nickname + '@' + options_domain_full
|
2021-12-29 21:55:09 +00:00
|
|
|
petname = get_pet_name(base_dir, nickname, domain, handle)
|
2022-01-04 10:33:30 +00:00
|
|
|
options_str += \
|
2021-02-23 17:51:48 +00:00
|
|
|
' ' + translate['Petname'] + ': \n' + \
|
|
|
|
' <input type="text" name="optionpetname" value="' + \
|
2021-04-23 12:04:42 +00:00
|
|
|
petname + '" ' + \
|
2021-12-31 21:18:12 +00:00
|
|
|
'accesskey="' + access_keys['enterPetname'] + '">\n' \
|
2021-02-23 17:51:48 +00:00
|
|
|
' <button type="submit" class="buttonsmall" ' + \
|
|
|
|
'name="submitPetname">' + \
|
|
|
|
translate['Submit'] + '</button><br>\n'
|
2020-11-09 22:44:03 +00:00
|
|
|
|
2021-07-06 20:38:08 +00:00
|
|
|
# Notify when a post arrives from this person
|
2022-01-04 10:33:30 +00:00
|
|
|
if is_following_actor(base_dir, nickname, domain, options_actor):
|
|
|
|
checkbox_str = \
|
2021-07-06 20:38:08 +00:00
|
|
|
' <input type="checkbox" class="profilecheckbox" ' + \
|
|
|
|
'name="notifyOnPost" checked> 🔔' + \
|
|
|
|
translate['Notify me when this account posts'] + \
|
|
|
|
'\n <button type="submit" class="buttonsmall" ' + \
|
|
|
|
'name="submitNotifyOnPost">' + \
|
|
|
|
translate['Submit'] + '</button><br>\n'
|
2021-12-29 21:55:09 +00:00
|
|
|
if not notify_when_person_posts(base_dir, nickname, domain,
|
2022-01-04 10:33:30 +00:00
|
|
|
options_nickname,
|
|
|
|
options_domain_full):
|
|
|
|
checkbox_str = checkbox_str.replace(' checked>', '>')
|
|
|
|
options_str += checkbox_str
|
2021-07-06 20:38:08 +00:00
|
|
|
|
2022-01-04 10:33:30 +00:00
|
|
|
checkbox_str = \
|
2021-02-23 17:29:22 +00:00
|
|
|
' <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-12-29 21:55:09 +00:00
|
|
|
if not receiving_calendar_events(base_dir, nickname, domain,
|
2022-01-04 10:33:30 +00:00
|
|
|
options_nickname,
|
|
|
|
options_domain_full):
|
|
|
|
checkbox_str = checkbox_str.replace(' checked>', '>')
|
|
|
|
options_str += checkbox_str
|
2020-12-17 14:25:00 +00:00
|
|
|
|
2021-02-23 17:51:48 +00:00
|
|
|
# checkbox for permission to post to newswire
|
2022-01-04 10:33:30 +00:00
|
|
|
newswire_posts_permitted = False
|
|
|
|
if options_domain_full == domain_full:
|
2021-12-31 21:18:12 +00:00
|
|
|
admin_nickname = get_config_param(base_dir, 'admin')
|
|
|
|
if (nickname == admin_nickname or
|
2021-12-28 19:33:29 +00:00
|
|
|
(is_moderator(base_dir, nickname) and
|
2022-01-04 10:33:30 +00:00
|
|
|
not is_moderator(base_dir, options_nickname))):
|
|
|
|
newswire_blocked_filename = \
|
2021-12-25 16:17:53 +00:00
|
|
|
base_dir + '/accounts/' + \
|
2022-01-04 10:33:30 +00:00
|
|
|
options_nickname + '@' + options_domain + \
|
|
|
|
'/.nonewswire'
|
|
|
|
checkbox_str = \
|
2021-02-23 17:51:48 +00:00
|
|
|
' <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'
|
2022-01-04 10:33:30 +00:00
|
|
|
if os.path.isfile(newswire_blocked_filename):
|
|
|
|
checkbox_str = checkbox_str.replace(' checked>', '>')
|
2021-02-23 17:51:48 +00:00
|
|
|
else:
|
2022-01-04 10:33:30 +00:00
|
|
|
newswire_posts_permitted = True
|
|
|
|
options_str += checkbox_str
|
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
|
2022-01-04 10:33:30 +00:00
|
|
|
if newswire_posts_permitted:
|
|
|
|
moderated_filename = \
|
2021-12-25 16:17:53 +00:00
|
|
|
base_dir + '/accounts/' + \
|
2022-01-04 10:33:30 +00:00
|
|
|
options_nickname + '@' + \
|
|
|
|
options_domain + '/.newswiremoderated'
|
|
|
|
checkbox_str = \
|
2021-02-23 17:29:22 +00:00
|
|
|
' <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'
|
2022-01-04 10:33:30 +00:00
|
|
|
if not os.path.isfile(moderated_filename):
|
|
|
|
checkbox_str = checkbox_str.replace(' checked>', '>')
|
|
|
|
options_str += checkbox_str
|
2021-02-23 17:29:22 +00:00
|
|
|
|
2021-02-23 17:51:48 +00:00
|
|
|
# checkbox for permission to post to featured articles
|
2022-01-04 10:33:30 +00:00
|
|
|
if news_instance and options_domain_full == domain_full:
|
2021-12-31 21:18:12 +00:00
|
|
|
admin_nickname = get_config_param(base_dir, 'admin')
|
|
|
|
if (nickname == admin_nickname or
|
2021-12-28 19:33:29 +00:00
|
|
|
(is_moderator(base_dir, nickname) and
|
2022-01-04 10:33:30 +00:00
|
|
|
not is_moderator(base_dir, options_nickname))):
|
|
|
|
checkbox_str = \
|
2021-02-23 17:51:48 +00:00
|
|
|
' <input type="checkbox" ' + \
|
|
|
|
'class="profilecheckbox" ' + \
|
|
|
|
'name="postsToFeatures" checked> ' + \
|
|
|
|
translate['Featured writer'] + \
|
|
|
|
'\n <button type="submit" class="buttonsmall" ' + \
|
|
|
|
'name="submitPostToFeatures">' + \
|
|
|
|
translate['Submit'] + '</button><br>\n'
|
2022-01-04 10:33:30 +00:00
|
|
|
if not is_featured_writer(base_dir, options_nickname,
|
|
|
|
options_domain):
|
|
|
|
checkbox_str = checkbox_str.replace(' checked>', '>')
|
|
|
|
options_str += checkbox_str
|
2021-02-23 17:51:48 +00:00
|
|
|
|
2022-01-04 10:33:30 +00:00
|
|
|
options_str += options_link_str
|
|
|
|
back_path = '/'
|
2020-11-10 20:40:19 +00:00
|
|
|
if nickname:
|
2022-01-04 10:33:30 +00:00
|
|
|
back_path = '/users/' + nickname + '/' + default_timeline
|
|
|
|
if 'moderation' in back_to_path:
|
|
|
|
back_path = '/users/' + nickname + '/moderation'
|
|
|
|
if authorized and origin_path_str == '/users/' + nickname:
|
|
|
|
options_str += \
|
|
|
|
' <a href="' + back_path + '"><button type="button" ' + \
|
2021-04-23 12:04:42 +00:00
|
|
|
'class="buttonIcon" name="submitBack" ' + \
|
2021-12-31 21:18:12 +00:00
|
|
|
'accesskey="' + access_keys['menuTimeline'] + '">' + \
|
2021-04-23 12:04:42 +00:00
|
|
|
translate['Go Back'] + '</button></a>\n'
|
2021-02-23 17:58:52 +00:00
|
|
|
else:
|
2022-01-04 10:33:30 +00:00
|
|
|
options_str += \
|
|
|
|
' <a href="' + origin_path_str + '"><button type="button" ' + \
|
2021-04-23 12:04:42 +00:00
|
|
|
'class="buttonIcon" name="submitBack" accesskey="' + \
|
2021-12-31 21:18:12 +00:00
|
|
|
access_keys['menuTimeline'] + '">' + translate['Go Back'] + \
|
2021-02-23 17:58:52 +00:00
|
|
|
'</button></a>\n'
|
2021-02-23 17:29:22 +00:00
|
|
|
if authorized:
|
2022-01-04 10:33:30 +00:00
|
|
|
options_str += \
|
2021-04-23 12:04:42 +00:00
|
|
|
' <button type="submit" class="button" ' + \
|
|
|
|
'name="submitView" accesskey="' + \
|
2021-12-31 21:18:12 +00:00
|
|
|
access_keys['viewButton'] + '">' + \
|
2021-02-23 17:29:22 +00:00
|
|
|
translate['View'] + '</button>\n'
|
2022-01-04 10:33:30 +00:00
|
|
|
options_str += donate_str
|
2021-02-23 17:29:22 +00:00
|
|
|
if authorized:
|
2022-01-04 10:33:30 +00:00
|
|
|
options_str += \
|
2021-02-23 17:29:22 +00:00
|
|
|
' <button type="submit" class="button" name="submit' + \
|
2022-01-04 10:33:30 +00:00
|
|
|
follow_str + \
|
2021-12-31 21:18:12 +00:00
|
|
|
'" accesskey="' + access_keys['followButton'] + '">' + \
|
2022-01-04 10:33:30 +00:00
|
|
|
translate[follow_str] + '</button>\n'
|
|
|
|
options_str += \
|
2021-02-23 17:29:22 +00:00
|
|
|
' <button type="submit" class="button" name="submit' + \
|
2022-01-04 10:33:30 +00:00
|
|
|
block_str + '" accesskey="' + access_keys['blockButton'] + '">' + \
|
|
|
|
translate[block_str] + '</button>\n'
|
|
|
|
options_str += \
|
2021-04-23 12:04:42 +00:00
|
|
|
' <button type="submit" class="button" name="submitDM" ' + \
|
2021-12-31 21:18:12 +00:00
|
|
|
'accesskey="' + access_keys['menuDM'] + '">' + \
|
2021-02-23 17:29:22 +00:00
|
|
|
translate['DM'] + '</button>\n'
|
2022-01-04 10:33:30 +00:00
|
|
|
options_str += \
|
2021-02-23 17:29:22 +00:00
|
|
|
' <button type="submit" class="button" name="submit' + \
|
2022-01-04 10:33:30 +00:00
|
|
|
snooze_button_str + '" accesskey="' + \
|
|
|
|
access_keys['snoozeButton'] + '">' + \
|
|
|
|
translate[snooze_button_str] + '</button>\n'
|
|
|
|
options_str += \
|
2020-12-16 18:24:04 +00:00
|
|
|
' <button type="submit" class="button" ' + \
|
2021-04-23 12:04:42 +00:00
|
|
|
'name="submitReport" accesskey="' + \
|
2021-12-31 21:18:12 +00:00
|
|
|
access_keys['reportButton'] + '">' + \
|
2021-04-23 12:04:42 +00:00
|
|
|
translate['Report'] + '</button>\n'
|
2020-11-09 22:44:03 +00:00
|
|
|
|
2021-12-28 19:33:29 +00:00
|
|
|
if is_moderator(base_dir, nickname):
|
2022-01-04 10:33:30 +00:00
|
|
|
options_str += \
|
2021-02-23 17:29:22 +00:00
|
|
|
' <button type="submit" class="button" ' + \
|
2021-04-23 12:04:42 +00:00
|
|
|
'name="submitPersonInfo" accesskey="' + \
|
2021-12-31 21:18:12 +00:00
|
|
|
access_keys['infoButton'] + '">' + \
|
2021-02-23 17:29:22 +00:00
|
|
|
translate['Info'] + '</button>\n'
|
2020-11-09 22:44:03 +00:00
|
|
|
|
2022-01-04 10:33:30 +00:00
|
|
|
person_notes = ''
|
|
|
|
if origin_path_str == '/users/' + nickname:
|
|
|
|
person_notes_filename = \
|
2021-12-26 12:02:29 +00:00
|
|
|
acct_dir(base_dir, nickname, domain) + \
|
2021-02-23 17:35:26 +00:00
|
|
|
'/notes/' + handle + '.txt'
|
2022-01-04 10:33:30 +00:00
|
|
|
if os.path.isfile(person_notes_filename):
|
|
|
|
with open(person_notes_filename, 'r') as fp_notes:
|
|
|
|
person_notes = fp_notes.read()
|
2021-02-23 17:29:22 +00:00
|
|
|
|
2022-01-04 10:33:30 +00:00
|
|
|
options_str += \
|
2021-02-23 17:29:22 +00:00
|
|
|
' <br><br>' + translate['Notes'] + ': \n'
|
2022-01-04 10:33:30 +00:00
|
|
|
options_str += ' <button type="submit" class="buttonsmall" ' + \
|
2021-02-23 17:29:22 +00:00
|
|
|
'name="submitPersonNotes">' + \
|
|
|
|
translate['Submit'] + '</button><br>\n'
|
2022-01-04 10:33:30 +00:00
|
|
|
options_str += \
|
2021-02-23 17:29:22 +00:00
|
|
|
' <textarea id="message" ' + \
|
2021-04-23 12:04:42 +00:00
|
|
|
'name="optionnotes" style="height:400px" spellcheck="true" ' + \
|
2021-12-31 21:18:12 +00:00
|
|
|
'accesskey="' + access_keys['enterNotes'] + '">' + \
|
2022-01-04 10:33:30 +00:00
|
|
|
person_notes + '</textarea>\n'
|
2020-11-09 22:44:03 +00:00
|
|
|
|
2022-01-04 10:33:30 +00:00
|
|
|
options_str += \
|
2021-07-06 10:00:19 +00:00
|
|
|
' </form>\n' + \
|
|
|
|
'</center>\n' + \
|
|
|
|
'</div>\n' + \
|
|
|
|
'</div>\n'
|
2022-01-04 10:33:30 +00:00
|
|
|
options_str += html_footer()
|
|
|
|
return options_str
|