From 8409128c47a287ccdf4d5092f094648495367e5a Mon Sep 17 00:00:00 2001 From: Bryan Newbold Date: Thu, 4 Apr 2019 11:59:28 -0700 Subject: link to BibTeX (and test this) --- CHANGELOG.md | 1 + python/fatcat_web/templates/release_view.html | 13 ++++++++++++- python/tests/web_citation_csl.py | 26 ++++++++++++++++++++++++++ 3 files changed, 39 insertions(+), 1 deletion(-) create mode 100644 python/tests/web_citation_csl.py diff --git a/CHANGELOG.md b/CHANGELOG.md index 7b11cb40..7e8312fe 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -21,6 +21,7 @@ See also: - many tweaks to webface and guide - basic release, container, file webface editing - basic editgroup annotation and control (submit/accept) in webface +- CSL/BibTeX citation endpoints ## [0.2.0] - 2019-02-05 diff --git a/python/fatcat_web/templates/release_view.html b/python/fatcat_web/templates/release_view.html index fa157193..ef77360f 100644 --- a/python/fatcat_web/templates/release_view.html +++ b/python/fatcat_web/templates/release_view.html @@ -360,7 +360,6 @@ {% endif %} - {% if release.extra.is_oa == True %}
Open Access @@ -408,6 +407,18 @@
grouping other versions (eg, pre-print) and variants of this release
+{# this restriction, for CSL-JSON generation, rules out almost everything #} +{% if release.contribs and release.contribs[0].creator_id %} +
+
+ Cite This Release +
+
+ BibTeX +
+
+{% endif %} +
Lookup Links
diff --git a/python/tests/web_citation_csl.py b/python/tests/web_citation_csl.py new file mode 100644 index 00000000..1b6f34e1 --- /dev/null +++ b/python/tests/web_citation_csl.py @@ -0,0 +1,26 @@ + + +import json +import tempfile +import pytest +from fatcat_client.rest import ApiException +from fixtures import * + + +def test_release_bibtex(app): + + # "realistic" demo entity + rv = app.get('/release/aaaaaaaaaaaaarceaaaaaaaaam') + assert rv.status_code == 200 + assert b'BibTeX' in rv.data + rv = app.get('/release/aaaaaaaaaaaaarceaaaaaaaaam.bib') + assert rv.status_code == 200 + assert b'@article{' in rv.data + + # "dummy" demo entity + rv = app.get('/release/aaaaaaaaaaaaarceaaaaaaaaai') + assert rv.status_code == 200 + assert not b'BibTeX' in rv.data + with pytest.raises(ValueError): + rv = app.get('/release/aaaaaaaaaaaaarceaaaaaaaaai.bib') + -- cgit v1.2.3