aboutsummaryrefslogtreecommitdiffstats
path: root/python/fatcat_web/routes.py
diff options
context:
space:
mode:
authorBryan Newbold <bnewbold@robocracy.org>2019-02-20 19:21:19 -0800
committerBryan Newbold <bnewbold@robocracy.org>2019-02-20 19:21:23 -0800
commit7c04b83a6612b7a0c87afe4a1ed4bbb65568fea1 (patch)
tree96eca26306465d8801d3bbb2eda62e611afb97c6 /python/fatcat_web/routes.py
parent15ad67e4cd44c54a0f7a06f0eb0448d75c9ad1b6 (diff)
downloadfatcat-7c04b83a6612b7a0c87afe4a1ed4bbb65568fea1.tar.gz
fatcat-7c04b83a6612b7a0c87afe4a1ed4bbb65568fea1.zip
add container search
And tweak release search a bit: DOIs aren't auto-replaced unless they are the only word/query This query code is very duplicative and should be refactored
Diffstat (limited to 'python/fatcat_web/routes.py')
-rw-r--r--python/fatcat_web/routes.py30
1 files changed, 23 insertions, 7 deletions
diff --git a/python/fatcat_web/routes.py b/python/fatcat_web/routes.py
index f9faf328..7f10ee2b 100644
--- a/python/fatcat_web/routes.py
+++ b/python/fatcat_web/routes.py
@@ -7,7 +7,7 @@ from flask_login import login_required
from fatcat_web import app, api, auth_api, priv_api
from fatcat_web.auth import handle_token_login, handle_logout, load_user, handle_ia_xauth
from fatcat_client.rest import ApiException
-from fatcat_web.search import do_search
+from fatcat_web.search import do_release_search, do_container_search
from fatcat_tools.transforms import *
@@ -351,7 +351,7 @@ def changelog_entry_view(index):
### Search ##################################################################
@app.route('/release/search', methods=['GET', 'POST'])
-def search():
+def release_search():
limit = 20
query = request.args.get('q')
@@ -359,18 +359,34 @@ def search():
# Convert raw DOIs to DOI queries
if query is not None:
- oldquery = query.split()
- for word in oldquery:
- if word.startswith("10.") and word.count("/") >= 1:
- query = query.replace(word, 'doi:"{}"'.format(word))
+ if len(query.split()) == 1 and query.startswith("10.") and query.count("/") >= 1:
+ query = 'doi:"{}"'.format(query)
if 'q' in request.args.keys():
# always do files for HTML
- found = do_search(query, limit=limit, fulltext_only=fulltext_only)
+ found = do_release_search(query, limit=limit, fulltext_only=fulltext_only)
return render_template('release_search.html', found=found, query=query, fulltext_only=fulltext_only)
else:
return render_template('release_search.html', query=query, fulltext_only=fulltext_only)
+@app.route('/container/search', methods=['GET', 'POST'])
+def container_search():
+
+ limit = 20
+ query = request.args.get('q')
+
+ # Convert raw ISSN-L to ISSN-L query
+ if query is not None:
+ if len(query.split()) == 1 and len(query) == 9 and isdigit(query[0:4]) and query[4] == '-':
+ query = 'issnl:"{}"'.format(query)
+
+ if 'q' in request.args.keys():
+ # always do files for HTML
+ found = do_container_search(query, limit=limit)
+ return render_template('container_search.html', found=found, query=query)
+ else:
+ return render_template('container_search.html', query=query)
+
### Auth ####################################################################