forked from Archives/searxng
[enh] template_oscar: show addressdata if possible
This commit is contained in:
parent
2e7723a6c1
commit
c38917bb2a
@ -15,7 +15,7 @@ categories = ['map']
|
|||||||
paging = False
|
paging = False
|
||||||
|
|
||||||
# search-url
|
# search-url
|
||||||
url = 'https://nominatim.openstreetmap.org/search/{query}?format=json&polygon_geojson=1'
|
url = 'https://nominatim.openstreetmap.org/search/{query}?format=json&polygon_geojson=1&addressdetails=1'
|
||||||
|
|
||||||
result_base_url = 'https://openstreetmap.org/{osm_type}/{osm_id}'
|
result_base_url = 'https://openstreetmap.org/{osm_type}/{osm_id}'
|
||||||
|
|
||||||
@ -47,6 +47,30 @@ def response(resp):
|
|||||||
geojson = {u'type':u'Point',
|
geojson = {u'type':u'Point',
|
||||||
u'coordinates':[r['lon'],r['lat']]}
|
u'coordinates':[r['lon'],r['lat']]}
|
||||||
|
|
||||||
|
address_raw = r.get('address')
|
||||||
|
address = {}
|
||||||
|
|
||||||
|
# get name
|
||||||
|
if r['class'] == 'amenity' or\
|
||||||
|
r['class'] == 'shop' or\
|
||||||
|
r['class'] == 'tourism' or\
|
||||||
|
r['class'] == 'leisure':
|
||||||
|
if address_raw.get('address29'):
|
||||||
|
address = {'name':address_raw.get('address29')}
|
||||||
|
else:
|
||||||
|
address = {'name':address_raw.get(r['type'])}
|
||||||
|
|
||||||
|
# add rest of adressdata, if something is already found
|
||||||
|
if address.get('name'):
|
||||||
|
address.update({'house_number':address_raw.get('house_number'),
|
||||||
|
'road':address_raw.get('road'),
|
||||||
|
'locality':address_raw.get('town', address_raw.get('village')),
|
||||||
|
'postcode':address_raw.get('postcode'),
|
||||||
|
'country':address_raw.get('country'),
|
||||||
|
'country_code':address_raw.get('country_code')})
|
||||||
|
else:
|
||||||
|
address = None
|
||||||
|
|
||||||
# append result
|
# append result
|
||||||
results.append({'template': 'map.html',
|
results.append({'template': 'map.html',
|
||||||
'title': title,
|
'title': title,
|
||||||
@ -55,6 +79,7 @@ def response(resp):
|
|||||||
'latitude': r['lat'],
|
'latitude': r['lat'],
|
||||||
'boundingbox': r['boundingbox'],
|
'boundingbox': r['boundingbox'],
|
||||||
'geojson': geojson,
|
'geojson': geojson,
|
||||||
|
'address': address,
|
||||||
'url': url})
|
'url': url})
|
||||||
|
|
||||||
# return results
|
# return results
|
||||||
|
BIN
searx/static/oscar/css/oscar.min.css
vendored
BIN
searx/static/oscar/css/oscar.min.css
vendored
Binary file not shown.
@ -17,6 +17,8 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
.result-content {
|
.result-content {
|
||||||
|
margin-top: 5px;
|
||||||
|
|
||||||
.highlight {
|
.highlight {
|
||||||
font-weight:bold;
|
font-weight:bold;
|
||||||
}
|
}
|
||||||
|
@ -8,6 +8,28 @@
|
|||||||
<small> • <a class="text-info btn-collapse collapsed searx_init_map cursor-pointer" data-toggle="collapse" data-target="#result-map-{{ index }}" data-leaflet-target="osm-map-{{ index }}" data-map-lon="{{ result.longitude }}" data-map-lat="{{ result.latitude }}" {% if result.boundingbox %}data-map-boundingbox='{{ result.boundingbox|tojson|safe }}'{% endif %} {% if result.geojson %}data-map-geojson='{{ result.geojson|tojson|safe }}'{% endif %} data-btn-text-collapsed="{{ _('show map') }}" data-btn-text-not-collapsed="{{ _('hide map') }}">{{ icon('globe') }} {{ _('show map') }}</a></small>
|
<small> • <a class="text-info btn-collapse collapsed searx_init_map cursor-pointer" data-toggle="collapse" data-target="#result-map-{{ index }}" data-leaflet-target="osm-map-{{ index }}" data-map-lon="{{ result.longitude }}" data-map-lat="{{ result.latitude }}" {% if result.boundingbox %}data-map-boundingbox='{{ result.boundingbox|tojson|safe }}'{% endif %} {% if result.geojson %}data-map-geojson='{{ result.geojson|tojson|safe }}'{% endif %} data-btn-text-collapsed="{{ _('show map') }}" data-btn-text-not-collapsed="{{ _('hide map') }}">{{ icon('globe') }} {{ _('show map') }}</a></small>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
|
{% if result.address %}
|
||||||
|
<p class="result-content result-adress" itemscope itemtype="http://schema.org/PostalAddress">
|
||||||
|
{% if result.address.name %}
|
||||||
|
<strong itemprop="name">{{ result.address.name }}</strong><br/>
|
||||||
|
{% endif %}
|
||||||
|
{% if result.address.road %}
|
||||||
|
<span itemprop="streetAddress">
|
||||||
|
{% if result.address.house_number %}{{ result.address.house_number }}, {% endif %}
|
||||||
|
{{ result.address.road }}
|
||||||
|
</span><br/>
|
||||||
|
{% endif %}
|
||||||
|
{% if result.address.locality %}
|
||||||
|
<span itemprop="addressLocality">{{ result.address.locality }}</span>,
|
||||||
|
{% if result.address.postcode %} <span itemprop="postalCode">{{ result.address.postcode }}</span>{% endif %}
|
||||||
|
<br/>
|
||||||
|
{% endif %}
|
||||||
|
{% if result.address.country %}
|
||||||
|
<span itemprop="addressCountry">{{ result.address.country }}</span>
|
||||||
|
{% endif %}
|
||||||
|
</p><div class="clearfix"></div>
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
{% if result.content %}<p class="result-content">{{ result.content|safe }}</p>{% endif %}
|
{% if result.content %}<p class="result-content">{{ result.content|safe }}</p>{% endif %}
|
||||||
|
|
||||||
{% if (result.latitude and result.longitude) or result.boundingbox %}
|
{% if (result.latitude and result.longitude) or result.boundingbox %}
|
||||||
|
Loading…
Reference in New Issue
Block a user