Change button links to redirect to same timeline

main
Bob Mottram 2022-12-28 18:33:09 +00:00
parent 7b15a927b3
commit d955d4ab75
13 changed files with 262 additions and 107 deletions

121
daemon.py
View File

@ -9089,6 +9089,13 @@ class PubServer(BaseHTTPRequestHandler):
repeat_url = path.split('?repeat=')[1]
if '?' in repeat_url:
repeat_url = repeat_url.split('?')[0]
first_post_id = ''
if '?firstpost=' in path:
first_post_id = path.split('?firstpost=')[1]
if '?' in first_post_id:
first_post_id = first_post_id.split('?')[0]
first_post_id = first_post_id.replace('/', '--')
first_post_id = ';firstpost=' + first_post_id.replace('#', '--')
timeline_bookmark = ''
if '?bm=' in path:
timeline_bookmark = path.split('?bm=')[1]
@ -9252,16 +9259,10 @@ class PubServer(BaseHTTPRequestHandler):
self.server.lists_enabled,
timezone, mitm, bold_reading,
self.server.dogwhistles,
minimize_all_images)
minimize_all_images, None)
actor_absolute = self._get_instance_url(calling_domain) + actor
if announce_id:
first_post_id = announce_id.replace('/', '--')
else:
first_post_id = repeat_url.replace('/', '--')
first_post_id = ';firstpost=' + first_post_id.replace('#', '--')
actor_path_str = \
actor_absolute + '/' + timeline_str + '?page=' + \
str(page_number) + first_post_id + timeline_bookmark
@ -9285,6 +9286,14 @@ class PubServer(BaseHTTPRequestHandler):
if '?' in repeat_url:
repeat_url = repeat_url.split('?')[0]
first_post_id = ''
if '?firstpost=' in path:
first_post_id = path.split('?firstpost=')[1]
if '?' in first_post_id:
first_post_id = first_post_id.split('?')[0]
first_post_id = first_post_id.replace('/', '--')
first_post_id = ';firstpost=' + first_post_id.replace('#', '--')
timeline_bookmark = ''
if '?bm=' in path:
timeline_bookmark = path.split('?bm=')[1]
@ -9382,7 +9391,7 @@ class PubServer(BaseHTTPRequestHandler):
actor_path_str = \
actor_absolute + '/' + timeline_str + '?page=' + \
str(page_number) + timeline_bookmark
str(page_number) + first_post_id + timeline_bookmark
fitness_performance(getreq_start_time, self.server.fitness,
'_GET', '_undo_announce_button',
self.server.debug)
@ -9639,6 +9648,13 @@ class PubServer(BaseHTTPRequestHandler):
like_url = path.split('?like=')[1]
if '?' in like_url:
like_url = like_url.split('?')[0]
first_post_id = ''
if '?firstpost=' in path:
first_post_id = path.split('?firstpost=')[1]
if '?' in first_post_id:
first_post_id = first_post_id.split('?')[0]
first_post_id = first_post_id.replace('/', '--')
first_post_id = ';firstpost=' + first_post_id.replace('#', '--')
timeline_bookmark = ''
if '?bm=' in path:
timeline_bookmark = path.split('?bm=')[1]
@ -9809,7 +9825,7 @@ class PubServer(BaseHTTPRequestHandler):
self.server.lists_enabled,
timezone, mitm, bold_reading,
self.server.dogwhistles,
minimize_all_images)
minimize_all_images, None)
else:
print('WARN: Liked post not found: ' + liked_post_filename)
# clear the icon from the cache so that it gets updated
@ -9821,9 +9837,6 @@ class PubServer(BaseHTTPRequestHandler):
actor_absolute = self._get_instance_url(calling_domain) + actor
first_post_id = like_url2.replace('/', '--')
first_post_id = ';firstpost=' + first_post_id.replace('#', '--')
actor_path_str = \
actor_absolute + '/' + timeline_str + \
'?page=' + str(page_number) + first_post_id + \
@ -9848,6 +9861,13 @@ class PubServer(BaseHTTPRequestHandler):
like_url = path.split('?unlike=')[1]
if '?' in like_url:
like_url = like_url.split('?')[0]
first_post_id = ''
if '?firstpost=' in path:
first_post_id = path.split('?firstpost=')[1]
if '?' in first_post_id:
first_post_id = first_post_id.split('?')[0]
first_post_id = first_post_id.replace('/', '--')
first_post_id = ';firstpost=' + first_post_id.replace('#', '--')
timeline_bookmark = ''
if '?bm=' in path:
timeline_bookmark = path.split('?bm=')[1]
@ -10009,7 +10029,7 @@ class PubServer(BaseHTTPRequestHandler):
self.server.lists_enabled,
timezone, mitm, bold_reading,
self.server.dogwhistles,
minimize_all_images)
minimize_all_images, None)
else:
print('WARN: Unliked post not found: ' + liked_post_filename)
# clear the icon from the cache so that it gets updated
@ -10017,9 +10037,6 @@ class PubServer(BaseHTTPRequestHandler):
del self.server.iconsCache['like_inactive.png']
actor_absolute = self._get_instance_url(calling_domain) + actor
first_post_id = like_url2.replace('/', '--')
first_post_id = ';firstpost=' + first_post_id.replace('#', '--')
actor_path_str = \
actor_absolute + '/' + timeline_str + \
'?page=' + str(page_number) + first_post_id + \
@ -10046,6 +10063,13 @@ class PubServer(BaseHTTPRequestHandler):
reaction_url = path.split('?react=')[1]
if '?' in reaction_url:
reaction_url = reaction_url.split('?')[0]
first_post_id = ''
if '?firstpost=' in path:
first_post_id = path.split('?firstpost=')[1]
if '?' in first_post_id:
first_post_id = first_post_id.split('?')[0]
first_post_id = first_post_id.replace('/', '--')
first_post_id = ';firstpost=' + first_post_id.replace('#', '--')
timeline_bookmark = ''
if '?bm=' in path:
timeline_bookmark = path.split('?bm=')[1]
@ -10238,7 +10262,7 @@ class PubServer(BaseHTTPRequestHandler):
self.server.lists_enabled,
timezone, mitm, bold_reading,
self.server.dogwhistles,
minimize_all_images)
minimize_all_images, None)
else:
print('WARN: Emoji reaction post not found: ' +
reaction_post_filename)
@ -10248,9 +10272,6 @@ class PubServer(BaseHTTPRequestHandler):
actor_absolute = self._get_instance_url(calling_domain) + actor
first_post_id = reaction_url2.replace('/', '--')
first_post_id = ';firstpost=' + first_post_id.replace('#', '--')
actor_path_str = \
actor_absolute + '/' + timeline_str + \
'?page=' + str(page_number) + first_post_id + \
@ -10275,6 +10296,13 @@ class PubServer(BaseHTTPRequestHandler):
reaction_url = path.split('?unreact=')[1]
if '?' in reaction_url:
reaction_url = reaction_url.split('?')[0]
first_post_id = ''
if '?firstpost=' in path:
first_post_id = path.split('?firstpost=')[1]
if '?' in first_post_id:
first_post_id = first_post_id.split('?')[0]
first_post_id = first_post_id.replace('/', '--')
first_post_id = ';firstpost=' + first_post_id.replace('#', '--')
timeline_bookmark = ''
if '?bm=' in path:
timeline_bookmark = path.split('?bm=')[1]
@ -10457,16 +10485,13 @@ class PubServer(BaseHTTPRequestHandler):
self.server.lists_enabled,
timezone, mitm, bold_reading,
self.server.dogwhistles,
minimize_all_images)
minimize_all_images, None)
else:
print('WARN: Unreaction post not found: ' +
reaction_post_filename)
actor_absolute = self._get_instance_url(calling_domain) + actor
first_post_id = reaction_url2.replace('/', '--')
first_post_id = ';firstpost=' + first_post_id.replace('#', '--')
actor_path_str = \
actor_absolute + '/' + timeline_str + \
'?page=' + str(page_number) + first_post_id + \
@ -10594,6 +10619,13 @@ class PubServer(BaseHTTPRequestHandler):
bookmark_url = path.split('?bookmark=')[1]
if '?' in bookmark_url:
bookmark_url = bookmark_url.split('?')[0]
first_post_id = ''
if '?firstpost=' in path:
first_post_id = path.split('?firstpost=')[1]
if '?' in first_post_id:
first_post_id = first_post_id.split('?')[0]
first_post_id = first_post_id.replace('/', '--')
first_post_id = ';firstpost=' + first_post_id.replace('#', '--')
timeline_bookmark = ''
if '?bm=' in path:
timeline_bookmark = path.split('?bm=')[1]
@ -10721,7 +10753,7 @@ class PubServer(BaseHTTPRequestHandler):
self.server.lists_enabled,
timezone, mitm, bold_reading,
self.server.dogwhistles,
minimize_all_images)
minimize_all_images, None)
else:
print('WARN: Bookmarked post not found: ' + bookmark_filename)
# self._post_to_outbox(bookmark_json,
@ -10729,9 +10761,6 @@ class PubServer(BaseHTTPRequestHandler):
# curr_session, proxy_type)
actor_absolute = self._get_instance_url(calling_domain) + actor
first_post_id = bookmark_url.replace('/', '--')
first_post_id = ';firstpost=' + first_post_id.replace('#', '--')
actor_path_str = \
actor_absolute + '/' + timeline_str + \
'?page=' + str(page_number) + first_post_id + \
@ -10756,6 +10785,13 @@ class PubServer(BaseHTTPRequestHandler):
bookmark_url = path.split('?unbookmark=')[1]
if '?' in bookmark_url:
bookmark_url = bookmark_url.split('?')[0]
first_post_id = ''
if '?firstpost=' in path:
first_post_id = path.split('?firstpost=')[1]
if '?' in first_post_id:
first_post_id = first_post_id.split('?')[0]
first_post_id = first_post_id.replace('/', '--')
first_post_id = ';firstpost=' + first_post_id.replace('#', '--')
timeline_bookmark = ''
if '?bm=' in path:
timeline_bookmark = path.split('?bm=')[1]
@ -10885,15 +10921,12 @@ class PubServer(BaseHTTPRequestHandler):
self.server.lists_enabled,
timezone, mitm, bold_reading,
self.server.dogwhistles,
minimize_all_images)
minimize_all_images, None)
else:
print('WARN: Unbookmarked post not found: ' +
bookmark_filename)
actor_absolute = self._get_instance_url(calling_domain) + actor
first_post_id = bookmark_url.replace('/', '--')
first_post_id = ';firstpost=' + first_post_id.replace('#', '--')
actor_path_str = \
actor_absolute + '/' + timeline_str + \
'?page=' + str(page_number) + first_post_id + \
@ -11031,6 +11064,13 @@ class PubServer(BaseHTTPRequestHandler):
mute_url = path.split('?mute=')[1]
if '?' in mute_url:
mute_url = mute_url.split('?')[0]
first_post_id = ''
if '?firstpost=' in path:
first_post_id = path.split('?firstpost=')[1]
if '?' in first_post_id:
first_post_id = first_post_id.split('?')[0]
first_post_id = first_post_id.replace('/', '--')
first_post_id = ';firstpost=' + first_post_id.replace('#', '--')
timeline_bookmark = ''
if '?bm=' in path:
timeline_bookmark = path.split('?bm=')[1]
@ -11136,7 +11176,7 @@ class PubServer(BaseHTTPRequestHandler):
self.server.lists_enabled,
timezone, mitm, bold_reading,
self.server.dogwhistles,
minimize_all_images)
minimize_all_images, None)
else:
print('WARN: Muted post not found: ' + mute_filename)
@ -11151,9 +11191,6 @@ class PubServer(BaseHTTPRequestHandler):
fitness_performance(getreq_start_time, self.server.fitness,
'_GET', '_mute_button', self.server.debug)
first_post_id = mute_url.replace('/', '--')
first_post_id = ';firstpost=' + first_post_id.replace('#', '--')
page_number_str = str(page_number)
redirect_str = \
actor + '/' + timeline_str + '?page=' + page_number_str + \
@ -11171,6 +11208,13 @@ class PubServer(BaseHTTPRequestHandler):
mute_url = path.split('?unmute=')[1]
if '?' in mute_url:
mute_url = mute_url.split('?')[0]
first_post_id = ''
if '?firstpost=' in path:
first_post_id = path.split('?firstpost=')[1]
if '?' in first_post_id:
first_post_id = first_post_id.split('?')[0]
first_post_id = first_post_id.replace('/', '--')
first_post_id = ';firstpost=' + first_post_id.replace('#', '--')
timeline_bookmark = ''
if '?bm=' in path:
timeline_bookmark = path.split('?bm=')[1]
@ -11276,7 +11320,7 @@ class PubServer(BaseHTTPRequestHandler):
self.server.lists_enabled,
timezone, mitm, bold_reading,
self.server.dogwhistles,
minimize_all_images)
minimize_all_images, None)
else:
print('WARN: Unmuted post not found: ' + mute_filename)
if calling_domain.endswith('.onion') and onion_domain:
@ -11288,9 +11332,6 @@ class PubServer(BaseHTTPRequestHandler):
fitness_performance(getreq_start_time, self.server.fitness,
'_GET', '_undo_mute_button', self.server.debug)
first_post_id = mute_url.replace('/', '--')
first_post_id = ';firstpost=' + first_post_id.replace('#', '--')
page_number_str = str(page_number)
redirect_str = \
actor + '/' + timeline_str + '?page=' + page_number_str + \

