From 6c693fa39e5e384bf53770e1284ea9d9f53c6594 Mon Sep 17 00:00:00 2001 From: Bob Mottram Date: Sat, 16 Nov 2024 18:50:04 +0000 Subject: [PATCH] Don't show link for epicyon instances if none are known --- daemon_get.py | 11 ++++--- daemon_get_feeds.py | 26 +++++++++++++--- daemon_get_profile.py | 15 +++++++-- daemon_get_timeline.py | 60 ++++++++++++++++++++++++++++------- daemon_head.py | 7 +++-- daemon_post.py | 7 +++-- webapp_column_left.py | 18 ++++++----- webapp_frontscreen.py | 6 ++-- webapp_moderation.py | 6 ++-- webapp_profile.py | 6 ++-- webapp_timeline.py | 71 ++++++++++++++++++++++++++++-------------- 11 files changed, 166 insertions(+), 67 deletions(-) diff --git a/daemon_get.py b/daemon_get.py index 6614e5087..b5088fbab 100644 --- a/daemon_get.py +++ b/daemon_get.py @@ -340,9 +340,10 @@ def daemon_http_get(self) -> None: ua_str = get_user_agent(self) - if 'Epicyon/' in ua_str: - log_epicyon_instances(self.server.base_dir, calling_domain, - self.server.known_epicyon_instances) + if ua_str: + if 'Epicyon/' in ua_str: + log_epicyon_instances(self.server.base_dir, calling_domain, + self.server.known_epicyon_instances) if not _permitted_crawler_path(self.path): block, self.server.blocked_cache_last_updated, llm = \ @@ -2968,6 +2969,7 @@ def daemon_http_get(self) -> None: default_timeline = self.server.default_timeline shared_items_domains = \ self.server.shared_items_federated_domains + known_instances = self.server.known_epicyon_instances msg = \ html_links_mobile(self.server.base_dir, nickname, self.server.domain_full, @@ -2980,7 +2982,8 @@ def daemon_http_get(self) -> None: default_timeline, self.server.theme_name, access_keys, - shared_items_domains).encode('utf-8') + shared_items_domains, + known_instances).encode('utf-8') msglen = len(msg) set_headers(self, 'text/html', msglen, cookie, calling_domain, False) diff --git a/daemon_get_feeds.py b/daemon_get_feeds.py index 65eb897df..375f807ee 100644 --- a/daemon_get_feeds.py +++ b/daemon_get_feeds.py @@ -126,6 +126,8 @@ def show_shares_feed(self, authorized: bool, bold_reading = False if bold_reading_nicknames.get(nickname): bold_reading = True + known_epicyon_instances = \ + self.server.known_epicyon_instances msg = \ html_profile(signing_priv_key_pem, rss_icon_at_top, @@ -166,7 +168,8 @@ def show_shares_feed(self, authorized: bool, max_shares_on_profile, sites_unavailable, no_of_books, - auto_cw_cache) + auto_cw_cache, + known_epicyon_instances) msg = msg.encode('utf-8') msglen = len(msg) set_headers(self, 'text/html', msglen, @@ -310,6 +313,8 @@ def show_following_feed(self, authorized: bool, bold_reading = True if not authorized and hide_follows.get(nickname): following = {} + known_epicyon_instances = \ + self.server.known_epicyon_instances msg = \ html_profile(signing_priv_key_pem, @@ -352,7 +357,8 @@ def show_following_feed(self, authorized: bool, max_shares_on_profile, sites_unavailable, no_of_books, - auto_cw_cache).encode('utf-8') + auto_cw_cache, + known_epicyon_instances).encode('utf-8') msglen = len(msg) set_headers(self, 'text/html', msglen, cookie, calling_domain, False) @@ -497,6 +503,9 @@ def show_moved_feed(self, authorized: bool, if bold_reading_nicknames.get(nickname): bold_reading = True + known_epicyon_instances = \ + self.server.known_epicyon_instances + msg = \ html_profile(signing_priv_key_pem, rss_icon_at_top, @@ -538,7 +547,8 @@ def show_moved_feed(self, authorized: bool, max_shares_on_profile, sites_unavailable, no_of_books, - auto_cw_cache).encode('utf-8') + auto_cw_cache, + known_epicyon_instances).encode('utf-8') msglen = len(msg) set_headers(self, 'text/html', msglen, cookie, calling_domain, False) @@ -677,6 +687,8 @@ def show_inactive_feed(self, authorized: bool, bold_reading = False if bold_reading_nicknames.get(nickname): bold_reading = True + known_epicyon_instances = \ + self.server.known_epicyon_instances msg = \ html_profile(signing_priv_key_pem, rss_icon_at_top, @@ -718,7 +730,8 @@ def show_inactive_feed(self, authorized: bool, max_shares_on_profile, sites_unavailable, no_of_books, - auto_cw_cache).encode('utf-8') + auto_cw_cache, + known_epicyon_instances).encode('utf-8') msglen = len(msg) set_headers(self, 'text/html', msglen, cookie, calling_domain, False) @@ -859,6 +872,8 @@ def show_followers_feed(self, authorized: bool, bold_reading = False if bold_reading_nicknames.get(nickname): bold_reading = True + known_epicyon_instances = \ + self.server.known_epicyon_instances msg = \ html_profile(signing_priv_key_pem, rss_icon_at_top, @@ -901,7 +916,8 @@ def show_followers_feed(self, authorized: bool, max_shares_on_profile, sites_unavailable, no_of_books, - auto_cw_cache).encode('utf-8') + auto_cw_cache, + known_epicyon_instances).encode('utf-8') msglen = len(msg) set_headers(self, 'text/html', msglen, cookie, calling_domain, False) diff --git a/daemon_get_profile.py b/daemon_get_profile.py index fa391a497..ef768a4ef 100644 --- a/daemon_get_profile.py +++ b/daemon_get_profile.py @@ -110,6 +110,8 @@ def show_person_profile(self, authorized: bool, bold_reading = False if bold_reading_nicknames.get(nickname): bold_reading = True + known_epicyon_instances = \ + self.server.known_epicyon_instances msg = \ html_profile(signing_priv_key_pem, rss_icon_at_top, @@ -147,7 +149,8 @@ def show_person_profile(self, authorized: bool, max_shares_on_profile, sites_unavailable, no_of_books, - auto_cw_cache).encode('utf-8') + auto_cw_cache, + known_epicyon_instances).encode('utf-8') msglen = len(msg) set_headers(self, 'text/html', msglen, cookie, calling_domain, False) @@ -265,6 +268,8 @@ def show_roles(self, calling_domain: str, referer_domain: str, bold_reading = False if bold_reading_nicknames.get(nickname): bold_reading = True + known_epicyon_instances = \ + self.server.known_epicyon_instances msg = \ html_profile(signing_priv_key_pem, rss_icon_at_top, @@ -302,7 +307,8 @@ def show_roles(self, calling_domain: str, referer_domain: str, max_shares_on_profile, sites_unavailable, no_of_books, - auto_cw_cache) + auto_cw_cache, + known_epicyon_instances) msg = msg.encode('utf-8') msglen = len(msg) set_headers(self, 'text/html', msglen, @@ -412,6 +418,8 @@ def show_skills(self, calling_domain: str, referer_domain: str, bold_reading = False if bold_reading_nicknames.get(nick): bold_reading = True + known_epicyon_instances = \ + self.server.known_epicyon_instances msg = \ html_profile(signing_priv_key_pem, rss_icon_at_top, @@ -451,7 +459,8 @@ def show_skills(self, calling_domain: str, referer_domain: str, max_shares_on_profile, sites_unavailable, no_of_books, - auto_cw_cache) + auto_cw_cache, + known_epicyon_instances) msg = msg.encode('utf-8') msglen = len(msg) set_headers(self, 'text/html', msglen, diff --git a/daemon_get_timeline.py b/daemon_get_timeline.py index 560e4437c..bd01f209e 100644 --- a/daemon_get_timeline.py +++ b/daemon_get_timeline.py @@ -154,6 +154,8 @@ def show_media_timeline(self, authorized: bool, show_announces = True if hide_announces.get(nickname): show_announces = False + known_epicyon_instances = \ + self.server.known_epicyon_instances msg = \ html_inbox_media(default_timeline, recent_posts_cache, @@ -200,7 +202,8 @@ def show_media_timeline(self, authorized: bool, reverse_sequence, last_post_id, buy_sites, auto_cw_cache, - show_announces) + show_announces, + known_epicyon_instances) msg = msg.encode('utf-8') msglen = len(msg) set_headers(self, 'text/html', msglen, @@ -361,6 +364,8 @@ def show_blogs_timeline(self, authorized: bool, last_post_id = path.split(';lastpost=')[1] if ';' in last_post_id: last_post_id = last_post_id.split(';')[0] + known_epicyon_instances = \ + self.server.known_epicyon_instances msg = \ html_inbox_blogs(default_timeline, recent_posts_cache, @@ -406,7 +411,8 @@ def show_blogs_timeline(self, authorized: bool, min_images_for_accounts, reverse_sequence, last_post_id, buy_sites, - auto_cw_cache) + auto_cw_cache, + known_epicyon_instances) msg = msg.encode('utf-8') msglen = len(msg) set_headers(self, 'text/html', msglen, @@ -571,6 +577,8 @@ def show_news_timeline(self, authorized: bool, reverse_sequence = False if nickname in reverse_sequence_nicknames: reverse_sequence = True + known_epicyon_instances = \ + self.server.known_epicyon_instances msg = \ html_inbox_news(default_timeline, recent_posts_cache, @@ -617,7 +625,8 @@ def show_news_timeline(self, authorized: bool, min_images_for_accounts, reverse_sequence, buy_sites, - auto_cw_cache) + auto_cw_cache, + known_epicyon_instances) msg = msg.encode('utf-8') msglen = len(msg) set_headers(self, 'text/html', msglen, @@ -777,6 +786,8 @@ def show_features_timeline(self, authorized: bool, reverse_sequence = False if nickname in reverse_sequence_nicknames: reverse_sequence = True + known_epicyon_instances = \ + self.server.known_epicyon_instances msg = \ html_inbox_features(default_timeline, recent_posts_cache, @@ -823,7 +834,8 @@ def show_features_timeline(self, authorized: bool, min_images_for_accounts, reverse_sequence, buy_sites, - auto_cw_cache) + auto_cw_cache, + known_epicyon_instances) msg = msg.encode('utf-8') msglen = len(msg) set_headers(self, 'text/html', msglen, @@ -947,6 +959,8 @@ def show_shares_timeline(self, authorized: bool, reverse_sequence = False if nickname in reverse_sequence_nicknames: reverse_sequence = True + known_epicyon_instances = \ + self.server.known_epicyon_instances msg = \ html_shares(default_timeline, recent_posts_cache, @@ -989,7 +1003,8 @@ def show_shares_timeline(self, authorized: bool, min_images_for_accounts, reverse_sequence, buy_sites, - auto_cw_cache) + auto_cw_cache, + known_epicyon_instances) msg = msg.encode('utf-8') msglen = len(msg) set_headers(self, 'text/html', msglen, @@ -1089,6 +1104,8 @@ def show_wanted_timeline(self, authorized: bool, reverse_sequence = False if nickname in reverse_sequence_nicknames: reverse_sequence = True + known_epicyon_instances = \ + self.server.known_epicyon_instances msg = \ html_wanted(default_timeline, recent_posts_cache, @@ -1131,7 +1148,8 @@ def show_wanted_timeline(self, authorized: bool, min_images_for_accounts, reverse_sequence, buy_sites, - auto_cw_cache) + auto_cw_cache, + known_epicyon_instances) msg = msg.encode('utf-8') msglen = len(msg) set_headers(self, 'text/html', msglen, @@ -1264,6 +1282,8 @@ def show_bookmarks_timeline(self, authorized: bool, reverse_sequence = False if nickname in reverse_sequence_nicknames: reverse_sequence = True + known_epicyon_instances = \ + self.server.known_epicyon_instances msg = \ html_bookmarks(default_timeline, recent_posts_cache, @@ -1309,7 +1329,8 @@ def show_bookmarks_timeline(self, authorized: bool, min_images_for_accounts, reverse_sequence, buy_sites, - auto_cw_cache) + auto_cw_cache, + known_epicyon_instances) msg = msg.encode('utf-8') msglen = len(msg) set_headers(self, 'text/html', msglen, @@ -1471,6 +1492,8 @@ def show_outbox_timeline(self, authorized: bool, show_announces = True if hide_announces.get(nickname): show_announces = False + known_epicyon_instances = \ + self.server.known_epicyon_instances msg = \ html_outbox(default_timeline, recent_posts_cache, @@ -1515,7 +1538,8 @@ def show_outbox_timeline(self, authorized: bool, reverse_sequence, buy_sites, auto_cw_cache, - show_announces) + show_announces, + known_epicyon_instances) msg = msg.encode('utf-8') msglen = len(msg) set_headers(self, 'text/html', msglen, @@ -1658,6 +1682,8 @@ def show_mod_timeline(self, authorized: bool, reverse_sequence = False if nickname in reverse_sequence_nicknames: reverse_sequence = True + known_epicyon_instances = \ + self.server.known_epicyon_instances msg = \ html_moderation(default_timeline, recent_posts_cache, @@ -1703,7 +1729,8 @@ def show_mod_timeline(self, authorized: bool, min_images_for_accounts, reverse_sequence, buy_sites, - auto_cw_cache) + auto_cw_cache, + known_epicyon_instances) msg = msg.encode('utf-8') msglen = len(msg) set_headers(self, 'text/html', msglen, @@ -1861,6 +1888,8 @@ def show_dms(self, authorized: bool, last_post_id = path.split(';lastpost=')[1] if ';' in last_post_id: last_post_id = last_post_id.split(';')[0] + known_epicyon_instances = \ + self.server.known_epicyon_instances msg = \ html_inbox_dms(default_timeline, recent_posts_cache, @@ -1905,7 +1934,8 @@ def show_dms(self, authorized: bool, min_images_for_accounts, reverse_sequence, last_post_id, buy_sites, - auto_cw_cache) + auto_cw_cache, + known_epicyon_instances) msg = msg.encode('utf-8') msglen = len(msg) set_headers(self, 'text/html', msglen, @@ -2066,6 +2096,8 @@ def show_replies(self, authorized: bool, last_post_id = path.split(';lastpost=')[1] if ';' in last_post_id: last_post_id = last_post_id.split(';')[0] + known_epicyon_instances = \ + self.server.known_epicyon_instances msg = \ html_inbox_replies(default_timeline, recent_posts_cache, @@ -2111,7 +2143,8 @@ def show_replies(self, authorized: bool, min_images_for_accounts, reverse_sequence, last_post_id, buy_sites, - auto_cw_cache) + auto_cw_cache, + known_epicyon_instances) msg = msg.encode('utf-8') msglen = len(msg) set_headers(self, 'text/html', msglen, @@ -2283,6 +2316,8 @@ def show_inbox(self, authorized: bool, show_announces = True if hide_announces.get(nickname): show_announces = False + known_epicyon_instances = \ + self.server.known_epicyon_instances msg = \ html_inbox(default_timeline, recent_posts_cache, @@ -2330,7 +2365,8 @@ def show_inbox(self, authorized: bool, reverse_sequence, last_post_id, buy_sites, auto_cw_cache, - show_announces) + show_announces, + known_epicyon_instances) if getreq_start_time: fitness_performance(getreq_start_time, fitness, '_GET', '_show_inbox3', diff --git a/daemon_head.py b/daemon_head.py index 2a041ae99..dc05a2462 100644 --- a/daemon_head.py +++ b/daemon_head.py @@ -38,9 +38,10 @@ def daemon_http_head(self) -> None: ua_str = get_user_agent(self) - if 'Epicyon/' in ua_str: - log_epicyon_instances(self.server.base_dir, calling_domain, - self.server.known_epicyon_instances) + if ua_str: + if 'Epicyon/' in ua_str: + log_epicyon_instances(self.server.base_dir, calling_domain, + self.server.known_epicyon_instances) if self.headers.get('Host'): calling_domain = decoded_host(self.headers['Host']) diff --git a/daemon_post.py b/daemon_post.py index 616224861..5eccc4f62 100644 --- a/daemon_post.py +++ b/daemon_post.py @@ -164,9 +164,10 @@ def daemon_http_post(self) -> None: ua_str = get_user_agent(self) - if 'Epicyon/' in ua_str: - log_epicyon_instances(self.server.base_dir, calling_domain, - self.server.known_epicyon_instances) + if ua_str: + if 'Epicyon/' in ua_str: + log_epicyon_instances(self.server.base_dir, calling_domain, + self.server.known_epicyon_instances) block, self.server.blocked_cache_last_updated, _ = \ blocked_user_agent(calling_domain, ua_str, diff --git a/webapp_column_left.py b/webapp_column_left.py index 61835417b..8eb54fcd0 100644 --- a/webapp_column_left.py +++ b/webapp_column_left.py @@ -123,7 +123,8 @@ def get_left_column_content(base_dir: str, nickname: str, domain_full: str, rss_icon_at_top: bool, show_header_image: bool, front_page: bool, theme: str, access_keys: {}, - shared_items_federated_domains: []) -> str: + shared_items_federated_domains: [], + known_epicyon_instances: []) -> str: """Returns html content for the left column """ html_str = '' @@ -351,10 +352,11 @@ def get_left_column_content(base_dir: str, nickname: str, domain_full: str, html_str += \ '

