From 805a8b1001754fb8397e539dbc15a6cfd65661f2 Mon Sep 17 00:00:00 2001 From: Bryan Newbold Date: Wed, 5 Jun 2019 13:27:18 -0700 Subject: release lookup view --- python/fatcat_web/routes.py | 29 +++-- python/fatcat_web/templates/home.html | 1 + python/fatcat_web/templates/release_lookup.html | 140 ++++++++++++++++++++++++ python/tests/web_entity_views.py | 2 +- 4 files changed, 162 insertions(+), 10 deletions(-) create mode 100644 python/fatcat_web/templates/release_lookup.html diff --git a/python/fatcat_web/routes.py b/python/fatcat_web/routes.py index 1a743b7b..5fef1b96 100644 --- a/python/fatcat_web/routes.py +++ b/python/fatcat_web/routes.py @@ -1,8 +1,8 @@ import os import json -from flask import Flask, render_template, send_from_directory, request, \ - url_for, abort, g, redirect, jsonify, session, flash, Response +from flask import Flask, render_template, make_response, send_from_directory, \ + request, url_for, abort, g, redirect, jsonify, session, flash, Response from flask_login import login_required from flask_wtf.csrf import CSRFError @@ -223,14 +223,25 @@ def release_lookup(): 'arxiv', 'core', 'ark', 'mag'): if request.args.get(key): extid = key - break + extid_value = request.args.get(extid) + if extid_value: + extid_value = extid_value.strip() + break if extid is None: - abort(400) - try: - resp = api.lookup_release(**{extid: request.args.get(extid)}) - except ApiException as ae: - app.log.info(ae) - abort(ae.status) + return render_template('release_lookup.html') + try: + resp = api.lookup_release(**{extid: extid_value}) + except ApiException as ae: + if ae.status == 404 or ae.status == 400: + return make_response( + render_template('release_lookup.html', + lookup_key=extid, + lookup_value=extid_value, + lookup_error=ae.status), + ae.status) + else: + app.log.info(ae) + abort(ae.status) return redirect('/release/{}'.format(resp.ident)) @app.route('/release//history', methods=['GET']) diff --git a/python/fatcat_web/templates/home.html b/python/fatcat_web/templates/home.html index 809a859f..23563f07 100644 --- a/python/fatcat_web/templates/home.html +++ b/python/fatcat_web/templates/home.html @@ -66,6 +66,7 @@ indexing (aka, linking together of pre-prints and final copies). +
Other Identifiers Container
journal or serial diff --git a/python/fatcat_web/templates/release_lookup.html b/python/fatcat_web/templates/release_lookup.html new file mode 100644 index 00000000..0495da36 --- /dev/null +++ b/python/fatcat_web/templates/release_lookup.html @@ -0,0 +1,140 @@ +{% extends "base.html" %} + +{% macro lookup_form(key, example, lookup_key, lookup_value, lookup_error) -%} + +{%- endmacro %} + +{% block body %} + +

Lookup Release by Identifier

+ +{% if lookup_error == 400 %} +
+
400: Syntax Error
+{{ lookup_key }}:{{ lookup_value }} doesn't look right to us. See +below for details. +
+{% elif lookup_error == 404 %} +
+
404: Not Found
+Couldn't find a release with that identifier ({{ lookup_key }}:{{ +lookup_value }}). If you think it should be in the catalog, you could +search for an existing record missing that identifier, or create a new release +entity. +{% if lookup_key == "doi" %} +

You can check if it is a registered DOI by visiting: +https://doi.org/{{ lookup_value }} +{% elif lookup_key == "pmcid" %} +

You can check if it is a real PMCID by visiting: +https://www.ncbi.nlm.nih.gov/pmc/articles/{{ lookup_value }}/ +{% else %} +{% endif %} +

+{% endif %} + +
+ +

DOI

+

