mirror of https://github.com/searx/searx
Merge pull request #2707 from return42/fix-doi-default
[fix] default_doi_resolver in preferences
This commit is contained in:
commit
0c68f2ee5f
|
@ -29,7 +29,7 @@ def get_doi_resolver(args, preference_doi_resolver):
|
||||||
doi_resolvers = settings['doi_resolvers']
|
doi_resolvers = settings['doi_resolvers']
|
||||||
doi_resolver = args.get('doi_resolver', preference_doi_resolver)[0]
|
doi_resolver = args.get('doi_resolver', preference_doi_resolver)[0]
|
||||||
if doi_resolver not in doi_resolvers:
|
if doi_resolver not in doi_resolvers:
|
||||||
doi_resolvers = settings['default_doi_resolver']
|
doi_resolver = settings['default_doi_resolver']
|
||||||
doi_resolver_url = doi_resolvers[doi_resolver]
|
doi_resolver_url = doi_resolvers[doi_resolver]
|
||||||
return doi_resolver_url
|
return doi_resolver_url
|
||||||
|
|
||||||
|
@ -40,7 +40,7 @@ def on_result(request, search, result):
|
||||||
|
|
||||||
doi = extract_doi(result['parsed_url'])
|
doi = extract_doi(result['parsed_url'])
|
||||||
if doi and len(doi) < 50:
|
if doi and len(doi) < 50:
|
||||||
for suffix in ('/', '.pdf', '/full', '/meta', '/abstract'):
|
for suffix in ('/', '.pdf', '.xml', '/full', '/meta', '/abstract'):
|
||||||
if doi.endswith(suffix):
|
if doi.endswith(suffix):
|
||||||
doi = doi[:-len(suffix)]
|
doi = doi[:-len(suffix)]
|
||||||
result['url'] = get_doi_resolver(request.args, request.preferences.get_value('doi_resolver')) + doi
|
result['url'] = get_doi_resolver(request.args, request.preferences.get_value('doi_resolver')) + doi
|
||||||
|
|
|
@ -387,7 +387,7 @@ class Preferences:
|
||||||
}
|
}
|
||||||
),
|
),
|
||||||
'doi_resolver': MultipleChoiceSetting(
|
'doi_resolver': MultipleChoiceSetting(
|
||||||
['oadoi.org'],
|
[settings['default_doi_resolver'], ],
|
||||||
is_locked('doi_resolver'),
|
is_locked('doi_resolver'),
|
||||||
choices=DOI_RESOLVERS
|
choices=DOI_RESOLVERS
|
||||||
),
|
),
|
||||||
|
|
|
@ -1395,4 +1395,4 @@ doi_resolvers :
|
||||||
doai.io : 'https://dissem.in/'
|
doai.io : 'https://dissem.in/'
|
||||||
sci-hub.tw : 'https://sci-hub.tw/'
|
sci-hub.tw : 'https://sci-hub.tw/'
|
||||||
|
|
||||||
default_doi_resolver : 'sci-hub.tw'
|
default_doi_resolver : 'oadoi.org'
|
||||||
|
|
|
@ -165,7 +165,7 @@
|
||||||
{{ preferences_item_header(info, label, rtl, 'doi_resolver') }}
|
{{ preferences_item_header(info, label, rtl, 'doi_resolver') }}
|
||||||
<select class="form-control {{ custom_select_class(rtl) }}" name="doi_resolver" id="doi_resolver">
|
<select class="form-control {{ custom_select_class(rtl) }}" name="doi_resolver" id="doi_resolver">
|
||||||
{% for doi_resolver_name,doi_resolver_url in doi_resolvers.items() %}
|
{% for doi_resolver_name,doi_resolver_url in doi_resolvers.items() %}
|
||||||
<option value="{{ doi_resolver_name }}" {% if doi_resolver_name == current_doi_resolver %}selected="selected"{% endif %}>
|
<option value="{{ doi_resolver_name }}" {% if doi_resolver_url == current_doi_resolver %}selected="selected"{% endif %}>
|
||||||
{{ doi_resolver_name }} - {{ doi_resolver_url }}
|
{{ doi_resolver_name }} - {{ doi_resolver_url }}
|
||||||
</option>
|
</option>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
|
|
|
@ -96,7 +96,7 @@
|
||||||
<p class="value">
|
<p class="value">
|
||||||
<select id='doi_resolver' name='doi_resolver'>
|
<select id='doi_resolver' name='doi_resolver'>
|
||||||
{%- for doi_resolver_name,doi_resolver_url in doi_resolvers.items() -%}
|
{%- for doi_resolver_name,doi_resolver_url in doi_resolvers.items() -%}
|
||||||
<option value="{{ doi_resolver_name }}" {% if doi_resolver_name == current_doi_resolver %}selected="selected"{% endif %}>
|
<option value="{{ doi_resolver_name }}" {% if doi_resolver_url == current_doi_resolver %}selected="selected"{% endif %}>
|
||||||
{{- doi_resolver_name }} - {{ doi_resolver_url -}}
|
{{- doi_resolver_name }} - {{ doi_resolver_url -}}
|
||||||
</option>
|
</option>
|
||||||
{%- endfor -%}
|
{%- endfor -%}
|
||||||
|
|
Loading…
Reference in New Issue