diff --git a/daemon.py b/daemon.py index bc2599767..331e2e62e 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) @@ -9088,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] @@ -9251,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 @@ -9284,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] @@ -9381,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) @@ -9638,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] @@ -9808,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 @@ -9820,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 + \ @@ -9847,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] @@ -10008,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 @@ -10016,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 + \ @@ -10045,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] @@ -10237,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) @@ -10247,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 + \ @@ -10274,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] @@ -10456,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 + \ @@ -10593,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] @@ -10720,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, @@ -10728,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 + \ @@ -10755,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] @@ -10884,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 + \ @@ -11030,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] @@ -11135,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) @@ -11150,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 + \ @@ -11170,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] @@ -11275,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: @@ -11287,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 + \ @@ -12456,6 +12498,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, @@ -12500,7 +12547,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, @@ -12636,6 +12683,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, @@ -12678,7 +12730,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, @@ -12804,6 +12856,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, @@ -12847,7 +12904,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, @@ -12969,6 +13026,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, @@ -13012,7 +13074,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, @@ -13134,6 +13196,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, @@ -13177,7 +13244,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, @@ -22555,7 +22622,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/inbox.py b/inbox.py index c077ed2cf..d4442e6f1 100644 --- a/inbox.py +++ b/inbox.py @@ -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, diff --git a/outbox.py b/outbox.py index 2a557db43..eff60a035 100644 --- a/outbox.py +++ b/outbox.py @@ -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' 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/tests.py b/tests.py index 58f51b6a9..da05e6d37 100644 --- a/tests.py +++ b/tests.py @@ -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 @@ -770,7 +771,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 +840,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 +934,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 +1004,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 +1090,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 +1178,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 +1230,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 +1560,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 +1754,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 +2176,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 +2870,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 +2993,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 +4694,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 +5644,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 +6734,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 = \ @@ -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) diff --git a/webapp_confirm.py b/webapp_confirm.py index 75b81567d..7905272f6 100644 --- a/webapp_confirm.py +++ b/webapp_confirm.py @@ -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 += '
' + \
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_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_post.py b/webapp_post.py
index 8aa5fcc8b..6b0b975ae 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,30 @@ 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 = ''
+
+ first_post_id = first_post_id.replace('#', '/')
+ 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 +382,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 +422,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 +583,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 +606,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 +620,7 @@ def _get_edit_icon_html(base_dir: str, nickname: str, domain_full: str,
'' + \
'' + \
'' + \
'' + \
'' + \
'' + \
'' + \
'' + \
'\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 += \
' \n'
announce_str += \
@@ -785,7 +839,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 +892,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 +920,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 +946,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 +975,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 +992,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 +1021,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 +1031,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 +1042,7 @@ def _get_mute_icon_html(is_muted: bool,
mute_str = \
' \n'
mute_str += \
' ' + \
@@ -982,7 +1058,8 @@ def _get_mute_icon_html(is_muted: bool,
' \n'
mute_str += \
' ' + \
@@ -999,7 +1076,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 +1089,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 +1856,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 +1928,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 +2060,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 +2190,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 +2206,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 +2236,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 +2249,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 +2262,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 +2281,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 +2290,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 +2755,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 +2798,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 +2839,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 +2901,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 +2960,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 ed5f0fc2a..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)
@@ -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'])
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 760c33a89..8208c7ecf 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,14 @@ def html_timeline(default_timeline: str,
tl_str += '
' + \
page_number_buttons(users_path, box_name, page_number,
'timelineposts')
+ first_post_str = ''
+ if page_number > 2:
+ if last_post_id:
+ first_post_str = ';firstpost=' + last_post_id
tl_str += \
'