View File

@ -480,7 +480,8 @@ def _inbox_store_post_to_html_cache(recent_posts_cache: {},
theme_name, system_language, max_like_count,
not_dm, True, True, False, True, False,
cw_lists, lists_enabled, timezone, mitm,
bold_reading, dogwhistles, minimize_all_images)
bold_reading, dogwhistles, minimize_all_images,
None)
def valid_inbox(base_dir: str, nickname: str, domain: str) -> bool:
@ -1388,7 +1389,7 @@ def receive_edit_to_post(recent_posts_cache: {}, message_json: {},
False, True, False, cw_lists,
lists_enabled, timezone, mitm,
bold_reading, dogwhistles,
minimize_all_images)
minimize_all_images, None)
return True
@ -1617,7 +1618,7 @@ def _receive_like(recent_posts_cache: {},
False, True, False, cw_lists,
lists_enabled, timezone, mitm,
bold_reading, dogwhistles,
minimize_all_images)
minimize_all_images, None)
return True
@ -1742,7 +1743,7 @@ def _receive_undo_like(recent_posts_cache: {},
False, True, False, cw_lists,
lists_enabled, timezone, mitm,
bold_reading, dogwhistles,
minimize_all_images)
minimize_all_images, None)
return True
@ -1899,7 +1900,7 @@ def _receive_reaction(recent_posts_cache: {},
False, True, False, cw_lists,
lists_enabled, timezone, mitm,
bold_reading, dogwhistles,
minimize_all_images)
minimize_all_images, None)
return True
@ -2080,7 +2081,7 @@ def _receive_zot_reaction(recent_posts_cache: {},
False, True, False, cw_lists,
lists_enabled, timezone, mitm,
bold_reading, dogwhistles,
minimize_all_images)
minimize_all_images, None)
return True
@ -2225,7 +2226,7 @@ def _receive_undo_reaction(recent_posts_cache: {},
False, True, False, cw_lists,
lists_enabled, timezone, mitm,
bold_reading, dogwhistles,
minimize_all_images)
minimize_all_images, None)
return True
@ -2346,7 +2347,7 @@ def _receive_bookmark(recent_posts_cache: {},
False, True, False, cw_lists,
lists_enabled, timezone, mitm,
bold_reading, dogwhistles,
minimize_all_images)
minimize_all_images, None)
return True
@ -2469,7 +2470,7 @@ def _receive_undo_bookmark(recent_posts_cache: {},
manually_approve_followers,
False, True, False, cw_lists, lists_enabled,
timezone, mitm, bold_reading,
dogwhistles, minimize_all_images)
dogwhistles, minimize_all_images, None)
return True
@ -2710,7 +2711,7 @@ def _receive_announce(recent_posts_cache: {},
False, True, False, cw_lists,
lists_enabled, timezone, mitm,
bold_reading, dogwhistles,
minimize_all_images)
minimize_all_images, None)
if not announce_html:
print('WARN: Unable to generate html for announce ' +
str(message_json))
@ -3938,7 +3939,7 @@ def _receive_question_vote(server, base_dir: str, nickname: str, domain: str,
False, True, False, cw_lists,
lists_enabled, timezone, mitm,
bold_reading, dogwhistles,
minimize_all_images)
minimize_all_images, None)
# add id to inbox index
inbox_update_index('inbox', base_dir, handle,

View File

@ -570,7 +570,7 @@ def post_message_to_outbox(session, translate: {},
cw_lists, lists_enabled,
timezone, mitm,
bold_reading, dogwhistles,
minimize_all_images)
minimize_all_images, None)
if is_edited_post:
message_json['type'] = 'Update'

