From 7ae8db96d84dff856caea1233da6f1b561f95cdf Mon Sep 17 00:00:00 2001 From: Bob Mottram Date: Tue, 23 Aug 2022 10:01:41 +0100 Subject: [PATCH 01/21] Change position for map links to save vertical screen realestate --- maps.py | 2 +- webapp_search.py | 8 ++++++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/maps.py b/maps.py index 5a6eafac7..d1ec95230 100644 --- a/maps.py +++ b/maps.py @@ -617,5 +617,5 @@ def html_hashtag_maps(base_dir: str, tag_name: str, '" download="' + download_filename + '">' + \ description + '' if html_str: - html_str = '
🌍 ' + html_str + '
\n' + html_str = '🌍 ' + html_str return html_str diff --git a/webapp_search.py b/webapp_search.py index 333471058..8090050a5 100644 --- a/webapp_search.py +++ b/webapp_search.py @@ -797,6 +797,12 @@ def html_hashtag_search(nickname: str, domain: str, port: int, hashtag_search_form += '
\n' + \ '

#' + hashtag + '

\n' + # maps for geolocations with this hashtag + maps_str = html_hashtag_maps(base_dir, hashtag, translate) + if maps_str: + maps_str += ' ' + hashtag_search_form += maps_str + # RSS link for hashtag feed hashtag_search_form += '' hashtag_search_form += \ @@ -825,8 +831,6 @@ def html_hashtag_search(nickname: str, domain: str, port: int, hashtag_search_form += ' \n' hashtag_search_form += '\n' - hashtag_search_form += html_hashtag_maps(base_dir, hashtag, translate) - if start_index > 0: # previous page link hashtag_search_form += \ From 17e3daf3329c1a3e05444b7c2899a5e2bf29b4f0 Mon Sep 17 00:00:00 2001 From: Bob Mottram Date: Tue, 23 Aug 2022 10:08:50 +0100 Subject: [PATCH 02/21] Change position of RSS button --- webapp_search.py | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/webapp_search.py b/webapp_search.py index 8090050a5..8d8e9d23a 100644 --- a/webapp_search.py +++ b/webapp_search.py @@ -795,22 +795,22 @@ def html_hashtag_search(nickname: str, domain: str, port: int, hashtag + '\n' else: hashtag_search_form += '
\n' + \ - '

#' + hashtag + '

\n' - - # maps for geolocations with this hashtag - maps_str = html_hashtag_maps(base_dir, hashtag, translate) - if maps_str: - maps_str += ' ' - hashtag_search_form += maps_str + '

#' + hashtag + '

' # RSS link for hashtag feed - hashtag_search_form += '' + hashtag_search_form += ' ' hashtag_search_form += \ '
\n' + # maps for geolocations with this hashtag + maps_str = html_hashtag_maps(base_dir, hashtag, translate) + if maps_str: + maps_str = '
' + maps_str + '
\n' + hashtag_search_form += maps_str + # edit the category for this hashtag if is_editor(base_dir, nickname): category = get_hashtag_category(base_dir, hashtag) From 7fbc3a970a4892e0f4f3af97da7ad0a908e99b4e Mon Sep 17 00:00:00 2001 From: Bob Mottram Date: Tue, 23 Aug 2022 10:10:42 +0100 Subject: [PATCH 03/21] Include rss icon in header --- webapp_search.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/webapp_search.py b/webapp_search.py index 8d8e9d23a..2f8e7dca9 100644 --- a/webapp_search.py +++ b/webapp_search.py @@ -795,7 +795,7 @@ def html_hashtag_search(nickname: str, domain: str, port: int, hashtag + '\n' else: hashtag_search_form += '
\n' + \ - '

#' + hashtag + '

' + '

#' + hashtag # RSS link for hashtag feed hashtag_search_form += ' ' @@ -803,7 +803,7 @@ def html_hashtag_search(nickname: str, domain: str, port: int, '

\n' + 'icons/logorss.png" />\n' # maps for geolocations with this hashtag maps_str = html_hashtag_maps(base_dir, hashtag, translate) From 21f3eb12e0fb1bb3f679e717a43833253586818f Mon Sep 17 00:00:00 2001 From: Bob Mottram Date: Tue, 23 Aug 2022 10:13:36 +0100 Subject: [PATCH 04/21] Include rss icon in header --- webapp_search.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/webapp_search.py b/webapp_search.py index 2f8e7dca9..c008b9615 100644 --- a/webapp_search.py +++ b/webapp_search.py @@ -792,7 +792,7 @@ def html_hashtag_search(nickname: str, domain: str, port: int, if nickname: hashtag_search_form += '
\n' + \ '

#' + \ - hashtag + '

\n' + hashtag + '' else: hashtag_search_form += '
\n' + \ '

#' + hashtag From a3d5a7a61f4e0042b5bd1c00c4d12b4549849cd4 Mon Sep 17 00:00:00 2001 From: Bob Mottram Date: Tue, 23 Aug 2022 11:09:24 +0100 Subject: [PATCH 05/21] Support gpx format for hashtag maps --- daemon.py | 15 ++++++-- epicyon.py | 12 +++++- maps.py | 99 +++++++++++++++++++++++++++++++++++++++--------- tests.py | 16 ++++++-- webapp_search.py | 4 +- 5 files changed, 117 insertions(+), 29 deletions(-) diff --git a/daemon.py b/daemon.py index 671e2caec..28ed0ed5e 100644 --- a/daemon.py +++ b/daemon.py @@ -3898,7 +3898,8 @@ class PubServer(BaseHTTPRequestHandler): self.server.cw_lists, self.server.lists_enabled, timezone, bold_reading, - self.server.dogwhistles) + self.server.dogwhistles, + self.server.map_format) if hashtag_str: msg = hashtag_str.encode('utf-8') msglen = len(msg) @@ -8601,7 +8602,8 @@ class PubServer(BaseHTTPRequestHandler): self.server.cw_lists, self.server.lists_enabled, timezone, bold_reading, - self.server.dogwhistles) + self.server.dogwhistles, + self.server.map_format) if hashtag_str: msg = hashtag_str.encode('utf-8') msglen = len(msg) @@ -17091,7 +17093,8 @@ class PubServer(BaseHTTPRequestHandler): # hashtag map kml if self.path.startswith('/tagmaps/') or \ (authorized and '/tagmaps/' in self.path): - kml_str = kml_from_tagmaps_path(self.server.base_dir, self.path) + kml_str = kml_from_tagmaps_path(self.server.base_dir, self.path, + self.server.map_format) if kml_str: msg = kml_str.encode('utf-8') msglen = len(msg) @@ -20823,7 +20826,8 @@ def load_tokens(base_dir: str, tokens_dict: {}, tokens_lookup: {}) -> None: break -def run_daemon(clacks: str, +def run_daemon(map_format: str, + clacks: str, preferred_podcast_formats: [], check_actor_timeout: int, crawlers_allowed: [], @@ -20948,6 +20952,9 @@ def run_daemon(clacks: str, httpd.vcard_is_active = False httpd.masto_api_is_active = False + # use kml or gpx format for hashtag maps + httpd.map_format = map_format.lower() + httpd.dyslexic_font = dyslexic_font # license for content of the instance diff --git a/epicyon.py b/epicyon.py index c1752ad89..3f17730e3 100644 --- a/epicyon.py +++ b/epicyon.py @@ -735,6 +735,9 @@ def _command_options() -> None: help='Category of item being shared') parser.add_argument('--location', dest='location', type=str, default=None, help='Location/City of item being shared') + parser.add_argument('--mapFormat', dest='mapFormat', type=str, + default='gpx', + help='Format for hashtag maps GPX/KML') parser.add_argument('--duration', dest='duration', type=str, default=None, help='Duration for which to share an item') parser.add_argument('--registration', dest='registration', type=str, @@ -3380,6 +3383,12 @@ def _command_options() -> None: if not registration: registration = False + map_format = get_config_param(base_dir, 'mapFormat') + if map_format: + argb.mapFormat = map_format + else: + set_config_param(base_dir, 'mapFormat', argb.mapFormat) + minimumvotes = get_config_param(base_dir, 'minvotes') if minimumvotes: argb.minimumvotes = int(minimumvotes) @@ -3626,7 +3635,8 @@ def _command_options() -> None: if __name__ == "__main__": argb2, opt2 = _command_options() print('allowdeletion: ' + str(argb2.allowdeletion)) - run_daemon(argb2.clacks, + run_daemon(argb2.mapFormat, + argb2.clacks, opt2['preferred_podcast_formats'], argb2.check_actor_timeout, opt2['crawlers_allowed'], diff --git a/maps.py b/maps.py index d1ec95230..00af19bbf 100644 --- a/maps.py +++ b/maps.py @@ -526,8 +526,61 @@ def _hashtag_map_to_kml(base_dir: str, tag_name: str, return kml_str -def _hashtag_map_kml_within_hours(base_dir: str, tag_name: str, - hours: int) -> str: +def _hashtag_map_to_gpx(base_dir: str, tag_name: str, + start_hours_since_epoch: int, + end_hours_since_epoch: int) -> str: + """Returns the GPX for a given hashtag between the given times + """ + place_ctr = 0 + osm_domain = 'openstreetmap.org' + tag_map_filename = base_dir + '/tagmaps/' + tag_name + '.txt' + + gpx_str = '\n' + gpx_str = '\n' + + if os.path.isfile(tag_map_filename): + map_links = [] + try: + with open(tag_map_filename, 'r', encoding='utf-8') as fp_tag: + map_links = fp_tag.read().split('\n') + except OSError: + print('EX: unable to read tag map links ' + tag_map_filename) + if map_links: + start_secs_since_epoch = int(start_hours_since_epoch * 60 * 60) + end_secs_since_epoch = int(end_hours_since_epoch * 60 * 60) + for link_line in map_links: + link_line = link_line.strip().split(' ') + if len(link_line) < 3: + continue + secs_since_epoch = int(link_line[0]) + if secs_since_epoch < start_secs_since_epoch or \ + secs_since_epoch > end_secs_since_epoch: + continue + map_link = link_line[1] + zoom, latitude, longitude = \ + geocoords_from_map_link(map_link, osm_domain) + if not zoom: + continue + if not latitude: + continue + if not longitude: + continue + post_id = link_line[2] + place_ctr += 1 + gpx_str = '\n' + gpx_str += ' ' + str(place_ctr) + '\n' + gpx_str += ' \n' + gpx_str = '\n' + + gpx_str += '' + if place_ctr == 0: + return None + return gpx_str + + +def _hashtag_map_within_hours(base_dir: str, tag_name: str, + hours: int, map_format: str) -> str: """Returns kml for a hashtag containing maps for the last number of hours """ secs_since_epoch = \ @@ -535,11 +588,17 @@ def _hashtag_map_kml_within_hours(base_dir: str, tag_name: str, datetime.datetime(1970, 1, 1)).total_seconds()) end_hours_since_epoch = int(secs_since_epoch / (60 * 60)) start_hours_since_epoch = end_hours_since_epoch - hours - kml_str = \ - _hashtag_map_to_kml(base_dir, tag_name, - start_hours_since_epoch, - end_hours_since_epoch) - return kml_str + if map_format == 'gpx': + map_str = \ + _hashtag_map_to_gpx(base_dir, tag_name, + start_hours_since_epoch, + end_hours_since_epoch) + else: + map_str = \ + _hashtag_map_to_kml(base_dir, tag_name, + start_hours_since_epoch, + end_hours_since_epoch) + return map_str def _get_tagmaps_time_periods() -> {}: @@ -560,7 +619,8 @@ def _get_tagmaps_time_periods() -> {}: } -def kml_from_tagmaps_path(base_dir: str, path: str) -> str: +def kml_from_tagmaps_path(base_dir: str, path: str, + map_format: str) -> str: """Returns kml for a given tagmaps path /tagmaps/tagname-time_period """ @@ -577,13 +637,14 @@ def kml_from_tagmaps_path(base_dir: str, path: str) -> str: endpoint_str = \ '/tagmaps/' + tag_name + '-' + period_str2.replace(' ', '_') if path == endpoint_str: - return _hashtag_map_kml_within_hours(base_dir, tag_name, - abs(hours)) + hours = abs(hours) + return _hashtag_map_within_hours(base_dir, tag_name, + hours, map_format) return None def html_hashtag_maps(base_dir: str, tag_name: str, - translate: {}) -> str: + translate: {}, map_format: str) -> str: """Returns html for maps associated with a hashtag """ tag_map_filename = base_dir + '/tagmaps/' + tag_name + '.txt' @@ -593,21 +654,23 @@ def html_hashtag_maps(base_dir: str, tag_name: str, time_period = _get_tagmaps_time_periods() html_str = '' - kml_str = None + map_str = None for period_str, hours in time_period.items(): - new_kml_str = \ - _hashtag_map_kml_within_hours(base_dir, tag_name, abs(hours)) - if not new_kml_str: + hours = abs(hours) + new_map_str = \ + _hashtag_map_within_hours(base_dir, tag_name, hours, + map_format) + if not new_map_str: continue - if new_kml_str == kml_str: + if new_map_str == map_str: continue - kml_str = new_kml_str + map_str = new_map_str period_str2 = period_str.replace('Last ', '').lower() endpoint_str = \ '/tagmaps/' + tag_name + '-' + period_str2.replace(' ', '_') download_filename = \ (tag_name + '-' + - period_str.lower()).replace(' ', '_') + '.kml' + period_str.lower()).replace(' ', '_') + '.' + map_format if html_str: html_str += ' ' description = period_str diff --git a/tests.py b/tests.py index 3db7589d9..3dcb75603 100644 --- a/tests.py +++ b/tests.py @@ -841,8 +841,10 @@ def create_server_alice(path: str, domain: str, port: int, check_actor_timeout = 2 preferred_podcast_formats = None clacks = None + map_format = 'gpx' print('Server running: Alice') - run_daemon(clacks, preferred_podcast_formats, + run_daemon(map_format, + clacks, preferred_podcast_formats, check_actor_timeout, crawlers_allowed, dyslexic_font, @@ -1002,8 +1004,10 @@ def create_server_bob(path: str, domain: str, port: int, check_actor_timeout = 2 preferred_podcast_formats = None clacks = None + map_format = 'gpx' print('Server running: Bob') - run_daemon(clacks, preferred_podcast_formats, + run_daemon(map_format, + clacks, preferred_podcast_formats, check_actor_timeout, crawlers_allowed, dyslexic_font, @@ -1085,8 +1089,10 @@ def create_server_eve(path: str, domain: str, port: int, federation_list: [], check_actor_timeout = 2 preferred_podcast_formats = None clacks = None + map_format = 'gpx' print('Server running: Eve') - run_daemon(clacks, preferred_podcast_formats, + run_daemon(map_format, + clacks, preferred_podcast_formats, check_actor_timeout, crawlers_allowed, dyslexic_font, @@ -1170,8 +1176,10 @@ def create_server_group(path: str, domain: str, port: int, check_actor_timeout = 2 preferred_podcast_formats = None clacks = None + map_format = 'gpx' print('Server running: Group') - run_daemon(clacks, preferred_podcast_formats, + run_daemon(map_format, + clacks, preferred_podcast_formats, check_actor_timeout, crawlers_allowed, dyslexic_font, diff --git a/webapp_search.py b/webapp_search.py index c008b9615..6fc10788a 100644 --- a/webapp_search.py +++ b/webapp_search.py @@ -738,7 +738,7 @@ def html_hashtag_search(nickname: str, domain: str, port: int, signing_priv_key_pem: str, cw_lists: {}, lists_enabled: str, timezone: str, bold_reading: bool, - dogwhistles: {}) -> str: + dogwhistles: {}, map_format: str) -> str: """Show a page containing search results for a hashtag or after selecting a hashtag from the swarm """ @@ -806,7 +806,7 @@ def html_hashtag_search(nickname: str, domain: str, port: int, 'icons/logorss.png" />

\n' # maps for geolocations with this hashtag - maps_str = html_hashtag_maps(base_dir, hashtag, translate) + maps_str = html_hashtag_maps(base_dir, hashtag, translate, map_format) if maps_str: maps_str = '
' + maps_str + '
\n' hashtag_search_form += maps_str From e982e91559656e15a2aa01f8f67ec6fc1294ec37 Mon Sep 17 00:00:00 2001 From: Bob Mottram Date: Tue, 23 Aug 2022 11:12:30 +0100 Subject: [PATCH 06/21] Missing plus --- maps.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/maps.py b/maps.py index 00af19bbf..fd9518d41 100644 --- a/maps.py +++ b/maps.py @@ -536,7 +536,7 @@ def _hashtag_map_to_gpx(base_dir: str, tag_name: str, tag_map_filename = base_dir + '/tagmaps/' + tag_name + '.txt' gpx_str = '\n' - gpx_str = '\n' + gpx_str += '\n' if os.path.isfile(tag_map_filename): map_links = [] @@ -567,11 +567,11 @@ def _hashtag_map_to_gpx(base_dir: str, tag_name: str, continue post_id = link_line[2] place_ctr += 1 - gpx_str = '\n' gpx_str += ' ' + str(place_ctr) + '\n' gpx_str += ' \n' - gpx_str = '\n' + gpx_str += '\n' gpx_str += '' if place_ctr == 0: From 3fddcd4b8eeb614ca3d2fee82647cf1bb72950f2 Mon Sep 17 00:00:00 2001 From: Bob Mottram Date: Tue, 23 Aug 2022 11:22:00 +0100 Subject: [PATCH 07/21] Default to kml --- epicyon.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/epicyon.py b/epicyon.py index 3f17730e3..a80a62e6c 100644 --- a/epicyon.py +++ b/epicyon.py @@ -736,7 +736,7 @@ def _command_options() -> None: parser.add_argument('--location', dest='location', type=str, default=None, help='Location/City of item being shared') parser.add_argument('--mapFormat', dest='mapFormat', type=str, - default='gpx', + default='kml', help='Format for hashtag maps GPX/KML') parser.add_argument('--duration', dest='duration', type=str, default=None, help='Duration for which to share an item') From e0df4e1cacefbc9c0adf937c2389e504964414a5 Mon Sep 17 00:00:00 2001 From: Bob Mottram Date: Tue, 23 Aug 2022 11:26:18 +0100 Subject: [PATCH 08/21] Fix link formatting --- maps.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/maps.py b/maps.py index fd9518d41..e8ffbe097 100644 --- a/maps.py +++ b/maps.py @@ -570,7 +570,7 @@ def _hashtag_map_to_gpx(base_dir: str, tag_name: str, gpx_str += '\n' gpx_str += ' ' + str(place_ctr) + '\n' - gpx_str += ' \n' + gpx_str += ' \n' gpx_str += '\n' gpx_str += '' From c3472c4ff7c007739ab8ec4561a19bb410a531e7 Mon Sep 17 00:00:00 2001 From: Bob Mottram Date: Tue, 23 Aug 2022 11:28:37 +0100 Subject: [PATCH 09/21] Back to gpx --- epicyon.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/epicyon.py b/epicyon.py index a80a62e6c..3f17730e3 100644 --- a/epicyon.py +++ b/epicyon.py @@ -736,7 +736,7 @@ def _command_options() -> None: parser.add_argument('--location', dest='location', type=str, default=None, help='Location/City of item being shared') parser.add_argument('--mapFormat', dest='mapFormat', type=str, - default='kml', + default='gpx', help='Format for hashtag maps GPX/KML') parser.add_argument('--duration', dest='duration', type=str, default=None, help='Duration for which to share an item') From 2e0b5e9f9a51742dd49cc6beb7dd141f00f9cb71 Mon Sep 17 00:00:00 2001 From: Bob Mottram Date: Tue, 23 Aug 2022 11:29:54 +0100 Subject: [PATCH 10/21] Set post url as the waypoint name --- maps.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/maps.py b/maps.py index e8ffbe097..f1576668e 100644 --- a/maps.py +++ b/maps.py @@ -569,7 +569,7 @@ def _hashtag_map_to_gpx(base_dir: str, tag_name: str, place_ctr += 1 gpx_str += '\n' - gpx_str += ' ' + str(place_ctr) + '\n' + gpx_str += ' ' + post_id + '\n' gpx_str += ' \n' gpx_str += '\n' From de2da713814b72917e8e5ce6529fd28cff66170f Mon Sep 17 00:00:00 2001 From: Bob Mottram Date: Tue, 23 Aug 2022 11:49:58 +0100 Subject: [PATCH 11/21] gpx mime type --- daemon.py | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/daemon.py b/daemon.py index 28ed0ed5e..a556b7b36 100644 --- a/daemon.py +++ b/daemon.py @@ -17093,13 +17093,17 @@ class PubServer(BaseHTTPRequestHandler): # hashtag map kml if self.path.startswith('/tagmaps/') or \ (authorized and '/tagmaps/' in self.path): - kml_str = kml_from_tagmaps_path(self.server.base_dir, self.path, + map_str = kml_from_tagmaps_path(self.server.base_dir, self.path, self.server.map_format) - if kml_str: - msg = kml_str.encode('utf-8') + if map_str: + msg = map_str.encode('utf-8') msglen = len(msg) - header_type = \ - 'application/vnd.google-earth.kml+xml; charset=utf-8' + if self.server.map_format == 'gpx': + header_type = \ + 'application/gpx+xml; charset=utf-8' + else: + header_type = \ + 'application/vnd.google-earth.kml+xml; charset=utf-8' self._set_headers(header_type, msglen, None, calling_domain, True) self._write(msg) From b325afa07020b7a5aaf7f6dfa548f46c6c6a4e75 Mon Sep 17 00:00:00 2001 From: Bob Mottram Date: Tue, 23 Aug 2022 12:01:17 +0100 Subject: [PATCH 12/21] Rename function --- daemon.py | 7 ++++--- maps.py | 6 +++--- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/daemon.py b/daemon.py index a556b7b36..c18eed448 100644 --- a/daemon.py +++ b/daemon.py @@ -403,7 +403,7 @@ from crawlers import blocked_user_agent from crawlers import load_known_web_bots from qrcode import save_domain_qrcode from importFollowing import run_import_following_watchdog -from maps import kml_from_tagmaps_path +from maps import map_format_from_tagmaps_path import os @@ -17093,8 +17093,9 @@ class PubServer(BaseHTTPRequestHandler): # hashtag map kml if self.path.startswith('/tagmaps/') or \ (authorized and '/tagmaps/' in self.path): - map_str = kml_from_tagmaps_path(self.server.base_dir, self.path, - self.server.map_format) + map_str = \ + map_format_from_tagmaps_path(self.server.base_dir, self.path, + self.server.map_format) if map_str: msg = map_str.encode('utf-8') msglen = len(msg) diff --git a/maps.py b/maps.py index f1576668e..787343336 100644 --- a/maps.py +++ b/maps.py @@ -619,9 +619,9 @@ def _get_tagmaps_time_periods() -> {}: } -def kml_from_tagmaps_path(base_dir: str, path: str, - map_format: str) -> str: - """Returns kml for a given tagmaps path +def map_format_from_tagmaps_path(base_dir: str, path: str, + map_format: str) -> str: + """Returns gpx/kml for a given tagmaps path /tagmaps/tagname-time_period """ if '/tagmaps/' not in path: From 2dfd323e10cec2847b89e9e68b9ff07ad071f1e1 Mon Sep 17 00:00:00 2001 From: Bob Mottram Date: Tue, 23 Aug 2022 12:23:47 +0100 Subject: [PATCH 13/21] Tidying --- maps.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/maps.py b/maps.py index 787343336..d315d9487 100644 --- a/maps.py +++ b/maps.py @@ -587,7 +587,7 @@ def _hashtag_map_within_hours(base_dir: str, tag_name: str, int((datetime.datetime.utcnow() - datetime.datetime(1970, 1, 1)).total_seconds()) end_hours_since_epoch = int(secs_since_epoch / (60 * 60)) - start_hours_since_epoch = end_hours_since_epoch - hours + start_hours_since_epoch = end_hours_since_epoch - abs(hours) if map_format == 'gpx': map_str = \ _hashtag_map_to_gpx(base_dir, tag_name, @@ -637,7 +637,6 @@ def map_format_from_tagmaps_path(base_dir: str, path: str, endpoint_str = \ '/tagmaps/' + tag_name + '-' + period_str2.replace(' ', '_') if path == endpoint_str: - hours = abs(hours) return _hashtag_map_within_hours(base_dir, tag_name, hours, map_format) return None @@ -656,7 +655,6 @@ def html_hashtag_maps(base_dir: str, tag_name: str, html_str = '' map_str = None for period_str, hours in time_period.items(): - hours = abs(hours) new_map_str = \ _hashtag_map_within_hours(base_dir, tag_name, hours, map_format) From f9739c4774f7067bf2915951a26285c6818ca325 Mon Sep 17 00:00:00 2001 From: Bob Mottram Date: Tue, 23 Aug 2022 12:35:27 +0100 Subject: [PATCH 14/21] Test --- maps.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/maps.py b/maps.py index d315d9487..2e482345b 100644 --- a/maps.py +++ b/maps.py @@ -553,6 +553,9 @@ def _hashtag_map_to_gpx(base_dir: str, tag_name: str, if len(link_line) < 3: continue secs_since_epoch = int(link_line[0]) + print('***maptest secs_since_epoch ' + str(secs_since_epoch)) + print('***maptest start_secs_since_epoch ' + str(start_secs_since_epoch)) + print('***maptest end_secs_since_epoch ' + str(end_secs_since_epoch)) if secs_since_epoch < start_secs_since_epoch or \ secs_since_epoch > end_secs_since_epoch: continue From e2db921c87a7ec9b070d95b43a0792e783f00448 Mon Sep 17 00:00:00 2001 From: Bob Mottram Date: Tue, 23 Aug 2022 12:40:51 +0100 Subject: [PATCH 15/21] Ensure that end hours are at least the same as current --- maps.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/maps.py b/maps.py index 2e482345b..2a2c8722f 100644 --- a/maps.py +++ b/maps.py @@ -589,8 +589,9 @@ def _hashtag_map_within_hours(base_dir: str, tag_name: str, secs_since_epoch = \ int((datetime.datetime.utcnow() - datetime.datetime(1970, 1, 1)).total_seconds()) - end_hours_since_epoch = int(secs_since_epoch / (60 * 60)) - start_hours_since_epoch = end_hours_since_epoch - abs(hours) + curr_hours_since_epoch = int(secs_since_epoch / (60 * 60)) + start_hours_since_epoch = curr_hours_since_epoch - abs(hours) + end_hours_since_epoch = curr_hours_since_epoch + 2 if map_format == 'gpx': map_str = \ _hashtag_map_to_gpx(base_dir, tag_name, From 61f5b2ea80be8f37432207029a25d5e9390447e1 Mon Sep 17 00:00:00 2001 From: Bob Mottram Date: Tue, 23 Aug 2022 12:42:08 +0100 Subject: [PATCH 16/21] Tidying --- maps.py | 3 --- 1 file changed, 3 deletions(-) diff --git a/maps.py b/maps.py index 2a2c8722f..76f4896db 100644 --- a/maps.py +++ b/maps.py @@ -553,9 +553,6 @@ def _hashtag_map_to_gpx(base_dir: str, tag_name: str, if len(link_line) < 3: continue secs_since_epoch = int(link_line[0]) - print('***maptest secs_since_epoch ' + str(secs_since_epoch)) - print('***maptest start_secs_since_epoch ' + str(start_secs_since_epoch)) - print('***maptest end_secs_since_epoch ' + str(end_secs_since_epoch)) if secs_since_epoch < start_secs_since_epoch or \ secs_since_epoch > end_secs_since_epoch: continue From 7d403879434b65627a52a587708d0b3bbc53106d Mon Sep 17 00:00:00 2001 From: Bob Mottram Date: Tue, 23 Aug 2022 13:00:00 +0100 Subject: [PATCH 17/21] Try without download --- maps.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/maps.py b/maps.py index 76f4896db..c49afafb0 100644 --- a/maps.py +++ b/maps.py @@ -676,8 +676,10 @@ def html_hashtag_maps(base_dir: str, tag_name: str, if translate.get(period_str): description = translate[period_str] html_str += '' + \ - description + '' + '">' + description + '' +# html_str += '' + \ +# description + '' if html_str: html_str = '🌍 ' + html_str return html_str From b7d56f475ff11b14a5df65d66c0c0f895324dbca Mon Sep 17 00:00:00 2001 From: Bob Mottram Date: Tue, 23 Aug 2022 13:04:47 +0100 Subject: [PATCH 18/21] Restore download --- maps.py | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/maps.py b/maps.py index c49afafb0..76f4896db 100644 --- a/maps.py +++ b/maps.py @@ -676,10 +676,8 @@ def html_hashtag_maps(base_dir: str, tag_name: str, if translate.get(period_str): description = translate[period_str] html_str += '' + description + '' -# html_str += '' + \ -# description + '' + '" download="' + download_filename + '">' + \ + description + '' if html_str: html_str = '🌍 ' + html_str return html_str From e752c684804ccd5d207ec4626eae8b064562007b Mon Sep 17 00:00:00 2001 From: Bob Mottram Date: Tue, 23 Aug 2022 13:16:58 +0100 Subject: [PATCH 19/21] Default to kml --- epicyon.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/epicyon.py b/epicyon.py index 3f17730e3..a80a62e6c 100644 --- a/epicyon.py +++ b/epicyon.py @@ -736,7 +736,7 @@ def _command_options() -> None: parser.add_argument('--location', dest='location', type=str, default=None, help='Location/City of item being shared') parser.add_argument('--mapFormat', dest='mapFormat', type=str, - default='gpx', + default='kml', help='Format for hashtag maps GPX/KML') parser.add_argument('--duration', dest='duration', type=str, default=None, help='Duration for which to share an item') From 4f9bfec9ed479b268ea7b6b80af0f6c295d2ad38 Mon Sep 17 00:00:00 2001 From: Bob Mottram Date: Tue, 23 Aug 2022 14:00:51 +0100 Subject: [PATCH 20/21] Comments --- maps.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/maps.py b/maps.py index 76f4896db..17a23ab03 100644 --- a/maps.py +++ b/maps.py @@ -581,7 +581,8 @@ def _hashtag_map_to_gpx(base_dir: str, tag_name: str, def _hashtag_map_within_hours(base_dir: str, tag_name: str, hours: int, map_format: str) -> str: - """Returns kml for a hashtag containing maps for the last number of hours + """Returns gpx/kml for a hashtag containing maps for the + last number of hours """ secs_since_epoch = \ int((datetime.datetime.utcnow() - From be4638706c5e70bb5a9db9c8b19b197a8f610e3f Mon Sep 17 00:00:00 2001 From: Bob Mottram Date: Tue, 23 Aug 2022 15:14:15 +0100 Subject: [PATCH 21/21] When searching for hashtags, don't force lower case --- daemon.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/daemon.py b/daemon.py index c18eed448..5abe4bb91 100644 --- a/daemon.py +++ b/daemon.py @@ -3853,7 +3853,10 @@ class PubServer(BaseHTTPRequestHandler): search_str = search_str.split('&')[0] search_str = \ urllib.parse.unquote_plus(search_str.strip()) - search_str = search_str.lower().strip() + search_str = search_str.strip() + # hashtags can be combined case + if not search_str.startswith('#'): + search_str = search_str.lower() print('search_str: ' + search_str) if search_for_emoji: search_str = ':' + search_str + ':'