From 41b3bf129c4c3a1f8075d32960a8d7f241e5fe5b Mon Sep 17 00:00:00 2001 From: Bob Mottram Date: Wed, 28 Dec 2022 11:43:11 +0000 Subject: [PATCH 1/7] Switch default content license to noncommercial This may deter some sketchy databrokering --- daemon.py | 5 +++-- desktop_client.py | 2 +- epicyon.py | 3 ++- tests.py | 30 +++++++++++++++--------------- webapp_profile.py | 2 +- 5 files changed, 22 insertions(+), 20 deletions(-) diff --git a/daemon.py b/daemon.py index bc2599767..37a66489f 100644 --- a/daemon.py +++ b/daemon.py @@ -6470,7 +6470,8 @@ class PubServer(BaseHTTPRequestHandler): license_str else: license_str = \ - 'https://creativecommons.org/licenses/by/4.0' + 'https://creativecommons.org/' + \ + 'licenses/by-nc/4.0' set_config_param(base_dir, 'contentLicenseUrl', license_str) @@ -22555,7 +22556,7 @@ def run_daemon(max_hashtags: int, # license for content of the instance if not content_license_url: - content_license_url = 'https://creativecommons.org/licenses/by/4.0' + content_license_url = 'https://creativecommons.org/licenses/by-nc/4.0' httpd.content_license_url = content_license_url # fitness metrics diff --git a/desktop_client.py b/desktop_client.py index 8633cd3df..9a21a3d6b 100644 --- a/desktop_client.py +++ b/desktop_client.py @@ -1419,7 +1419,7 @@ def run_desktop_client(base_dir: str, proxy_type: str, http_prefix: str, # TODO: this should probably be retrieved somehow from the server signing_priv_key_pem = None - content_license_url = 'https://creativecommons.org/licenses/by/4.0' + content_license_url = 'https://creativecommons.org/licenses/by-nc/4.0' blocked_cache = {} languages_understood = [] diff --git a/epicyon.py b/epicyon.py index 47ef8ee1a..7f04ccdfa 100644 --- a/epicyon.py +++ b/epicyon.py @@ -149,7 +149,8 @@ def _command_options() -> None: default=None, help='Location for an event when sending a c2s post') parser.add_argument('--content_license_url', type=str, - default='https://creativecommons.org/licenses/by/4.0', + default='https://creativecommons.org/' + + 'licenses/by-nc/4.0', help='Url of the license used for the ' + 'instance content') parser.add_argument('--import_emoji', type=str, diff --git a/tests.py b/tests.py index 58f51b6a9..be4fe4f3f 100644 --- a/tests.py +++ b/tests.py @@ -770,7 +770,7 @@ def create_server_alice(path: str, domain: str, port: int, test_is_article = False conversation_id = None translate = {} - content_license_url = 'https://creativecommons.org/licenses/by/4.0' + content_license_url = 'https://creativecommons.org/licenses/by-nc/4.0' create_public_post(path, nickname, domain, port, http_prefix, "No wise fish would go anywhere without a porpoise", test_save_to_file, @@ -839,7 +839,7 @@ def create_server_alice(path: str, domain: str, port: int, max_like_count = 10 default_reply_interval_hrs = 9999999999 lists_enabled = '' - content_license_url = 'https://creativecommons.org/licenses/by/4.0' + content_license_url = 'https://creativecommons.org/licenses/by-nc/4.0' dyslexic_font = False crawlers_allowed = [] check_actor_timeout = 2 @@ -933,7 +933,7 @@ def create_server_bob(path: str, domain: str, port: int, test_location = None test_is_article = False conversation_id = None - content_license_url = 'https://creativecommons.org/licenses/by/4.0' + content_license_url = 'https://creativecommons.org/licenses/by-nc/4.0' translate = {} create_public_post(path, nickname, domain, port, http_prefix, "It's your life, live it your way.", @@ -1003,7 +1003,7 @@ def create_server_bob(path: str, domain: str, port: int, max_like_count = 10 default_reply_interval_hrs = 9999999999 lists_enabled = '' - content_license_url = 'https://creativecommons.org/licenses/by/4.0' + content_license_url = 'https://creativecommons.org/licenses/by-nc/4.0' dyslexic_font = False crawlers_allowed = [] check_actor_timeout = 2 @@ -1089,7 +1089,7 @@ def create_server_eve(path: str, domain: str, port: int, federation_list: [], low_bandwidth = True default_reply_interval_hrs = 9999999999 lists_enabled = '' - content_license_url = 'https://creativecommons.org/licenses/by/4.0' + content_license_url = 'https://creativecommons.org/licenses/by-nc/4.0' dyslexic_font = False crawlers_allowed = [] check_actor_timeout = 2 @@ -1177,7 +1177,7 @@ def create_server_group(path: str, domain: str, port: int, low_bandwidth = True default_reply_interval_hrs = 9999999999 lists_enabled = '' - content_license_url = 'https://creativecommons.org/licenses/by/4.0' + content_license_url = 'https://creativecommons.org/licenses/by-nc/4.0' dyslexic_font = False crawlers_allowed = [] check_actor_timeout = 2 @@ -1229,7 +1229,7 @@ def test_post_message_between_servers(base_dir: str) -> None: languages_understood = [system_language] http_prefix = 'http' proxy_type = None - content_license_url = 'https://creativecommons.org/licenses/by/4.0' + content_license_url = 'https://creativecommons.org/licenses/by-nc/4.0' if os.path.isdir(base_dir + '/.tests'): shutil.rmtree(base_dir + '/.tests', ignore_errors=False, onerror=None) @@ -1559,7 +1559,7 @@ def test_follow_between_servers(base_dir: str) -> None: http_prefix = 'http' proxy_type = None federation_list = [] - content_license_url = 'https://creativecommons.org/licenses/by/4.0' + content_license_url = 'https://creativecommons.org/licenses/by-nc/4.0' if os.path.isdir(base_dir + '/.tests'): shutil.rmtree(base_dir + '/.tests', ignore_errors=False, onerror=None) @@ -1753,7 +1753,7 @@ def test_shared_items_federation(base_dir: str) -> None: http_prefix = 'http' proxy_type = None federation_list = [] - content_license_url = 'https://creativecommons.org/licenses/by/4.0' + content_license_url = 'https://creativecommons.org/licenses/by-nc/4.0' if os.path.isdir(base_dir + '/.tests'): shutil.rmtree(base_dir + '/.tests', ignore_errors=False, onerror=None) @@ -2175,7 +2175,7 @@ def test_group_follow(base_dir: str) -> None: http_prefix = 'http' proxy_type = None federation_list = [] - content_license_url = 'https://creativecommons.org/licenses/by/4.0' + content_license_url = 'https://creativecommons.org/licenses/by-nc/4.0' if os.path.isdir(base_dir + '/.tests'): shutil.rmtree(base_dir + '/.tests', ignore_errors=False, onerror=None) @@ -2869,7 +2869,7 @@ def _test_create_person_account(base_dir: str): conversation_id = None low_bandwidth = True translate = {} - content_license_url = 'https://creativecommons.org/licenses/by/4.0' + content_license_url = 'https://creativecommons.org/licenses/by-nc/4.0' content = \ "If your \"independent organization\" is government funded...\n\n" + \ "(yawn)\n\n...then it's not really independent.\n\n" + \ @@ -2992,7 +2992,7 @@ def test_client_to_server(base_dir: str): global TEST_SERVER_ALICE_RUNNING global TEST_SERVER_BOB_RUNNING - content_license_url = 'https://creativecommons.org/licenses/by/4.0' + content_license_url = 'https://creativecommons.org/licenses/by-nc/4.0' TEST_SERVER_ALICE_RUNNING = False TEST_SERVER_BOB_RUNNING = False @@ -4693,7 +4693,7 @@ def _test_reply_to_public_post(base_dir: str) -> None: test_is_article = False conversation_id = None low_bandwidth = True - content_license_url = 'https://creativecommons.org/licenses/by/4.0' + content_license_url = 'https://creativecommons.org/licenses/by-nc/4.0' translate = {} reply = \ create_public_post(base_dir, nickname, domain, port, http_prefix, @@ -5643,7 +5643,7 @@ def _test_links_within_post(base_dir: str) -> None: test_is_article = False conversation_id = None low_bandwidth = True - content_license_url = 'https://creativecommons.org/licenses/by/4.0' + content_license_url = 'https://creativecommons.org/licenses/by-nc/4.0' translate = {} post_json_object = \ @@ -6733,7 +6733,7 @@ def _test_can_replyto(base_dir: str) -> None: test_is_article = False conversation_id = None low_bandwidth = True - content_license_url = 'https://creativecommons.org/licenses/by/4.0' + content_license_url = 'https://creativecommons.org/licenses/by-nc/4.0' translate = {} post_json_object = \ diff --git a/webapp_profile.py b/webapp_profile.py index ed5f0fc2a..eb87ac8e0 100644 --- a/webapp_profile.py +++ b/webapp_profile.py @@ -1537,7 +1537,7 @@ def _html_edit_profile_instance(base_dir: str, translate: {}, content_license_url = \ get_config_param(base_dir, 'contentLicenseUrl') if not content_license_url: - content_license_url = 'https://creativecommons.org/licenses/by/4.0' + content_license_url = 'https://creativecommons.org/licenses/by-nc/4.0' instance_str = begin_edit_section(translate['Instance Settings']) From 441459ce7eb40c08b607d492a844cf718bfb0dbc Mon Sep 17 00:00:00 2001 From: Bob Mottram Date: Wed, 28 Dec 2022 14:14:44 +0000 Subject: [PATCH 2/7] Consistent page up on timeline --- daemon.py | 35 ++++++++++++++++++++++++---- person.py | 2 ++ webapp_moderation.py | 2 +- webapp_timeline.py | 55 +++++++++++++++++++++++++++++--------------- 4 files changed, 69 insertions(+), 25 deletions(-) diff --git a/daemon.py b/daemon.py index 37a66489f..78412d036 100644 --- a/daemon.py +++ b/daemon.py @@ -12457,6 +12457,11 @@ class PubServer(BaseHTTPRequestHandler): reverse_sequence = False if nickname in self.server.reverse_sequence: reverse_sequence = True + last_post_id = None + if ';lastpost=' in path: + last_post_id = path.split(';lastpost=')[1] + if ';' in last_post_id: + last_post_id = last_post_id.split(';')[0] msg = \ html_inbox(default_timeline, recent_posts_cache, @@ -12501,7 +12506,7 @@ class PubServer(BaseHTTPRequestHandler): self.server.dogwhistles, ua_str, self.server.min_images_for_accounts, - reverse_sequence) + reverse_sequence, last_post_id) if getreq_start_time: fitness_performance(getreq_start_time, self.server.fitness, @@ -12637,6 +12642,11 @@ class PubServer(BaseHTTPRequestHandler): reverse_sequence = False if nickname in self.server.reverse_sequence: reverse_sequence = True + last_post_id = None + if ';lastpost=' in path: + last_post_id = path.split(';lastpost=')[1] + if ';' in last_post_id: + last_post_id = last_post_id.split(';')[0] msg = \ html_inbox_dms(self.server.default_timeline, self.server.recent_posts_cache, @@ -12679,7 +12689,7 @@ class PubServer(BaseHTTPRequestHandler): timezone, bold_reading, self.server.dogwhistles, ua_str, self.server.min_images_for_accounts, - reverse_sequence) + reverse_sequence, last_post_id) msg = msg.encode('utf-8') msglen = len(msg) self._set_headers('text/html', msglen, @@ -12805,6 +12815,11 @@ class PubServer(BaseHTTPRequestHandler): reverse_sequence = False if nickname in self.server.reverse_sequence: reverse_sequence = True + last_post_id = None + if ';lastpost=' in path: + last_post_id = path.split(';lastpost=')[1] + if ';' in last_post_id: + last_post_id = last_post_id.split(';')[0] msg = \ html_inbox_replies(self.server.default_timeline, self.server.recent_posts_cache, @@ -12848,7 +12863,7 @@ class PubServer(BaseHTTPRequestHandler): self.server.dogwhistles, ua_str, self.server.min_images_for_accounts, - reverse_sequence) + reverse_sequence, last_post_id) msg = msg.encode('utf-8') msglen = len(msg) self._set_headers('text/html', msglen, @@ -12970,6 +12985,11 @@ class PubServer(BaseHTTPRequestHandler): reverse_sequence = False if nickname in self.server.reverse_sequence: reverse_sequence = True + last_post_id = None + if ';lastpost=' in path: + last_post_id = path.split(';lastpost=')[1] + if ';' in last_post_id: + last_post_id = last_post_id.split(';')[0] msg = \ html_inbox_media(self.server.default_timeline, self.server.recent_posts_cache, @@ -13013,7 +13033,7 @@ class PubServer(BaseHTTPRequestHandler): timezone, bold_reading, self.server.dogwhistles, ua_str, self.server.min_images_for_accounts, - reverse_sequence) + reverse_sequence, last_post_id) msg = msg.encode('utf-8') msglen = len(msg) self._set_headers('text/html', msglen, @@ -13135,6 +13155,11 @@ class PubServer(BaseHTTPRequestHandler): reverse_sequence = False if nickname in self.server.reverse_sequence: reverse_sequence = True + last_post_id = None + if ';lastpost=' in path: + last_post_id = path.split(';lastpost=')[1] + if ';' in last_post_id: + last_post_id = last_post_id.split(';')[0] msg = \ html_inbox_blogs(self.server.default_timeline, self.server.recent_posts_cache, @@ -13178,7 +13203,7 @@ class PubServer(BaseHTTPRequestHandler): timezone, bold_reading, self.server.dogwhistles, ua_str, self.server.min_images_for_accounts, - reverse_sequence) + reverse_sequence, last_post_id) msg = msg.encode('utf-8') msglen = len(msg) self._set_headers('text/html', msglen, diff --git a/person.py b/person.py index 877d6e03a..6badac74a 100644 --- a/person.py +++ b/person.py @@ -996,6 +996,8 @@ def person_box_json(recent_posts_cache: {}, 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('--', '/') diff --git a/webapp_moderation.py b/webapp_moderation.py index 3e9120c3e..5ebb799a5 100644 --- a/webapp_moderation.py +++ b/webapp_moderation.py @@ -88,7 +88,7 @@ def html_moderation(default_timeline: str, max_like_count, shared_items_federated_domains, signing_priv_key_pem, cw_lists, lists_enabled, timezone, bold_reading, dogwhistles, ua_str, - min_images_for_accounts, reverse_sequence) + min_images_for_accounts, reverse_sequence, None) def html_account_info(translate: {}, diff --git a/webapp_timeline.py b/webapp_timeline.py index 760c33a89..1c8b4f32a 100644 --- a/webapp_timeline.py +++ b/webapp_timeline.py @@ -500,7 +500,8 @@ def html_timeline(default_timeline: str, timezone: str, bold_reading: bool, dogwhistles: {}, ua_str: str, min_images_for_accounts: [], - reverse_sequence: bool) -> str: + reverse_sequence: bool, + last_post_id: str) -> str: """Show the timeline as html """ enable_timing_log = False @@ -925,10 +926,13 @@ def html_timeline(default_timeline: str, tl_str += '
' + \ page_number_buttons(users_path, box_name, page_number, 'timelineposts') + first_post_str = '' + if last_post_id: + first_post_str = ';firstpost=' + last_post_id tl_str += \ '
\n' + \ ' ' + \ '' + \ ' str: + reverse_sequence: bool, + last_post_id: str) -> str: """Show the DM timeline as html """ artist = is_artist(base_dir, nickname) @@ -1580,7 +1594,7 @@ def html_inbox_dms(default_timeline: str, cw_lists, lists_enabled, timezone, bold_reading, dogwhistles, ua_str, min_images_for_accounts, - reverse_sequence) + reverse_sequence, last_post_id) def html_inbox_replies(default_timeline: str, @@ -1613,7 +1627,8 @@ def html_inbox_replies(default_timeline: str, timezone: str, bold_reading: bool, dogwhistles: {}, ua_str: str, min_images_for_accounts: [], - reverse_sequence: bool) -> str: + reverse_sequence: bool, + last_post_id: str) -> str: """Show the replies timeline as html """ artist = is_artist(base_dir, nickname) @@ -1639,7 +1654,7 @@ def html_inbox_replies(default_timeline: str, shared_items_federated_domains, signing_priv_key_pem, cw_lists, lists_enabled, timezone, bold_reading, dogwhistles, ua_str, min_images_for_accounts, - reverse_sequence) + reverse_sequence, last_post_id) def html_inbox_media(default_timeline: str, @@ -1672,7 +1687,8 @@ def html_inbox_media(default_timeline: str, timezone: str, bold_reading: bool, dogwhistles: {}, ua_str: str, min_images_for_accounts: [], - reverse_sequence: bool) -> str: + reverse_sequence: bool, + last_post_id: str) -> str: """Show the media timeline as html """ artist = is_artist(base_dir, nickname) @@ -1698,7 +1714,7 @@ def html_inbox_media(default_timeline: str, shared_items_federated_domains, signing_priv_key_pem, cw_lists, lists_enabled, timezone, bold_reading, dogwhistles, ua_str, min_images_for_accounts, - reverse_sequence) + reverse_sequence, last_post_id) def html_inbox_blogs(default_timeline: str, @@ -1731,7 +1747,8 @@ def html_inbox_blogs(default_timeline: str, timezone: str, bold_reading: bool, dogwhistles: {}, ua_str: str, min_images_for_accounts: [], - reverse_sequence: bool) -> str: + reverse_sequence: bool, + last_post_id: str) -> str: """Show the blogs timeline as html """ artist = is_artist(base_dir, nickname) @@ -1757,7 +1774,7 @@ def html_inbox_blogs(default_timeline: str, shared_items_federated_domains, signing_priv_key_pem, cw_lists, lists_enabled, timezone, bold_reading, dogwhistles, ua_str, min_images_for_accounts, - reverse_sequence) + reverse_sequence, last_post_id) def html_inbox_features(default_timeline: str, @@ -1816,7 +1833,7 @@ def html_inbox_features(default_timeline: str, shared_items_federated_domains, signing_priv_key_pem, cw_lists, lists_enabled, timezone, bold_reading, dogwhistles, ua_str, min_images_for_accounts, - reverse_sequence) + reverse_sequence, None) def html_inbox_news(default_timeline: str, @@ -1874,7 +1891,7 @@ def html_inbox_news(default_timeline: str, shared_items_federated_domains, signing_priv_key_pem, cw_lists, lists_enabled, timezone, bold_reading, dogwhistles, ua_str, min_images_for_accounts, - reverse_sequence) + reverse_sequence, None) def html_outbox(default_timeline: str, @@ -1935,4 +1952,4 @@ def html_outbox(default_timeline: str, shared_items_federated_domains, signing_priv_key_pem, cw_lists, lists_enabled, timezone, bold_reading, dogwhistles, ua_str, min_images_for_accounts, - reverse_sequence) + reverse_sequence, None) From 7b15a927b3e1e38534c345ee4df95e9634620282 Mon Sep 17 00:00:00 2001 From: Bob Mottram Date: Wed, 28 Dec 2022 14:28:54 +0000 Subject: [PATCH 3/7] Page 1 of the timeline always shows latest posts --- webapp_timeline.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/webapp_timeline.py b/webapp_timeline.py index 1c8b4f32a..a6df107c4 100644 --- a/webapp_timeline.py +++ b/webapp_timeline.py @@ -927,8 +927,9 @@ def html_timeline(default_timeline: str, page_number_buttons(users_path, box_name, page_number, 'timelineposts') first_post_str = '' - if last_post_id: - first_post_str = ';firstpost=' + last_post_id + if page_number > 2: + if last_post_id: + first_post_str = ';firstpost=' + last_post_id tl_str += \ '
\n' + \ ' ' + \ diff --git a/webapp_conversation.py b/webapp_conversation.py index d56b8d6bb..7efe476ab 100644 --- a/webapp_conversation.py +++ b/webapp_conversation.py @@ -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 diff --git a/webapp_create_post.py b/webapp_create_post.py index 33bf69c64..7537e6e42 100644 --- a/webapp_create_post.py +++ b/webapp_create_post.py @@ -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 = '\n' diff --git a/webapp_frontscreen.py b/webapp_frontscreen.py index c6eb567f3..6c829bcdf 100644 --- a/webapp_frontscreen.py +++ b/webapp_frontscreen.py @@ -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 diff --git a/webapp_likers.py b/webapp_likers.py index 2829e3e87..d5221b8da 100644 --- a/webapp_likers.py +++ b/webapp_likers.py @@ -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 diff --git a/webapp_post.py b/webapp_post.py index 8aa5fcc8b..10ab1d1c5 100644 --- a/webapp_post.py +++ b/webapp_post.py @@ -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, '' + \ '' + edit_blog_post_str + \
@@ -582,7 +630,7 @@ def _get_edit_icon_html(base_dir: str, nickname: str, domain_full: str,
                     '<a class=' + \ '' + edit_blog_post_str + \
@@ -596,7 +644,7 @@ def _get_edit_icon_html(base_dir: str, nickname: str, domain_full: str,
                 '<a class=' + \ '' + edit_event_str + \
@@ -611,7 +659,7 @@ def _get_edit_icon_html(base_dir: str, nickname: str, domain_full: str,
                 '<a class=' + \ '' + edit_post_str + \
@@ -626,7 +674,7 @@ def _get_edit_icon_html(base_dir: str, nickname: str, domain_full: str,
                 '<a class=' + \ '' + edit_post_str + \
@@ -641,7 +689,7 @@ def _get_edit_icon_html(base_dir: str, nickname: str, domain_full: str,
                 '<a class=' + \ '' + edit_post_str + \
@@ -656,7 +704,7 @@ def _get_edit_icon_html(base_dir: str, nickname: str, domain_full: str,
                 '<a class=' + \ '' + edit_post_str + \
@@ -671,7 +719,7 @@ def _get_edit_icon_html(base_dir: str, nickname: str, domain_full: str,
                 '<a class=' + \ '' + 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:
     \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 += '\n' + first_post_str = '' + if first_post_id: + first_post_str = '?firstpost=' + first_post_id + like_str += \ ' \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 = \ ' \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 = \ ' \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 = \ ' \n' mute_str += \ ' ' + \ @@ -982,7 +1057,8 @@ def _get_mute_icon_html(is_muted: bool, ' \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 = \ ' \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): diff --git a/webapp_profile.py b/webapp_profile.py index eb87ac8e0..bab835c6a 100644 --- a/webapp_profile.py +++ b/webapp_profile.py @@ -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) diff --git a/webapp_search.py b/webapp_search.py index 723b716fe..077cb99cb 100644 --- a/webapp_search.py +++ b/webapp_search.py @@ -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 diff --git a/webapp_timeline.py b/webapp_timeline.py index a6df107c4..8208c7ecf 100644 --- a/webapp_timeline.py +++ b/webapp_timeline.py @@ -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') From a05a43d03b327ec8802f57c1f3a6b283ff1206e8 Mon Sep 17 00:00:00 2001 From: Bob Mottram Date: Wed, 28 Dec 2022 18:57:57 +0000 Subject: [PATCH 5/7] Debug --- daemon.py | 1 + 1 file changed, 1 insertion(+) diff --git a/daemon.py b/daemon.py index 331e2e62e..bfa531fc9 100644 --- a/daemon.py +++ b/daemon.py @@ -9708,6 +9708,7 @@ class PubServer(BaseHTTPRequestHandler): return like_actor = \ local_actor_url(http_prefix, self.post_to_nickname, domain_full) + print('actor_liked path: ' + path) actor_liked = path.split('?actor=')[1] if '?' in actor_liked: actor_liked = actor_liked.split('?')[0] From 0b43a52defcd47aedf851dce9415b7f6d8490f6a Mon Sep 17 00:00:00 2001 From: Bob Mottram Date: Wed, 28 Dec 2022 19:02:04 +0000 Subject: [PATCH 6/7] Replace hash --- webapp_post.py | 1 + 1 file changed, 1 insertion(+) diff --git a/webapp_post.py b/webapp_post.py index 10ab1d1c5..6b0b975ae 100644 --- a/webapp_post.py +++ b/webapp_post.py @@ -322,6 +322,7 @@ def prepare_post_from_html_cache(nickname: str, post_html: str, box_name: str, if first_post_id is None: first_post_id = '' + first_post_id = first_post_id.replace('#', '/') if '?firstpost=' in with_page_number: with_page_number = \ replace_link_variable(with_page_number, From 3986a7044ed989561c50268782d656c5b6d0cbe3 Mon Sep 17 00:00:00 2001 From: Bob Mottram Date: Wed, 28 Dec 2022 19:06:39 +0000 Subject: [PATCH 7/7] Remove debug --- daemon.py | 1 - 1 file changed, 1 deletion(-) diff --git a/daemon.py b/daemon.py index bfa531fc9..331e2e62e 100644 --- a/daemon.py +++ b/daemon.py @@ -9708,7 +9708,6 @@ class PubServer(BaseHTTPRequestHandler): return like_actor = \ local_actor_url(http_prefix, self.post_to_nickname, domain_full) - print('actor_liked path: ' + path) actor_liked = path.split('?actor=')[1] if '?' in actor_liked: actor_liked = actor_liked.split('?')[0]