View File

@ -173,6 +173,7 @@ from newswire import parse_feed_date
from newswire import limit_word_lengths
from mastoapiv1 import get_masto_api_v1id_from_nickname
from mastoapiv1 import get_nickname_from_masto_api_v1id
from webapp_post import replace_link_variable
from webapp_post import prepare_html_post_nickname
from speaker import speaker_replace_links
from markdown import markdown_to_html
@ -7668,6 +7669,25 @@ def _test_reply_language(base_dir: str) -> None:
assert not get_reply_language(base_dir, post_json_object)
def _test_replace_variable():
print('test_replace_variable')
link = 'red?firstpost=123'
result = replace_link_variable(link, 'firstpost', '456', '?')
expected = 'red?firstpost=456'
if result != expected:
print('expected: ' + expected)
print('result: ' + result)
assert result == expected
link = 'red?firstpost=123?test?firstpost=444?abc'
result = replace_link_variable(link, 'firstpost', '356', '?')
expected = 'red?firstpost=356?test?firstpost=356?abc'
if result != expected:
print('expected: ' + expected)
print('result: ' + result)
assert result == expected
def run_all_tests():
base_dir = os.getcwd()
print('Running tests...')
@ -7685,6 +7705,7 @@ def run_all_tests():
_test_checkbox_names()
_test_thread_functions()
_test_functions()
_test_replace_variable()
_test_missing_theme_colors(base_dir)
_test_reply_language(base_dir)
_test_emoji_in_actor_name(base_dir)

View File

@ -96,7 +96,7 @@ def html_confirm_delete(server,
False, False, False, False, False, False,
cw_lists, lists_enabled, timezone, mitm,
bold_reading, dogwhistles,
minimize_all_images)
minimize_all_images, None)
delete_post_str += '<center>'
delete_post_str += \
' <p class="followText">' + \

View File

@ -96,7 +96,7 @@ def html_conversation_view(post_id: str,
cw_lists, lists_enabled,
timezone, False, bold_reading,
dogwhistles,
minimize_all_images)
minimize_all_images, None)
if post_str:
conv_str += text_mode_separator + separator_str + post_str

View File

@ -429,7 +429,7 @@ def html_new_post(edit_post_params: {},
cw_lists, lists_enabled,
timezone, False,
bold_reading, dogwhistles,
minimize_all_images)
minimize_all_images, None)
reply_str = '<input type="hidden" ' + \
'name="replyTo" value="' + in_reply_to + '">\n'

View File

@ -95,7 +95,7 @@ def _html_front_screen_posts(recent_posts_cache: {}, max_recent_posts: int,
cw_lists, lists_enabled,
timezone, False,
bold_reading, dogwhistles,
minimize_all_images)
minimize_all_images, None)
if post_str:
profile_str += post_str + separator_str
ctr += 1

View File

@ -113,7 +113,7 @@ def html_likers_of_post(base_dir: str, nickname: str,
cw_lists, lists_enabled,
timezone, mitm, bold_reading,
dogwhistles,
minimize_all_images)
minimize_all_images, None)
# show likers beneath the post
obj = post_json_object

View File

