From bcbf7bd610d74f4fec49d30db3ff3e94e4e665cd Mon Sep 17 00:00:00 2001 From: Bob Mottram Date: Thu, 19 Dec 2024 10:25:24 +0000 Subject: [PATCH] Text mode removals on profile after search --- daemon_post.py | 3 ++- daemon_post_person_options.py | 12 ++++++++---- daemon_post_search.py | 9 ++++++--- webapp_profile.py | 8 +++++++- 4 files changed, 23 insertions(+), 9 deletions(-) diff --git a/daemon_post.py b/daemon_post.py index 691460d4a..51506824f 100644 --- a/daemon_post.py +++ b/daemon_post.py @@ -737,7 +737,8 @@ def daemon_http_post(self) -> None: self.server.default_post_language, self.server.newswire, self.server.block_federated, - self.server.mitm_servers) + self.server.mitm_servers, + ua_str) self.server.postreq_busy = False return diff --git a/daemon_post_person_options.py b/daemon_post_person_options.py index af723be90..d4b9cdb94 100644 --- a/daemon_post_person_options.py +++ b/daemon_post_person_options.py @@ -247,7 +247,8 @@ def _person_options_view(self, options_confirm_params: str, cookie: str, calling_domain: str, curr_session, access_keys: {}, - mitm_servers: []) -> bool: + mitm_servers: [], + ua_str: str) -> bool: """Person options screen, view button See html_person_options """ @@ -328,7 +329,8 @@ def _person_options_view(self, options_confirm_params: str, max_shares_on_profile, no_of_books, auto_cw_cache, - mitm_servers) + mitm_servers, + ua_str) if profile_str: msg = profile_str.encode('utf-8') msglen = len(msg) @@ -1289,7 +1291,8 @@ def person_options2(self, path: str, default_post_language: str, newswire: {}, block_federated: [], - mitm_servers: []) -> None: + mitm_servers: [], + ua_str: str) -> None: """Receive POST from person options screen """ page_number = 1 @@ -1418,7 +1421,8 @@ def person_options2(self, path: str, cookie, calling_domain, curr_session, access_keys, - mitm_servers): + mitm_servers, + ua_str): return if _person_option_receive_petname(self, options_confirm_params, diff --git a/daemon_post_search.py b/daemon_post_search.py index 3c54274ad..33e380a92 100644 --- a/daemon_post_search.py +++ b/daemon_post_search.py @@ -445,7 +445,8 @@ def _receive_search_handle(self, search_str: str, auto_cw_cache: {}, actor_str: str, curr_session, access_keys: {}, - mitm_servers: []) -> bool: + mitm_servers: [], + ua_str: str) -> bool: """Receive a search for a fediverse handle or url from the search screen """ remote_only = False @@ -601,7 +602,8 @@ def _receive_search_handle(self, search_str: str, max_shares_on_profile, no_of_books, auto_cw_cache, - mitm_servers) + mitm_servers, + ua_str) if profile_str: msg = profile_str.encode('utf-8') msglen = len(msg) @@ -997,7 +999,8 @@ def receive_search_query(self, calling_domain: str, cookie: str, no_of_books, auto_cw_cache, actor_str, curr_session, access_keys, - mitm_servers): + mitm_servers, + ua_str): return elif (search_str.startswith(':') or search_str.endswith(' emoji')): diff --git a/webapp_profile.py b/webapp_profile.py index 16fb5a1bd..4e65ee4bb 100644 --- a/webapp_profile.py +++ b/webapp_profile.py @@ -16,6 +16,7 @@ from flags import is_system_account from flags import is_group_account from flags import is_valid_date from flags import is_premium_account +from utils import text_mode_removals from utils import replace_strings from utils import data_dir from utils import time_days_ago @@ -88,6 +89,7 @@ from follow import is_follower_of_person from follow import get_follower_domains from follow import is_following_actor from webapp_frontscreen import html_front_screen +from webapp_utils import text_mode_browser from webapp_utils import html_following_dropdown from webapp_utils import edit_number_field from webapp_utils import html_keyboard_navigation @@ -249,7 +251,8 @@ def html_profile_after_search(authorized: bool, max_shares_on_profile: int, no_of_books: int, auto_cw_cache: {}, - mitm_servers: []) -> str: + mitm_servers: [], + ua_str: str) -> str: """Show a profile page after a search for a fediverse address """ http = False @@ -625,6 +628,9 @@ def html_profile_after_search(authorized: bool, if i >= 8: break + if text_mode_browser(ua_str): + profile_str = text_mode_removals(profile_str, translate) + instance_title = get_config_param(base_dir, 'instanceTitle') preload_images = [] return html_header_with_external_style(css_filename,