From 388503d92ff8a1f26a0376cc42cefb077a1d6401 Mon Sep 17 00:00:00 2001 From: Bryan Newbold Date: Wed, 5 Jun 2019 15:56:52 -0700 Subject: more lookup views --- python/fatcat_web/routes.py | 84 ++++++++++++++++++++--- python/fatcat_web/templates/container_lookup.html | 63 +++++++++++++++++ python/fatcat_web/templates/creator_lookup.html | 54 +++++++++++++++ python/fatcat_web/templates/entity_macros.html | 18 +++++ python/fatcat_web/templates/file_lookup.html | 55 +++++++++++++++ python/fatcat_web/templates/home.html | 3 + python/fatcat_web/templates/release_lookup.html | 39 ++++------- 7 files changed, 279 insertions(+), 37 deletions(-) create mode 100644 python/fatcat_web/templates/container_lookup.html create mode 100644 python/fatcat_web/templates/creator_lookup.html create mode 100644 python/fatcat_web/templates/file_lookup.html (limited to 'python/fatcat_web') diff --git a/python/fatcat_web/routes.py b/python/fatcat_web/routes.py index 5fef1b96..7ddd8cca 100644 --- a/python/fatcat_web/routes.py +++ b/python/fatcat_web/routes.py @@ -39,13 +39,32 @@ def container_lookup(): for key in ('issnl', 'wikidata_qid'): 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) + return render_template('container_lookup.html') try: resp = api.lookup_container(**{extid: request.args.get(extid)}) + except ValueError: + return make_response( + render_template('container_lookup.html', + lookup_key=extid, + lookup_value=extid_value, + lookup_error=400), + 400) except ApiException as ae: - abort(ae.status) + if ae.status == 404 or ae.status == 400: + return make_response( + render_template('container_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('/container/{}'.format(resp.ident)) @app.route('/container/', methods=['GET']) @@ -92,13 +111,32 @@ def creator_lookup(): for key in ('orcid', 'wikidata_qid'): 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) + return render_template('creator_lookup.html') try: - resp = api.lookup_creator(**{extid: request.args.get(extid)}) + resp = api.lookup_creator(**{extid: extid_value}) + except ValueError: + return make_response( + render_template('creator_lookup.html', + lookup_key=extid, + lookup_value=extid_value, + lookup_error=400), + 400) except ApiException as ae: - abort(ae.status) + if ae.status == 404 or ae.status == 400: + return make_response( + render_template('creator_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('/creator/{}'.format(resp.ident)) @app.route('/creator/', methods=['GET']) @@ -133,13 +171,32 @@ def file_lookup(): for key in ('md5', 'sha1', 'sha256'): 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) + return render_template('file_lookup.html') try: resp = api.lookup_file(**{extid: request.args.get(extid)}) + except ValueError: + return make_response( + render_template('file_lookup.html', + lookup_key=extid, + lookup_value=extid_value, + lookup_error=400), + 400) except ApiException as ae: - abort(ae.status) + if ae.status == 404 or ae.status == 400: + return make_response( + render_template('file_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('/file/{}'.format(resp.ident)) @app.route('/file/', methods=['GET']) @@ -231,6 +288,13 @@ def release_lookup(): return render_template('release_lookup.html') try: resp = api.lookup_release(**{extid: extid_value}) + except ValueError: + return make_response( + render_template('release_lookup.html', + lookup_key=extid, + lookup_value=extid_value, + lookup_error=400), + 400) except ApiException as ae: if ae.status == 404 or ae.status == 400: return make_response( diff --git a/python/fatcat_web/templates/container_lookup.html b/python/fatcat_web/templates/container_lookup.html new file mode 100644 index 00000000..1848739a --- /dev/null +++ b/python/fatcat_web/templates/container_lookup.html @@ -0,0 +1,63 @@ +{% extends "base.html" %} +{% import "entity_macros.html" as entity_macros %} + +{% block body %} + +

Lookup Container 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 container 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 container +entity. +{% if lookup_key == "doi" %} +

You can check if it is a registered ISSN-L by visiting: +https://portal.issn.org/{{ lookup_value }}. If this is a valid +electronic or print ISSN, but not the ISSN-L for the container, you need to use +the indicated "linking" ISSN. +{% elif lookup_key == "wikidata_qid" %} +

You can check if it is a real Wikidata entity by visiting: +https://www.wikidata.org/wiki/{{ lookup_value }}/ +{% endif %} +

+{% endif %} + +
+ +

ISSN-L

+

The "linking" ISSN for a journal or other publication is one of the +"print" or "electronic" +International +Standard Serial Numbers, which has been selected to represent the resource +in all media. It is usually the ISSN which was registered first, and defaults +to the "print" ISSN number for a journal. Fatcat uses ISSN-L as the primary +identifier for journals to reduce confusion and potential for duplication. The +ISSN organization publicly publishes a mapping between linking and +print/electronic ISSNs. +{{ entity_macros.lookup_form("issnl", "1234-567X", lookup_key, lookup_value, lookup_error) }} +  Must include the dash + +

+
+ +

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. +{{ entity_macros.lookup_form("wikidata_qid", "Q94324", lookup_key, lookup_value, lookup_error) }} +  Include the "Q" prefix. + +

+ +{% endblock %} diff --git a/python/fatcat_web/templates/creator_lookup.html b/python/fatcat_web/templates/creator_lookup.html new file mode 100644 index 00000000..741efbda --- /dev/null +++ b/python/fatcat_web/templates/creator_lookup.html @@ -0,0 +1,54 @@ +{% extends "base.html" %} +{% import "entity_macros.html" as entity_macros %} + +{% block body %} + +

Lookup Creator 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 creator 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 creator +entity. +{% if lookup_key == "orcid" %} +

You can check if it is a registered ORCiD: +https://orcid.org/{{ lookup_value }} +{% elif lookup_key == "wikidata_qid" %} +

You can check if it is a real Wikidata entity by visiting: +https://www.wikidata.org/wiki/{{ lookup_value }}/ +{% endif %} +

+{% endif %} + +
+ +

ORCID

+

Open Researcher and +Contributor ID is used to unambiguously refer to a research author. They +are free to register. +{{ entity_macros.lookup_form("creator", "orcid", "0000-0002-1825-0097", lookup_key, lookup_value, lookup_error) }} +  Must include the dashes + +

+
+ +

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 releases (papers, books) and container (journal) +entities to Wikidata by QID. Anybody can edit Wikidata and create QIDs. +{{ entity_macros.lookup_form("creator", "wikidata_qid", "Q94324", lookup_key, lookup_value, lookup_error) }} +  Include the "Q" prefix. + +

+ +{% endblock %} diff --git a/python/fatcat_web/templates/entity_macros.html b/python/fatcat_web/templates/entity_macros.html index c47782a8..a2b2f996 100644 --- a/python/fatcat_web/templates/entity_macros.html +++ b/python/fatcat_web/templates/entity_macros.html @@ -96,3 +96,21 @@ {%- endmacro %} + +{% macro lookup_form(entity_type, key, example, lookup_key, lookup_value, lookup_error) -%} + +{%- endmacro %} diff --git a/python/fatcat_web/templates/file_lookup.html b/python/fatcat_web/templates/file_lookup.html new file mode 100644 index 00000000..c4255f47 --- /dev/null +++ b/python/fatcat_web/templates/file_lookup.html @@ -0,0 +1,55 @@ +{% extends "base.html" %} +{% import "entity_macros.html" as entity_macros %} + +{% block body %} + +

Lookup File by Hash

+ +{% 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 file with that hash ({{ lookup_key }}:{{ +lookup_value }}). If you think it should be in the catalog, you could +search for an existing record missing that hash, or create a new file +entity. +
+{% endif %} + +
+ +

SHA-1, SHA-256, MD5

+

SHA-1 and +SHA-256 are popular +cryptographic message digests. They can be used to detect accidental +corruption, intentional modification, and can be used as unique identifiers for +a file. The chance of there existing multiple files with the same hash is +effectively zero due to random chance; the chance of somebody having +intentionally created files with the same hash depends on the strength of the +hash function. + +

SHA-256 is considered "strong" today and used in new software. +{{ entity_macros.lookup_form("file", "sha256", "cd65a99c0d95f3208f4ea28bc73f641a6901a22dfb882d14d5c208821b56c09c", lookup_key, lookup_value, lookup_error) }} +  Lower-case hexideximal, 64 characters +

+ +

SHA-1 has shown weaknesses, but is used widely in data archiving software. +{{ entity_macros.lookup_form("file", "sha1", "79ed4e54acdd521ca5f7b52a2964c9c116c3e3bf", lookup_key, lookup_value, lookup_error) }} +  Lower-case hexideximal, 40 characters +

+ +

MD5 is an older but still +commonly used checksum. It was originally designed in 1992 to be +cryptographically secure, but is no longer considered secure in that context. +It is still perfectly adequate for detecting accidental file corruption. +{{ entity_macros.lookup_form("file", "md5", "eebc51dd5684ec7fd07f7ac0c30e7a78", lookup_key, lookup_value, lookup_error) }} +  Lower-case hexideximal, 32 characters + +

+ +{% endblock %} diff --git a/python/fatcat_web/templates/home.html b/python/fatcat_web/templates/home.html index 23563f07..87968f30 100644 --- a/python/fatcat_web/templates/home.html +++ b/python/fatcat_web/templates/home.html @@ -84,6 +84,7 @@ indexing (aka, linking together of pre-prints and final copies). +
Other Identifiers Creator @@ -102,6 +103,7 @@ indexing (aka, linking together of pre-prints and final copies). +
Other Identifiers File
specific digital blobs (immutable) @@ -118,6 +120,7 @@ indexing (aka, linking together of pre-prints and final copies). +
Other Hashes File Set
datasets, suplementary materials diff --git a/python/fatcat_web/templates/release_lookup.html b/python/fatcat_web/templates/release_lookup.html index 0495da36..924d70db 100644 --- a/python/fatcat_web/templates/release_lookup.html +++ b/python/fatcat_web/templates/release_lookup.html @@ -1,22 +1,5 @@ {% extends "base.html" %} - -{% macro lookup_form(key, example, lookup_key, lookup_value, lookup_error) -%} - -{%- endmacro %} +{% import "entity_macros.html" as entity_macros %} {% block body %} @@ -41,7 +24,9 @@ entity. {% 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 %} +{% elif lookup_key == "wikidata_qid" %} +

You can check if it is a real Wikidata entity by visiting: +https://www.wikidata.org/wiki/{{ lookup_value }}/ {% endif %} {% endif %} @@ -56,7 +41,7 @@ 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) }} +{{ entity_macros.lookup_form("release", "doi", "10.1234/abc.5489", lookup_key, lookup_value, lookup_error) }}   Don't include a URL like "http://dx.doi.org/" @@ -68,7 +53,7 @@ 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) }} +{{ entity_macros.lookup_form("release", "pmid", "823835", lookup_key, lookup_value, lookup_error) }}

PubMed Central @@ -76,7 +61,7 @@ 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) }} +{{ entity_macros.lookup_form("release", "pmcid", "PMC93932", lookup_key, lookup_value, lookup_error) }}   Include the "PMC" prefix. @@ -88,7 +73,7 @@ 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) }} +{{ entity_macros.lookup_form("release", "wikidata_qid", "Q94324", lookup_key, lookup_value, lookup_error) }}   Include the "Q" prefix. @@ -98,7 +83,7 @@ to Wikidata by QID. Anybody can edit Wikidata and create QIDs.

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) }} +{{ entity_macros.lookup_form("release", "ark", "ark:2349/sddd92", lookup_key, lookup_value, lookup_error) }}   Only the identifier part (starting with "ark:"), not the full URL. @@ -108,7 +93,7 @@ used by archival systems (as opposed to publishers or repositories).

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) }} +{{ entity_macros.lookup_form("release", "isbn13", "978-3-16-148410-0", lookup_key, lookup_value, lookup_error) }}   Canonical ISBN-13 number (not ISBN-9), with hyphens @@ -120,7 +105,7 @@ 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) }} +{{ entity_macros.lookup_form("release", "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. @@ -133,7 +118,7 @@ are numbers internally assigned to works archived on 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) }} +{{ entity_macros.lookup_form("release", "jstor", "92492", lookup_key, lookup_value, lookup_error) }} -- cgit v1.2.3