aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--CHANGELOG.md1
-rw-r--r--python/fatcat_web/templates/release_view.html13
-rw-r--r--python/tests/web_citation_csl.py26
3 files changed, 39 insertions, 1 deletions
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 @@
</div>
{% endif %}
-
{% if release.extra.is_oa == True %}
<div class="ui segment attached">
<b><i class="ui icon unlock alternate green"></i> Open Access</b>
@@ -408,6 +407,18 @@
<br>grouping other versions (eg, pre-print) and variants of this release
</div>
+{# this restriction, for CSL-JSON generation, rules out almost everything #}
+{% if release.contribs and release.contribs[0].creator_id %}
+<div class="ui segment attached accordion">
+ <div class="title" style="padding: 0px;">
+ <i class="dropdown icon"></i><b>Cite This Release</b>
+ </div>
+ <div class="content">
+ <a href="/release/{{ release.ident }}.bib">BibTeX</a>
+ </div>
+</div>
+{% endif %}
+
<div class="ui segment attached accordion">
<div class="title" style="padding: 0px;"><i class="dropdown icon"></i><b>Lookup Links</b></div>
<div class="content">
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')
+