\n'
if blocked_following:
blocked_following.sort()
info_form += '
\n'
info_form += '
' + translate['Blocked following'] + '
\n'
info_form += \
'
' + \
translate['Receives posts from the following accounts'] + \
':
\n'
for actor in blocked_following:
following_nickname = get_nickname_from_actor(actor)
if not following_nickname:
return ''
following_domain, following_port = get_domain_from_actor(actor)
following_domain_full = \
get_full_domain(following_domain, following_port)
info_form += '' + \
following_nickname + '@' + following_domain_full + \
'
\n'
info_form += '
\n'
if blocked_followers:
blocked_followers.sort()
info_form += '
\n'
info_form += '
' + translate['Blocked followers'] + '
\n'
info_form += \
'
' + \
translate['Sends out posts to the following accounts'] + \
':
\n'
for actor in blocked_followers:
follower_nickname = get_nickname_from_actor(actor)
if not follower_nickname:
return ''
follower_domain, follower_port = get_domain_from_actor(actor)
follower_domain_full = \
get_full_domain(follower_domain, follower_port)
info_form += '' + \
follower_nickname + '@' + \
follower_domain_full + '
\n'
info_form += '
\n'
if word_frequency:
max_count = 1
for word, count in word_frequency.items():
if count > max_count:
max_count = count
minimum_word_count = int(max_count / 2)
if minimum_word_count >= 3:
info_form += '
\n'
info_form += '
' + translate['Word frequencies'] + '
\n'
word_swarm = ''
ctr = 0
for word, count in word_frequency.items():
if count >= minimum_word_count:
if ctr > 0:
word_swarm += ' '
if count < max_count - int(max_count / 4):
word_swarm += word
else:
if count != max_count:
word_swarm += '' + word + ''
else:
word_swarm += '' + word + ''
ctr += 1
info_form += word_swarm
info_form += '
\n'
info_form += html_footer()
return info_form
def _get_global_block_reason(search_text: str,
blocking_reasons_filename: str) -> str:
"""Returns the reason why a domain was globally blocked
"""
if not text_in_file(search_text, blocking_reasons_filename):
return ''
reasons_str = ''
try:
with open(blocking_reasons_filename, 'r',
encoding='utf-8') as fp_reas:
reasons_str = fp_reas.read()
except OSError:
print('WARN: Failed to raed blocking reasons ' +
blocking_reasons_filename)
if not reasons_str:
return ''
reasons_lines = reasons_str.split('\n')
for line in reasons_lines:
if line.startswith(search_text):
if ' ' in line:
return line.split(' ', 1)[1]
return ''
def html_moderation_info(translate: {}, base_dir: str,
nickname: str, domain: str, theme: str,
access_keys: {}) -> str:
msg_str1 = \
'These are globally blocked for all accounts on this instance'
msg_str2 = \
'Any blocks or suspensions made by moderators will be shown here.'
info_form = ''
css_filename = base_dir + '/epicyon-profile.css'
if os.path.isfile(base_dir + '/epicyon.css'):
css_filename = base_dir + '/epicyon.css'
instance_title = \
get_config_param(base_dir, 'instanceTitle')
info_form = html_header_with_external_style(css_filename,
instance_title, None)
# show banner
banner_file, _ = \
get_banner_file(base_dir, nickname, domain, theme)
moderation_link = '/users/' + nickname + '/moderation'
info_form += \
'\n\n'
info_form += \
'\n' + \
'\n \n'
info_form += \
'