forked from Ponysearch/Ponysearch
[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
2 changed files with 7 additions and 12 deletions
|
@ -11,8 +11,6 @@ description = gettext('Avoid paywalls by redirecting to open-access versions of
|
||||||
default_on = False
|
default_on = False
|
||||||
preference_section = 'general'
|
preference_section = 'general'
|
||||||
|
|
||||||
doi_resolvers = settings['doi_resolvers']
|
|
||||||
|
|
||||||
|
|
||||||
def extract_doi(url):
|
def extract_doi(url):
|
||||||
match = regex.search(url.path)
|
match = regex.search(url.path)
|
||||||
|
@ -25,13 +23,12 @@ def extract_doi(url):
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
|
||||||
def get_doi_resolver(args, preference_doi_resolver):
|
def get_doi_resolver(preferences):
|
||||||
doi_resolvers = settings['doi_resolvers']
|
doi_resolvers = settings['doi_resolvers']
|
||||||
doi_resolver = args.get('doi_resolver', preference_doi_resolver)[0]
|
selected_resolver = preferences.get_value('doi_resolver')[0]
|
||||||
if doi_resolver not in doi_resolvers:
|
if selected_resolver not in doi_resolvers:
|
||||||
doi_resolver = settings['default_doi_resolver']
|
selected_resolver = settings['default_doi_resolver']
|
||||||
doi_resolver_url = doi_resolvers[doi_resolver]
|
return doi_resolvers[selected_resolver]
|
||||||
return doi_resolver_url
|
|
||||||
|
|
||||||
|
|
||||||
def on_result(request, search, result):
|
def on_result(request, search, result):
|
||||||
|
@ -43,6 +40,6 @@ def on_result(request, search, result):
|
||||||
for suffix in ('/', '.pdf', '.xml', '/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.preferences) + doi
|
||||||
result['parsed_url'] = urlparse(result['url'])
|
result['parsed_url'] = urlparse(result['url'])
|
||||||
return True
|
return True
|
||||||
|
|
|
@ -1040,9 +1040,7 @@ def preferences():
|
||||||
themes = themes,
|
themes = themes,
|
||||||
plugins = plugins,
|
plugins = plugins,
|
||||||
doi_resolvers = settings['doi_resolvers'],
|
doi_resolvers = settings['doi_resolvers'],
|
||||||
current_doi_resolver = get_doi_resolver(
|
current_doi_resolver = get_doi_resolver(request.preferences),
|
||||||
request.args, request.preferences.get_value('doi_resolver')
|
|
||||||
),
|
|
||||||
allowed_plugins = allowed_plugins,
|
allowed_plugins = allowed_plugins,
|
||||||
theme = get_current_theme_name(),
|
theme = get_current_theme_name(),
|
||||||
preferences_url_params = request.preferences.get_as_url_params(),
|
preferences_url_params = request.preferences.get_as_url_params(),
|
||||||
|
|
Loading…
Reference in a new issue