+Digital object identifer: "it's not an identifier for a digital object, +it's a digital identifier for an object". Except they are pretty much all +digital objects. Fatcat doesn't include all DOIs (eg, for granular components +or TV shows), but it should for all complete research publications. DOIs are +generated by publishers, who pay a fee to registrars like Crossref, Datacite, +or JALC. +{{ lookup_form("doi", "10.1234/abc.5489", lookup_key, lookup_value, lookup_error) }} +  Don't include a URL like "http://dx.doi.org/" + +

+
+ +

PubMed

+

PubMed/MEDLINE is a +catalog of biomedical publications. Catalog updates are published frequently, +and may include deletions. Fatcat currently is only updated with new entries, +it does not delete PMIDs. PubMed is edited by a large staff of trained +catalogers, and has strict inclusion criteria for journals. +{{ lookup_form("pmid", "823835", lookup_key, lookup_value, lookup_error) }} +
+ +

PubMed Central +Identifiers (PMCID) reference works deposited in the US (or European) PMC +repositories. Not all works with a PMCID have a PMID. PMCIDs can be versioned +(eg, with a trailing ".2"), but these are rare and most Fatcat releases only +have the non-versioned PMCID. +{{ lookup_form("pmcid", "PMC93932", lookup_key, lookup_value, lookup_error) }} +  Include the "PMC" prefix. + +

+
+ +

Wikidata QID

+

Wikidata is the +structured, machine-readable database that complements Wikipedia. Entities, +which can include bibliographic entities like books and papers, are identified +by a "QID". Fatcat also links container (journal) and creator (author) entities +to Wikidata by QID. Anybody can edit Wikidata and create QIDs. +{{ lookup_form("wikidata_qid", "Q94324", lookup_key, lookup_value, lookup_error) }} +  Include the "Q" prefix. + +

+
+ +

ARK

+

Archival +Resource Keys are no-cost, distributed identifiers based on URLs. Mostly +used by archival systems (as opposed to publishers or repositories). +{{ lookup_form("ark", "ark:2349/sddd92", lookup_key, lookup_value, lookup_error) }} +  Only the identifier part (starting with "ark:"), not the full URL. + +

+
+ +

ISBN

+

+International Standard Book Number, assigned to specific published versions +of a book (including ebooks). +{{ lookup_form("isbn13", "978-3-16-148410-0", lookup_key, lookup_value, lookup_error) }} +  Canonical ISBN-13 number (not ISBN-9), with hyphens + +

+
+ +

arXiv

+

arXiv identifiers are +generated for works deposited in the free arxiv.org pre-print repository. +Identifiers are generated for each version of a work, eg ending in "v3". Fatcat +releases must be versioned; if you don't know the version you can always lookup +"v1" and then look for other releases under the same work. +{{ lookup_form("arxiv", "0706.0001v1 or math-GT/0309136v2", lookup_key, lookup_value, lookup_error) }} +  Old and new style supported, but version always required for exact lookups. + +

+
+ +

JSTOR

+

JSTOR identifiers +are numbers internally assigned to works archived on +jstor.org. Many works also have a DOI with the +number after a 10.2307/ prefix, but not all works have such a DOI. +Fatcat mostly has JSTOR identifiers for works in the "Early Journal +Collection", which are in the public domain. +{{ lookup_form("jstor", "92492", lookup_key, lookup_value, lookup_error) }} + +

+ +{% endblock %} diff --git a/python/tests/web_entity_views.py b/python/tests/web_entity_views.py index 1adf3fdf..ba1b9f0a 100644 --- a/python/tests/web_entity_views.py +++ b/python/tests/web_entity_views.py @@ -80,7 +80,7 @@ def test_lookups(app): assert rv.status_code == 404 rv = app.get('/release/lookup') - assert rv.status_code == 400 + assert rv.status_code == 200 rv = app.get('/release/lookup?doi=10.123/abc') assert rv.status_code == 302 rv = app.get('/release/lookup?doi=10.123%2Fabc') -- cgit v1.2.3