aboutsummaryrefslogtreecommitdiffstats
path: root/python/fatcat_web/routes.py
diff options
context:
space:
mode:
authorBryan Newbold <bnewbold@robocracy.org>2019-03-18 16:09:13 -0700
committerBryan Newbold <bnewbold@robocracy.org>2019-03-18 16:12:02 -0700
commit81a82573dc78a8cbf2f86100043f74f1305f4c56 (patch)
treea515d387d68361594275e31771da4e7f108fbe57 /python/fatcat_web/routes.py
parent3d82671bd350681c62b53125b887b01543e8ad7c (diff)
downloadfatcat-81a82573dc78a8cbf2f86100043f74f1305f4c56.tar.gz
fatcat-81a82573dc78a8cbf2f86100043f74f1305f4c56.zip
expose bibtex and citeproc; revert /unstable/ prefixes
Diffstat (limited to 'python/fatcat_web/routes.py')
-rw-r--r--python/fatcat_web/routes.py35
1 files changed, 32 insertions, 3 deletions
diff --git a/python/fatcat_web/routes.py b/python/fatcat_web/routes.py
index d660da86..e2c5fc3a 100644
--- a/python/fatcat_web/routes.py
+++ b/python/fatcat_web/routes.py
@@ -2,7 +2,7 @@
import os
import json
from flask import Flask, render_template, send_from_directory, request, \
- url_for, abort, g, redirect, jsonify, session, flash
+ url_for, abort, g, redirect, jsonify, session, flash, Response
from flask_login import login_required
from fatcat_client.rest import ApiException
@@ -507,7 +507,7 @@ def stats_page():
### Pseudo-APIs #############################################################
-@app.route('/unstable/stats.json', methods=['GET', 'OPTIONS'])
+@app.route('/stats.json', methods=['GET', 'OPTIONS'])
@crossdomain(origin='*',headers=['access-control-allow-origin','Content-Type'])
def stats_json():
try:
@@ -518,7 +518,6 @@ def stats_json():
abort(503)
return jsonify(stats)
-@app.route('/unstable/container/issnl/<issnl>/stats.json', methods=['GET', 'OPTIONS'])
@app.route('/container/issnl/<issnl>/stats.json', methods=['GET', 'OPTIONS'])
@crossdomain(origin='*',headers=['access-control-allow-origin','Content-Type'])
def container_issnl_stats(issnl):
@@ -529,6 +528,36 @@ def container_issnl_stats(issnl):
abort(503)
return jsonify(stats)
+@app.route('/release/<ident>.bib', methods=['GET'])
+def release_bibtex(ident):
+ try:
+ entity = api.get_release(ident)
+ except ApiException as ae:
+ abort(ae.status)
+ csl = release_to_csl(entity)
+ bibtex = citeproc_csl(csl, 'bibtex')
+ return Response(bibtex, mimetype="text/plain")
+
+@app.route('/release/<ident>/citeproc', methods=['GET'])
+def release_citeproc(ident):
+ style = request.args.get('style', 'harvard1')
+ is_html = request.args.get('html', False)
+ if is_html and is_html.lower() in ('yes', '1', 'true', 'y', 't'):
+ is_html = True
+ else:
+ is_html = False
+
+ try:
+ entity = api.get_release(ident)
+ except ApiException as ae:
+ abort(ae.status)
+ csl = release_to_csl(entity)
+ cite = citeproc_csl(csl, style, is_html)
+ if is_html:
+ return Response(cite)
+ else:
+ return Response(cite, mimetype="text/plain")
+
### Auth ####################################################################