mirror of https://gitlab.com/bashrc2/epicyon
Internationalise default text for media in text mode browsers
parent
d14395f857
commit
7ced1067dd
|
@ -313,7 +313,8 @@ def replace_link_variable(link: str, variable_name: str, value: str,
|
||||||
return result + curr_str
|
return result + curr_str
|
||||||
|
|
||||||
|
|
||||||
def _prepare_video_post_from_html_cache(post_html: str) -> str:
|
def _prepare_video_post_from_html_cache(post_html: str,
|
||||||
|
translate: {}) -> str:
|
||||||
""" replaces the <video> tag to make it more friendly for
|
""" replaces the <video> tag to make it more friendly for
|
||||||
text mode browsers
|
text mode browsers
|
||||||
"""
|
"""
|
||||||
|
@ -339,7 +340,7 @@ def _prepare_video_post_from_html_cache(post_html: str) -> str:
|
||||||
if '"' in description:
|
if '"' in description:
|
||||||
description = description.split('"')[0]
|
description = description.split('"')[0]
|
||||||
if not description:
|
if not description:
|
||||||
description = '[VIDEO]'
|
description = '[' + translate['Media'].upper() + ']'
|
||||||
new_post_html += \
|
new_post_html += \
|
||||||
'<a href="' + url + '" target="_blank" ' + \
|
'<a href="' + url + '" target="_blank" ' + \
|
||||||
'rel="nofollow noopener noreferrer">' + \
|
'rel="nofollow noopener noreferrer">' + \
|
||||||
|
@ -350,7 +351,8 @@ def _prepare_video_post_from_html_cache(post_html: str) -> str:
|
||||||
return new_post_html
|
return new_post_html
|
||||||
|
|
||||||
|
|
||||||
def _prepare_audio_post_from_html_cache(post_html: str) -> str:
|
def _prepare_audio_post_from_html_cache(post_html: str,
|
||||||
|
translate: {}) -> str:
|
||||||
""" replaces the <audio> tag to make it more friendly for
|
""" replaces the <audio> tag to make it more friendly for
|
||||||
text mode browsers
|
text mode browsers
|
||||||
"""
|
"""
|
||||||
|
@ -376,7 +378,7 @@ def _prepare_audio_post_from_html_cache(post_html: str) -> str:
|
||||||
if '"' in description:
|
if '"' in description:
|
||||||
description = description.split('"')[0]
|
description = description.split('"')[0]
|
||||||
if not description:
|
if not description:
|
||||||
description = '[AUDIO]'
|
description = '[' + translate['Media'].upper() + ']'
|
||||||
new_post_html += \
|
new_post_html += \
|
||||||
'<a href="' + url + '" target="_blank" ' + \
|
'<a href="' + url + '" target="_blank" ' + \
|
||||||
'rel="nofollow noopener noreferrer">' + \
|
'rel="nofollow noopener noreferrer">' + \
|
||||||
|
@ -389,16 +391,18 @@ def _prepare_audio_post_from_html_cache(post_html: str) -> str:
|
||||||
|
|
||||||
def prepare_post_from_html_cache(nickname: str, post_html: str, box_name: str,
|
def prepare_post_from_html_cache(nickname: str, post_html: str, box_name: str,
|
||||||
page_number: int, first_post_id: str,
|
page_number: int, first_post_id: str,
|
||||||
ua_str: str) -> str:
|
ua_str: str, translate: {}) -> str:
|
||||||
"""Sets the page number on a cached html post
|
"""Sets the page number on a cached html post
|
||||||
"""
|
"""
|
||||||
|
|
||||||
# ensure that media is playable from a text mode browser
|
# ensure that media is playable from a text mode browser
|
||||||
if text_mode_browser(ua_str):
|
if text_mode_browser(ua_str):
|
||||||
if '<video' in post_html:
|
if '<video' in post_html:
|
||||||
post_html = _prepare_video_post_from_html_cache(post_html)
|
post_html = _prepare_video_post_from_html_cache(post_html,
|
||||||
|
translate)
|
||||||
if '<audio' in post_html:
|
if '<audio' in post_html:
|
||||||
post_html = _prepare_audio_post_from_html_cache(post_html)
|
post_html = _prepare_audio_post_from_html_cache(post_html,
|
||||||
|
translate)
|
||||||
|
|
||||||
# if on the bookmarks timeline then remain there
|
# if on the bookmarks timeline then remain there
|
||||||
if box_name in ('tlbookmarks', 'bookmarks'):
|
if box_name in ('tlbookmarks', 'bookmarks'):
|
||||||
|
@ -484,7 +488,8 @@ def _get_post_from_recent_cache(session,
|
||||||
max_recent_posts: int,
|
max_recent_posts: int,
|
||||||
signing_priv_key_pem: str,
|
signing_priv_key_pem: str,
|
||||||
first_post_id: str,
|
first_post_id: str,
|
||||||
ua_str: str) -> str:
|
ua_str: str,
|
||||||
|
translate: {}) -> str:
|
||||||
"""Attempts to get the html post from the recent posts cache in memory
|
"""Attempts to get the html post from the recent posts cache in memory
|
||||||
"""
|
"""
|
||||||
if box_name == 'tlmedia':
|
if box_name == 'tlmedia':
|
||||||
|
@ -524,7 +529,7 @@ def _get_post_from_recent_cache(session,
|
||||||
post_html = \
|
post_html = \
|
||||||
prepare_post_from_html_cache(nickname, post_html,
|
prepare_post_from_html_cache(nickname, post_html,
|
||||||
box_name, page_number, first_post_id,
|
box_name, page_number, first_post_id,
|
||||||
ua_str)
|
ua_str, translate)
|
||||||
update_recent_posts_cache(recent_posts_cache, max_recent_posts,
|
update_recent_posts_cache(recent_posts_cache, max_recent_posts,
|
||||||
post_json_object, post_html)
|
post_json_object, post_html)
|
||||||
_log_post_timing(enable_timing_log, post_start_time, '3')
|
_log_post_timing(enable_timing_log, post_start_time, '3')
|
||||||
|
@ -2167,7 +2172,8 @@ def individual_post_as_html(signing_priv_key_pem: str,
|
||||||
recent_posts_cache,
|
recent_posts_cache,
|
||||||
max_recent_posts,
|
max_recent_posts,
|
||||||
signing_priv_key_pem,
|
signing_priv_key_pem,
|
||||||
first_post_id, ua_str)
|
first_post_id, ua_str,
|
||||||
|
translate)
|
||||||
if post_html:
|
if post_html:
|
||||||
return post_html
|
return post_html
|
||||||
if use_cache_only and post_json_object['type'] != 'Announce':
|
if use_cache_only and post_json_object['type'] != 'Announce':
|
||||||
|
@ -2315,7 +2321,8 @@ def individual_post_as_html(signing_priv_key_pem: str,
|
||||||
recent_posts_cache,
|
recent_posts_cache,
|
||||||
max_recent_posts,
|
max_recent_posts,
|
||||||
signing_priv_key_pem,
|
signing_priv_key_pem,
|
||||||
first_post_id, ua_str)
|
first_post_id, ua_str,
|
||||||
|
translate)
|
||||||
if post_html:
|
if post_html:
|
||||||
return post_html
|
return post_html
|
||||||
|
|
||||||
|
|
|
@ -1014,7 +1014,8 @@ def html_timeline(default_timeline: str,
|
||||||
box_name,
|
box_name,
|
||||||
page_number,
|
page_number,
|
||||||
first_post_id,
|
first_post_id,
|
||||||
ua_str)
|
ua_str,
|
||||||
|
translate)
|
||||||
_log_timeline_timing(enable_timing_log,
|
_log_timeline_timing(enable_timing_log,
|
||||||
timeline_start_time,
|
timeline_start_time,
|
||||||
box_name, '10')
|
box_name, '10')
|
||||||
|
|
Loading…
Reference in New Issue