@ -275,8 +275,31 @@ def prepare_html_post_nickname(nickname: str, post_html: str) -> str:
return new_post_str
def replace_link_variable(link: str, variable_name: str, value: str,
separator: str = '?') -> str:
"""Replaces a variable within the given link
"""
full_var = separator + variable_name + '='
if full_var not in link:
return link
curr_str = link
result = ''
while full_var in curr_str:
prefix = curr_str.split(full_var, 1)[0] + full_var
next_str = curr_str.split(full_var, 1)[1]
if separator in next_str:
next_str = next_str.split(separator, 1)[1]
result += prefix + value + separator
curr_str = next_str
else:
result += prefix + value
curr_str = ''
return result + curr_str
def prepare_post_from_html_cache(nickname: str, post_html: str, box_name: str,
page_number: int) -> str:
page_number: int, first_post_id: str) -> str:
"""Sets the page number on a cached html post
"""
# if on the bookmarks timeline then remain there
@ -289,10 +312,29 @@ def prepare_post_from_html_cache(nickname: str, post_html: str, box_name: str,
post_html = \
post_html.replace('?page=' + page_number_str, '?page=-999')
# add the page number
with_page_number = \
post_html.replace(';-999;', ';' + str(page_number) + ';')
with_page_number = \
with_page_number.replace('?page=-999', '?page=' + str(page_number))
# add first post in the timeline
if first_post_id is None:
first_post_id = ''
if '?firstpost=' in with_page_number:
with_page_number = \
replace_link_variable(with_page_number,
'firstpost', first_post_id, '?')
elif ';firstpost=' in with_page_number:
with_page_number = \
replace_link_variable(with_page_number,
'firstpost', first_post_id, ';')
else:
with_page_number = \
with_page_number.replace('?page=',
'?firstpost=' + first_post_id +
'?page=')
return prepare_html_post_nickname(nickname, with_page_number)
@ -339,7 +381,8 @@ def _get_post_from_recent_cache(session,
page_number: int,
recent_posts_cache: {},
max_recent_posts: int,
signing_priv_key_pem: str) -> str:
signing_priv_key_pem: str,
first_post_id: str) -> str:
"""Attempts to get the html post from the recent posts cache in memory
"""
if box_name == 'tlmedia':
@ -378,7 +421,7 @@ def _get_post_from_recent_cache(session,
post_html = \
prepare_post_from_html_cache(nickname, post_html,
box_name, page_number)
box_name, page_number, first_post_id)
update_recent_posts_cache(recent_posts_cache, max_recent_posts,
post_json_object, post_html)
_log_post_timing(enable_timing_log, post_start_time, '3')
@ -539,7 +582,8 @@ def _get_reply_icon_html(base_dir: str, nickname: str, domain: str,
def _get_edit_icon_html(base_dir: str, nickname: str, domain_full: str,
post_json_object: {}, actor_nickname: str,
translate: {}, is_event: bool) -> str:
translate: {}, is_event: bool,
first_post_id: str) -> str:
"""Returns html for the edit icon/button
"""
edit_str = ''
@ -561,6 +605,10 @@ def _get_edit_icon_html(base_dir: str, nickname: str, domain_full: str,
if post_json_object['object'].get('inReplyTo'):
reply_to = ';replyTo=' + post_json_object['object']['inReplyTo']
first_post_str = ''
if first_post_id:
first_post_str = ';firstpost=' + first_post_id
if is_blog_post(post_json_object):
edit_blog_post_str = 'Edit blog post'
if translate.get(edit_blog_post_str):
@ -571,7 +619,7 @@ def _get_edit_icon_html(base_dir: str, nickname: str, domain_full: str,
'<a class="imageAnchor" href="/users/' + \
nickname + '/tlblogs?editblogpost=' + \
post_id.split('/statuses/')[1] + \
';actor=' + actor_nickname + \
';actor=' + actor_nickname + first_post_str + \
'" title="' + edit_blog_post_str + '" tabindex="10">' + \
'<img loading="lazy" decoding="async" title="' + \
edit_blog_post_str + '" alt="' + edit_blog_post_str + \
@ -582,7 +630,7 @@ def _get_edit_icon_html(base_dir: str, nickname: str, domain_full: str,
'<a class="imageAnchor" href="/users/' + \
nickname + '/editnewspost=' + \
post_id.split('/statuses/')[1] + \
'?actor=' + actor_nickname + \
'?actor=' + actor_nickname + first_post_str + \
'" title="' + edit_blog_post_str + '" tabindex="10">' + \
'<img loading="lazy" decoding="async" title="' + \
edit_blog_post_str + '" alt="' + edit_blog_post_str + \
@ -596,7 +644,7 @@ def _get_edit_icon_html(base_dir: str, nickname: str, domain_full: str,
'<a class="imageAnchor" href="/users/' + nickname + \
'/tlblogs?editeventpost=' + \
post_id.split('/statuses/')[1] + \
'?actor=' + actor_nickname + \
'?actor=' + actor_nickname + first_post_str + \
'" title="' + edit_event_str + '" tabindex="10">' + \
'<img loading="lazy" decoding="async" title="' + \
edit_event_str + '" alt="' + edit_event_str + \
@ -611,7 +659,7 @@ def _get_edit_icon_html(base_dir: str, nickname: str, domain_full: str,
'<a class="imageAnchor" href="/users/' + \
nickname + '?postedit=' + \
post_id.split('/statuses/')[1] + ';scope=public' + \
';actor=' + actor_nickname + reply_to + \
';actor=' + actor_nickname + first_post_str + reply_to + \
'" title="' + edit_post_str + '" tabindex="10">' + \
'<img loading="lazy" decoding="async" title="' + \
edit_post_str + '" alt="' + edit_post_str + \
@ -626,7 +674,7 @@ def _get_edit_icon_html(base_dir: str, nickname: str, domain_full: str,
'<a class="imageAnchor" href="/users/' + \
nickname + '?postedit=' + \
post_id.split('/statuses/')[1] + ';scope=reminder' + \
';actor=' + actor_nickname + reply_to + \
';actor=' + actor_nickname + first_post_str + reply_to + \
'" title="' + edit_post_str + '" tabindex="10">' + \
'<img loading="lazy" decoding="async" title="' + \
edit_post_str + '" alt="' + edit_post_str + \
@ -641,7 +689,7 @@ def _get_edit_icon_html(base_dir: str, nickname: str, domain_full: str,
'<a class="imageAnchor" href="/users/' + \
nickname + '?postedit=' + \
post_id.split('/statuses/')[1] + ';scope=dm' + \
';actor=' + actor_nickname + reply_to + \
';actor=' + actor_nickname + first_post_str + reply_to + \
'" title="' + edit_post_str + '" tabindex="10">' + \
'<img loading="lazy" decoding="async" title="' + \
edit_post_str + '" alt="' + edit_post_str + \
@ -656,7 +704,7 @@ def _get_edit_icon_html(base_dir: str, nickname: str, domain_full: str,
'<a class="imageAnchor" href="/users/' + \
nickname + '?postedit=' + \
post_id.split('/statuses/')[1] + ';scope=unlisted' + \
';actor=' + actor_nickname + reply_to + \
';actor=' + actor_nickname + first_post_str + reply_to + \
'" title="' + edit_post_str + '" tabindex="10">' + \
'<img loading="lazy" decoding="async" title="' + \
edit_post_str + '" alt="' + edit_post_str + \
@ -671,7 +719,7 @@ def _get_edit_icon_html(base_dir: str, nickname: str, domain_full: str,
'<a class="imageAnchor" href="/users/' + \
nickname + '?postedit=' + \
post_id.split('/statuses/')[1] + ';scope=followers' + \
';actor=' + actor_nickname + reply_to + \
';actor=' + actor_nickname + first_post_str + reply_to + \
'" title="' + edit_post_str + '" tabindex="10">' + \
'<img loading="lazy" decoding="async" title="' + \
edit_post_str + '" alt="' + edit_post_str + \
@ -692,7 +740,8 @@ def _get_announce_icon_html(is_announced: bool,
page_number_param: str,
timeline_post_bookmark: str,
box_name: str,
max_announce_count: int) -> str:
max_announce_count: int,
first_post_id: str) -> str:
"""Returns html for announce icon/button at the bottom of the post
"""
announce_str = ''
@ -759,13 +808,17 @@ def _get_announce_icon_html(is_announced: bool,
announce_count_str.replace('(', '').replace(')', '').strip()
announce_str += '</a></label>\n'
first_post_str = ''
if first_post_id:
first_post_str = '?firstpost=' + first_post_id
announce_link_str = '?' + \
announce_link + '=' + announce_post_id + page_number_param
announce_str += \
' <a class="imageAnchor" href="/users/' + \
nickname + announce_link_str + unannounce_link_str + \
'?actor=' + post_json_object['actor'] + \
'?bm=' + timeline_post_bookmark + \
'?bm=' + timeline_post_bookmark + first_post_str + \
'?tl=' + box_name + '" title="' + announce_title + '" tabindex="10">\n'
announce_str += \
@ -785,7 +838,8 @@ def _get_like_icon_html(nickname: str, domain_full: str,
translate: {}, page_number_param: str,
timeline_post_bookmark: str,
box_name: str,
max_like_count: int) -> str:
max_like_count: int,
first_post_id: str) -> str:
"""Returns html for like icon/button
"""
if not show_like_button or is_moderation_post:
@ -837,12 +891,16 @@ def _get_like_icon_html(nickname: str, domain_full: str,
like_str += like_count_str.replace('(', '').replace(')', '').strip()
like_str += '</a></label>\n'
first_post_str = ''
if first_post_id:
first_post_str = '?firstpost=' + first_post_id
like_str += \
' <a class="imageAnchor" href="/users/' + nickname + '?' + \
like_link + '=' + like_post_id + \
page_number_param + \
'?actor=' + post_json_object['actor'] + \
'?bm=' + timeline_post_bookmark + \
'?bm=' + timeline_post_bookmark + first_post_str + \
'?tl=' + box_name + '" title="' + like_title + like_count_str + \
'" tabindex="10">\n'
like_str += \
@ -861,7 +919,8 @@ def _get_bookmark_icon_html(nickname: str, domain_full: str,
enable_timing_log: bool,
post_start_time, box_name: str,
page_number_param: str,
timeline_post_bookmark: str) -> str:
timeline_post_bookmark: str,
first_post_id: str) -> str:
"""Returns html for bookmark icon/button
"""
bookmark_str = ''
@ -886,12 +945,17 @@ def _get_bookmark_icon_html(nickname: str, domain_full: str,
bookmark_post_id = \
remove_hash_from_post_id(post_json_object['object']['id'])
bookmark_post_id = remove_id_ending(bookmark_post_id)
first_post_str = ''
if first_post_id:
first_post_str = '?firstpost=' + first_post_id
bookmark_str = \
' <a class="imageAnchor" href="/users/' + nickname + '?' + \
bookmark_link + '=' + bookmark_post_id + \
page_number_param + \
'?actor=' + post_json_object['actor'] + \
'?bm=' + timeline_post_bookmark + \
'?bm=' + timeline_post_bookmark + first_post_str + \
'?tl=' + box_name + '" title="' + bookmark_title + \
'" tabindex="10">\n'
bookmark_str += \
@ -910,7 +974,8 @@ def _get_reaction_icon_html(nickname: str, post_json_object: {},
enable_timing_log: bool,
post_start_time, box_name: str,
page_number_param: str,
timeline_post_reaction: str) -> str:
timeline_post_reaction: str,
first_post_id: str) -> str:
"""Returns html for reaction icon/button
"""
reaction_str = ''
@ -926,11 +991,16 @@ def _get_reaction_icon_html(nickname: str, post_json_object: {},
reaction_post_id = \
remove_hash_from_post_id(post_json_object['object']['id'])
reaction_post_id = remove_id_ending(reaction_post_id)
first_post_str = ''
if first_post_id:
first_post_str = '?firstpost=' + first_post_id
reaction_str = \
' <a class="imageAnchor" href="/users/' + nickname + \
'?selreact=' + reaction_post_id + page_number_param + \
'?actor=' + post_json_object['actor'] + \
'?bm=' + timeline_post_reaction + \
'?bm=' + timeline_post_reaction + first_post_str + \
'?tl=' + box_name + '" title="' + reaction_title + \
'" tabindex="10">\n'
reaction_str += \
@ -950,7 +1020,8 @@ def _get_mute_icon_html(is_muted: bool,
page_number_param: str,
box_name: str,
timeline_post_bookmark: str,
translate: {}) -> str:
translate: {},
first_post_id: str) -> str:
"""Returns html for mute icon/button
"""
mute_str = ''
@ -959,6 +1030,10 @@ def _get_mute_icon_html(is_muted: bool,
message_id.startswith(post_actor))):
return mute_str
first_post_str = ''
if first_post_id:
first_post_str = '?firstpost=' + first_post_id
if not is_muted:
mute_this_post_str = 'Mute this post'
if translate.get('Mute this post'):
@ -966,7 +1041,7 @@ def _get_mute_icon_html(is_muted: bool,
mute_str = \
' <a class="imageAnchor" href="/users/' + nickname + \
'?mute=' + message_id + page_number_param + '?tl=' + box_name + \
'?bm=' + timeline_post_bookmark + \
'?bm=' + timeline_post_bookmark + first_post_str + \
'" title="' + mute_this_post_str + '" tabindex="10">\n'
mute_str += \
' ' + \
@ -982,7 +1057,8 @@ def _get_mute_icon_html(is_muted: bool,
' <a class="imageAnchor" href="/users/' + \
nickname + '?unmute=' + message_id + \
page_number_param + '?tl=' + box_name + '?bm=' + \
timeline_post_bookmark + '" title="' + undo_mute_str + \
timeline_post_bookmark + first_post_str + \
'" title="' + undo_mute_str + \
'" tabindex="10">\n'
mute_str += \
' ' + \
@ -999,7 +1075,8 @@ def _get_delete_icon_html(nickname: str, domain_full: str,
message_id: str,
post_json_object: {},
page_number_param: str,
translate: {}) -> str:
translate: {},
first_post_id: str) -> str:
"""Returns html for delete icon/button
"""
delete_str = ''
@ -1011,10 +1088,15 @@ def _get_delete_icon_html(nickname: str, domain_full: str,
delete_this_post_str = 'Delete this post'
if translate.get(delete_this_post_str):
delete_this_post_str = translate[delete_this_post_str]
first_post_str = ''
if first_post_id:
first_post_str = '?firstpost=' + first_post_id
delete_str = \
' <a class="imageAnchor" href="/users/' + \
nickname + \
'?delete=' + message_id + page_number_param + \
nickname + '?delete=' + message_id + \
page_number_param + first_post_str + \
'" title="' + delete_this_post_str + '" tabindex="10">\n'
delete_str += \
' ' + \
@ -1773,7 +1855,8 @@ def individual_post_as_html(signing_priv_key_pem: str,
timezone: str,
mitm: bool, bold_reading: bool,
dogwhistles: {},
minimize_all_images: bool) -> str:
minimize_all_images: bool,
first_post_id: str) -> str:
""" Shows a single post as html
"""
if not post_json_object:
@ -1844,7 +1927,8 @@ def individual_post_as_html(signing_priv_key_pem: str,
page_number,
recent_posts_cache,
max_recent_posts,
signing_priv_key_pem)
signing_priv_key_pem,
first_post_id)
if post_html:
return post_html
if use_cache_only and post_json_object['type'] != 'Announce':
@ -1975,7 +2059,8 @@ def individual_post_as_html(signing_priv_key_pem: str,
page_number,
recent_posts_cache,
max_recent_posts,
signing_priv_key_pem)
signing_priv_key_pem,
first_post_id)
if post_html:
return post_html
@ -2104,7 +2189,7 @@ def individual_post_as_html(signing_priv_key_pem: str,
edit_str = _get_edit_icon_html(base_dir, nickname, domain_full,
post_json_object, actor_nickname,
translate, False)
translate, False, first_post_id)
_log_post_timing(enable_timing_log, post_start_time, '11')
@ -2120,7 +2205,8 @@ def individual_post_as_html(signing_priv_key_pem: str,
translate,
page_number_param,
timeline_post_bookmark,
box_name, max_like_count)
box_name, max_like_count,
first_post_id)
_log_post_timing(enable_timing_log, post_start_time, '12')
@ -2149,7 +2235,8 @@ def individual_post_as_html(signing_priv_key_pem: str,
post_start_time,
translate, page_number_param,
timeline_post_bookmark,
box_name, max_like_count)
box_name, max_like_count,
first_post_id)
_log_post_timing(enable_timing_log, post_start_time, '12.5')
@ -2161,7 +2248,8 @@ def individual_post_as_html(signing_priv_key_pem: str,
enable_timing_log,
post_start_time, box_name,
page_number_param,
timeline_post_bookmark)
timeline_post_bookmark,
first_post_id)
_log_post_timing(enable_timing_log, post_start_time, '12.9')
@ -2173,7 +2261,8 @@ def individual_post_as_html(signing_priv_key_pem: str,
enable_timing_log,
post_start_time, box_name,
page_number_param,
timeline_post_bookmark)
timeline_post_bookmark,
first_post_id)
_log_post_timing(enable_timing_log, post_start_time, '12.10')
@ -2191,7 +2280,7 @@ def individual_post_as_html(signing_priv_key_pem: str,
page_number_param,
box_name,
timeline_post_bookmark,
translate)
translate, first_post_id)
delete_str = \
_get_delete_icon_html(nickname, domain_full,
@ -2200,7 +2289,7 @@ def individual_post_as_html(signing_priv_key_pem: str,
message_id,
post_json_object,
page_number_param,
translate)
translate, first_post_id)
_log_post_timing(enable_timing_log, post_start_time, '13.1')
@ -2665,7 +2754,7 @@ def html_individual_post(recent_posts_cache: {}, max_recent_posts: int,
False, authorized, False, False, False, False,
cw_lists, lists_enabled, timezone, mitm,
bold_reading, dogwhistles,
minimize_all_images)
minimize_all_images, None)
message_id = remove_id_ending(post_json_object['id'])
# show the previous posts
@ -2708,7 +2797,8 @@ def html_individual_post(recent_posts_cache: {}, max_recent_posts: int,
timezone, mitm,
bold_reading,
dogwhistles,
minimize_all_images) + post_str
minimize_all_images,
None) + post_str
# show the following posts
post_filename = locate_post(base_dir, nickname, domain, message_id)
@ -2748,7 +2838,7 @@ def html_individual_post(recent_posts_cache: {}, max_recent_posts: int,
cw_lists, lists_enabled,
timezone, False,
bold_reading, dogwhistles,
minimize_all_images)
minimize_all_images, None)
css_filename = base_dir + '/epicyon-profile.css'
if os.path.isfile(base_dir + '/epicyon.css'):
css_filename = base_dir + '/epicyon.css'
@ -2810,7 +2900,7 @@ def html_post_replies(recent_posts_cache: {}, max_recent_posts: int,
cw_lists, lists_enabled,
timezone, False,
bold_reading, dogwhistles,
minimize_all_images)
minimize_all_images, None)
css_filename = base_dir + '/epicyon-profile.css'
if os.path.isfile(base_dir + '/epicyon.css'):
@ -2869,7 +2959,7 @@ def html_emoji_reaction_picker(recent_posts_cache: {}, max_recent_posts: int,
False, False, False, False, False, False,
cw_lists, lists_enabled, timezone, False,
bold_reading, dogwhistles,
minimize_all_images)
minimize_all_images, None)
reactions_filename = base_dir + '/emoji/reactions.json'
if not os.path.isfile(reactions_filename):

View File

@ -406,7 +406,7 @@ def html_profile_after_search(recent_posts_cache: {}, max_recent_posts: int,
cw_lists, lists_enabled,
timezone, False,
bold_reading, dogwhistles,
minimize_all_images)
minimize_all_images, None)
i += 1
if i >= 8:
break
@ -1291,7 +1291,7 @@ def _html_profile_posts(recent_posts_cache: {}, max_recent_posts: int,
cw_lists, lists_enabled,
timezone, False,
bold_reading, dogwhistles,
minimize_all_images)
minimize_all_images, None)
if post_str and item_id not in shown_items:
profile_str += post_str + separator_str
shown_items.append(item_id)

View File

@ -807,7 +807,7 @@ def html_history_search(translate: {}, base_dir: str,
cw_lists, lists_enabled,
timezone, False, bold_reading,
dogwhistles,
minimize_all_images)
minimize_all_images, None)
if post_str:
history_search_form += separator_str + post_str
index += 1
@ -1026,7 +1026,7 @@ def html_hashtag_search(nickname: str, domain: str, port: int,
store_to_sache, False, cw_lists,
lists_enabled, timezone, False,
bold_reading, dogwhistles,
minimize_all_images)
minimize_all_images, None)
if post_str:
hashtag_search_form += separator_str + post_str
index += 1

View File

@ -986,15 +986,16 @@ def html_timeline(default_timeline: str,
if box_name != 'tlmedia' and recent_posts_cache.get('html'):
post_id = remove_id_ending(item['id']).replace('/', '#')
if recent_posts_cache['html'].get(post_id):
if not first_post_id:
first_post_id = post_id
last_post_id = post_id
curr_tl_str = recent_posts_cache['html'][post_id]
curr_tl_str = \
prepare_post_from_html_cache(nickname,
curr_tl_str,
box_name,
page_number)
if not first_post_id:
first_post_id = post_id
last_post_id = post_id
page_number,
first_post_id)
_log_timeline_timing(enable_timing_log,
timeline_start_time,
box_name, '10')
@ -1035,7 +1036,8 @@ def html_timeline(default_timeline: str,
cw_lists, lists_enabled,
timezone, mitm,
bold_reading, dogwhistles,
minimize_all_images)
minimize_all_images,
first_post_id)
_log_timeline_timing(enable_timing_log,
timeline_start_time, box_name, '12')