diff options
author | Bryan Newbold <bnewbold@robocracy.org> | 2021-02-26 12:02:49 -0800 |
---|---|---|
committer | Bryan Newbold <bnewbold@robocracy.org> | 2021-02-26 12:03:32 -0800 |
commit | 7850ce229de7c817c04509ddc8339a7934774c06 (patch) | |
tree | ef40121717c0145a97160909efc46c8ca6ed1f75 | |
parent | 0880e0ecca4e65fd00a4ffafec948873be45193e (diff) | |
download | fatcat-7850ce229de7c817c04509ddc8339a7934774c06.tar.gz fatcat-7850ce229de7c817c04509ddc8339a7934774c06.zip |
web: try container search along with release for generic queries
-rw-r--r-- | python/fatcat_web/routes.py | 15 | ||||
-rw-r--r-- | python/fatcat_web/templates/release_search.html | 10 |
2 files changed, 22 insertions, 3 deletions
diff --git a/python/fatcat_web/routes.py b/python/fatcat_web/routes.py index eda947cd..7cf1f854 100644 --- a/python/fatcat_web/routes.py +++ b/python/fatcat_web/routes.py @@ -685,7 +685,7 @@ def generic_search(): if len(query.split()) != 1: # multi-term? must be a real search - return redirect(url_for('release_search', q=query)) + return redirect(url_for('release_search', q=query, generic=1)) if clean_doi(query): return redirect(url_for('release_lookup', doi=clean_doi(query))) @@ -704,7 +704,7 @@ def generic_search(): if clean_orcid(query): return redirect(url_for('creator_lookup', orcid=clean_orcid(query))) - return redirect(url_for('release_search', q=query)) + return redirect(url_for('release_search', q=query, generic=1)) @app.route('/release/search', methods=['GET', 'POST']) def release_search(): @@ -712,12 +712,21 @@ def release_search(): if 'q' not in request.args.keys(): return render_template('release_search.html', query=ReleaseQuery(), found=None) + container_found = None + if request.args.get('generic'): + container_query = GenericQuery.from_args(request.args) + container_query.limit = 1 + try: + container_found = do_container_search(container_query) + except Exception: + pass + query = ReleaseQuery.from_args(request.args) try: found = do_release_search(query) except FatcatSearchError as fse: return render_template('release_search.html', query=query, es_error=fse), fse.status_code - return render_template('release_search.html', query=query, found=found) + return render_template('release_search.html', query=query, found=found, container_found=container_found) @app.route('/container/search', methods=['GET', 'POST']) def container_search(): diff --git a/python/fatcat_web/templates/release_search.html b/python/fatcat_web/templates/release_search.html index 4de56fa2..59a234c0 100644 --- a/python/fatcat_web/templates/release_search.html +++ b/python/fatcat_web/templates/release_search.html @@ -35,6 +35,16 @@ <div class="ui container text"> <br> +{% if container_found and container_found.results %} + <div class="ui tiny info floating message" style="margin: 0em auto; max-width: 40em;"> + <div class="header">Were you looking for this journal, instead of publications?</div> + <div style="padding-left: 0.5em;"> + {{ entity_macros.container_search_result_row(container_found.results[0]) }} + </div> + </div> + <br clear="all"> +{% endif %} + {% if found %} {% if found.results %} |