forked from Icycoide/searxng
[enh] openstreetmap / map template: improve results
implements ideas described in #69 * update the engine * use wikidata * update map.html template
This commit is contained in:
parent
92c8a8829f
commit
c75425655f
9 changed files with 16192 additions and 146 deletions
|
@ -10,6 +10,7 @@ IMDB_PREFIX_TO_URL_ID = {
|
|||
'co': 'imdb_company',
|
||||
'ev': 'imdb_event'
|
||||
}
|
||||
HTTP_WIKIMEDIA_IMAGE = 'http://commons.wikimedia.org/wiki/Special:FilePath/'
|
||||
|
||||
|
||||
def get_imdb_url_id(imdb_item_id):
|
||||
|
@ -17,6 +18,14 @@ def get_imdb_url_id(imdb_item_id):
|
|||
return IMDB_PREFIX_TO_URL_ID.get(id_prefix)
|
||||
|
||||
|
||||
def get_wikimedia_image_id(url):
|
||||
if url.startswith(HTTP_WIKIMEDIA_IMAGE):
|
||||
return url[len(HTTP_WIKIMEDIA_IMAGE):]
|
||||
if url.startswith('File:'):
|
||||
return url[len('File:'):]
|
||||
return url
|
||||
|
||||
|
||||
def get_external_url(url_id, item_id, alternative="default"):
|
||||
"""Return an external URL or None if url_id is not found.
|
||||
|
||||
|
@ -25,8 +34,11 @@ def get_external_url(url_id, item_id, alternative="default"):
|
|||
|
||||
If item_id is None, the raw URL with the $1 is returned.
|
||||
"""
|
||||
if url_id == 'imdb_id' and item_id is not None:
|
||||
url_id = get_imdb_url_id(item_id)
|
||||
if item_id is not None:
|
||||
if url_id == 'imdb_id':
|
||||
url_id = get_imdb_url_id(item_id)
|
||||
elif url_id == 'wikimedia_image':
|
||||
item_id = get_wikimedia_image_id(item_id)
|
||||
|
||||
url_description = EXTERNAL_URLS.get(url_id)
|
||||
if url_description:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue