merge-requests/30/head
Bob Mottram 2024-12-18 19:20:27 +00:00
parent b3deebfa22
commit dc36b23f14
4 changed files with 16 additions and 9 deletions

View File

@ -5394,3 +5394,11 @@ def save_mitm_servers(base_dir: str, mitm_servers: []) -> None:
fp_mitm.write(mitm_servers_str)
except OSError:
print('EX: error while saving mitm_servers.txt')
def text_mode_removals(text: str, translate: {}) -> str:
"""Removes some elements of a post when displaying in a text mode browser
"""
text = text.replace(translate['SHOW MORE'], '')
text = text.replace(translate['mitm'], '👁 ')
return text

View File

@ -16,6 +16,7 @@ from utils import get_config_param
from utils import get_nickname_from_actor
from utils import get_domain_from_actor
from utils import get_attributed_to
from utils import text_mode_removals
from blocking import is_blocked
from webapp_utils import text_mode_browser
from webapp_utils import html_header_with_external_style
@ -174,8 +175,7 @@ def html_conversation_view(authorized: bool, post_id: str,
# is no way to hide/expand sections.
# Also replace MITM text with an eye icon
if text_mode_browser(ua_str):
conv_str = conv_str.replace(translate['SHOW MORE'], '')
conv_str = conv_str.replace(translate['mitm'], '👁 ')
conv_str = text_mode_removals(conv_str, translate)
conv_str += text_mode_separator + html_footer()
return conv_str

View File

@ -35,6 +35,7 @@ from flags import is_news_post
from flags import is_recent_post
from flags import is_chat_message
from flags import is_pgp_encrypted
from utils import text_mode_removals
from utils import remove_header_tags
from utils import get_actor_from_post_id
from utils import contains_statuses
@ -406,7 +407,7 @@ def prepare_post_from_html_cache(nickname: str, post_html: str, box_name: str,
translate,
'audio')
# replace MITM text with an eye icon
post_html = post_html.replace(translate['mitm'], '👁 ')
post_html = text_mode_removals(post_html, translate)
# if on the bookmarks timeline then remain there
if box_name in ('tlbookmarks', 'bookmarks'):

View File

@ -22,6 +22,7 @@ from utils import acct_dir
from utils import local_actor_url
from utils import remove_eol
from utils import get_actor_from_post
from utils import text_mode_removals
from follow import follower_approval_active
from person import is_person_snoozed
from markdown import markdown_to_html
@ -949,8 +950,7 @@ def html_timeline(default_timeline: str,
# is no way to hide/expand sections.
# Also replace MITM text with an eye icon
if is_text_browser:
tl_str = tl_str.replace(translate['SHOW MORE'], '')
tl_str = tl_str.replace(translate['mitm'], '👁 ')
tl_str = text_mode_removals(tl_str, translate)
tl_str += \
_html_timeline_end(base_dir, nickname, domain_full,
@ -980,8 +980,7 @@ def html_timeline(default_timeline: str,
# is no way to hide/expand sections.
# Also replace MITM text with an eye icon
if is_text_browser:
tl_str = tl_str.replace(translate['SHOW MORE'], '')
tl_str = tl_str.replace(translate['mitm'], '👁 ')
tl_str = text_mode_removals(tl_str, translate)
tl_str += \
_html_timeline_end(base_dir, nickname, domain_full,
@ -1214,8 +1213,7 @@ def html_timeline(default_timeline: str,
# is no way to hide/expand sections.
# Also replace MITM text with an eye icon
if is_text_browser:
tl_str = tl_str.replace(translate['SHOW MORE'], '')
tl_str = tl_str.replace(translate['mitm'], '👁 ')
tl_str = text_mode_removals(tl_str, translate)
tl_str += \
_html_timeline_end(base_dir, nickname, domain_full,