From ebfd0eb2b79f73eef108ac1ad89c07174ad6441c Mon Sep 17 00:00:00 2001 From: Markus Heiser Date: Sun, 4 Apr 2021 13:36:33 +0200 Subject: [PATCH] [fix] default_doi_resolver in preferences Instead of a hard-coded `oadoi.org` default, use the default value from `settings.yml`. Fix an issue in the themes: The replacement 'current_doi_resolver' contains the doi_resolver_url, not the name of the DOI resolver. Compare return value of:: searx.plugins.oa_doi_rewrite.get_doi_resolver(...) Fix a typo in `get_doi_resolver(..)`: suggested by @kvch: *L32 should set doi_resolver not doi_resolvers* Signed-off-by: Markus Heiser --- searx/plugins/oa_doi_rewrite.py | 4 ++-- searx/preferences.py | 2 +- searx/settings.yml | 2 +- searx/templates/oscar/preferences.html | 2 +- searx/templates/simple/preferences.html | 2 +- 5 files changed, 6 insertions(+), 6 deletions(-) diff --git a/searx/plugins/oa_doi_rewrite.py b/searx/plugins/oa_doi_rewrite.py index eef29f10..02a71294 100644 --- a/searx/plugins/oa_doi_rewrite.py +++ b/searx/plugins/oa_doi_rewrite.py @@ -29,7 +29,7 @@ def get_doi_resolver(args, preference_doi_resolver): doi_resolvers = settings['doi_resolvers'] doi_resolver = args.get('doi_resolver', preference_doi_resolver)[0] 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] return doi_resolver_url @@ -40,7 +40,7 @@ def on_result(request, search, result): doi = extract_doi(result['parsed_url']) 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): doi = doi[:-len(suffix)] result['url'] = get_doi_resolver(request.args, request.preferences.get_value('doi_resolver')) + doi diff --git a/searx/preferences.py b/searx/preferences.py index a9f16ff7..1c4aab33 100644 --- a/searx/preferences.py +++ b/searx/preferences.py @@ -387,7 +387,7 @@ class Preferences: } ), 'doi_resolver': MultipleChoiceSetting( - ['oadoi.org'], + [settings['default_doi_resolver'], ], is_locked('doi_resolver'), choices=DOI_RESOLVERS ), diff --git a/searx/settings.yml b/searx/settings.yml index 84aca86f..50bccb1e 100644 --- a/searx/settings.yml +++ b/searx/settings.yml @@ -1395,4 +1395,4 @@ doi_resolvers : doai.io : 'https://dissem.in/' sci-hub.tw : 'https://sci-hub.tw/' -default_doi_resolver : 'sci-hub.tw' +default_doi_resolver : 'oadoi.org' diff --git a/searx/templates/oscar/preferences.html b/searx/templates/oscar/preferences.html index 6d593840..3f9192e2 100644 --- a/searx/templates/oscar/preferences.html +++ b/searx/templates/oscar/preferences.html @@ -165,7 +165,7 @@ {{ preferences_item_header(info, label, rtl, 'doi_resolver') }} {%- for doi_resolver_name,doi_resolver_url in doi_resolvers.items() -%} - {%- endfor -%}