mirror of
https://github.com/searxng/searxng.git
synced 2024-11-17 18:00:12 +01:00
[mod] oa_doi_rewrite plugin: get_doi_resolver: remove args parameter
doi_resolvers.get_value('preferences') already contains the value from request.args.get('doi_resolver')
This commit is contained in:
parent
a3789b3bb4
commit
fc20c561bf
@ -11,8 +11,6 @@ description = gettext('Avoid paywalls by redirecting to open-access versions of
|
||||
default_on = False
|
||||
preference_section = 'general'
|
||||
|
||||
doi_resolvers = settings['doi_resolvers']
|
||||
|
||||
|
||||
def extract_doi(url):
|
||||
match = regex.search(url.path)
|
||||
@ -25,13 +23,12 @@ def extract_doi(url):
|
||||
return None
|
||||
|
||||
|
||||
def get_doi_resolver(args, preference_doi_resolver):
|
||||
def get_doi_resolver(preferences):
|
||||
doi_resolvers = settings['doi_resolvers']
|
||||
doi_resolver = args.get('doi_resolver', preference_doi_resolver)[0]
|
||||
if doi_resolver not in doi_resolvers:
|
||||
doi_resolver = settings['default_doi_resolver']
|
||||
doi_resolver_url = doi_resolvers[doi_resolver]
|
||||
return doi_resolver_url
|
||||
selected_resolver = preferences.get_value('doi_resolver')[0]
|
||||
if selected_resolver not in doi_resolvers:
|
||||
selected_resolver = settings['default_doi_resolver']
|
||||
return doi_resolvers[selected_resolver]
|
||||
|
||||
|
||||
def on_result(request, search, result):
|
||||
@ -43,6 +40,6 @@ def on_result(request, search, result):
|
||||
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
|
||||
result['url'] = get_doi_resolver(request.preferences) + doi
|
||||
result['parsed_url'] = urlparse(result['url'])
|
||||
return True
|
||||
|
@ -1040,9 +1040,7 @@ def preferences():
|
||||
themes = themes,
|
||||
plugins = plugins,
|
||||
doi_resolvers = settings['doi_resolvers'],
|
||||
current_doi_resolver = get_doi_resolver(
|
||||
request.args, request.preferences.get_value('doi_resolver')
|
||||
),
|
||||
current_doi_resolver = get_doi_resolver(request.preferences),
|
||||
allowed_plugins = allowed_plugins,
|
||||
theme = get_current_theme_name(),
|
||||
preferences_url_params = request.preferences.get_as_url_params(),
|
||||
|
Loading…
Reference in New Issue
Block a user