mirror of https://gitlab.com/bashrc2/epicyon
Handle address within location
parent
36544e214e
commit
b22997956f
22
maps.py
22
maps.py
|
|
@ -57,12 +57,19 @@ def _get_location_from_tags(tags: []) -> str:
|
||||||
location_str = locn['name'].replace('\n', ' ')
|
location_str = locn['name'].replace('\n', ' ')
|
||||||
location_str = remove_html(location_str)
|
location_str = remove_html(location_str)
|
||||||
if locn.get('url'):
|
if locn.get('url'):
|
||||||
|
# location name and link
|
||||||
if isinstance(locn['url'], str):
|
if isinstance(locn['url'], str):
|
||||||
if resembles_url(locn['url']):
|
if resembles_url(locn['url']):
|
||||||
location_str = \
|
location_str = \
|
||||||
'<a href="' + locn['url'] + '" target="_blank" ' + \
|
'<a href="' + locn['url'] + '" target="_blank" ' + \
|
||||||
'rel="nofollow noopener noreferrer">' + \
|
'rel="nofollow noopener noreferrer">' + \
|
||||||
location_str + '</a>'
|
location_str + '</a>'
|
||||||
|
if locn.get('address'):
|
||||||
|
# location name and address
|
||||||
|
if isinstance(locn['address'], str):
|
||||||
|
locn_address = remove_html(locn['address'])
|
||||||
|
locn_address = locn_address.replace(', ', '<br>')
|
||||||
|
location_str += '<br><address>' + locn_address + '</address>'
|
||||||
return location_str
|
return location_str
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
|
@ -72,6 +79,7 @@ def get_location_from_post(post_json_object: {}) -> str:
|
||||||
"""
|
"""
|
||||||
locn = None
|
locn = None
|
||||||
locn_url = None
|
locn_url = None
|
||||||
|
locn_address = None
|
||||||
|
|
||||||
# location represented via a tag
|
# location represented via a tag
|
||||||
post_obj = post_json_object
|
post_obj = post_json_object
|
||||||
|
|
@ -101,18 +109,32 @@ def get_location_from_post(post_json_object: {}) -> str:
|
||||||
if locn2.get('url'):
|
if locn2.get('url'):
|
||||||
if isinstance(locn2['url'], str):
|
if isinstance(locn2['url'], str):
|
||||||
locn_url = locn2['url']
|
locn_url = locn2['url']
|
||||||
|
if locn2.get('address'):
|
||||||
|
if isinstance(locn2['address'], str):
|
||||||
|
locn_address = remove_html(locn2['address'])
|
||||||
|
locn_address = locn_address.replace(', ', '<br>')
|
||||||
if locn_exists:
|
if locn_exists:
|
||||||
|
# location geocoordinate
|
||||||
osm_domain = 'osm.org'
|
osm_domain = 'osm.org'
|
||||||
zoom = 17
|
zoom = 17
|
||||||
locn = _geocoords_to_osm_link(osm_domain, zoom,
|
locn = _geocoords_to_osm_link(osm_domain, zoom,
|
||||||
locn2['latitude'],
|
locn2['latitude'],
|
||||||
locn2['longitude'])
|
locn2['longitude'])
|
||||||
elif locn_url:
|
elif locn_url:
|
||||||
|
# location name and link
|
||||||
if locn:
|
if locn:
|
||||||
|
if '<a href=' not in locn:
|
||||||
locn = '<a href="' + locn_url + '" target="_blank" ' + \
|
locn = '<a href="' + locn_url + '" target="_blank" ' + \
|
||||||
'rel="nofollow noopener noreferrer">' + locn + '</a>'
|
'rel="nofollow noopener noreferrer">' + locn + '</a>'
|
||||||
else:
|
else:
|
||||||
locn = locn_url
|
locn = locn_url
|
||||||
|
elif locn_address:
|
||||||
|
# location name and address
|
||||||
|
if locn:
|
||||||
|
if '<address>' not in locn:
|
||||||
|
locn += '<br><address>' + locn_address + '</address>'
|
||||||
|
else:
|
||||||
|
locn = '<address>' + locn_address + '</address>'
|
||||||
|
|
||||||
return locn
|
return locn
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -3223,6 +3223,9 @@ def individual_post_as_html(signing_priv_key_pem: str,
|
||||||
set_map_preferences_coords(base_dir, nickname, domain,
|
set_map_preferences_coords(base_dir, nickname, domain,
|
||||||
map_latitude, map_longitude,
|
map_latitude, map_longitude,
|
||||||
map_zoom)
|
map_zoom)
|
||||||
|
if not map_str and location_str:
|
||||||
|
map_str = '<p>' + translate['Location'] + ': ' + \
|
||||||
|
location_str + '</p>\n'
|
||||||
|
|
||||||
if is_muted:
|
if is_muted:
|
||||||
content_str = ''
|
content_str = ''
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue