mirror of https://github.com/searxng/searxng.git
google engine :remove OSM map
This commit is contained in:
parent
b8fc531b60
commit
72c8de35a2
|
@ -282,7 +282,8 @@ def response(resp):
|
||||||
results.append({'url': url,
|
results.append({'url': url,
|
||||||
'title': title,
|
'title': title,
|
||||||
'content': content})
|
'content': content})
|
||||||
except:
|
except Exception, e:
|
||||||
|
print e
|
||||||
continue
|
continue
|
||||||
|
|
||||||
# parse suggestion
|
# parse suggestion
|
||||||
|
@ -305,7 +306,8 @@ def parse_images(result, google_hostname):
|
||||||
'title': '',
|
'title': '',
|
||||||
'content': '',
|
'content': '',
|
||||||
'img_src': img_src,
|
'img_src': img_src,
|
||||||
'template': 'images.html'})
|
'template': 'images.html'
|
||||||
|
})
|
||||||
|
|
||||||
return results
|
return results
|
||||||
|
|
||||||
|
@ -316,12 +318,13 @@ def parse_map_near(parsed_url, x, google_hostname):
|
||||||
for result in x:
|
for result in x:
|
||||||
title = extract_text_from_dom(result, map_near_title)
|
title = extract_text_from_dom(result, map_near_title)
|
||||||
url = parse_url(extract_text_from_dom(result, map_near_url), google_hostname)
|
url = parse_url(extract_text_from_dom(result, map_near_url), google_hostname)
|
||||||
|
attributes = []
|
||||||
phone = extract_text_from_dom(result, map_near_phone)
|
phone = extract_text_from_dom(result, map_near_phone)
|
||||||
if phone is not None:
|
add_attributes(attributes, property_phone, phone, 'tel:' + phone)
|
||||||
phone = property_phone + ": " + phone
|
results.append({'title': title,
|
||||||
results.append({'url': url,
|
'url': url,
|
||||||
'title': title,
|
'content': attributes_to_html(attributes)
|
||||||
'content': phone})
|
})
|
||||||
|
|
||||||
return results
|
return results
|
||||||
|
|
||||||
|
@ -335,69 +338,45 @@ def parse_map_detail(parsed_url, result, google_hostname):
|
||||||
m = re.search('ll\=([0-9\.]+),([0-9\.]+)\&z\=([0-9]+)', parsed_url.query)
|
m = re.search('ll\=([0-9\.]+),([0-9\.]+)\&z\=([0-9]+)', parsed_url.query)
|
||||||
|
|
||||||
if m is not None:
|
if m is not None:
|
||||||
# geoloc found
|
# geoloc found (ignored)
|
||||||
lon = float(m.group(2))
|
lon = float(m.group(2)) # noqa
|
||||||
lat = float(m.group(1))
|
lat = float(m.group(1)) # noqa
|
||||||
zoom = int(m.group(3))
|
zoom = int(m.group(3)) # noqa
|
||||||
|
|
||||||
# TODO : map zoom to dlon / dlat
|
|
||||||
dlon = 0.000001
|
|
||||||
dlat = 0.000001
|
|
||||||
|
|
||||||
boundingbox = [round(lat - dlat, 7), round(lat + dlat, 7), round(lon - dlon, 7), round(lon + dlon, 7)]
|
|
||||||
map_url = url_map\
|
|
||||||
.replace('{latitude}', str(lat))\
|
|
||||||
.replace('{longitude}', str(lon))\
|
|
||||||
.replace('{zoom}', str(zoom+2))
|
|
||||||
|
|
||||||
geojson = {u'type': u'Point',
|
|
||||||
u'coordinates': [lon, lat]
|
|
||||||
}
|
|
||||||
|
|
||||||
# attributes
|
# attributes
|
||||||
attributes = []
|
attributes = []
|
||||||
add_attributes(attributes, property_address, extract_text_from_dom(result, map_address_xpath))
|
address = extract_text_from_dom(result, map_address_xpath)
|
||||||
add_attributes(attributes, property_phone, extract_text_from_dom(result, map_phone_xpath))
|
phone = extract_text_from_dom(result, map_phone_xpath)
|
||||||
|
add_attributes(attributes, property_address, address, 'geo:' + str(lat) + ',' + str(lon))
|
||||||
|
add_attributes(attributes, property_phone, phone, 'tel:' + phone)
|
||||||
|
|
||||||
# title / content / url
|
# title / content / url
|
||||||
website_title = extract_text_from_dom(result, map_website_title_xpath)
|
website_title = extract_text_from_dom(result, map_website_title_xpath)
|
||||||
content = extract_text_from_dom(result, content_xpath)
|
content = extract_text_from_dom(result, content_xpath)
|
||||||
website_url = parse_url(extract_text_from_dom(result, map_website_url_xpath), google_hostname)
|
website_url = parse_url(extract_text_from_dom(result, map_website_url_xpath), google_hostname)
|
||||||
|
|
||||||
# add an infobox if there is a website
|
# add a result if there is a website
|
||||||
if website_url is not None:
|
if website_url is not None:
|
||||||
results.append({'infobox': website_title,
|
results.append({'title': website_title,
|
||||||
'id': website_url,
|
'content': (content + '<br />' if content is not None else '')
|
||||||
'content': content,
|
+ attributes_to_html(attributes),
|
||||||
'attributes': attributes,
|
'url': website_url
|
||||||
'urls': [
|
|
||||||
{'title': url_get_label(website_url), 'url': website_url},
|
|
||||||
{'title': property_location, 'url': map_url}
|
|
||||||
]
|
|
||||||
})
|
})
|
||||||
|
|
||||||
# usefull because user can see the map directly into searx
|
|
||||||
results.append({'template': 'map.html',
|
|
||||||
'title': website_title,
|
|
||||||
'content': (content + '<br />' if content is not None else '')
|
|
||||||
+ attributes_to_html(attributes),
|
|
||||||
'longitude': lon,
|
|
||||||
'latitude': lat,
|
|
||||||
'boundingbox': boundingbox,
|
|
||||||
'geojson': geojson,
|
|
||||||
'url': website_url if website_url is not None else map_url
|
|
||||||
})
|
|
||||||
return results
|
return results
|
||||||
|
|
||||||
|
|
||||||
def add_attributes(attributes, name, value):
|
def add_attributes(attributes, name, value, url):
|
||||||
if value is not None and len(value) > 0:
|
if value is not None and len(value) > 0:
|
||||||
attributes.append({'label': name, 'value': value})
|
attributes.append({'label': name, 'value': value, 'url': url})
|
||||||
|
|
||||||
|
|
||||||
def attributes_to_html(attributes):
|
def attributes_to_html(attributes):
|
||||||
retval = '<table class="table table-striped">'
|
retval = '<table class="table table-striped">'
|
||||||
for a in attributes:
|
for a in attributes:
|
||||||
retval = retval + '<tr><th>' + a.get('label') + '</th><td>' + a.get('value') + '</td></tr>'
|
value = a.get('value')
|
||||||
|
if 'url' in a:
|
||||||
|
value = '<a href="' + a.get('url') + '">' + value + '</a>'
|
||||||
|
retval = retval + '<tr><th>' + a.get('label') + '</th><td>' + value + '</td></tr>'
|
||||||
retval = retval + '</table>'
|
retval = retval + '</table>'
|
||||||
return retval
|
return retval
|
||||||
|
|
Loading…
Reference in New Issue