epicyon/webapp_timeline.py

1770 lines
79 KiB
Python
Raw Normal View History

2020-11-09 22:44:03 +00:00
__filename__ = "webapp_timeline.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__ = "Timeline"
2020-11-09 22:44:03 +00:00
import os
import time
from shutil import copyfile
2021-12-26 14:17:13 +00:00
from utils import is_artist
2021-12-27 21:42:08 +00:00
from utils import dangerous_markup
2021-12-26 14:08:58 +00:00
from utils import get_config_param
2021-12-26 12:45:03 +00:00
from utils import get_full_domain
2021-12-26 13:27:57 +00:00
from utils import is_editor
2021-12-27 11:20:57 +00:00
from utils import remove_id_ending
2021-12-26 12:02:29 +00:00
from utils import acct_dir
2021-12-26 18:03:39 +00:00
from utils import is_float
2021-12-26 10:19:59 +00:00
from utils import local_actor_url
2021-12-28 20:32:11 +00:00
from follow import follower_approval_active
2021-12-29 21:55:09 +00:00
from person import is_person_snoozed
from markdown import markdown_to_html
from webapp_utils import html_keyboard_navigation
from webapp_utils import html_hide_from_screen_reader
from webapp_utils import html_post_separator
from webapp_utils import get_banner_file
from webapp_utils import html_header_with_external_style
from webapp_utils import html_footer
from webapp_utils import shares_timeline_json
from webapp_utils import html_highlight_label
from webapp_post import prepare_post_from_html_cache
from webapp_post import individual_post_as_html
from webapp_column_left import get_left_column_content
from webapp_column_right import get_right_column_content
from webapp_headerbuttons import header_buttons_timeline
2021-12-28 19:33:29 +00:00
from posts import is_moderator
2021-12-29 21:55:09 +00:00
from announce import is_self_announce
2020-11-09 22:44:03 +00:00
2021-12-31 21:18:12 +00:00
def _log_timeline_timing(enable_timing_log: bool, timeline_start_time,
box_name: str, debug_id: str) -> None:
2020-12-01 17:23:34 +00:00
"""Create a log of timings for performance tuning
"""
2021-12-31 21:18:12 +00:00
if not enable_timing_log:
2020-12-01 17:23:34 +00:00
return
2021-12-31 21:18:12 +00:00
time_diff = int((time.time() - timeline_start_time) * 1000)
if time_diff > 100:
2020-12-01 17:23:34 +00:00
print('TIMELINE TIMING ' +
2021-12-31 21:18:12 +00:00
box_name + ' ' + debug_id + ' = ' + str(time_diff))
2020-12-01 17:23:34 +00:00
2021-12-31 21:18:12 +00:00
def _get_help_for_timeline(base_dir: str, box_name: str) -> str:
"""Shows help text for the given timeline
"""
# get the filename for help for this timeline
2021-12-31 21:18:12 +00:00
help_filename = base_dir + '/accounts/help_' + box_name + '.md'
if not os.path.isfile(help_filename):
language = \
2021-12-26 14:08:58 +00:00
get_config_param(base_dir, 'language')
2021-02-26 12:24:55 +00:00
if not language:
language = 'en'
2021-12-25 23:35:50 +00:00
theme_name = \
2021-12-26 14:08:58 +00:00
get_config_param(base_dir, 'theme')
2021-12-31 21:18:12 +00:00
default_filename = None
2021-12-25 23:35:50 +00:00
if theme_name:
2021-12-31 21:18:12 +00:00
default_filename = \
2021-12-25 23:35:50 +00:00
base_dir + '/theme/' + theme_name + '/welcome/' + \
2021-12-31 21:18:12 +00:00
'help_' + box_name + '_' + language + '.md'
if not os.path.isfile(default_filename):
default_filename = None
if not default_filename:
default_filename = \
2021-12-25 16:17:53 +00:00
base_dir + '/defaultwelcome/' + \
2021-12-31 21:18:12 +00:00
'help_' + box_name + '_' + language + '.md'
if not os.path.isfile(default_filename):
default_filename = \
base_dir + '/defaultwelcome/help_' + box_name + '_en.md'
if os.path.isfile(default_filename):
copyfile(default_filename, help_filename)
# show help text
2021-12-31 21:18:12 +00:00
if os.path.isfile(help_filename):
instance_title = \
2021-12-26 14:08:58 +00:00
get_config_param(base_dir, 'instanceTitle')
2021-12-31 21:18:12 +00:00
if not instance_title:
instance_title = 'Epicyon'
with open(help_filename, 'r') as help_file:
help_text = help_file.read()
if dangerous_markup(help_text, False):
return ''
2021-12-31 21:18:12 +00:00
help_text = help_text.replace('INSTANCE', instance_title)
2021-02-26 12:29:42 +00:00
return '<div class="container">\n' + \
2021-12-31 21:18:12 +00:00
markdown_to_html(help_text) + '\n' + \
2021-02-26 12:42:29 +00:00
'</div>\n'
return ''
2021-12-31 21:18:12 +00:00
def _html_timeline_new_post(manually_approve_followers: bool,
box_name: str, icons_as_buttons: bool,
users_path: str, translate: {}) -> str:
2021-06-27 21:40:12 +00:00
"""Returns html for the new post button
"""
2021-12-31 21:18:12 +00:00
new_post_button_str = ''
if box_name == 'dm':
2021-12-25 19:19:14 +00:00
if not icons_as_buttons:
2021-12-31 21:18:12 +00:00
new_post_button_str += \
'<a class="imageAnchor" href="' + users_path + \
2022-03-28 08:47:53 +00:00
'/newdm?nodropdown"><img loading="lazy" ' + \
'decoding="async" src="/' + \
2021-06-27 21:40:12 +00:00
'icons/newpost.png" title="' + \
translate['Create a new DM'] + \
'" alt="| ' + translate['Create a new DM'] + \
'" class="timelineicon"/></a>\n'
else:
2021-12-31 21:18:12 +00:00
new_post_button_str += \
'<a href="' + users_path + '/newdm?nodropdown">' + \
2021-06-27 21:40:12 +00:00
'<button class="button"><span>' + \
translate['Post'] + ' </span></button></a>'
2021-12-31 21:18:12 +00:00
elif box_name in ('tlblogs', 'tlnews', 'tlfeatures'):
2021-12-25 19:19:14 +00:00
if not icons_as_buttons:
2021-12-31 21:18:12 +00:00
new_post_button_str += \
'<a class="imageAnchor" href="' + users_path + \
2022-03-28 08:47:53 +00:00
'/newblog"><img loading="lazy" decoding="async" src="/' + \
2021-06-27 21:40:12 +00:00
'icons/newpost.png" title="' + \
translate['Create a new post'] + '" alt="| ' + \
translate['Create a new post'] + \
'" class="timelineicon"/></a>\n'
else:
2021-12-31 21:18:12 +00:00
new_post_button_str += \
'<a href="' + users_path + '/newblog">' + \
2021-06-27 21:40:12 +00:00
'<button class="button"><span>' + \
translate['Post'] + '</span></button></a>'
2021-12-31 21:18:12 +00:00
elif box_name == 'tlshares':
2021-12-25 19:19:14 +00:00
if not icons_as_buttons:
2021-12-31 21:18:12 +00:00
new_post_button_str += \
'<a class="imageAnchor" href="' + users_path + \
2022-03-28 08:47:53 +00:00
'/newshare?nodropdown">' + \
'<img loading="lazy" decoding="async" src="/' + \
2021-06-27 21:40:12 +00:00
'icons/newpost.png" title="' + \
translate['Create a new shared item'] + '" alt="| ' + \
translate['Create a new shared item'] + \
'" class="timelineicon"/></a>\n'
else:
2021-12-31 21:18:12 +00:00
new_post_button_str += \
'<a href="' + users_path + '/newshare?nodropdown">' + \
2021-06-27 21:40:12 +00:00
'<button class="button"><span>' + \
translate['Post'] + '</span></button></a>'
2021-12-31 21:18:12 +00:00
elif box_name == 'tlwanted':
2021-12-25 19:19:14 +00:00
if not icons_as_buttons:
2021-12-31 21:18:12 +00:00
new_post_button_str += \
'<a class="imageAnchor" href="' + users_path + \
2022-03-28 08:47:53 +00:00
'/newwanted?nodropdown">' + \
'<img loading="lazy" decoding="async" src="/' + \
2021-08-09 18:41:05 +00:00
'icons/newpost.png" title="' + \
translate['Create a new wanted item'] + '" alt="| ' + \
translate['Create a new wanted item'] + \
'" class="timelineicon"/></a>\n'
else:
2021-12-31 21:18:12 +00:00
new_post_button_str += \
'<a href="' + users_path + '/newwanted?nodropdown">' + \
2021-08-09 18:41:05 +00:00
'<button class="button"><span>' + \
translate['Post'] + '</span></button></a>'
2021-06-27 21:40:12 +00:00
else:
2021-12-31 21:18:12 +00:00
if not manually_approve_followers:
2021-12-25 19:19:14 +00:00
if not icons_as_buttons:
2021-12-31 21:18:12 +00:00
new_post_button_str += \
'<a class="imageAnchor" href="' + users_path + \
2022-03-28 08:47:53 +00:00
'/newpost">' + \
'<img loading="lazy" decoding="async" src="/' + \
2021-06-27 21:40:12 +00:00
'icons/newpost.png" title="' + \
translate['Create a new post'] + '" alt="| ' + \
translate['Create a new post'] + \
'" class="timelineicon"/></a>\n'
else:
2021-12-31 21:18:12 +00:00
new_post_button_str += \
'<a href="' + users_path + '/newpost">' + \
2021-06-27 21:40:12 +00:00
'<button class="button"><span>' + \
translate['Post'] + '</span></button></a>'
else:
2021-12-25 19:19:14 +00:00
if not icons_as_buttons:
2021-12-31 21:18:12 +00:00
new_post_button_str += \
'<a class="imageAnchor" href="' + users_path + \
2022-03-28 08:47:53 +00:00
'/newfollowers">' + \
'<img loading="lazy" decoding="async" src="/' + \
2021-06-27 21:40:12 +00:00
'icons/newpost.png" title="' + \
translate['Create a new post'] + \
'" alt="| ' + translate['Create a new post'] + \
'" class="timelineicon"/></a>\n'
else:
2021-12-31 21:18:12 +00:00
new_post_button_str += \
'<a href="' + users_path + '/newfollowers">' + \
2021-06-27 21:40:12 +00:00
'<button class="button"><span>' + \
translate['Post'] + '</span></button></a>'
2021-12-31 21:18:12 +00:00
return new_post_button_str
2021-06-27 21:40:12 +00:00
2021-12-31 21:18:12 +00:00
def _html_timeline_moderation_buttons(moderator: bool, box_name: str,
nickname: str,
moderation_action_str: str,
2021-12-29 21:55:09 +00:00
translate: {}) -> str:
2021-06-27 22:01:58 +00:00
"""Returns html for the moderation screen buttons
"""
2021-12-31 21:18:12 +00:00
tl_str = ''
if moderator and box_name == 'moderation':
tl_str += \
2021-06-27 22:01:58 +00:00
'<form id="modtimeline" method="POST" action="/users/' + \
nickname + '/moderationaction">'
2021-12-31 21:18:12 +00:00
tl_str += '<div class="container">\n'
2021-06-27 22:01:58 +00:00
idx = 'Nickname or URL. Block using *@domain or nickname@domain'
2021-12-31 21:18:12 +00:00
tl_str += \
2021-06-27 22:01:58 +00:00
' <b>' + translate[idx] + '</b><br>\n'
2021-12-31 21:18:12 +00:00
if moderation_action_str:
tl_str += ' <input type="text" ' + \
2021-06-27 22:01:58 +00:00
'name="moderationAction" value="' + \
2021-12-31 21:18:12 +00:00
moderation_action_str + '" autofocus><br>\n'
2021-06-27 22:01:58 +00:00
else:
2021-12-31 21:18:12 +00:00
tl_str += ' <input type="text" ' + \
2021-06-27 22:01:58 +00:00
'name="moderationAction" value="" autofocus><br>\n'
2021-12-31 21:18:12 +00:00
tl_str += \
2021-06-27 22:01:58 +00:00
' <input type="submit" title="' + \
translate['Information about current blocks/suspensions'] + \
'" alt="' + \
translate['Information about current blocks/suspensions'] + \
' | " ' + \
'name="submitInfo" value="' + translate['Info'] + '">\n'
2021-12-31 21:18:12 +00:00
tl_str += \
2021-06-27 22:01:58 +00:00
' <input type="submit" title="' + \
translate['Remove the above item'] + '" ' + \
'alt="' + translate['Remove the above item'] + ' | " ' + \
'name="submitRemove" value="' + \
translate['Remove'] + '">\n'
2021-12-31 21:18:12 +00:00
tl_str += \
2021-06-27 22:01:58 +00:00
' <input type="submit" title="' + \
translate['Suspend the above account nickname'] + '" ' + \
'alt="' + \
translate['Suspend the above account nickname'] + ' | " ' + \
'name="submitSuspend" value="' + translate['Suspend'] + '">\n'
2021-12-31 21:18:12 +00:00
tl_str += \
2021-06-27 22:01:58 +00:00
' <input type="submit" title="' + \
translate['Remove a suspension for an account nickname'] + '" ' + \
'alt="' + \
translate['Remove a suspension for an account nickname'] + \
' | " ' + \
'name="submitUnsuspend" value="' + \
translate['Unsuspend'] + '">\n'
2021-12-31 21:18:12 +00:00
tl_str += \
2021-06-27 22:01:58 +00:00
' <input type="submit" title="' + \
translate['Block an account on another instance'] + '" ' + \
'alt="' + \
translate['Block an account on another instance'] + ' | " ' + \
'name="submitBlock" value="' + translate['Block'] + '">\n'
2021-12-31 21:18:12 +00:00
tl_str += \
2021-06-27 22:01:58 +00:00
' <input type="submit" title="' + \
translate['Unblock an account on another instance'] + '" ' + \
'alt="' + \
translate['Unblock an account on another instance'] + ' | " ' + \
'name="submitUnblock" value="' + translate['Unblock'] + '">\n'
2021-12-31 21:18:12 +00:00
tl_str += \
2021-06-27 22:01:58 +00:00
' <input type="submit" title="' + \
translate['Filter out words'] + '" ' + \
'alt="' + \
translate['Filter out words'] + ' | " ' + \
'name="submitFilter" value="' + translate['Filter'] + '">\n'
2021-12-31 21:18:12 +00:00
tl_str += \
2021-06-27 22:01:58 +00:00
' <input type="submit" title="' + \
translate['Unfilter words'] + '" ' + \
'alt="' + \
translate['Unfilter words'] + ' | " ' + \
'name="submitUnfilter" value="' + translate['Unfilter'] + '">\n'
2021-12-31 21:18:12 +00:00
tl_str += '</div>\n</form>\n'
return tl_str
2021-06-27 22:01:58 +00:00
2021-12-29 21:55:09 +00:00
def _html_timeline_keyboard(moderator: bool, text_mode_banner: str,
2021-12-31 21:18:12 +00:00
users_path: str,
nickname: str, new_calendar_event: bool,
new_dm: bool, new_reply: bool,
new_share: bool, new_wanted: bool,
follow_approvals: bool,
access_keys: {}, translate: {}) -> str:
2021-06-27 22:14:48 +00:00
"""Returns html for timeline keyboard navigation
"""
2021-12-31 21:18:12 +00:00
calendar_str = translate['Calendar']
if new_calendar_event:
calendar_str = '<strong>' + calendar_str + '</strong>'
dm_str = translate['DM']
if new_dm:
dm_str = '<strong>' + dm_str + '</strong>'
replies_str = translate['Replies']
if new_reply:
replies_str = '<strong>' + replies_str + '</strong>'
shares_str = translate['Shares']
if new_share:
shares_str = '<strong>' + shares_str + '</strong>'
wanted_str = translate['Wanted']
if new_wanted:
wanted_str = '<strong>' + wanted_str + '</strong>'
menu_profile = \
2021-12-29 21:55:09 +00:00
html_hide_from_screen_reader('👤') + ' ' + \
2021-06-27 22:14:48 +00:00
translate['Switch to profile view']
2021-12-31 21:18:12 +00:00
menu_inbox = \
2021-12-29 21:55:09 +00:00
html_hide_from_screen_reader('📥') + ' ' + translate['Inbox']
2021-12-31 21:18:12 +00:00
menu_outbox = \
2021-12-29 21:55:09 +00:00
html_hide_from_screen_reader('📤') + ' ' + translate['Sent']
2021-12-31 21:18:12 +00:00
menu_search = \
2021-12-29 21:55:09 +00:00
html_hide_from_screen_reader('🔍') + ' ' + \
2021-06-27 22:14:48 +00:00
translate['Search and follow']
2021-12-31 21:18:12 +00:00
menu_calendar = \
html_hide_from_screen_reader('📅') + ' ' + calendar_str
menu_dm = \
html_hide_from_screen_reader('📩') + ' ' + dm_str
menu_replies = \
html_hide_from_screen_reader('📨') + ' ' + replies_str
menu_bookmarks = \
2021-12-29 21:55:09 +00:00
html_hide_from_screen_reader('🔖') + ' ' + translate['Bookmarks']
2021-12-31 21:18:12 +00:00
menu_shares = \
html_hide_from_screen_reader('🤝') + ' ' + shares_str
menu_wanted = \
html_hide_from_screen_reader('') + ' ' + wanted_str
menu_blogs = \
2021-12-29 21:55:09 +00:00
html_hide_from_screen_reader('📝') + ' ' + translate['Blogs']
2021-12-31 21:18:12 +00:00
menu_newswire = \
2021-12-29 21:55:09 +00:00
html_hide_from_screen_reader('📰') + ' ' + translate['Newswire']
2021-12-31 21:18:12 +00:00
menu_links = \
2021-12-29 21:55:09 +00:00
html_hide_from_screen_reader('🔗') + ' ' + translate['Links']
2021-12-31 21:18:12 +00:00
menu_new_post = \
2021-12-29 21:55:09 +00:00
html_hide_from_screen_reader('') + ' ' + \
translate['Create a new post']
2021-12-31 21:18:12 +00:00
menu_moderation = \
2021-12-29 21:55:09 +00:00
html_hide_from_screen_reader('⚡️') + ' ' + translate['Mod']
2021-12-31 21:18:12 +00:00
nav_links = {
menu_profile: '/users/' + nickname,
menu_inbox: users_path + '/inbox#timelineposts',
menu_search: users_path + '/search',
menu_new_post: users_path + '/newpost',
menu_calendar: users_path + '/calendar',
menu_dm: users_path + '/dm#timelineposts',
menu_replies: users_path + '/tlreplies#timelineposts',
menu_outbox: users_path + '/outbox#timelineposts',
menu_bookmarks: users_path + '/tlbookmarks#timelineposts',
menu_shares: users_path + '/tlshares#timelineposts',
menu_wanted: users_path + '/tlwanted#timelineposts',
menu_blogs: users_path + '/tlblogs#timelineposts',
menu_newswire: users_path + '/newswiremobile',
menu_links: users_path + '/linksmobile'
2021-06-27 22:14:48 +00:00
}
2021-12-31 21:18:12 +00:00
nav_access_keys = {}
for variable_name, key in access_keys.items():
if not locals().get(variable_name):
2021-06-27 22:14:48 +00:00
continue
2021-12-31 21:18:12 +00:00
nav_access_keys[locals()[variable_name]] = key
2021-06-27 22:14:48 +00:00
if moderator:
2021-12-31 21:18:12 +00:00
nav_links[menu_moderation] = users_path + '/moderation#modtimeline'
return html_keyboard_navigation(text_mode_banner, nav_links,
nav_access_keys,
None, users_path, translate,
follow_approvals)
2021-12-29 21:55:09 +00:00
def _html_timeline_end(base_dir: str, nickname: str, domain_full: str,
http_prefix: str, translate: {},
moderator: bool, editor: bool,
newswire: {}, positive_voting: bool,
show_publish_as_icon: bool,
rss_icon_at_top: bool, publish_button_at_top: bool,
authorized: bool, theme: str,
2021-12-31 21:18:12 +00:00
default_timeline: str, access_keys: {},
box_name: str,
enable_timing_log: bool, timeline_start_time) -> str:
2021-07-28 11:26:03 +00:00
"""Ending of the timeline, containing the right column
"""
# end of timeline-posts
2021-12-31 21:18:12 +00:00
tl_str = ' </div>\n'
2021-07-28 11:26:03 +00:00
# end of column-center
2021-12-31 21:18:12 +00:00
tl_str += ' </td>\n'
2021-07-28 11:26:03 +00:00
# right column
2021-12-31 21:18:12 +00:00
right_column_str = \
get_right_column_content(base_dir, nickname, domain_full,
http_prefix, translate,
moderator, editor,
newswire, positive_voting,
False, None, True,
show_publish_as_icon,
rss_icon_at_top,
publish_button_at_top,
authorized, True, theme,
default_timeline, access_keys)
tl_str += ' <td valign="top" class="col-right" ' + \
2021-07-28 11:26:03 +00:00
'id="newswire" tabindex="-1">' + \
2021-12-31 21:18:12 +00:00
right_column_str + ' </td>\n'
tl_str += ' </tr>\n'
2021-07-28 11:26:03 +00:00
2021-12-31 21:18:12 +00:00
_log_timeline_timing(enable_timing_log, timeline_start_time, box_name, '9')
2021-07-28 11:26:03 +00:00
2021-12-31 21:18:12 +00:00
tl_str += ' </tbody>\n'
tl_str += '</table>\n'
return tl_str
2021-07-28 11:26:03 +00:00
2021-12-31 21:18:12 +00:00
def _page_number_buttons(users_path: str, box_name: str,
page_number: int) -> str:
2021-09-24 17:26:21 +00:00
"""Shows selactable page numbers at the bottom of the screen
"""
2021-12-31 21:18:12 +00:00
pages_width = 3
min_page_number = page_number - pages_width
if min_page_number < 1:
min_page_number = 1
max_page_number = min_page_number + 1 + (pages_width * 2)
num_str = ''
for page in range(min_page_number, max_page_number):
if num_str:
num_str += ''
page_str = str(page)
if page == page_number:
page_str = '<mark>' + str(page) + '</mark>'
num_str += \
'<a href="' + users_path + '/' + box_name + '?page=' + \
str(page) + '" class="pageslist">' + page_str + '</a>'
return '<center>' + num_str + '</center>'
def html_timeline(css_cache: {}, default_timeline: str,
2021-12-29 21:55:09 +00:00
recent_posts_cache: {}, max_recent_posts: int,
2021-12-31 21:18:12 +00:00
translate: {}, page_number: int,
items_per_page: int, session, base_dir: str,
2021-12-29 21:55:09 +00:00
cached_webfingers: {}, person_cache: {},
2021-12-31 21:18:12 +00:00
nickname: str, domain: str, port: int, timeline_json: {},
box_name: str, allow_deletion: bool,
2021-12-29 21:55:09 +00:00
http_prefix: str, project_version: str,
2021-12-31 21:18:12 +00:00
manually_approve_followers: bool,
2021-12-29 21:55:09 +00:00
minimal: bool,
yt_replace_domain: str,
twitter_replacement_domain: str,
show_published_date_only: bool,
newswire: {}, moderator: bool,
editor: bool, artist: bool,
positive_voting: bool,
show_publish_as_icon: bool,
full_width_tl_button_header: bool,
icons_as_buttons: bool,
rss_icon_at_top: bool,
publish_button_at_top: bool,
authorized: bool,
2021-12-31 21:18:12 +00:00
moderation_action_str: str,
2021-12-29 21:55:09 +00:00
theme: str,
peertube_instances: [],
allow_local_network_access: bool,
text_mode_banner: str,
2021-12-31 21:18:12 +00:00
access_keys: {}, system_language: str,
2021-12-29 21:55:09 +00:00
max_like_count: int,
shared_items_federated_domains: [],
signing_priv_key_pem: str,
2022-02-25 19:12:40 +00:00
cw_lists: {}, lists_enabled: str,
2022-03-24 13:14:41 +00:00
timezone: str, bold_reading: bool) -> str:
2020-11-10 15:12:07 +00:00
"""Show the timeline as html
2020-11-09 22:44:03 +00:00
"""
2021-12-31 21:18:12 +00:00
enable_timing_log = False
2020-12-01 17:23:34 +00:00
2021-12-31 21:18:12 +00:00
timeline_start_time = time.time()
2020-11-09 22:44:03 +00:00
2021-12-31 21:18:12 +00:00
account_dir = acct_dir(base_dir, nickname, domain)
2020-11-09 22:44:03 +00:00
2020-11-10 15:12:07 +00:00
# should the calendar icon be highlighted?
2021-12-31 21:18:12 +00:00
new_calendar_event = False
calendar_image = 'calendar.png'
calendar_path = '/calendar'
calendar_file = account_dir + '/.newCalendar'
if os.path.isfile(calendar_file):
new_calendar_event = True
calendar_image = 'calendar_notify.png'
with open(calendar_file, 'r') as calfile:
calendar_path = calfile.read().replace('##sent##', '')
calendar_path = calendar_path.replace('\n', '').replace('\r', '')
if '/calendar' not in calendar_path:
calendar_path = '/calendar'
2020-11-09 22:44:03 +00:00
2020-11-10 15:12:07 +00:00
# should the DM button be highlighted?
2021-12-31 21:18:12 +00:00
new_dm = False
dm_file = account_dir + '/.newDM'
if os.path.isfile(dm_file):
new_dm = True
if box_name == 'dm':
try:
2021-12-31 21:18:12 +00:00
os.remove(dm_file)
2021-11-25 18:42:38 +00:00
except OSError:
2021-12-31 21:18:12 +00:00
print('EX: html_timeline unable to delete ' + dm_file)
2020-11-09 22:44:03 +00:00
2020-11-10 15:12:07 +00:00
# should the Replies button be highlighted?
2021-12-31 21:18:12 +00:00
new_reply = False
reply_file = account_dir + '/.newReply'
if os.path.isfile(reply_file):
new_reply = True
if box_name == 'tlreplies':
try:
2021-12-31 21:18:12 +00:00
os.remove(reply_file)
2021-11-25 18:42:38 +00:00
except OSError:
2021-12-31 21:18:12 +00:00
print('EX: html_timeline unable to delete ' + reply_file)
2020-11-09 22:44:03 +00:00
2020-11-10 15:12:07 +00:00
# should the Shares button be highlighted?
2021-12-31 21:18:12 +00:00
new_share = False
new_share_file = account_dir + '/.newShare'
if os.path.isfile(new_share_file):
new_share = True
if box_name == 'tlshares':
try:
2021-12-31 21:18:12 +00:00
os.remove(new_share_file)
2021-11-25 18:42:38 +00:00
except OSError:
2021-12-31 21:18:12 +00:00
print('EX: html_timeline unable to delete ' + new_share_file)
2020-11-09 22:44:03 +00:00
2021-08-09 18:41:05 +00:00
# should the Wanted button be highlighted?
2021-12-31 21:18:12 +00:00
new_wanted = False
new_wanted_file = account_dir + '/.newWanted'
if os.path.isfile(new_wanted_file):
new_wanted = True
if box_name == 'tlwanted':
try:
2021-12-31 21:18:12 +00:00
os.remove(new_wanted_file)
2021-11-25 18:42:38 +00:00
except OSError:
2021-12-31 21:18:12 +00:00
print('EX: html_timeline unable to delete ' + new_wanted_file)
2021-08-09 18:41:05 +00:00
2020-11-10 15:12:07 +00:00
# should the Moderation/reports button be highlighted?
2021-12-31 21:18:12 +00:00
new_report = False
new_report_file = account_dir + '/.newReport'
if os.path.isfile(new_report_file):
new_report = True
if box_name == 'moderation':
try:
2021-12-31 21:18:12 +00:00
os.remove(new_report_file)
2021-11-25 18:42:38 +00:00
except OSError:
2021-12-31 21:18:12 +00:00
print('EX: html_timeline unable to delete ' + new_report_file)
2020-11-09 22:44:03 +00:00
2021-12-31 21:18:12 +00:00
separator_str = ''
if box_name != 'tlmedia':
separator_str = html_post_separator(base_dir, None)
2020-11-09 22:44:03 +00:00
2020-11-10 15:12:07 +00:00
# the css filename
2021-12-31 21:18:12 +00:00
css_filename = base_dir + '/epicyon-profile.css'
2021-12-25 16:17:53 +00:00
if os.path.isfile(base_dir + '/epicyon.css'):
2021-12-31 21:18:12 +00:00
css_filename = base_dir + '/epicyon.css'
2020-11-09 22:44:03 +00:00
2020-11-10 15:12:07 +00:00
# filename of the banner shown at the top
2021-12-31 21:18:12 +00:00
banner_file, _ = \
2021-12-29 21:55:09 +00:00
get_banner_file(base_dir, nickname, domain, theme)
2020-11-09 22:44:03 +00:00
2021-12-31 21:18:12 +00:00
_log_timeline_timing(enable_timing_log, timeline_start_time, box_name, '1')
2020-11-09 22:44:03 +00:00
2020-11-10 15:12:07 +00:00
# is the user a moderator?
if not moderator:
2021-12-28 19:33:29 +00:00
moderator = is_moderator(base_dir, nickname)
2020-11-09 22:44:03 +00:00
2020-11-10 15:12:07 +00:00
# is the user a site editor?
if not editor:
2021-12-26 13:27:57 +00:00
editor = is_editor(base_dir, nickname)
2020-11-09 22:44:03 +00:00
2021-12-31 21:18:12 +00:00
_log_timeline_timing(enable_timing_log, timeline_start_time, box_name, '2')
2020-11-09 22:44:03 +00:00
2020-11-10 15:12:07 +00:00
# the appearance of buttons - highlighted or not
2021-12-31 21:18:12 +00:00
inbox_button = 'button'
blogs_button = 'button'
features_button = 'button'
news_button = 'button'
dm_button = 'button'
if new_dm:
dm_button = 'buttonhighlighted'
replies_button = 'button'
if new_reply:
replies_button = 'buttonhighlighted'
media_button = 'button'
bookmarks_button = 'button'
# eventsButton = 'button'
2021-12-31 21:18:12 +00:00
sent_button = 'button'
shares_button = 'button'
if new_share:
shares_button = 'buttonhighlighted'
wanted_button = 'button'
if new_wanted:
wanted_button = 'buttonhighlighted'
moderation_button = 'button'
if new_report:
moderation_button = 'buttonhighlighted'
if box_name == 'inbox':
inbox_button = 'buttonselected'
elif box_name == 'tlblogs':
blogs_button = 'buttonselected'
elif box_name == 'tlfeatures':
features_button = 'buttonselected'
elif box_name == 'tlnews':
news_button = 'buttonselected'
elif box_name == 'dm':
dm_button = 'buttonselected'
if new_dm:
dm_button = 'buttonselectedhighlighted'
elif box_name == 'tlreplies':
replies_button = 'buttonselected'
if new_reply:
replies_button = 'buttonselectedhighlighted'
elif box_name == 'tlmedia':
media_button = 'buttonselected'
elif box_name == 'outbox':
sent_button = 'buttonselected'
elif box_name == 'moderation':
moderation_button = 'buttonselected'
if new_report:
moderation_button = 'buttonselectedhighlighted'
elif box_name == 'tlshares':
shares_button = 'buttonselected'
if new_share:
shares_button = 'buttonselectedhighlighted'
elif box_name == 'tlwanted':
wanted_button = 'buttonselected'
if new_wanted:
wanted_button = 'buttonselectedhighlighted'
elif box_name in ('tlbookmarks', 'bookmarks'):
bookmarks_button = 'buttonselected'
2020-11-09 22:44:03 +00:00
2020-11-10 15:12:07 +00:00
# get the full domain, including any port number
2021-12-31 21:18:12 +00:00
full_domain = get_full_domain(domain, port)
2020-11-09 22:44:03 +00:00
2021-12-31 21:18:12 +00:00
users_path = '/users/' + nickname
actor = http_prefix + '://' + full_domain + users_path
2020-11-09 22:44:03 +00:00
2021-12-31 21:18:12 +00:00
show_individual_post_icons = True
2020-11-10 15:12:07 +00:00
# show an icon for new follow approvals
2021-12-31 21:18:12 +00:00
follow_approvals = ''
follow_requests_filename = \
2021-12-26 12:02:29 +00:00
acct_dir(base_dir, nickname, domain) + '/followrequests.txt'
2021-12-31 21:18:12 +00:00
if os.path.isfile(follow_requests_filename):
with open(follow_requests_filename, 'r') as foll_file:
for line in foll_file:
2020-11-10 15:12:07 +00:00
if len(line) > 0:
# show follow approvals icon
2021-12-31 21:18:12 +00:00
follow_approvals = \
'<a href="' + users_path + \
2021-04-23 12:24:34 +00:00
'/followers#buttonheader" ' + \
2021-12-31 21:18:12 +00:00
'accesskey="' + access_keys['followButton'] + '">' + \
2022-03-28 08:47:53 +00:00
'<img loading="lazy" decoding="async" ' + \
2020-11-10 15:12:07 +00:00
'class="timelineicon" alt="' + \
translate['Approve follow requests'] + \
'" title="' + translate['Approve follow requests'] + \
2020-12-09 13:08:26 +00:00
'" src="/icons/person.png"/></a>\n'
2020-11-10 15:12:07 +00:00
break
2020-11-09 22:44:03 +00:00
2021-12-31 21:18:12 +00:00
_log_timeline_timing(enable_timing_log, timeline_start_time, box_name, '3')
2020-11-10 15:12:07 +00:00
# moderation / reports button
2021-12-31 21:18:12 +00:00
moderation_button_str = ''
2020-11-10 15:12:07 +00:00
if moderator and not minimal:
2021-12-31 21:18:12 +00:00
moderation_button_str = \
'<a href="' + users_path + \
2020-11-10 15:12:07 +00:00
'/moderation"><button class="' + \
2021-12-31 21:18:12 +00:00
moderation_button + '"><span>' + \
html_highlight_label(translate['Mod'], new_report) + \
2020-11-10 15:12:07 +00:00
' </span></button></a>'
# shares, bookmarks and events buttons
2021-12-31 21:18:12 +00:00
shares_button_str = ''
wanted_button_str = ''
bookmarks_button_str = ''
events_button_str = ''
2020-11-10 15:12:07 +00:00
if not minimal:
2021-12-31 21:18:12 +00:00
shares_button_str = \
'<a href="' + users_path + '/tlshares"><button class="' + \
shares_button + '"><span>' + \
html_highlight_label(translate['Shares'], new_share) + \
2020-11-09 22:44:03 +00:00
'</span></button></a>'
2021-12-31 21:18:12 +00:00
wanted_button_str = \
'<a href="' + users_path + '/tlwanted"><button class="' + \
wanted_button + '"><span>' + \
html_highlight_label(translate['Wanted'], new_wanted) + \
2021-08-09 18:41:05 +00:00
'</span></button></a>'
2021-12-31 21:18:12 +00:00
bookmarks_button_str = \
'<a href="' + users_path + '/tlbookmarks"><button class="' + \
bookmarks_button + '"><span>' + translate['Bookmarks'] + \
2020-11-10 15:12:07 +00:00
'</span></button></a>'
2020-11-09 22:44:03 +00:00
2021-12-31 21:18:12 +00:00
instance_title = \
2021-12-26 14:08:58 +00:00
get_config_param(base_dir, 'instanceTitle')
2021-12-31 21:18:12 +00:00
tl_str = \
html_header_with_external_style(css_filename, instance_title, None)
2020-11-10 15:12:07 +00:00
2021-12-31 21:18:12 +00:00
_log_timeline_timing(enable_timing_log, timeline_start_time, box_name, '4')
2020-11-09 22:44:03 +00:00
2020-11-10 15:12:07 +00:00
# if this is a news instance and we are viewing the news timeline
2021-12-31 21:18:12 +00:00
news_header = False
if default_timeline == 'tlfeatures' and box_name == 'tlfeatures':
news_header = True
2020-11-10 15:12:07 +00:00
2021-12-31 21:18:12 +00:00
new_post_button_str = ''
2020-11-10 15:12:07 +00:00
# start of headericons div
2021-12-31 21:18:12 +00:00
if not news_header:
2021-12-25 19:19:14 +00:00
if not icons_as_buttons:
2021-12-31 21:18:12 +00:00
new_post_button_str += '<div class="headericons">'
2020-11-10 15:12:07 +00:00
# what screen to go to when a new post is created
2021-12-31 21:18:12 +00:00
new_post_button_str += \
_html_timeline_new_post(manually_approve_followers, box_name,
icons_as_buttons, users_path, translate)
2020-11-09 22:44:03 +00:00
2021-02-05 15:30:51 +00:00
# keyboard navigation
2021-12-31 21:18:12 +00:00
tl_str += \
2021-12-29 21:55:09 +00:00
_html_timeline_keyboard(moderator, text_mode_banner,
2021-12-31 21:18:12 +00:00
users_path, nickname,
new_calendar_event, new_dm, new_reply,
new_share, new_wanted,
follow_approvals, access_keys, translate)
2020-11-09 22:44:03 +00:00
2020-11-10 15:12:07 +00:00
# banner and row of buttons
2021-12-31 21:18:12 +00:00
tl_str += \
2020-12-27 16:57:15 +00:00
'<header>\n' + \
2020-11-10 15:12:07 +00:00
'<a href="/users/' + nickname + '" title="' + \
translate['Switch to profile view'] + '" alt="' + \
translate['Switch to profile view'] + '">\n'
2022-03-28 08:47:53 +00:00
tl_str += '<img loading="lazy" decoding="async" ' + \
'class="timeline-banner" alt="" ' + \
2021-12-31 21:18:12 +00:00
'src="' + users_path + '/' + banner_file + '" /></a>\n' + \
2020-12-27 16:57:15 +00:00
'</header>\n'
2020-11-10 15:12:07 +00:00
2021-12-25 19:31:24 +00:00
if full_width_tl_button_header:
2021-12-31 21:18:12 +00:00
tl_str += \
header_buttons_timeline(default_timeline, box_name, page_number,
translate, users_path, media_button,
blogs_button, features_button,
news_button, inbox_button,
dm_button, new_dm, replies_button,
new_reply, minimal, sent_button,
shares_button_str, wanted_button_str,
bookmarks_button_str,
events_button_str, moderation_button_str,
new_post_button_str, base_dir, nickname,
domain, timeline_start_time,
new_calendar_event, calendar_path,
calendar_image, follow_approvals,
icons_as_buttons, access_keys)
2020-11-10 15:12:07 +00:00
# start the timeline
2021-12-31 21:18:12 +00:00
tl_str += \
2021-07-06 12:50:38 +00:00
'<table class="timeline">\n' + \
' <colgroup>\n' + \
' <col span="1" class="column-left">\n' + \
' <col span="1" class="column-center">\n' + \
' <col span="1" class="column-right">\n' + \
' </colgroup>\n' + \
' <tbody>\n' + \
' <tr>\n'
2020-11-10 15:12:07 +00:00
2021-12-26 12:45:03 +00:00
domain_full = get_full_domain(domain, port)
2020-11-10 15:12:07 +00:00
# left column
2021-12-31 21:18:12 +00:00
left_column_str = \
2021-12-29 21:55:09 +00:00
get_left_column_content(base_dir, nickname, domain_full,
http_prefix, translate,
editor, artist, False, None, rss_icon_at_top,
2021-12-31 21:18:12 +00:00
True, False, theme, access_keys,
2021-12-29 21:55:09 +00:00
shared_items_federated_domains)
2021-12-31 21:18:12 +00:00
tl_str += ' <td valign="top" class="col-left" ' + \
2021-02-01 13:31:49 +00:00
'id="links" tabindex="-1">' + \
2021-12-31 21:18:12 +00:00
left_column_str + ' </td>\n'
2020-11-10 15:12:07 +00:00
# center column containing posts
2021-12-31 21:18:12 +00:00
tl_str += ' <td valign="top" class="col-center">\n'
2020-11-10 15:12:07 +00:00
2021-12-25 19:31:24 +00:00
if not full_width_tl_button_header:
2021-12-31 21:18:12 +00:00
tl_str += \
header_buttons_timeline(default_timeline, box_name, page_number,
translate, users_path, media_button,
blogs_button, features_button,
news_button, inbox_button,
dm_button, new_dm, replies_button,
new_reply, minimal, sent_button,
shares_button_str, wanted_button_str,
bookmarks_button_str,
events_button_str, moderation_button_str,
new_post_button_str, base_dir, nickname,
domain, timeline_start_time,
new_calendar_event, calendar_path,
calendar_image, follow_approvals,
icons_as_buttons, access_keys)
tl_str += ' <div id="timelineposts" class="timeline-posts">\n'
2020-11-18 18:22:05 +00:00
2020-11-10 15:12:07 +00:00
# second row of buttons for moderator actions
2021-12-31 21:18:12 +00:00
tl_str += \
_html_timeline_moderation_buttons(moderator, box_name, nickname,
moderation_action_str, translate)
2020-11-09 22:44:03 +00:00
2021-12-31 21:18:12 +00:00
_log_timeline_timing(enable_timing_log, timeline_start_time, box_name, '6')
2020-11-09 22:44:03 +00:00
2021-12-31 21:18:12 +00:00
if box_name == 'tlshares':
max_shares_per_account = items_per_page
return (tl_str +
_html_shares_timeline(translate, page_number, items_per_page,
2021-12-29 21:55:09 +00:00
base_dir, actor, nickname, domain, port,
2021-12-31 21:18:12 +00:00
max_shares_per_account, http_prefix,
2021-12-29 21:55:09 +00:00
shared_items_federated_domains,
'shares') +
_html_timeline_end(base_dir, nickname, domain_full,
http_prefix, translate,
moderator, editor,
newswire, positive_voting,
show_publish_as_icon,
rss_icon_at_top, publish_button_at_top,
authorized, theme,
2021-12-31 21:18:12 +00:00
default_timeline, access_keys,
box_name,
enable_timing_log, timeline_start_time) +
2021-12-29 21:55:09 +00:00
html_footer())
2021-12-31 21:18:12 +00:00
elif box_name == 'tlwanted':
max_shares_per_account = items_per_page
return (tl_str +
_html_shares_timeline(translate, page_number, items_per_page,
2021-12-29 21:55:09 +00:00
base_dir, actor, nickname, domain, port,
2021-12-31 21:18:12 +00:00
max_shares_per_account, http_prefix,
2021-12-29 21:55:09 +00:00
shared_items_federated_domains,
'wanted') +
_html_timeline_end(base_dir, nickname, domain_full,
http_prefix, translate,
moderator, editor,
newswire, positive_voting,
show_publish_as_icon,
rss_icon_at_top, publish_button_at_top,
authorized, theme,
2021-12-31 21:18:12 +00:00
default_timeline, access_keys,
box_name,
enable_timing_log, timeline_start_time) +
2021-12-29 21:55:09 +00:00
html_footer())
2021-12-31 21:18:12 +00:00
_log_timeline_timing(enable_timing_log, timeline_start_time, box_name, '7')
2020-11-09 22:44:03 +00:00
2021-02-07 21:45:31 +00:00
# separator between posts which only appears in shell browsers
# such as Lynx and is not read by screen readers
2021-12-31 21:18:12 +00:00
if box_name != 'tlmedia':
text_mode_separator = \
'<div class="transparent"><hr></div>'
2021-02-18 20:10:26 +00:00
else:
2021-12-31 21:18:12 +00:00
text_mode_separator = ''
2021-02-07 21:45:31 +00:00
2020-11-10 15:12:07 +00:00
# page up arrow
2021-12-31 21:18:12 +00:00
if page_number > 1:
tl_str += text_mode_separator
tl_str += '<br>' + \
_page_number_buttons(users_path, box_name, page_number)
tl_str += \
2020-11-10 15:12:07 +00:00
' <center>\n' + \
2021-12-31 21:18:12 +00:00
' <a href="' + users_path + '/' + box_name + \
'?page=' + str(page_number - 1) + \
'" accesskey="' + access_keys['Page up'] + '">' + \
2022-03-28 08:47:53 +00:00
'<img loading="lazy" decoding="async" class="pageicon" src="/' + \
2020-12-09 13:08:26 +00:00
'icons/pageup.png" title="' + \
2020-11-10 15:12:07 +00:00
translate['Page up'] + '" alt="' + \
translate['Page up'] + '"></a>\n' + \
' </center>\n'
2020-11-09 22:44:03 +00:00
2020-11-10 15:12:07 +00:00
# show the posts
2021-12-31 21:18:12 +00:00
item_ctr = 0
if timeline_json:
if 'orderedItems' not in timeline_json:
2021-08-01 19:43:20 +00:00
print('ERROR: no orderedItems in timeline for '
2021-12-31 21:18:12 +00:00
+ box_name + ' ' + str(timeline_json))
return ''
2021-12-31 21:18:12 +00:00
use_cache_only = False
if box_name == 'inbox':
use_cache_only = True
2021-12-31 21:18:12 +00:00
if timeline_json:
2020-11-10 15:12:07 +00:00
# if this is the media timeline then add an extra gallery container
2021-12-31 21:18:12 +00:00
if box_name == 'tlmedia':
if page_number > 1:
tl_str += '<br>'
tl_str += '<div class="galleryContainer">\n'
2020-11-09 22:44:03 +00:00
2020-11-10 15:12:07 +00:00
# show each post in the timeline
2021-12-31 21:18:12 +00:00
for item in timeline_json['orderedItems']:
2020-11-10 15:12:07 +00:00
if item['type'] == 'Create' or \
2021-03-05 15:45:03 +00:00
item['type'] == 'Announce':
2020-11-10 15:12:07 +00:00
# is the actor who sent this post snoozed?
2021-12-29 21:55:09 +00:00
if is_person_snoozed(base_dir, nickname, domain,
item['actor']):
2020-11-10 15:12:07 +00:00
continue
2021-12-29 21:55:09 +00:00
if is_self_announce(item):
continue
2020-11-09 22:44:03 +00:00
2020-11-10 15:12:07 +00:00
# is the post in the memory cache of recent ones?
2021-12-31 21:18:12 +00:00
curr_tl_str = None
if box_name != 'tlmedia' and recent_posts_cache.get('html'):
2021-12-27 11:20:57 +00:00
post_id = remove_id_ending(item['id']).replace('/', '#')
2021-12-26 20:01:37 +00:00
if recent_posts_cache['html'].get(post_id):
2021-12-31 21:18:12 +00:00
curr_tl_str = recent_posts_cache['html'][post_id]
curr_tl_str = \
2021-12-29 21:55:09 +00:00
prepare_post_from_html_cache(nickname,
2021-12-31 21:18:12 +00:00
curr_tl_str,
box_name,
page_number)
_log_timeline_timing(enable_timing_log,
timeline_start_time,
box_name, '10')
if not curr_tl_str:
_log_timeline_timing(enable_timing_log,
timeline_start_time,
box_name, '11')
2020-11-09 22:44:03 +00:00
mitm = False
if item.get('mitm'):
mitm = True
2020-11-10 15:12:07 +00:00
# read the post from disk
2021-12-31 21:18:12 +00:00
curr_tl_str = \
2021-12-29 21:55:09 +00:00
individual_post_as_html(signing_priv_key_pem,
False, recent_posts_cache,
max_recent_posts,
2021-12-31 21:18:12 +00:00
translate, page_number,
2021-12-29 21:55:09 +00:00
base_dir, session,
cached_webfingers,
person_cache,
nickname, domain, port,
item, None, True,
allow_deletion,
http_prefix, project_version,
2021-12-31 21:18:12 +00:00
box_name,
2021-12-29 21:55:09 +00:00
yt_replace_domain,
twitter_replacement_domain,
show_published_date_only,
peertube_instances,
allow_local_network_access,
theme, system_language,
max_like_count,
2021-12-31 21:18:12 +00:00
box_name != 'dm',
show_individual_post_icons,
manually_approve_followers,
False, True, use_cache_only,
2022-02-25 19:12:40 +00:00
cw_lists, lists_enabled,
2022-03-24 13:14:41 +00:00
timezone, mitm,
bold_reading)
2021-12-31 21:18:12 +00:00
_log_timeline_timing(enable_timing_log,
timeline_start_time, box_name, '12')
if curr_tl_str:
if curr_tl_str not in tl_str:
item_ctr += 1
tl_str += text_mode_separator + curr_tl_str
if separator_str:
tl_str += separator_str
if box_name == 'tlmedia':
tl_str += '</div>\n'
if item_ctr < 3:
print('Items added to html timeline ' + box_name + ': ' +
str(item_ctr) + ' ' + str(timeline_json['orderedItems']))
2020-11-10 15:12:07 +00:00
# page down arrow
2021-12-31 21:18:12 +00:00
if item_ctr > 0:
tl_str += text_mode_separator
tl_str += \
' <br>\n' + \
2020-11-10 15:12:07 +00:00
' <center>\n' + \
2021-12-31 21:18:12 +00:00
' <a href="' + users_path + '/' + box_name + '?page=' + \
str(page_number + 1) + \
'" accesskey="' + access_keys['Page down'] + '">' + \
2022-03-28 08:47:53 +00:00
'<img loading="lazy" decoding="async" class="pageicon" src="/' + \
2020-12-09 13:08:26 +00:00
'icons/pagedown.png" title="' + \
2020-11-10 15:12:07 +00:00
translate['Page down'] + '" alt="' + \
translate['Page down'] + '"></a>\n' + \
' </center>\n'
2021-12-31 21:18:12 +00:00
tl_str += _page_number_buttons(users_path, box_name, page_number)
tl_str += text_mode_separator
elif item_ctr == 0:
tl_str += _get_help_for_timeline(base_dir, box_name)
2020-11-18 18:22:05 +00:00
2021-12-31 21:18:12 +00:00
tl_str += \
2021-12-29 21:55:09 +00:00
_html_timeline_end(base_dir, nickname, domain_full,
http_prefix, translate,
moderator, editor,
newswire, positive_voting,
show_publish_as_icon,
rss_icon_at_top, publish_button_at_top,
authorized, theme,
2021-12-31 21:18:12 +00:00
default_timeline, access_keys,
box_name,
enable_timing_log, timeline_start_time)
tl_str += html_footer()
return tl_str
2020-11-09 22:44:03 +00:00
2021-12-31 21:18:12 +00:00
def html_individual_share(domain: str, share_id: str,
actor: str, shared_item: {}, translate: {},
show_contact: bool, remove_button: bool,
2021-12-29 21:55:09 +00:00
sharesFileType: str) -> str:
2020-11-10 15:12:07 +00:00
"""Returns an individual shared item as html
"""
2021-12-31 21:18:12 +00:00
profile_str = '<div class="container">\n'
profile_str += \
'<p class="share-title">' + shared_item['displayName'] + '</p>\n'
if shared_item.get('imageUrl'):
profile_str += '<a href="' + shared_item['imageUrl'] + '">\n'
profile_str += \
2022-03-28 08:47:53 +00:00
'<img loading="lazy" decoding="async" ' + \
'src="' + shared_item['imageUrl'] + \
2020-11-10 15:12:07 +00:00
'" alt="' + translate['Item image'] + '">\n</a>\n'
2021-12-31 21:18:12 +00:00
profile_str += '<p>' + shared_item['summary'] + '</p>\n<p>'
if shared_item.get('itemQty'):
if shared_item['itemQty'] > 1:
profile_str += \
2021-07-27 20:31:14 +00:00
'<b>' + translate['Quantity'] + ':</b> ' + \
2021-12-31 21:18:12 +00:00
str(shared_item['itemQty']) + '<br>'
profile_str += \
'<b>' + translate['Type'] + ':</b> ' + shared_item['itemType'] + '<br>'
profile_str += \
2021-09-21 09:58:55 +00:00
'<b>' + translate['Category'] + ':</b> ' + \
2021-12-31 21:18:12 +00:00
shared_item['category'] + '<br>'
if shared_item.get('location'):
profile_str += \
2021-07-27 20:29:29 +00:00
'<b>' + translate['Location'] + ':</b> ' + \
2021-12-31 21:18:12 +00:00
shared_item['location'] + '<br>'
contact_title_str = translate['Contact']
if shared_item.get('itemPrice') and shared_item.get('itemCurrency'):
if is_float(shared_item['itemPrice']):
if float(shared_item['itemPrice']) > 0:
profile_str += ' ' + \
2021-07-24 22:08:11 +00:00
'<b>' + translate['Price'] + ':</b> ' + \
2021-12-31 21:18:12 +00:00
shared_item['itemPrice'] + ' ' + \
shared_item['itemCurrency']
contact_title_str = translate['Buy']
profile_str += '</p>\n'
sharedesc = shared_item['displayName']
2021-09-19 16:20:12 +00:00
if '<' not in sharedesc and ';' not in sharedesc:
2021-12-31 21:18:12 +00:00
if show_contact:
button_style_str = 'button'
if shared_item['category'] == 'accommodation':
contact_title_str = translate['Request to stay']
button_style_str = 'contactbutton'
contact_actor = shared_item['actor']
profile_str += \
'<p>' + \
'<a href="' + actor + \
'?replydm=sharedesc:' + sharedesc + \
2021-12-31 21:18:12 +00:00
'?mention=' + contact_actor + '">' + \
'<button class="' + button_style_str + '">' + \
contact_title_str + '</button></a>\n'
profile_str += \
'<a href="' + contact_actor + '"><button class="button">' + \
2021-09-19 16:20:12 +00:00
translate['Profile'] + '</button></a>\n'
2021-12-31 21:18:12 +00:00
if remove_button and domain in share_id:
2021-08-09 20:05:14 +00:00
if sharesFileType == 'shares':
2021-12-31 21:18:12 +00:00
profile_str += \
' <a href="' + actor + '?rmshare=' + share_id + \
2021-08-09 20:05:14 +00:00
'"><button class="button">' + \
translate['Remove'] + '</button></a>\n'
else:
2021-12-31 21:18:12 +00:00
profile_str += \
' <a href="' + actor + '?rmwanted=' + share_id + \
2021-08-09 20:05:14 +00:00
'"><button class="button">' + \
translate['Remove'] + '</button></a>\n'
2021-12-31 21:18:12 +00:00
profile_str += '</div>\n'
return profile_str
2020-11-09 22:44:03 +00:00
2021-12-31 21:18:12 +00:00
def _html_shares_timeline(translate: {}, page_number: int, items_per_page: int,
2021-12-29 21:55:09 +00:00
base_dir: str, actor: str,
nickname: str, domain: str, port: int,
2021-12-31 21:18:12 +00:00
max_shares_per_account: int, http_prefix: str,
2021-12-29 21:55:09 +00:00
shared_items_federated_domains: [],
sharesFileType: str) -> str:
2020-11-10 15:12:07 +00:00
"""Show shared items timeline as html
"""
2021-12-31 21:18:12 +00:00
shares_json, lastPage = \
shares_timeline_json(actor, page_number, items_per_page,
base_dir, domain, nickname,
max_shares_per_account,
2021-12-29 21:55:09 +00:00
shared_items_federated_domains, sharesFileType)
2021-12-26 12:45:03 +00:00
domain_full = get_full_domain(domain, port)
2021-12-26 10:19:59 +00:00
actor = local_actor_url(http_prefix, nickname, domain_full)
2021-12-31 21:18:12 +00:00
admin_nickname = get_config_param(base_dir, 'admin')
admin_actor = ''
if admin_nickname:
admin_actor = \
local_actor_url(http_prefix, admin_nickname, domain_full)
timeline_str = ''
if page_number > 1:
timeline_str += '<br>' + \
_page_number_buttons(actor, 'tl' + sharesFileType, page_number)
timeline_str += \
2020-11-10 15:12:07 +00:00
' <center>\n' + \
' <a href="' + actor + '/tl' + sharesFileType + '?page=' + \
2021-12-31 21:18:12 +00:00
str(page_number - 1) + \
2022-03-28 08:47:53 +00:00
'"><img loading="lazy" decoding="async" ' + \
'class="pageicon" src="/' + \
2020-12-09 13:08:26 +00:00
'icons/pageup.png" title="' + translate['Page up'] + \
2020-11-10 15:12:07 +00:00
'" alt="' + translate['Page up'] + '"></a>\n' + \
' </center>\n'
2020-11-09 22:44:03 +00:00
2021-12-31 21:18:12 +00:00
separator_str = html_post_separator(base_dir, None)
2021-02-26 13:31:31 +00:00
ctr = 0
2021-12-31 21:18:12 +00:00
is_admin_account = False
if admin_actor and actor == admin_actor:
is_admin_account = True
is_moderator_account = False
2021-12-28 19:33:29 +00:00
if is_moderator(base_dir, nickname):
2021-12-31 21:18:12 +00:00
is_moderator_account = True
for _, shared_item in shares_json.items():
show_contact_button = False
if shared_item['actor'] != actor:
show_contact_button = True
show_remove_button = False
if '___' + domain in shared_item['shareId']:
if shared_item['actor'] == actor or \
is_admin_account or is_moderator_account:
show_remove_button = True
timeline_str += \
html_individual_share(domain, shared_item['shareId'],
actor, shared_item, translate,
show_contact_button, show_remove_button,
2021-12-29 21:55:09 +00:00
sharesFileType)
2021-12-31 21:18:12 +00:00
timeline_str += separator_str
2021-02-26 13:31:31 +00:00
ctr += 1
if ctr == 0:
2021-12-31 21:18:12 +00:00
timeline_str += _get_help_for_timeline(base_dir, 'tl' + sharesFileType)
2020-11-09 22:44:03 +00:00
2020-11-10 15:12:07 +00:00
if not lastPage:
2021-12-31 21:18:12 +00:00
timeline_str += \
2020-11-10 15:12:07 +00:00
' <center>\n' + \
' <a href="' + actor + '/tl' + sharesFileType + '?page=' + \
2021-12-31 21:18:12 +00:00
str(page_number + 1) + \
2022-03-28 08:47:53 +00:00
'"><img loading="lazy" decoding="async" ' + \
'class="pageicon" src="/' + \
2020-12-09 13:08:26 +00:00
'icons/pagedown.png" title="' + translate['Page down'] + \
2020-11-10 15:12:07 +00:00
'" alt="' + translate['Page down'] + '"></a>\n' + \
' </center>\n'
2021-12-31 21:18:12 +00:00
timeline_str += \
_page_number_buttons(actor, 'tl' + sharesFileType, page_number)
2020-11-09 22:44:03 +00:00
2021-12-31 21:18:12 +00:00
return timeline_str
2020-11-09 22:44:03 +00:00
2021-12-31 21:18:12 +00:00
def html_shares(css_cache: {}, default_timeline: str,
2021-12-29 21:55:09 +00:00
recent_posts_cache: {}, max_recent_posts: int,
2021-12-31 21:18:12 +00:00
translate: {}, page_number: int, items_per_page: int,
2021-12-29 21:55:09 +00:00
session, base_dir: str,
cached_webfingers: {}, person_cache: {},
nickname: str, domain: str, port: int,
allow_deletion: bool,
http_prefix: str, project_version: str,
yt_replace_domain: str,
twitter_replacement_domain: str,
show_published_date_only: bool,
newswire: {}, positive_voting: bool,
show_publish_as_icon: bool,
full_width_tl_button_header: bool,
icons_as_buttons: bool,
rss_icon_at_top: bool,
publish_button_at_top: bool,
authorized: bool, theme: str,
peertube_instances: [],
allow_local_network_access: bool,
text_mode_banner: str,
2021-12-31 21:18:12 +00:00
access_keys: {}, system_language: str,
2021-12-29 21:55:09 +00:00
max_like_count: int,
shared_items_federated_domains: [],
signing_priv_key_pem: str,
2022-02-25 19:12:40 +00:00
cw_lists: {}, lists_enabled: str,
2022-03-24 13:14:41 +00:00
timezone: str, bold_reading: bool) -> str:
2020-11-09 22:44:03 +00:00
"""Show the shares timeline as html
"""
2021-12-31 21:18:12 +00:00
manually_approve_followers = \
2021-12-28 20:32:11 +00:00
follower_approval_active(base_dir, nickname, domain)
2021-12-26 14:17:13 +00:00
artist = is_artist(base_dir, nickname)
2020-11-09 22:44:03 +00:00
2021-12-31 21:18:12 +00:00
return html_timeline(css_cache, default_timeline,
2021-12-29 21:55:09 +00:00
recent_posts_cache, max_recent_posts,
2021-12-31 21:18:12 +00:00
translate, page_number,
items_per_page, session, base_dir,
2021-12-29 21:55:09 +00:00
cached_webfingers, person_cache,
nickname, domain, port, None,
'tlshares', allow_deletion,
http_prefix, project_version,
2021-12-31 21:18:12 +00:00
manually_approve_followers,
2021-12-29 21:55:09 +00:00
False,
yt_replace_domain,
twitter_replacement_domain,
show_published_date_only,
newswire, False, False, artist,
positive_voting, show_publish_as_icon,
full_width_tl_button_header,
icons_as_buttons, rss_icon_at_top,
publish_button_at_top,
authorized, None, theme, peertube_instances,
allow_local_network_access, text_mode_banner,
2021-12-31 21:18:12 +00:00
access_keys, system_language, max_like_count,
2021-12-29 21:55:09 +00:00
shared_items_federated_domains,
signing_priv_key_pem,
2022-03-24 13:14:41 +00:00
cw_lists, lists_enabled, timezone,
bold_reading)
2021-12-29 21:55:09 +00:00
2021-12-31 21:18:12 +00:00
def html_wanted(css_cache: {}, default_timeline: str,
2021-12-29 21:55:09 +00:00
recent_posts_cache: {}, max_recent_posts: int,
2021-12-31 21:18:12 +00:00
translate: {}, page_number: int, items_per_page: int,
2021-12-29 21:55:09 +00:00
session, base_dir: str,
cached_webfingers: {}, person_cache: {},
nickname: str, domain: str, port: int,
allow_deletion: bool,
http_prefix: str, project_version: str,
yt_replace_domain: str,
twitter_replacement_domain: str,
show_published_date_only: bool,
newswire: {}, positive_voting: bool,
show_publish_as_icon: bool,
full_width_tl_button_header: bool,
icons_as_buttons: bool,
rss_icon_at_top: bool,
publish_button_at_top: bool,
authorized: bool, theme: str,
peertube_instances: [],
allow_local_network_access: bool,
text_mode_banner: str,
2021-12-31 21:18:12 +00:00
access_keys: {}, system_language: str,
2021-12-29 21:55:09 +00:00
max_like_count: int,
shared_items_federated_domains: [],
signing_priv_key_pem: str,
2022-02-25 19:12:40 +00:00
cw_lists: {}, lists_enabled: str,
2022-03-24 13:14:41 +00:00
timezone: str, bold_reading: bool) -> str:
2021-12-29 21:55:09 +00:00
"""Show the wanted timeline as html
"""
2021-12-31 21:18:12 +00:00
manually_approve_followers = \
2021-12-29 21:55:09 +00:00
follower_approval_active(base_dir, nickname, domain)
artist = is_artist(base_dir, nickname)
2021-12-31 21:18:12 +00:00
return html_timeline(css_cache, default_timeline,
2021-12-29 21:55:09 +00:00
recent_posts_cache, max_recent_posts,
2021-12-31 21:18:12 +00:00
translate, page_number,
items_per_page, session, base_dir,
2021-12-29 21:55:09 +00:00
cached_webfingers, person_cache,
nickname, domain, port, None,
'tlwanted', allow_deletion,
http_prefix, project_version,
2021-12-31 21:18:12 +00:00
manually_approve_followers,
2021-12-29 21:55:09 +00:00
False,
yt_replace_domain,
twitter_replacement_domain,
show_published_date_only,
newswire, False, False, artist,
positive_voting, show_publish_as_icon,
full_width_tl_button_header,
icons_as_buttons, rss_icon_at_top,
publish_button_at_top,
authorized, None, theme, peertube_instances,
allow_local_network_access, text_mode_banner,
2021-12-31 21:18:12 +00:00
access_keys, system_language, max_like_count,
2021-12-29 21:55:09 +00:00
shared_items_federated_domains,
signing_priv_key_pem,
2022-03-24 13:14:41 +00:00
cw_lists, lists_enabled, timezone,
bold_reading)
2021-12-29 21:55:09 +00:00
2021-12-31 21:18:12 +00:00
def html_inbox(css_cache: {}, default_timeline: str,
2021-12-26 20:01:37 +00:00
recent_posts_cache: {}, max_recent_posts: int,
2021-12-31 21:18:12 +00:00
translate: {}, page_number: int, items_per_page: int,
2021-12-25 16:17:53 +00:00
session, base_dir: str,
2021-12-25 22:28:18 +00:00
cached_webfingers: {}, person_cache: {},
2021-12-29 21:55:09 +00:00
nickname: str, domain: str, port: int, inboxJson: {},
2021-12-25 21:29:53 +00:00
allow_deletion: bool,
2021-12-25 20:34:38 +00:00
http_prefix: str, project_version: str,
2021-12-29 21:55:09 +00:00
minimal: bool,
2021-12-25 17:15:52 +00:00
yt_replace_domain: str,
2021-12-25 20:55:47 +00:00
twitter_replacement_domain: str,
2021-12-25 20:06:27 +00:00
show_published_date_only: bool,
2021-12-25 20:14:45 +00:00
newswire: {}, positive_voting: bool,
2021-12-25 19:34:20 +00:00
show_publish_as_icon: bool,
2021-12-25 19:31:24 +00:00
full_width_tl_button_header: bool,
2021-12-25 19:19:14 +00:00
icons_as_buttons: bool,
2021-12-25 19:09:03 +00:00
rss_icon_at_top: bool,
2021-12-25 19:00:00 +00:00
publish_button_at_top: bool,
2021-08-09 18:41:05 +00:00
authorized: bool, theme: str,
2021-12-25 23:38:53 +00:00
peertube_instances: [],
2021-12-25 18:54:50 +00:00
allow_local_network_access: bool,
2021-12-25 23:09:49 +00:00
text_mode_banner: str,
2021-12-31 21:18:12 +00:00
access_keys: {}, system_language: str,
2021-12-25 18:23:12 +00:00
max_like_count: int,
2021-12-25 18:05:01 +00:00
shared_items_federated_domains: [],
2021-12-25 23:03:28 +00:00
signing_priv_key_pem: str,
2022-02-25 19:12:40 +00:00
cw_lists: {}, lists_enabled: str,
2022-03-24 13:14:41 +00:00
timezone: str, bold_reading: bool) -> str:
2020-11-09 22:44:03 +00:00
"""Show the inbox as html
"""
2021-12-31 21:18:12 +00:00
manually_approve_followers = \
2021-12-28 20:32:11 +00:00
follower_approval_active(base_dir, nickname, domain)
2021-12-26 14:17:13 +00:00
artist = is_artist(base_dir, nickname)
2020-11-09 22:44:03 +00:00
2021-12-31 21:18:12 +00:00
return html_timeline(css_cache, default_timeline,
2021-12-29 21:55:09 +00:00
recent_posts_cache, max_recent_posts,
2021-12-31 21:18:12 +00:00
translate, page_number,
items_per_page, session, base_dir,
2021-12-29 21:55:09 +00:00
cached_webfingers, person_cache,
nickname, domain, port, inboxJson,
'inbox', allow_deletion,
http_prefix, project_version,
2021-12-31 21:18:12 +00:00
manually_approve_followers,
2021-12-29 21:55:09 +00:00
minimal,
yt_replace_domain,
twitter_replacement_domain,
show_published_date_only,
newswire, False, False, artist,
positive_voting, show_publish_as_icon,
full_width_tl_button_header,
icons_as_buttons, rss_icon_at_top,
publish_button_at_top,
authorized, None, theme, peertube_instances,
allow_local_network_access, text_mode_banner,
2021-12-31 21:18:12 +00:00
access_keys, system_language, max_like_count,
2021-12-29 21:55:09 +00:00
shared_items_federated_domains,
signing_priv_key_pem,
2022-03-24 13:14:41 +00:00
cw_lists, lists_enabled, timezone,
bold_reading)
2021-12-29 21:55:09 +00:00
2021-12-31 21:18:12 +00:00
def html_bookmarks(css_cache: {}, default_timeline: str,
2021-12-29 21:55:09 +00:00
recent_posts_cache: {}, max_recent_posts: int,
2021-12-31 21:18:12 +00:00
translate: {}, page_number: int, items_per_page: int,
2021-12-29 21:55:09 +00:00
session, base_dir: str,
cached_webfingers: {}, person_cache: {},
nickname: str, domain: str, port: int, bookmarksJson: {},
allow_deletion: bool,
http_prefix: str, project_version: str,
minimal: bool,
yt_replace_domain: str,
twitter_replacement_domain: str,
show_published_date_only: bool,
newswire: {}, positive_voting: bool,
show_publish_as_icon: bool,
full_width_tl_button_header: bool,
icons_as_buttons: bool,
rss_icon_at_top: bool,
publish_button_at_top: bool,
authorized: bool, theme: str,
peertube_instances: [],
allow_local_network_access: bool,
text_mode_banner: str,
2021-12-31 21:18:12 +00:00
access_keys: {}, system_language: str,
2021-12-29 21:55:09 +00:00
max_like_count: int,
shared_items_federated_domains: [],
signing_priv_key_pem: str,
2022-02-25 19:12:40 +00:00
cw_lists: {}, lists_enabled: str,
2022-03-24 13:14:41 +00:00
timezone: str, bold_reading: bool) -> str:
2020-11-09 22:44:03 +00:00
"""Show the bookmarks as html
"""
2021-12-31 21:18:12 +00:00
manually_approve_followers = \
2021-12-28 20:32:11 +00:00
follower_approval_active(base_dir, nickname, domain)
2021-12-26 14:17:13 +00:00
artist = is_artist(base_dir, nickname)
2020-11-09 22:44:03 +00:00
2021-12-31 21:18:12 +00:00
return html_timeline(css_cache, default_timeline,
2021-12-29 21:55:09 +00:00
recent_posts_cache, max_recent_posts,
2021-12-31 21:18:12 +00:00
translate, page_number,
items_per_page, session, base_dir,
2021-12-29 21:55:09 +00:00
cached_webfingers, person_cache,
nickname, domain, port, bookmarksJson,
'tlbookmarks', allow_deletion,
http_prefix, project_version,
2021-12-31 21:18:12 +00:00
manually_approve_followers,
2021-12-29 21:55:09 +00:00
minimal,
yt_replace_domain,
twitter_replacement_domain,
show_published_date_only,
newswire, False, False, artist,
positive_voting, show_publish_as_icon,
full_width_tl_button_header,
icons_as_buttons, rss_icon_at_top,
publish_button_at_top,
authorized, None, theme, peertube_instances,
allow_local_network_access, text_mode_banner,
2021-12-31 21:18:12 +00:00
access_keys, system_language, max_like_count,
2021-12-29 21:55:09 +00:00
shared_items_federated_domains, signing_priv_key_pem,
2022-03-24 13:14:41 +00:00
cw_lists, lists_enabled, timezone,
bold_reading)
2021-12-29 21:55:09 +00:00
2022-01-04 13:34:31 +00:00
def html_inbox_dms(css_cache: {}, default_timeline: str,
recent_posts_cache: {}, max_recent_posts: int,
translate: {}, page_number: int, items_per_page: int,
session, base_dir: str,
cached_webfingers: {}, person_cache: {},
nickname: str, domain: str, port: int, inboxJson: {},
allow_deletion: bool,
http_prefix: str, project_version: str,
minimal: bool,
yt_replace_domain: str,
twitter_replacement_domain: str,
show_published_date_only: bool,
newswire: {}, positive_voting: bool,
show_publish_as_icon: bool,
full_width_tl_button_header: bool,
icons_as_buttons: bool,
rss_icon_at_top: bool,
publish_button_at_top: bool,
authorized: bool, theme: str,
peertube_instances: [],
allow_local_network_access: bool,
text_mode_banner: str,
access_keys: {}, system_language: str,
max_like_count: int,
shared_items_federated_domains: [],
signing_priv_key_pem: str,
2022-02-25 19:12:40 +00:00
cw_lists: {}, lists_enabled: str,
2022-03-24 13:14:41 +00:00
timezone: str, bold_reading: bool) -> str:
2020-11-09 22:44:03 +00:00
"""Show the DM timeline as html
"""
2021-12-26 14:17:13 +00:00
artist = is_artist(base_dir, nickname)
2021-12-31 21:18:12 +00:00
return html_timeline(css_cache, default_timeline,
2021-12-29 21:55:09 +00:00
recent_posts_cache, max_recent_posts,
2021-12-31 21:18:12 +00:00
translate, page_number,
items_per_page, session, base_dir,
2021-12-29 21:55:09 +00:00
cached_webfingers, person_cache,
nickname, domain, port, inboxJson,
'dm', allow_deletion,
http_prefix, project_version, False, minimal,
yt_replace_domain,
twitter_replacement_domain,
show_published_date_only,
newswire, False, False, artist, positive_voting,
show_publish_as_icon,
full_width_tl_button_header,
icons_as_buttons, rss_icon_at_top,
publish_button_at_top,
authorized, None, theme, peertube_instances,
allow_local_network_access, text_mode_banner,
2021-12-31 21:18:12 +00:00
access_keys, system_language, max_like_count,
2021-12-29 21:55:09 +00:00
shared_items_federated_domains,
signing_priv_key_pem,
2022-03-24 13:14:41 +00:00
cw_lists, lists_enabled, timezone,
bold_reading)
2021-12-29 21:55:09 +00:00
2021-12-31 21:18:12 +00:00
def html_inbox_replies(css_cache: {}, default_timeline: str,
2021-12-29 21:55:09 +00:00
recent_posts_cache: {}, max_recent_posts: int,
2021-12-31 21:18:12 +00:00
translate: {}, page_number: int, items_per_page: int,
2021-12-29 21:55:09 +00:00
session, base_dir: str,
cached_webfingers: {}, person_cache: {},
nickname: str, domain: str, port: int, inboxJson: {},
allow_deletion: bool,
http_prefix: str, project_version: str,
minimal: bool,
yt_replace_domain: str,
twitter_replacement_domain: str,
show_published_date_only: bool,
newswire: {}, positive_voting: bool,
show_publish_as_icon: bool,
full_width_tl_button_header: bool,
icons_as_buttons: bool,
rss_icon_at_top: bool,
publish_button_at_top: bool,
authorized: bool, theme: str,
peertube_instances: [],
allow_local_network_access: bool,
text_mode_banner: str,
2021-12-31 21:18:12 +00:00
access_keys: {}, system_language: str,
2021-12-29 21:55:09 +00:00
max_like_count: int,
shared_items_federated_domains: [],
signing_priv_key_pem: str,
2022-02-25 19:12:40 +00:00
cw_lists: {}, lists_enabled: str,
2022-03-24 13:14:41 +00:00
timezone: str, bold_reading: bool) -> str:
2021-12-29 21:55:09 +00:00
"""Show the replies timeline as html
"""
artist = is_artist(base_dir, nickname)
2021-12-31 21:18:12 +00:00
return html_timeline(css_cache, default_timeline,
2021-12-29 21:55:09 +00:00
recent_posts_cache, max_recent_posts,
2021-12-31 21:18:12 +00:00
translate, page_number,
items_per_page, session, base_dir,
2021-12-29 21:55:09 +00:00
cached_webfingers, person_cache,
nickname, domain, port, inboxJson, 'tlreplies',
allow_deletion, http_prefix, project_version, False,
minimal,
yt_replace_domain,
twitter_replacement_domain,
show_published_date_only,
newswire, False, False, artist,
positive_voting, show_publish_as_icon,
full_width_tl_button_header,
icons_as_buttons, rss_icon_at_top,
publish_button_at_top,
authorized, None, theme, peertube_instances,
allow_local_network_access, text_mode_banner,
2021-12-31 21:18:12 +00:00
access_keys, system_language, max_like_count,
2021-12-29 21:55:09 +00:00
shared_items_federated_domains, signing_priv_key_pem,
2022-03-24 13:14:41 +00:00
cw_lists, lists_enabled, timezone, bold_reading)
2021-12-29 21:55:09 +00:00
2021-12-31 21:18:12 +00:00
def html_inbox_media(css_cache: {}, default_timeline: str,
2021-12-26 20:01:37 +00:00
recent_posts_cache: {}, max_recent_posts: int,
2021-12-31 21:18:12 +00:00
translate: {}, page_number: int, items_per_page: int,
2021-12-25 16:17:53 +00:00
session, base_dir: str,
2021-12-25 22:28:18 +00:00
cached_webfingers: {}, person_cache: {},
2020-11-09 22:44:03 +00:00
nickname: str, domain: str, port: int, inboxJson: {},
2021-12-25 21:29:53 +00:00
allow_deletion: bool,
2021-12-25 20:34:38 +00:00
http_prefix: str, project_version: str,
2021-09-18 17:08:14 +00:00
minimal: bool,
2021-12-25 17:15:52 +00:00
yt_replace_domain: str,
2021-12-25 20:55:47 +00:00
twitter_replacement_domain: str,
2021-12-25 20:06:27 +00:00
show_published_date_only: bool,
2021-12-25 20:14:45 +00:00
newswire: {}, positive_voting: bool,
2021-12-25 19:34:20 +00:00
show_publish_as_icon: bool,
2021-12-25 19:31:24 +00:00
full_width_tl_button_header: bool,
2021-12-25 19:19:14 +00:00
icons_as_buttons: bool,
2021-12-25 19:09:03 +00:00
rss_icon_at_top: bool,
2021-12-25 19:00:00 +00:00
publish_button_at_top: bool,
2020-12-23 23:59:49 +00:00
authorized: bool, theme: str,
2021-12-25 23:38:53 +00:00
peertube_instances: [],
2021-12-25 18:54:50 +00:00
allow_local_network_access: bool,
2021-12-25 23:09:49 +00:00
text_mode_banner: str,
2021-12-31 21:18:12 +00:00
access_keys: {}, system_language: str,
2021-12-25 18:23:12 +00:00
max_like_count: int,
2021-12-25 18:05:01 +00:00
shared_items_federated_domains: [],
2021-12-25 23:03:28 +00:00
signing_priv_key_pem: str,
2022-02-25 19:12:40 +00:00
cw_lists: {}, lists_enabled: str,
2022-03-24 13:14:41 +00:00
timezone: str, bold_reading: bool) -> str:
2020-11-09 22:44:03 +00:00
"""Show the media timeline as html
"""
2021-12-26 14:17:13 +00:00
artist = is_artist(base_dir, nickname)
2021-12-31 21:18:12 +00:00
return html_timeline(css_cache, default_timeline,
2021-12-29 21:55:09 +00:00
recent_posts_cache, max_recent_posts,
2021-12-31 21:18:12 +00:00
translate, page_number,
items_per_page, session, base_dir,
2021-12-29 21:55:09 +00:00
cached_webfingers, person_cache,
nickname, domain, port, inboxJson, 'tlmedia',
allow_deletion, http_prefix, project_version, False,
minimal,
yt_replace_domain,
twitter_replacement_domain,
show_published_date_only,
newswire, False, False, artist,
positive_voting, show_publish_as_icon,
full_width_tl_button_header,
icons_as_buttons, rss_icon_at_top,
publish_button_at_top,
authorized, None, theme, peertube_instances,
allow_local_network_access, text_mode_banner,
2021-12-31 21:18:12 +00:00
access_keys, system_language, max_like_count,
2021-12-29 21:55:09 +00:00
shared_items_federated_domains, signing_priv_key_pem,
2022-03-24 13:14:41 +00:00
cw_lists, lists_enabled, timezone, bold_reading)
2021-12-29 21:55:09 +00:00
2021-12-31 21:18:12 +00:00
def html_inbox_blogs(css_cache: {}, default_timeline: str,
2021-12-29 21:55:09 +00:00
recent_posts_cache: {}, max_recent_posts: int,
2021-12-31 21:18:12 +00:00
translate: {}, page_number: int, items_per_page: int,
2021-12-29 21:55:09 +00:00
session, base_dir: str,
cached_webfingers: {}, person_cache: {},
nickname: str, domain: str, port: int, inboxJson: {},
allow_deletion: bool,
http_prefix: str, project_version: str,
minimal: bool,
yt_replace_domain: str,
twitter_replacement_domain: str,
show_published_date_only: bool,
newswire: {}, positive_voting: bool,
show_publish_as_icon: bool,
full_width_tl_button_header: bool,
icons_as_buttons: bool,
rss_icon_at_top: bool,
publish_button_at_top: bool,
authorized: bool, theme: str,
peertube_instances: [],
allow_local_network_access: bool,
text_mode_banner: str,
2021-12-31 21:18:12 +00:00
access_keys: {}, system_language: str,
2021-12-29 21:55:09 +00:00
max_like_count: int,
shared_items_federated_domains: [],
signing_priv_key_pem: str,
2022-02-25 19:12:40 +00:00
cw_lists: {}, lists_enabled: str,
2022-03-24 13:14:41 +00:00
timezone: str, bold_reading: bool) -> str:
2020-11-09 22:44:03 +00:00
"""Show the blogs timeline as html
"""
2021-12-26 14:17:13 +00:00
artist = is_artist(base_dir, nickname)
2021-12-31 21:18:12 +00:00
return html_timeline(css_cache, default_timeline,
2021-12-29 21:55:09 +00:00
recent_posts_cache, max_recent_posts,
2021-12-31 21:18:12 +00:00
translate, page_number,
items_per_page, session, base_dir,
2021-12-29 21:55:09 +00:00
cached_webfingers, person_cache,
nickname, domain, port, inboxJson, 'tlblogs',
allow_deletion, http_prefix, project_version, False,
minimal,
yt_replace_domain,
twitter_replacement_domain,
show_published_date_only,
newswire, False, False, artist,
positive_voting, show_publish_as_icon,
full_width_tl_button_header,
icons_as_buttons, rss_icon_at_top,
publish_button_at_top,
authorized, None, theme, peertube_instances,
allow_local_network_access, text_mode_banner,
2021-12-31 21:18:12 +00:00
access_keys, system_language, max_like_count,
2021-12-29 21:55:09 +00:00
shared_items_federated_domains, signing_priv_key_pem,
2022-03-24 13:14:41 +00:00
cw_lists, lists_enabled, timezone, bold_reading)
2021-12-29 21:55:09 +00:00
2021-12-31 21:18:12 +00:00
def html_inbox_features(css_cache: {}, default_timeline: str,
2021-12-29 21:55:09 +00:00
recent_posts_cache: {}, max_recent_posts: int,
2021-12-31 21:18:12 +00:00
translate: {}, page_number: int, items_per_page: int,
2021-12-29 21:55:09 +00:00
session, base_dir: str,
cached_webfingers: {}, person_cache: {},
nickname: str, domain: str, port: int, inboxJson: {},
allow_deletion: bool,
http_prefix: str, project_version: str,
minimal: bool,
yt_replace_domain: str,
twitter_replacement_domain: str,
show_published_date_only: bool,
newswire: {}, positive_voting: bool,
show_publish_as_icon: bool,
full_width_tl_button_header: bool,
icons_as_buttons: bool,
rss_icon_at_top: bool,
publish_button_at_top: bool,
authorized: bool,
theme: str,
peertube_instances: [],
allow_local_network_access: bool,
text_mode_banner: str,
2021-12-31 21:18:12 +00:00
access_keys: {}, system_language: str,
2021-12-29 21:55:09 +00:00
max_like_count: int,
shared_items_federated_domains: [],
signing_priv_key_pem: str,
2022-02-25 19:12:40 +00:00
cw_lists: {}, lists_enabled: str,
2022-03-24 13:14:41 +00:00
timezone: str, bold_reading: bool) -> str:
2020-11-27 11:22:47 +00:00
"""Show the features timeline as html
"""
2021-12-31 21:18:12 +00:00
return html_timeline(css_cache, default_timeline,
2021-12-29 21:55:09 +00:00
recent_posts_cache, max_recent_posts,
2021-12-31 21:18:12 +00:00
translate, page_number,
items_per_page, session, base_dir,
2021-12-29 21:55:09 +00:00
cached_webfingers, person_cache,
nickname, domain, port, inboxJson, 'tlfeatures',
allow_deletion, http_prefix, project_version, False,
minimal,
yt_replace_domain,
twitter_replacement_domain,
show_published_date_only,
newswire, False, False, False,
positive_voting, show_publish_as_icon,
full_width_tl_button_header,
icons_as_buttons, rss_icon_at_top,
publish_button_at_top,
authorized, None, theme, peertube_instances,
allow_local_network_access, text_mode_banner,
2021-12-31 21:18:12 +00:00
access_keys, system_language, max_like_count,
2021-12-29 21:55:09 +00:00
shared_items_federated_domains, signing_priv_key_pem,
2022-03-24 13:14:41 +00:00
cw_lists, lists_enabled, timezone, bold_reading)
2021-12-29 21:55:09 +00:00
2021-12-31 21:18:12 +00:00
def html_inbox_news(css_cache: {}, default_timeline: str,
2021-12-29 21:55:09 +00:00
recent_posts_cache: {}, max_recent_posts: int,
2021-12-31 21:18:12 +00:00
translate: {}, page_number: int, items_per_page: int,
2021-12-29 21:55:09 +00:00
session, base_dir: str,
cached_webfingers: {}, person_cache: {},
nickname: str, domain: str, port: int, inboxJson: {},
allow_deletion: bool,
http_prefix: str, project_version: str,
minimal: bool,
yt_replace_domain: str,
twitter_replacement_domain: str,
show_published_date_only: bool,
newswire: {}, moderator: bool, editor: bool, artist: bool,
positive_voting: bool, show_publish_as_icon: bool,
full_width_tl_button_header: bool,
icons_as_buttons: bool,
rss_icon_at_top: bool,
publish_button_at_top: bool,
authorized: bool, theme: str,
peertube_instances: [],
allow_local_network_access: bool,
text_mode_banner: str,
2021-12-31 21:18:12 +00:00
access_keys: {}, system_language: str,
2021-12-29 21:55:09 +00:00
max_like_count: int,
shared_items_federated_domains: [],
signing_priv_key_pem: str,
2022-02-25 19:12:40 +00:00
cw_lists: {}, lists_enabled: str,
2022-03-24 13:14:41 +00:00
timezone: str, bold_reading: bool) -> str:
2020-11-09 22:44:03 +00:00
"""Show the news timeline as html
"""
2021-12-31 21:18:12 +00:00
return html_timeline(css_cache, default_timeline,
2021-12-29 21:55:09 +00:00
recent_posts_cache, max_recent_posts,
2021-12-31 21:18:12 +00:00
translate, page_number,
items_per_page, session, base_dir,
2021-12-29 21:55:09 +00:00
cached_webfingers, person_cache,
nickname, domain, port, inboxJson, 'tlnews',
allow_deletion, http_prefix, project_version, False,
minimal,
yt_replace_domain,
twitter_replacement_domain,
show_published_date_only,
newswire, moderator, editor, artist,
positive_voting, show_publish_as_icon,
full_width_tl_button_header,
icons_as_buttons, rss_icon_at_top,
publish_button_at_top,
authorized, None, theme, peertube_instances,
allow_local_network_access, text_mode_banner,
2021-12-31 21:18:12 +00:00
access_keys, system_language, max_like_count,
2021-12-29 21:55:09 +00:00
shared_items_federated_domains, signing_priv_key_pem,
2022-03-24 13:14:41 +00:00
cw_lists, lists_enabled, timezone, bold_reading)
2021-12-29 21:55:09 +00:00
2021-12-31 21:18:12 +00:00
def html_outbox(css_cache: {}, default_timeline: str,
2021-12-29 21:55:09 +00:00
recent_posts_cache: {}, max_recent_posts: int,
2021-12-31 21:18:12 +00:00
translate: {}, page_number: int, items_per_page: int,
2021-12-29 21:55:09 +00:00
session, base_dir: str,
cached_webfingers: {}, person_cache: {},
nickname: str, domain: str, port: int, outboxJson: {},
allow_deletion: bool,
http_prefix: str, project_version: str,
minimal: bool,
yt_replace_domain: str,
twitter_replacement_domain: str,
show_published_date_only: bool,
newswire: {}, positive_voting: bool,
show_publish_as_icon: bool,
full_width_tl_button_header: bool,
icons_as_buttons: bool,
rss_icon_at_top: bool,
publish_button_at_top: bool,
authorized: bool, theme: str,
peertube_instances: [],
allow_local_network_access: bool,
text_mode_banner: str,
2021-12-31 21:18:12 +00:00
access_keys: {}, system_language: str,
2021-12-29 21:55:09 +00:00
max_like_count: int,
shared_items_federated_domains: [],
signing_priv_key_pem: str,
2022-02-25 19:12:40 +00:00
cw_lists: {}, lists_enabled: str,
2022-03-24 13:14:41 +00:00
timezone: str, bold_reading: bool) -> str:
2020-11-09 22:44:03 +00:00
"""Show the Outbox as html
"""
2021-12-31 21:18:12 +00:00
manually_approve_followers = \
2021-12-28 20:32:11 +00:00
follower_approval_active(base_dir, nickname, domain)
2021-12-26 14:17:13 +00:00
artist = is_artist(base_dir, nickname)
2021-12-31 21:18:12 +00:00
return html_timeline(css_cache, default_timeline,
2021-12-29 21:55:09 +00:00
recent_posts_cache, max_recent_posts,
2021-12-31 21:18:12 +00:00
translate, page_number,
items_per_page, session, base_dir,
2021-12-29 21:55:09 +00:00
cached_webfingers, person_cache,
nickname, domain, port, outboxJson, 'outbox',
allow_deletion, http_prefix, project_version,
2021-12-31 21:18:12 +00:00
manually_approve_followers, minimal,
2021-12-29 21:55:09 +00:00
yt_replace_domain,
twitter_replacement_domain,
show_published_date_only,
newswire, False, False, artist, positive_voting,
show_publish_as_icon,
full_width_tl_button_header,
icons_as_buttons, rss_icon_at_top,
publish_button_at_top,
authorized, None, theme, peertube_instances,
allow_local_network_access, text_mode_banner,
2021-12-31 21:18:12 +00:00
access_keys, system_language, max_like_count,
2021-12-29 21:55:09 +00:00
shared_items_federated_domains, signing_priv_key_pem,
2022-03-24 13:14:41 +00:00
cw_lists, lists_enabled, timezone, bold_reading)