Allow default download filename for mozilla browsers

merge-requests/30/head
Bob Mottram 2024-11-03 22:11:41 +00:00
parent bb122c5647
commit c997c49f88
6 changed files with 30 additions and 17 deletions

View File

@ -3104,7 +3104,8 @@ def daemon_http_get(self) -> None:
self.server.access_keys, self.server.access_keys,
self.server.min_images_for_accounts, self.server.min_images_for_accounts,
self.server.buy_sites, self.server.buy_sites,
self.server.auto_cw_cache) self.server.auto_cw_cache,
ua_str)
self.server.getreq_busy = False self.server.getreq_busy = False
return return

View File

@ -168,7 +168,8 @@ def hashtag_search2(self, calling_domain: str,
access_keys: {}, access_keys: {},
min_images_for_accounts: [], min_images_for_accounts: [],
buy_sites: [], buy_sites: [],
auto_cw_cache: {}) -> None: auto_cw_cache: {},
ua_str: str) -> None:
"""Return the result of a hashtag search """Return the result of a hashtag search
""" """
page_number = 1 page_number = 1
@ -235,7 +236,7 @@ def hashtag_search2(self, calling_domain: str,
'search', 'search',
min_images_for_accounts, min_images_for_accounts,
buy_sites, buy_sites,
auto_cw_cache) auto_cw_cache, ua_str)
if hashtag_str: if hashtag_str:
msg = hashtag_str.encode('utf-8') msg = hashtag_str.encode('utf-8')
msglen = len(msg) msglen = len(msg)

View File

@ -458,7 +458,8 @@ def daemon_http_post(self) -> None:
self.server.key_shortcuts, self.server.key_shortcuts,
self.server.max_shares_on_profile, self.server.max_shares_on_profile,
self.server.no_of_books, self.server.no_of_books,
self.server.shared_items_federated_domains) self.server.shared_items_federated_domains,
ua_str)
self.server.postreq_busy = False self.server.postreq_busy = False
return return

View File

@ -84,7 +84,8 @@ def _receive_search_hashtag(self, actor_str: str,
min_images_for_accounts: {}, min_images_for_accounts: {},
buy_sites: [], buy_sites: [],
auto_cw_cache: {}, auto_cw_cache: {},
calling_domain: str) -> bool: calling_domain: str,
ua_str: str) -> bool:
"""Receive a search for a hashtag from the search screen """Receive a search for a hashtag from the search screen
""" """
nickname = get_nickname_from_actor(actor_str) nickname = get_nickname_from_actor(actor_str)
@ -132,7 +133,7 @@ def _receive_search_hashtag(self, actor_str: str,
'search', 'search',
min_images_for_accounts, min_images_for_accounts,
buy_sites, buy_sites,
auto_cw_cache) auto_cw_cache, ua_str)
if hashtag_str: if hashtag_str:
msg = hashtag_str.encode('utf-8') msg = hashtag_str.encode('utf-8')
msglen = len(msg) msglen = len(msg)
@ -752,7 +753,8 @@ def receive_search_query(self, calling_domain: str, cookie: str,
key_shortcuts: {}, key_shortcuts: {},
max_shares_on_profile: int, max_shares_on_profile: int,
no_of_books: int, no_of_books: int,
shared_items_federated_domains: []) -> None: shared_items_federated_domains: [],
ua_str: str) -> None:
"""Receive a search query """Receive a search query
""" """
# get the page number # get the page number
@ -857,7 +859,8 @@ def receive_search_query(self, calling_domain: str, cookie: str,
min_images_for_accounts, min_images_for_accounts,
buy_sites, buy_sites,
auto_cw_cache, auto_cw_cache,
calling_domain): calling_domain,
ua_str):
return return
elif (search_str.startswith('*') or elif (search_str.startswith('*') or
search_str.endswith(' skill')): search_str.endswith(' skill')):

12
maps.py
View File

@ -867,7 +867,7 @@ def map_format_from_tagmaps_path(base_dir: str, path: str,
def html_hashtag_maps(base_dir: str, tag_name: str, def html_hashtag_maps(base_dir: str, tag_name: str,
translate: {}, map_format: str, translate: {}, map_format: str,
nickname: str, domain: str, nickname: str, domain: str,
session) -> str: session, ua_str: str) -> str:
"""Returns html for maps associated with a hashtag """Returns html for maps associated with a hashtag
""" """
tag_map_filename = base_dir + '/tagmaps/' + tag_name + '.txt' tag_map_filename = base_dir + '/tagmaps/' + tag_name + '.txt'
@ -878,6 +878,7 @@ def html_hashtag_maps(base_dir: str, tag_name: str,
html_str = '' html_str = ''
map_str = None map_str = None
ua_str_lower = ua_str.lower()
for period_str, hours in time_period.items(): for period_str, hours in time_period.items():
new_map_str = \ new_map_str = \
_hashtag_map_within_hours(base_dir, tag_name, hours, _hashtag_map_within_hours(base_dir, tag_name, hours,
@ -889,13 +890,18 @@ def html_hashtag_maps(base_dir: str, tag_name: str,
continue continue
map_str = new_map_str map_str = new_map_str
period_str2 = period_str.replace('Last ', '').lower() period_str2 = period_str.replace('Last ', '').lower()
endpoint_str = \ tag_name_str = tag_name + '-' + period_str2.replace(' ', '_')
'/tagmaps/' + tag_name + '-' + period_str2.replace(' ', '_') endpoint_str = '/tagmaps/' + tag_name_str
if html_str: if html_str:
html_str += ' ' html_str += ' '
description = period_str description = period_str
if translate.get(period_str): if translate.get(period_str):
description = translate[period_str] description = translate[period_str]
if 'mozilla' in ua_str_lower or 'firefox' in ua_str_lower:
html_str += '<a href="' + endpoint_str + \
'" download="' + tag_name_str + '.kml">' + \
description + '</a>'
else:
# NOTE: don't use download="preferredfilename" which is # NOTE: don't use download="preferredfilename" which is
# unsupported by some browsers # unsupported by some browsers
html_str += '<a href="' + endpoint_str + '" download>' + \ html_str += '<a href="' + endpoint_str + '" download>' + \

View File

@ -880,7 +880,8 @@ def html_hashtag_search(nickname: str, domain: str, port: int,
dogwhistles: {}, map_format: str, dogwhistles: {}, map_format: str,
access_keys: {}, box_name: str, access_keys: {}, box_name: str,
min_images_for_accounts: [], min_images_for_accounts: [],
buy_sites: {}, auto_cw_cache: {}) -> str: buy_sites: {}, auto_cw_cache: {},
ua_str: str) -> str:
"""Show a page containing search results for a hashtag """Show a page containing search results for a hashtag
or after selecting a hashtag from the swarm or after selecting a hashtag from the swarm
""" """
@ -972,7 +973,7 @@ def html_hashtag_search(nickname: str, domain: str, port: int,
# maps for geolocations with this hashtag # maps for geolocations with this hashtag
maps_str = html_hashtag_maps(base_dir, hashtag, translate, map_format, maps_str = html_hashtag_maps(base_dir, hashtag, translate, map_format,
nickname, domain, session) nickname, domain, session, ua_str)
if maps_str: if maps_str:
maps_str = '<center>' + maps_str + '</center>\n' maps_str = '<center>' + maps_str + '</center>\n'
hashtag_search_form += maps_str hashtag_search_form += maps_str