diff --git a/maps.py b/maps.py index e2dc9c4be..e34d168aa 100644 --- a/maps.py +++ b/maps.py @@ -57,12 +57,19 @@ def _get_location_from_tags(tags: []) -> str: location_str = locn['name'].replace('\n', ' ') location_str = remove_html(location_str) if locn.get('url'): + # location name and link if isinstance(locn['url'], str): if resembles_url(locn['url']): location_str = \ '' + \ location_str + '' + if locn.get('address'): + # location name and address + if isinstance(locn['address'], str): + locn_address = remove_html(locn['address']) + locn_address = locn_address.replace(', ', '
') + location_str += '
' + locn_address + '
' return location_str return None @@ -72,6 +79,7 @@ def get_location_from_post(post_json_object: {}) -> str: """ locn = None locn_url = None + locn_address = None # location represented via a tag post_obj = post_json_object @@ -101,18 +109,32 @@ def get_location_from_post(post_json_object: {}) -> str: if locn2.get('url'): if isinstance(locn2['url'], str): locn_url = locn2['url'] + if locn2.get('address'): + if isinstance(locn2['address'], str): + locn_address = remove_html(locn2['address']) + locn_address = locn_address.replace(', ', '
') if locn_exists: + # location geocoordinate osm_domain = 'osm.org' zoom = 17 locn = _geocoords_to_osm_link(osm_domain, zoom, locn2['latitude'], locn2['longitude']) elif locn_url: + # location name and link if locn: - locn = '' + locn + '' + if '' + locn + '' + else: + locn = locn_url + elif locn_address: + # location name and address + if locn: + if '
' not in locn: + locn += '
' + locn_address + '
' else: - locn = locn_url + locn = '
' + locn_address + '
' return locn diff --git a/webapp_post.py b/webapp_post.py index e1aa852bd..50714519c 100644 --- a/webapp_post.py +++ b/webapp_post.py @@ -3223,6 +3223,9 @@ def individual_post_as_html(signing_priv_key_pem: str, set_map_preferences_coords(base_dir, nickname, domain, map_latitude, map_longitude, map_zoom) + if not map_str and location_str: + map_str = '

' + translate['Location'] + ': ' + \ + location_str + '

\n' if is_muted: content_str = ''