[mod] science category: various update of about PR 1705

dependabot/pip/master/sphinx-6.1.3
Alexandre Flament 2 years ago
parent 08b8859705
commit d6446be38f

@ -369,13 +369,9 @@ the parameter ``template`` must be set to the desired type.
- :py:class:`str` - :py:class:`str`
- volume number - volume number
* - start_page * - pages
- :py:class:`int` - :py:class:`str`
- page number where the article starts - page range where the article is
* - end_page
- :py:class:`int`
- page number where the article ends
* - number * - number
- :py:class:`str` - :py:class:`str`

@ -33,10 +33,10 @@ def response(resp):
if record_type == 'book-chapter': if record_type == 'book-chapter':
title = record['container-title'][0] title = record['container-title'][0]
if record['title'][0].lower().strip() != title.lower().strip(): if record['title'][0].lower().strip() != title.lower().strip():
title = title + ' (' + record['title'][0] + ')' title = html_to_text(title) + ' (' + html_to_text(record['title'][0]) + ')'
journal = None journal = None
else: else:
title = record['title'][0] title = html_to_text(record['title'][0])
journal = record.get('container-title', [None])[0] journal = record.get('container-title', [None])[0]
url = record.get('resource', {}).get('primary', {}).get('URL') or record['URL'] url = record.get('resource', {}).get('primary', {}).get('URL') or record['URL']
authors = [author.get('given', '') + ' ' + author.get('family', '') for author in record.get('author', [])] authors = [author.get('given', '') + ' ' + author.get('family', '') for author in record.get('author', [])]

@ -48,7 +48,6 @@ def request(query, params):
def response(resp): def response(resp):
res = loads(resp.text) res = loads(resp.text)
results = [] results = []
for result in res['results']: for result in res['results']:
url = result.get('primaryPaperLink', {}).get('url') url = result.get('primaryPaperLink', {}).get('url')
if not url and result.get('links'): if not url and result.get('links'):
@ -72,7 +71,7 @@ def response(resp):
# pick for the first alternate link, but not from the crawler # pick for the first alternate link, but not from the crawler
pdf_url = None pdf_url = None
for doc in result.get('alternatePaperLinks', []): for doc in result.get('alternatePaperLinks', []):
if doc['linkType'] != 'crawler': if doc['linkType'] not in ('crawler', 'doi'):
pdf_url = doc['url'] pdf_url = doc['url']
break break

@ -58,8 +58,7 @@ def response(resp):
'authors': authors, 'authors': authors,
'doi': record.get('doi'), 'doi': record.get('doi'),
'journal': record.get('publicationName'), 'journal': record.get('publicationName'),
'start_page': record.get('start_page'), 'pages': record.get('start_page') + '-' + record.get('end_page'),
'end_page': record.get('end_page'),
'tags': tags, 'tags': tags,
'issn': [record.get('issn')], 'issn': [record.get('issn')],
'isbn': [record.get('isbn')], 'isbn': [record.get('isbn')],

@ -412,7 +412,8 @@ engines:
- name: crossref - name: crossref
engine: crossref engine: crossref
shortcut: cr shortcut: cr
timeout: 10 timeout: 30
disable: true
- name: yep - name: yep
engine: json_engine engine: json_engine

@ -13,8 +13,8 @@
.{{- result.number -}} .{{- result.number -}}
{%- endif -%} {%- endif -%}
{%- endif -%} {%- endif -%}
{%- if result.start_page -%} {%- if result.pages -%}
 {{- result.start_page -}} / {{- result.end_page -}}  {{- result.pages -}}
{%- endif -%} {%- endif -%}
</span> </span>
</div> </div>

@ -77,7 +77,7 @@ from searx.webutils import (
is_hmac_of, is_hmac_of,
is_flask_run_cmdline, is_flask_run_cmdline,
group_engines_in_tab, group_engines_in_tab,
searxng_format_date, searxng_l10n_timespan,
) )
from searx.webadapter import ( from searx.webadapter import (
get_search_query_from_webapp, get_search_query_from_webapp,
@ -723,7 +723,7 @@ def search():
except ValueError: except ValueError:
result['publishedDate'] = None result['publishedDate'] = None
else: else:
result['publishedDate'] = searxng_format_date(result['publishedDate']) result['publishedDate'] = searxng_l10n_timespan(result['publishedDate'])
# set result['open_group'] = True when the template changes from the previous result # set result['open_group'] = True when the template changes from the previous result
# set result['close_group'] = True when the template changes on the next result # set result['close_group'] = True when the template changes on the next result

@ -141,7 +141,13 @@ def highlight_content(content, query):
return content return content
def searxng_format_date(dt: datetime): # pylint: disable=invalid-name def searxng_l10n_timespan(dt: datetime) -> str: # pylint: disable=invalid-name
"""Returns a human-readable and translated string indicating how long ago
a date was in the past / the time span of the date to the present.
On January 1st, midnight, the returned string only indicates how many years
ago the date was.
"""
# TODO, check if timezone is calculated right # pylint: disable=fixme # TODO, check if timezone is calculated right # pylint: disable=fixme
d = dt.date() d = dt.date()
t = dt.time() t = dt.time()

Loading…
Cancel
Save