' + \ translate['About this Instance'] + '

' - html_str += \ - '

' + \ - translate['Epicyon Instances'] + '

' + if known_epicyon_instances: + html_str += \ + '

' + \ + translate['Epicyon Instances'] + '

' html_str += \ '

' + \ translate['User Manual'] + '

' @@ -379,7 +381,8 @@ def html_links_mobile(base_dir: str, icons_as_buttons: bool, default_timeline: str, theme: str, access_keys: {}, - shared_items_federated_domains: []) -> str: + shared_items_federated_domains: [], + known_epicyon_instances: []) -> str: """Show the left column links within mobile view """ html_str = '' @@ -426,7 +429,8 @@ def html_links_mobile(base_dir: str, False, timeline_path, rss_icon_at_top, False, False, theme, access_keys, - shared_items_federated_domains) + shared_items_federated_domains, + known_epicyon_instances) if editor and not _links_exist(base_dir): html_str += '


\n
\n ' html_str += translate['Select the edit icon to add web links'] diff --git a/webapp_frontscreen.py b/webapp_frontscreen.py index 9f4cd7fb2..a7886af74 100644 --- a/webapp_frontscreen.py +++ b/webapp_frontscreen.py @@ -131,7 +131,8 @@ def html_front_screen(signing_priv_key_pem: str, dogwhistles: {}, min_images_for_accounts: [], buy_sites: {}, - auto_cw_cache: {}) -> str: + auto_cw_cache: {}, + known_epicyon_instances: []) -> str: """Show the news instance front screen """ bold_reading = False @@ -176,7 +177,8 @@ def html_front_screen(signing_priv_key_pem: str, False, False, False, None, rss_icon_at_top, True, True, theme, access_keys, - shared_items_federated_domains) + shared_items_federated_domains, + known_epicyon_instances) profile_header_str += \ ' \n' + \ ' \n' diff --git a/webapp_moderation.py b/webapp_moderation.py index eb171e03c..8a2bc3a49 100644 --- a/webapp_moderation.py +++ b/webapp_moderation.py @@ -66,7 +66,8 @@ def html_moderation(default_timeline: str, min_images_for_accounts: [], reverse_sequence: bool, buy_sites: {}, - auto_cw_cache: {}) -> str: + auto_cw_cache: {}, + known_epicyon_instances: []) -> str: """Show the moderation feed as html This is what you see when selecting the "mod" timeline """ @@ -95,7 +96,8 @@ def html_moderation(default_timeline: str, signing_priv_key_pem, cw_lists, lists_enabled, timezone, bold_reading, dogwhistles, ua_str, min_images_for_accounts, reverse_sequence, None, - buy_sites, auto_cw_cache, show_announces) + buy_sites, auto_cw_cache, show_announces, + known_epicyon_instances) def html_account_info(translate: {}, diff --git a/webapp_profile.py b/webapp_profile.py index d488a7677..6efaf8ad4 100644 --- a/webapp_profile.py +++ b/webapp_profile.py @@ -1031,7 +1031,8 @@ def html_profile(signing_priv_key_pem: str, max_shares_on_profile: int, sites_unavailable: [], no_of_books: int, - auto_cw_cache: {}) -> str: + auto_cw_cache: {}, + known_epicyon_instances: []) -> str: """Show the profile page as html """ show_moved_accounts = False @@ -1063,7 +1064,8 @@ def html_profile(signing_priv_key_pem: str, shared_items_federated_domains, cw_lists, lists_enabled, {}, min_images_for_accounts, buy_sites, - auto_cw_cache) + auto_cw_cache, + known_epicyon_instances) domain, port = get_domain_from_actor(profile_json['id']) if not domain: diff --git a/webapp_timeline.py b/webapp_timeline.py index e3d9017ca..f27fe0e66 100644 --- a/webapp_timeline.py +++ b/webapp_timeline.py @@ -522,7 +522,8 @@ def html_timeline(default_timeline: str, last_post_id: str, buy_sites: {}, auto_cw_cache: {}, - show_announces: bool) -> str: + show_announces: bool, + known_epicyon_instances: []) -> str: """Show the timeline as html """ enable_timing_log = False @@ -891,7 +892,8 @@ def html_timeline(default_timeline: str, editor, artist, False, None, rss_icon_at_top, True, False, theme, access_keys, - shared_items_federated_domains) + shared_items_federated_domains, + known_epicyon_instances) tl_str += ' \n' + \ '