summaryrefslogtreecommitdiffstats
path: root/python/fatcat_web/routes.py
diff options
context:
space:
mode:
authorBryan Newbold <bnewbold@robocracy.org>2019-06-11 10:43:54 -0700
committerBryan Newbold <bnewbold@robocracy.org>2019-06-13 14:36:59 -0700
commit55ebdd8f06e73ef904e8c216a6e8a67f7fded8d2 (patch)
tree57f12af517a33c41f37de016d555add00bf56c58 /python/fatcat_web/routes.py
parent016315f69a03473625d4d8ea3c450eb814e26911 (diff)
downloadfatcat-55ebdd8f06e73ef904e8c216a6e8a67f7fded8d2.tar.gz
fatcat-55ebdd8f06e73ef904e8c216a6e8a67f7fded8d2.zip
start work on 'generic' search box
Diffstat (limited to 'python/fatcat_web/routes.py')
-rw-r--r--python/fatcat_web/routes.py30
1 files changed, 26 insertions, 4 deletions
diff --git a/python/fatcat_web/routes.py b/python/fatcat_web/routes.py
index ebb70d90..61ba0029 100644
--- a/python/fatcat_web/routes.py
+++ b/python/fatcat_web/routes.py
@@ -9,6 +9,7 @@ from flask_wtf.csrf import CSRFError
from fatcat_client import Editgroup, EditgroupAnnotation
from fatcat_client.rest import ApiException
from fatcat_tools.transforms import *
+from fatcat_tools.normal import *
from fatcat_web import app, api, auth_api, priv_api, mwoauth
from fatcat_web.auth import handle_token_login, handle_logout, load_user, handle_ia_xauth, handle_wmoauth
from fatcat_web.cors import crossdomain
@@ -496,6 +497,31 @@ def reviewable_view():
### Search ##################################################################
+@app.route('/search', methods=['GET', 'POST'])
+def generic_search():
+ if not 'q' in request.args.keys():
+ return redirect('/release/search')
+ query = request.args.get('q').strip()
+
+ if len(query.split()) != 1:
+ # multi-term? must be a real search
+ return redirect(url_for('release_search', q=query))
+
+ if clean_doi(query):
+ return redirect(url_for('release_lookup', doi=clean_doi(query)))
+ if clean_pmcid(query):
+ return redirect(url_for('release_lookup', pmcid=clean_pmcid(query)))
+ if clean_sha1(query):
+ return redirect(url_for('file_lookup', sha1=clean_sha1(query)))
+ if clean_issn(query):
+ return redirect(url_for('container_lookup', issnl=clean_issn(query)))
+ if clean_isbn13(query):
+ return redirect(url_for('release_lookup', isbn13=clean_isbn13(query)))
+ if clean_orcid(query):
+ return redirect(url_for('creator_lookup', orcid=clean_orcid(query)))
+
+ return redirect(url_for('release_search', q=query))
+
@app.route('/release/search', methods=['GET', 'POST'])
def release_search():
@@ -734,10 +760,6 @@ def page_about():
def page_rfc():
return render_template('rfc.html')
-@app.route('/search', methods=['GET'])
-def page_search_redirect():
- return redirect("/release/search")
-
@app.route('/robots.txt', methods=['GET'])
def robots():
return send_from_directory(os.path.join(app.root_path, 'static'),