From d5b24df069fc96d396afbb302633a077e5dbfb39 Mon Sep 17 00:00:00 2001 From: Bryan Newbold Date: Thu, 15 Apr 2021 18:34:11 -0700 Subject: first iteration of basic citation inbound/outbound views --- .../templates/release_view_fuzzy_refs.html | 95 ++++++++++++++++++++++ 1 file changed, 95 insertions(+) create mode 100644 python/fatcat_web/templates/release_view_fuzzy_refs.html (limited to 'python/fatcat_web/templates/release_view_fuzzy_refs.html') diff --git a/python/fatcat_web/templates/release_view_fuzzy_refs.html b/python/fatcat_web/templates/release_view_fuzzy_refs.html new file mode 100644 index 00000000..bc1fa171 --- /dev/null +++ b/python/fatcat_web/templates/release_view_fuzzy_refs.html @@ -0,0 +1,95 @@ +{% set release = entity %} +{% set entity_view = "references" %} +{% set entity_type = "release" %} +{% import "entity_macros.html" as entity_macros %} +{% extends "entity_base.html" %} + +{% block entity_main %} + +{% if direction == "inbound" %} +

Inbound Matched References

+ Other releases citing this one +{% elif direction == "outbound" %} +

Outbound Matched References

+ This release citing other releases +{% endif %} + +

Found {{ hits.count_total }} references in {{ hits.query_wall_time_ms }}ms. +{% if hits.count_total != hits.count_returned %} + Showing {{ hits.offset + 1 }} - {{ hits.offset + hits.count_returned }} + {% if hits.offset + hits.limit < hits.count_total %} +  next... + {% endif %} +{% endif %} + + + +{% for ref in enriched_refs %} + {% set release = ref.release %} + +
+ {% if direction == "outbound" %} + {% if ref.ref.ref_key %} + [{{ ref.ref.ref_key }}] + {% endif %} + {% endif %} +
{{ ref.ref.match_status }} +
{{ ref.ref.match_provenance }} +
+ {{ release.title }} + {% if release.release_type not in ["article-journal", "conference-paper"] %} + [{{ release.release_type or "unknown-type" }}] + {% endif %} +
+ {% for contrib in release.contribs[:5] %} + {% if contrib.creator %} + {{ contrib.creator.display_name }} + {% else %} + {{ contrib.raw_name }} + {% endif %} + {% if not loop.last %}, {% endif %} + {% endfor %} + {% if release.contribs | length > 5 %}(+ more) {%endif %} +
+ {% if release.release_year %}{{ release.release_year }}  {% endif %} + {% if release.container %} + {{ release.container.name }} + {% elif release.extra and release.extra.container_name %} + {{ release.extra.container_name }} + {% endif %} + {% if release.release_stage != "published" %} +  {{ release.release_stage or "unpublished" }} + {% endif %} + +
+ {% if release.version %} + version:{{ release.release_year }}  + {% endif %} + {% if release.number %} + number:{{ release.number }}  + {% endif %} + {% if release.ext_ids.doi %} + doi:{{ release.ext_ids.doi }}  + {% endif %} + {# TODO: links #} + {% if release.ext_ids.arxiv %} + arXiv:{{ release.ext_ids.arxiv }}  + {% endif %} + {% if release.ext_ids.pmcid %} + pmcid:{{ release.ext_ids.pmcid }}  + {% endif %} + {% if release.ext_ids.pmid %} + pmid:{{ release.ext_ids.pmid }}  + {% endif %} + {% if release.ext_ids.dblp %} + dblp:{{ release.ext_ids.dblp }}  + {% endif %} +
+ {% if ref.access %} + {{ ref.access[0].access_type.name }} + {% endif %} +{% endfor %} +
+ +{% endblock %} + -- cgit v1.2.3 From 570074b514259bf6345c376faea8128f279bd0b4 Mon Sep 17 00:00:00 2001 From: Bryan Newbold Date: Thu, 15 Apr 2021 23:48:06 -0700 Subject: web: inbound/outbound refs as links (temporarily); change URL names --- python/fatcat_web/ref_routes.py | 4 ++-- python/fatcat_web/templates/entity_base.html | 4 ++++ python/fatcat_web/templates/release_view_fuzzy_refs.html | 2 +- 3 files changed, 7 insertions(+), 3 deletions(-) (limited to 'python/fatcat_web/templates/release_view_fuzzy_refs.html') diff --git a/python/fatcat_web/ref_routes.py b/python/fatcat_web/ref_routes.py index dc39299f..bd8ae550 100644 --- a/python/fatcat_web/ref_routes.py +++ b/python/fatcat_web/ref_routes.py @@ -18,7 +18,7 @@ from fatcat_web.forms import * from fatcat_web.entity_helpers import * -@app.route('/release//refs/inbound', methods=['GET']) +@app.route('/release//inbound-refs', methods=['GET']) def release_view_refs_inbound(ident): # lookup release ident, ensure it exists @@ -35,7 +35,7 @@ def release_view_refs_inbound(ident): return render_template('release_view_fuzzy_refs.html', direction="inbound", entity=release, hits=hits, enriched_refs=enriched_refs), 200 -@app.route('/release//refs/outbound', methods=['GET']) +@app.route('/release//outbound-refs', methods=['GET']) def release_view_refs_outbound(ident): # lookup release ident, ensure it exists diff --git a/python/fatcat_web/templates/entity_base.html b/python/fatcat_web/templates/entity_base.html index 36280f5d..c23dbef2 100644 --- a/python/fatcat_web/templates/entity_base.html +++ b/python/fatcat_web/templates/entity_base.html @@ -86,6 +86,10 @@ {% elif entity_type == "release" and entity.state != 'deleted' %} {{ entity_tab("contribs", "Authors", "/contribs", entity._authors|count ) }} {{ entity_tab("references", "References", "/references", entity.refs|count) }} + {% if entity.state == 'active' %} + {{ entity_tab("inbound-refs", "Inbound", "/inbound-refs") }} + {{ entity_tab("outbound-refs", "Outbound", "/outbound-refs") }} + {% endif %} {% endif %} {{ entity_tab("metadata", "Metadata", "/metadata") }} diff --git a/python/fatcat_web/templates/release_view_fuzzy_refs.html b/python/fatcat_web/templates/release_view_fuzzy_refs.html index bc1fa171..9ceb6060 100644 --- a/python/fatcat_web/templates/release_view_fuzzy_refs.html +++ b/python/fatcat_web/templates/release_view_fuzzy_refs.html @@ -1,5 +1,5 @@ {% set release = entity %} -{% set entity_view = "references" %} +{% set entity_view = "{{ direction }}-refs" %} {% set entity_type = "release" %} {% import "entity_macros.html" as entity_macros %} {% extends "entity_base.html" %} -- cgit v1.2.3 From c2395869ff7860bb2c7f080fd6c097e299ea58bf Mon Sep 17 00:00:00 2001 From: Bryan Newbold Date: Wed, 23 Jun 2021 19:49:36 -0700 Subject: fixes for newer ref index --- python/fatcat_tools/references.py | 2 +- .../templates/release_view_fuzzy_refs.html | 59 ++++------------------ 2 files changed, 11 insertions(+), 50 deletions(-) (limited to 'python/fatcat_web/templates/release_view_fuzzy_refs.html') diff --git a/python/fatcat_tools/references.py b/python/fatcat_tools/references.py index 7e1f4f71..976967d4 100644 --- a/python/fatcat_tools/references.py +++ b/python/fatcat_tools/references.py @@ -68,7 +68,7 @@ class BiblioRef(BaseModel): # skipped: target_wikipedia_article # crossref, pubmed, grobid, etc - match_provenance: str + match_provenance: Optional[str] # strong, weak, etc match_status: Optional[str] # TODO: "match_strength"? diff --git a/python/fatcat_web/templates/release_view_fuzzy_refs.html b/python/fatcat_web/templates/release_view_fuzzy_refs.html index 9ceb6060..ee39d15b 100644 --- a/python/fatcat_web/templates/release_view_fuzzy_refs.html +++ b/python/fatcat_web/templates/release_view_fuzzy_refs.html @@ -33,56 +33,17 @@ {% endif %} {% endif %}
{{ ref.ref.match_status }} -
{{ ref.ref.match_provenance }} + {% if ref.ref.match_provenance %} +
{{ ref.ref.match_provenance }} + {% endif %} - {{ release.title }} - {% if release.release_type not in ["article-journal", "conference-paper"] %} - [{{ release.release_type or "unknown-type" }}] - {% endif %} -
- {% for contrib in release.contribs[:5] %} - {% if contrib.creator %} - {{ contrib.creator.display_name }} - {% else %} - {{ contrib.raw_name }} - {% endif %} - {% if not loop.last %}, {% endif %} - {% endfor %} - {% if release.contribs | length > 5 %}(+ more) {%endif %} -
- {% if release.release_year %}{{ release.release_year }}  {% endif %} - {% if release.container %} - {{ release.container.name }} - {% elif release.extra and release.extra.container_name %} - {{ release.extra.container_name }} - {% endif %} - {% if release.release_stage != "published" %} -  {{ release.release_stage or "unpublished" }} - {% endif %} - -
- {% if release.version %} - version:{{ release.release_year }}  - {% endif %} - {% if release.number %} - number:{{ release.number }}  - {% endif %} - {% if release.ext_ids.doi %} - doi:{{ release.ext_ids.doi }}  - {% endif %} - {# TODO: links #} - {% if release.ext_ids.arxiv %} - arXiv:{{ release.ext_ids.arxiv }}  - {% endif %} - {% if release.ext_ids.pmcid %} - pmcid:{{ release.ext_ids.pmcid }}  - {% endif %} - {% if release.ext_ids.pmid %} - pmid:{{ release.ext_ids.pmid }}  - {% endif %} - {% if release.ext_ids.dblp %} - dblp:{{ release.ext_ids.dblp }}  - {% endif %} + {% if release %} + {% entity_macros.release_summary(release) %} + {% elif ref.ref.target_unstructured %} + {{ ref.ref.target_unstructured }} + {% else %} + blank + {% endif %} {% if ref.access %} {{ ref.access[0].access_type.name }} -- cgit v1.2.3 From 61ed521cc40c1ee76692e9c4054e89fa63320600 Mon Sep 17 00:00:00 2001 From: Bryan Newbold Date: Thu, 24 Jun 2021 18:45:08 -0700 Subject: improvements to fuzzy refs view - fixes to release summary macro - show tab counts correctly by re-using generic entity get helper - table styling; 'prev' link - openlibrary access links - parse-and-match button for unmatched+unstructured refs --- python/fatcat_web/ref_routes.py | 12 +-- python/fatcat_web/templates/entity_macros.html | 17 ++-- .../templates/release_view_fuzzy_refs.html | 93 +++++++++++++++------- 3 files changed, 75 insertions(+), 47 deletions(-) (limited to 'python/fatcat_web/templates/release_view_fuzzy_refs.html') diff --git a/python/fatcat_web/ref_routes.py b/python/fatcat_web/ref_routes.py index bd8ae550..e08aaf15 100644 --- a/python/fatcat_web/ref_routes.py +++ b/python/fatcat_web/ref_routes.py @@ -21,11 +21,7 @@ from fatcat_web.entity_helpers import * @app.route('/release//inbound-refs', methods=['GET']) def release_view_refs_inbound(ident): - # lookup release ident, ensure it exists - try: - release = api.get_release(ident) - except ApiException as ae: - abort(ae.status) + release = generic_get_entity("release", ident) offset = request.args.get('offset', '0') offset = max(0, int(offset)) if offset.isnumeric() else 0 @@ -38,11 +34,7 @@ def release_view_refs_inbound(ident): @app.route('/release//outbound-refs', methods=['GET']) def release_view_refs_outbound(ident): - # lookup release ident, ensure it exists - try: - release = api.get_release(ident) - except ApiException as ae: - abort(ae.status) + release = generic_get_entity("release", ident) offset = request.args.get('offset', '0') offset = max(0, int(offset)) if offset.isnumeric() else 0 diff --git a/python/fatcat_web/templates/entity_macros.html b/python/fatcat_web/templates/entity_macros.html index 94770afb..24d1b6d0 100644 --- a/python/fatcat_web/templates/entity_macros.html +++ b/python/fatcat_web/templates/entity_macros.html @@ -394,30 +394,29 @@ yellow {% if release.release_type not in ["article-journal", "conference-paper"] %} [{{ release.release_type or "unknown-type" }}] {% endif %} -
+ {% if release.contribs %}
{% endif %} {% for contrib in release.contribs[:5] %} {% if contrib.creator %} - {{ contrib.creator.display_name }} + {{ contrib.creator.display_name }} {% else %} {{ contrib.raw_name }} - {% endif %} - {% if not loop.last %}, {% endif %} + {%- endif %} + {%- if not loop.last %}, {% endif %} {% endfor %} - {% if release.contribs | length > 5 %}(+ more) {%endif %} -
+ {% if release.contribs | length > 5 %} (+ more) {%endif %} + {% if release.release_year or release.container or (release.extra and release.extra.container_name) %}
{% endif %} {% if release.release_year %}{{ release.release_year }}  {% endif %} {% if release.container %} - {{ release.container.name }} + {{ release.container.name }} {% elif release.extra and release.extra.container_name %} {{ release.extra.container_name }} {% endif %} {% if release.release_stage != "published" %}  {{ release.release_stage or "unpublished" }} {% endif %} -
{% if release.version %} - version:{{ release.release_year }}  + version:{{ release.version }}  {% endif %} {% if release.number %} number:{{ release.number }}  diff --git a/python/fatcat_web/templates/release_view_fuzzy_refs.html b/python/fatcat_web/templates/release_view_fuzzy_refs.html index ee39d15b..7b286fd3 100644 --- a/python/fatcat_web/templates/release_view_fuzzy_refs.html +++ b/python/fatcat_web/templates/release_view_fuzzy_refs.html @@ -4,53 +4,90 @@ {% import "entity_macros.html" as entity_macros %} {% extends "entity_base.html" %} +{% macro pagination_row(hits) %} + + {% if hits.offset %} + « prev   + {% endif %} + Showing {{ hits.offset + 1 }} - {{ hits.offset + hits.count_returned }} of {{ hits.count_total}} references (in {{ hits.query_wall_time_ms }}ms) + {% if hits.count_total != hits.count_returned and hits.offset + hits.limit < hits.count_total %} +  next » + {% endif %} +{% endmacro %} + {% block entity_main %} {% if direction == "inbound" %} -

Inbound Matched References

- Other releases citing this one +

Referenced By

+ Citations to this release by other works. {% elif direction == "outbound" %} -

Outbound Matched References

- This release citing other releases -{% endif %} - -

Found {{ hits.count_total }} references in {{ hits.query_wall_time_ms }}ms. -{% if hits.count_total != hits.count_returned %} - Showing {{ hits.offset + 1 }} - {{ hits.offset + hits.count_returned }} - {% if hits.offset + hits.limit < hits.count_total %} -  next... - {% endif %} +

References

+ NOTE: currently batch computed and may include additional references sources, or be missing recent changes, compared to entity reference list. {% endif %} - +{% if enriched_refs %} +
+ + -{% for ref in enriched_refs %} - {% set release = ref.release %} - +{% if hits.count_total != hits.count_returned %} + + +{% endif %}
+ {{ pagination_row(hits) }} +
+{% for row in enriched_refs %} + {% set release = row.release %} +
+ {# TODO: ref_locator? #} {% if direction == "outbound" %} - {% if ref.ref.ref_key %} - [{{ ref.ref.ref_key }}] + {% if row.ref.ref_key %} + [{{ row.ref.ref_key }}]
{% endif %} {% endif %} -
{{ ref.ref.match_status }} - {% if ref.ref.match_provenance %} -
{{ ref.ref.match_provenance }} + {{ row.ref.match_status }}
+ {% if row.ref.match_provenance %} + via {{ row.ref.match_provenance }} {% endif %}
{% if release %} - {% entity_macros.release_summary(release) %} - {% elif ref.ref.target_unstructured %} - {{ ref.ref.target_unstructured }} + {{ entity_macros.release_summary(release) }} + {% elif row.ref.target_unstructured %} + {{ row.ref.target_unstructured }} {% else %} blank {% endif %} - - {% if ref.access %} - {{ ref.access[0].access_type.name }} - {% endif %} + + {% if row.access %} + {% for access in row.access %} + {{ access.access_type.name }}
+ {% endfor %} + {% elif row.ref.target_unstructured %} +
+ + + +
+ {% endif %} + + {# TODO: include these as access options instead #} + {% if row.ref.target_openlibrary_work %} + openlibrary.org + {% endif %} + {% if row.ref.target_url %} + web +
wayback (?) + {% endif %} {% endfor %}
+ {{ pagination_row(hits) }} +
+{% else %} +

None found +{% endif %} {% endblock %} -- cgit v1.2.3 From 7489ef7a979574effa74f1f17cebb81eefb1b71a Mon Sep 17 00:00:00 2001 From: Bryan Newbold Date: Fri, 23 Jul 2021 11:56:42 -0700 Subject: refs: refactor web paths; enrich refs as generic; remove old refs link --- proposals/2021-01-29_citation_api.md | 102 ++++++++------------- python/fatcat_tools/references.py | 85 +++++++---------- python/fatcat_web/ref_routes.py | 16 ++-- python/fatcat_web/templates/entity_base.html | 5 +- .../templates/release_view_fuzzy_refs.html | 12 +-- 5 files changed, 91 insertions(+), 129 deletions(-) (limited to 'python/fatcat_web/templates/release_view_fuzzy_refs.html') diff --git a/proposals/2021-01-29_citation_api.md b/proposals/2021-01-29_citation_api.md index 1e329d61..f8d9e676 100644 --- a/proposals/2021-01-29_citation_api.md +++ b/proposals/2021-01-29_citation_api.md @@ -41,13 +41,13 @@ into a columnar file format like Parquet to get storage efficiency advances, type/schema enforcement, and easier ingest and use for large-scale data analysis. -TODO: more? - ## Schemas First, a combined JSON/pydantic/elasticsearch object that represents a -reference between two things: +reference from one thing to another, where the "source" must be known, but the +"target" may either be known ("matched") or ambiguous (eg, just a reference +string): BiblioRef ("bibliographic reference") _key: Optional[str] elasticsearch doc key @@ -60,8 +60,6 @@ reference between two things: source_work_ident: Optional[str] source_wikipedia_article: Optional[str] with lang prefix like "en:Superglue" - # skipped: source_openlibrary_work - # skipped: source_url_surt source_release_stage: Optional[str] source_year: Optional[int] @@ -71,7 +69,9 @@ reference between two things: ref_key: Optional[str] eg, "Lee86", "BIB23" ref_locator: Optional[str] - eg, page number + eg, specific page number in the book being referenced, if + applicable. Not used for, eg, first page of paper in a + volume/issue. # target of reference (identifiers) target_release_ident: Optional[str] @@ -82,15 +82,15 @@ reference between two things: would not be stored in elasticsearch, but would be auto-generated by all "get" methods from the SURT, so calling code does not need to do SURT transform - # skipped: target_wikipedia_article match_provenance: str crossref, pubmed, grobid, etc + TODO: "ref_provenance" match_status: Optional[str] strong, weak, etc - TODO: "match_strength"? + TODO: "match_strength"? "match_confidence"? match_reason: Optional[str] - "doi", "isbn", "fuzzy title, author", etc + "doi", "isbn", "title-fuzzy, author", etc maybe "fuzzy-title-author"? target_unstructured: string (only if no release_ident link/match) @@ -116,33 +116,22 @@ jinja templated to display lists of references in the user interface. size_bytes: Optional[int] thumbnail_url: Optional[str] - CslBiblioRef - # an "enriched" version of BiblioRef with metadata about the source or - # target entity. would be "hydrated" via a lookup to, eg, the - # `fatcat_release` elasticsearch index (fast mget fetch with a single - # request), as opposed to fatcat API fetches - biblio_ref: BiblioRef - source_csl/target_csl: free-form CSL-JSON - source_access/target_access: List[AccessOption] - - FatcatBiblioRef + EnrichedBiblioRef # enriched version of BiblioRef with complete ReleaseEntity object as - # fetched from the fatcat API. CSL-JSON metadata would be derived from - # the full release entity. + # fetched from entity catalogs, if available. For example, fatcat API. biblio_ref: BiblioRef source_release/target_release: Optional[ReleaseEntity] complete ReleaseEntity from API, with optional expand/hide fields - source_csl/target_csl: free-form CSL-JSON - CSL-JSON version of ReleaseEntity metadata source_access/target_access: List[AccessOption] + # TODO: target_openlibrary? source_wikipedia? ## Datastore Would store in Elasticsearch as a live database, at least to start. -TODO: try generating ~1 million of these objects to estimate index size (at -billions of docs). +Example Elasticsearch index `fatcat_ref_v02_20210716` has 1.8 billion docs +(references), and consumes 435 GBytes of disk. Might be reasonable to use PostgreSQL in the future, with more explicit control over indexes and tuning for latency. But Elasticsearch is pretty easy to @@ -172,59 +161,46 @@ operate (eg, replicas). count_inbound_refs(...) -> int same parameters as get_inbound_refs(), but returns just a count - get_all_outbound_refs(...) -> List[BiblioRef] - get_all_inbound_refs(...) -> List[BiblioRef] - same as get_outbound_refs()/get_inbound_refs(), but does a scroll (return list or iterator?) - (optional; maybe not public) + # UNIMPLEMENTED + #get_all_outbound_refs(...) -> List[BiblioRef] + #get_all_inbound_refs(...) -> List[BiblioRef] + # same as get_outbound_refs()/get_inbound_refs(), but does a scroll (return list or iterator?) + # (optional; maybe not public) - # run elasticsearch mget query for all ref idents and include "enriched" refs when possible - # for outbound URL refs, would do wayback CDX fetches to find a direct wayback URL - # TODO: for openlibrary, would this query openlibrary.org API? or some fatcat-specific index? - enrich_inbound_refs(refs: List[BiblioRef]) -> List[CslBiblioRef] - enrich_outbound_refs(refs: List[BiblioRef]) -> List[CslBiblioRef] - - # run fatcat API fetches for each ref and return "enriched" refs - enrich_inbound_refs_fatcat(refs: List[BiblioRef], hide, expand) -> List[FatcatBiblioRef] - enrich_outbound_refs_fatcat(refs: List[BiblioRef], hide, expand) -> List[FatcatBiblioRef] + # run catalog API fetches for each and return "enriched" refs + enrich_inbound_refs(refs: List[BiblioRef], hide, expand) -> List[EnrichedBiblioRef] + enrich_outbound_refs(refs: List[BiblioRef], hide, expand) -> List[EnrichedBiblioRef] ## HTTP API Endpoints -Possible HTTP API endpoints... not even sure we would use these or expose them -publicly? - - citations-api.fatcat.wiki - /refs/inbound - &release_ident= - &work_ident= - &openlibrary_work= - &url= - /refs/outbound - &release_ident= - &work_ident= - /refs/csl/outbound - /refs/fatcat/outbound - - api.fatcat.wiki/citations/v0 - /inbound - - fatcat.wiki/release/{release_ident}/refs/outbound.json - fatcat.wiki/work/{work_ident}/refs/outbound.json - &filter_type - &filter_stage +Initial web endpoints, including unstable pseudo-APIs: + + fatcat.wiki/release/{release_ident}/refs/in (and .json) + fatcat.wiki/release/{release_ident}/refs/out (and .json) &limit &offset + &sort (for inbound) + &filter_stage (for inbound) - fatcat.wiki/refs/openlibrary/{openlibrary_ident}/inbound.json + fatcat.wiki/openlibrary/{openlibrary_ident}/refs/in (and .json) + &limit + &offset + &sort + &filter_stage - fatcat.wiki/refs/url/inbound.json + fatcat.wiki/web/refs/in (and .json) &url= + &limit + &offset + &sort (newest, oldest) + &filter_stage ## Design Notes This proposed schema is relatively close to what the "normalize" SQL table would look like (many-to-many relationship). -Especiall for "redistributing as bulk corpus", we might want to consider an +Especially for "redistributing as bulk corpus", we might want to consider an alternative data model which is a single source entity containing a list of outbound references. Could even be a single source *work* for fatcat content, with many release under the entity. One advantage of this is that source diff --git a/python/fatcat_tools/references.py b/python/fatcat_tools/references.py index 1d8a0d0d..a0079efd 100644 --- a/python/fatcat_tools/references.py +++ b/python/fatcat_tools/references.py @@ -3,26 +3,13 @@ Helper routines for working with the fatcat citation graph, which is a separate index of reference links between works in the main catalog. See bulk citation and citation API proposals for design documentation. - -TODO: - - surt_ify() helper (URL to SURT for queries) - CSL enrichment method (using only elasticsearch mget) - CSL enrichment for fatcat enrichment - access transform - microfilm access in access transform - - all_outbound_refs(...) -> List[BiblioRef] - all_inbound_refs(...) -> List[BiblioRef] - same as get_outbound_refs()/get_inbound_refs(), but does a scroll (return list or iterator?) - (optional; maybe not public) """ import sys import json import datetime import argparse -from typing import Optional, List, Any, Dict +from typing import Optional, List, Any, Dict, Union from pydantic import BaseModel import elasticsearch @@ -45,8 +32,6 @@ class BiblioRef(BaseModel): source_work_ident: Optional[str] # with lang prefix like "en:Superglue" source_wikipedia_article: Optional[str] - # skipped: source_openlibrary_work - # skipped: source_url_surt source_release_stage: Optional[str] source_year: Optional[int] @@ -65,7 +50,6 @@ class BiblioRef(BaseModel): target_url_surt: Optional[str] # would not be stored in elasticsearch, but would be auto-generated by all "get" methods from the SURT, so calling code does not need to do SURT transform target_url: Optional[str] - # skipped: target_wikipedia_article # crossref, pubmed, grobid, etc match_provenance: Optional[str] @@ -92,31 +76,20 @@ class BiblioRef(BaseModel): # TODO: if target_openlibrary_work, add an access option? return self -class CslBiblioRef(BaseModel): - # an "enriched" version of BiblioRef with metadata about the source or - # target entity. would be "hydrated" via a lookup to, eg, the - # `fatcat_release` elasticsearch index (fast mget fetch with a single - # request), as opposed to fatcat API fetches - ref: BiblioRef - csl: Optional[Dict[str, Any]] - access: List[AccessOption] - - class Config: - arbitrary_types_allowed = True -class FatcatBiblioRef(BaseModel): +class EnrichedBiblioRef(BaseModel): # enriched version of BiblioRef with complete ReleaseEntity object as # fetched from the fatcat API. CSL-JSON metadata would be derived from # the full release entity. ref: BiblioRef release: Optional[ReleaseEntity] # TODO: openlibrary work? - #csl: Optional[Dict[str, Any]] access: List[AccessOption] class Config: arbitrary_types_allowed = True + class RefHits(BaseModel): count_returned: int count_total: int @@ -124,9 +97,13 @@ class RefHits(BaseModel): limit: int query_time_ms: int query_wall_time_ms: int - result_refs: List[BiblioRef] + result_refs: List[Union[BiblioRef,EnrichedBiblioRef]] -def _execute_ref_query(search: Any, limit: int, offset: Optional[int] = None) -> List[BiblioRef]: + +def _execute_ref_query(search: Any, limit: int, offset: Optional[int] = None) -> RefHits: + """ + Internal helper for querying elasticsearch refs index and transforming hits + """ limit = min((int(limit or 15), 200)) if not offset or offset < 0: @@ -179,7 +156,7 @@ def get_outbound_refs( limit: int = 100, offset: Optional[int] = None, es_index: str = "fatcat_ref", -) -> List[BiblioRef]: +) -> RefHits: search = Search(using=es_client, index=es_index) @@ -199,6 +176,7 @@ def get_outbound_refs( hits.result_refs = sorted(hits.result_refs, key=lambda r: r.ref_index or 0) return hits + def get_inbound_refs( es_client: Any, release_ident: Optional[str] = None, @@ -208,12 +186,11 @@ def get_inbound_refs( url: Optional[str] = None, consolidate_works: bool = True, filter_stage: List[str] = [], - filter_type: List[str] = [], + sort: Optional[str] = None, limit: int = 25, offset: Optional[int] = None, es_index: str = "fatcat_ref", ) -> List[BiblioRef]: - # TODO: filter_stage, filter_type if url and not url_surt: url = surt_ify(url) @@ -239,10 +216,19 @@ def get_inbound_refs( else: raise ValueError("require a lookup key") - search = search.sort("-source_year") + if filter_stage: + search = search.filter("term", source_stage=filter_stage) + + if sort == "newest": + search = search.sort("-source_year") + elif sort == "oldest": + search = search.sort("source_year") + else: + search = search.sort("-source_year") return _execute_ref_query(search, limit=limit, offset=offset) + def count_inbound_refs( es_client: Any, release_ident: Optional[str] = None, @@ -251,7 +237,6 @@ def count_inbound_refs( url_surt: Optional[str] = None, url: Optional[str] = None, filter_stage: List[str] = [], - filter_type: List[str] = [], es_index: str = "fatcat_ref", ) -> int: """ @@ -274,28 +259,26 @@ def count_inbound_refs( else: raise ValueError("require a lookup key") + if filter_stage: + search = search.filter("term", source_stage=filter_stage) + return search.count() -# run elasticsearch mget query for all ref idents and include "enriched" refs when possible -# for outbound URL refs, would do wayback CDX fetches to find a direct wayback URL -# TODO: for openlibrary, would this query openlibrary.org API? or some fatcat-specific index? -#enrich_inbound_refs(refs: List[BiblioRef]) -> List[CslBiblioRef] -#enrich_outbound_refs(refs: List[BiblioRef]) -> List[CslBiblioRef] # run fatcat API fetches for each ref and return "enriched" refs -def enrich_inbound_refs_fatcat(refs: List[BiblioRef], fatcat_api_client: Any, hide: Optional[str] = "refs", expand: Optional[str] = "container,files,webcaptures,filesets") -> List[FatcatBiblioRef]: +def enrich_inbound_refs(refs: List[BiblioRef], fatcat_api_client: Any, hide: Optional[str] = "refs", expand: Optional[str] = "container,files,webcaptures,filesets") -> List[EnrichedBiblioRef]: enriched = [] for ref in refs: if ref.source_release_ident: release = fatcat_api_client.get_release(ref.source_release_ident, hide=hide, expand=expand) - enriched.append(FatcatBiblioRef( + enriched.append(EnrichedBiblioRef( ref=ref, #csl=None, access=release_access_options(release), release=release, )) else: - enriched.append(FatcatBiblioRef( + enriched.append(EnrichedBiblioRef( ref=ref, #csl=None, access=[], @@ -303,21 +286,20 @@ def enrich_inbound_refs_fatcat(refs: List[BiblioRef], fatcat_api_client: Any, hi )) return enriched -def enrich_outbound_refs_fatcat(refs: List[BiblioRef], fatcat_api_client: Any, hide: Optional[str] = "refs", expand: Optional[str] = "container,files,webcaptures,filesets") -> List[FatcatBiblioRef]: + +def enrich_outbound_refs(refs: List[BiblioRef], fatcat_api_client: Any, hide: Optional[str] = "refs", expand: Optional[str] = "container,files,webcaptures,filesets") -> List[EnrichedBiblioRef]: enriched = [] for ref in refs: if ref.target_release_ident: release = fatcat_api_client.get_release(ref.target_release_ident, hide=hide, expand=expand) - enriched.append(FatcatBiblioRef( + enriched.append(EnrichedBiblioRef( ref=ref, - #csl=None, access=release_access_options(release), release=release, )) else: - enriched.append(FatcatBiblioRef( + enriched.append(EnrichedBiblioRef( ref=ref, - #csl=None, access=[], release=None, )) @@ -325,6 +307,9 @@ def enrich_outbound_refs_fatcat(refs: List[BiblioRef], fatcat_api_client: Any, h def run_ref_query(args) -> None: + """ + CLI helper/debug tool (prints to stdout) + """ release_ident = None work_ident = None if args.ident.startswith("release_"): diff --git a/python/fatcat_web/ref_routes.py b/python/fatcat_web/ref_routes.py index e08aaf15..e24b4ac6 100644 --- a/python/fatcat_web/ref_routes.py +++ b/python/fatcat_web/ref_routes.py @@ -11,14 +11,14 @@ from fatcat_openapi_client.rest import ApiException from fuzzycat.grobid_unstructured import grobid_api_process_citation, transform_grobid_ref_xml, grobid_ref_to_release from fuzzycat.simple import close_fuzzy_biblio_matches, close_fuzzy_release_matches -from fatcat_tools.references import enrich_inbound_refs_fatcat, enrich_outbound_refs_fatcat, get_inbound_refs, get_outbound_refs +from fatcat_tools.references import enrich_inbound_refs, enrich_outbound_refs, get_inbound_refs, get_outbound_refs from fatcat_tools.transforms.access import release_access_options from fatcat_web import app, api, auth_api from fatcat_web.forms import * from fatcat_web.entity_helpers import * -@app.route('/release//inbound-refs', methods=['GET']) +@app.route('/release//refs/in', methods=['GET']) def release_view_refs_inbound(ident): release = generic_get_entity("release", ident) @@ -27,11 +27,12 @@ def release_view_refs_inbound(ident): offset = max(0, int(offset)) if offset.isnumeric() else 0 hits = get_inbound_refs(release_ident=ident, es_client=app.es_client, offset=offset, limit=30) - enriched_refs = enrich_inbound_refs_fatcat(hits.result_refs, fatcat_api_client=api, expand="container,files,webcaptures") + enriched_refs = enrich_inbound_refs(hits.result_refs, fatcat_api_client=api, expand="container,files,webcaptures") - return render_template('release_view_fuzzy_refs.html', direction="inbound", entity=release, hits=hits, enriched_refs=enriched_refs), 200 + return render_template('release_view_fuzzy_refs.html', direction="in", entity=release, hits=hits, enriched_refs=enriched_refs), 200 -@app.route('/release//outbound-refs', methods=['GET']) + +@app.route('/release//refs/out', methods=['GET']) def release_view_refs_outbound(ident): release = generic_get_entity("release", ident) @@ -40,9 +41,10 @@ def release_view_refs_outbound(ident): offset = max(0, int(offset)) if offset.isnumeric() else 0 hits = get_outbound_refs(release_ident=ident, es_client=app.es_client, offset=offset, limit=30) - enriched_refs = enrich_outbound_refs_fatcat(hits.result_refs, fatcat_api_client=api, expand="container,files,webcaptures") + enriched_refs = enrich_outbound_refs(hits.result_refs, fatcat_api_client=api, expand="container,files,webcaptures") + + return render_template('release_view_fuzzy_refs.html', direction="out", entity=release, hits=hits, enriched_refs=enriched_refs), 200 - return render_template('release_view_fuzzy_refs.html', direction="outbound", entity=release, hits=hits, enriched_refs=enriched_refs), 200 @app.route('/reference/match', methods=['GET', 'POST']) def reference_match(): diff --git a/python/fatcat_web/templates/entity_base.html b/python/fatcat_web/templates/entity_base.html index c23dbef2..78a151a0 100644 --- a/python/fatcat_web/templates/entity_base.html +++ b/python/fatcat_web/templates/entity_base.html @@ -85,10 +85,9 @@ {{ entity_tab("coverage", "Coverage", "/coverage") }} {% elif entity_type == "release" and entity.state != 'deleted' %} {{ entity_tab("contribs", "Authors", "/contribs", entity._authors|count ) }} - {{ entity_tab("references", "References", "/references", entity.refs|count) }} {% if entity.state == 'active' %} - {{ entity_tab("inbound-refs", "Inbound", "/inbound-refs") }} - {{ entity_tab("outbound-refs", "Outbound", "/outbound-refs") }} + {{ entity_tab("refs-out", "References", "/refs/out") }} + {{ entity_tab("refs-in", "Cited By", "/refs/in") }} {% endif %} {% endif %} {{ entity_tab("metadata", "Metadata", "/metadata") }} diff --git a/python/fatcat_web/templates/release_view_fuzzy_refs.html b/python/fatcat_web/templates/release_view_fuzzy_refs.html index 7b286fd3..43860a31 100644 --- a/python/fatcat_web/templates/release_view_fuzzy_refs.html +++ b/python/fatcat_web/templates/release_view_fuzzy_refs.html @@ -1,5 +1,5 @@ {% set release = entity %} -{% set entity_view = "{{ direction }}-refs" %} +{% set entity_view = "refs-" + direction %} {% set entity_type = "release" %} {% import "entity_macros.html" as entity_macros %} {% extends "entity_base.html" %} @@ -17,10 +17,10 @@ {% block entity_main %} -{% if direction == "inbound" %} -

Referenced By

- Citations to this release by other works. -{% elif direction == "outbound" %} +{% if direction == "in" %} +

Cited By

+ References to this release by other works. +{% elif direction == "out" %}

References

NOTE: currently batch computed and may include additional references sources, or be missing recent changes, compared to entity reference list. {% endif %} @@ -36,7 +36,7 @@ {% set release = row.release %} {# TODO: ref_locator? #} - {% if direction == "outbound" %} + {% if direction == "out" %} {% if row.ref.ref_key %} [{{ row.ref.ref_key }}]
{% endif %} -- cgit v1.2.3 From 1125eddcac0c9b2673dbfb1f62bb0fa9b1ab4054 Mon Sep 17 00:00:00 2001 From: Bryan Newbold Date: Fri, 23 Jul 2021 17:48:35 -0700 Subject: web: refactor refs table into separate refs_macros file --- python/fatcat_web/templates/entity_macros.html | 41 ++++++++++- python/fatcat_web/templates/refs_macros.html | 86 ++++++++++++++++++++++ .../templates/release_view_fuzzy_refs.html | 74 +------------------ 3 files changed, 127 insertions(+), 74 deletions(-) create mode 100644 python/fatcat_web/templates/refs_macros.html (limited to 'python/fatcat_web/templates/release_view_fuzzy_refs.html') diff --git a/python/fatcat_web/templates/entity_macros.html b/python/fatcat_web/templates/entity_macros.html index 24d1b6d0..ac2b5a15 100644 --- a/python/fatcat_web/templates/entity_macros.html +++ b/python/fatcat_web/templates/entity_macros.html @@ -390,7 +390,7 @@ yellow {# this is useful for things like showing lists of releases in tables #} {% macro release_summary(release) %} -{{ release.title }} + {{ release.title }} {% if release.release_type not in ["article-journal", "conference-paper"] %} [{{ release.release_type or "unknown-type" }}] {% endif %} @@ -411,8 +411,13 @@ yellow {% elif release.extra and release.extra.container_name %} {{ release.extra.container_name }} {% endif %} - {% if release.release_stage != "published" %} -  {{ release.release_stage or "unpublished" }} + + {% if release.release_stage == "submitted" %} +  pre-print + {% elif release.release_stage and release.release_stage != "published" %} +  {{ release.release_stage }} version + {% elif not release.release_stage %} +  unpublished {% endif %}
{% if release.version %} @@ -438,3 +443,33 @@ yellow dblp:{{ release.ext_ids.dblp }}  {% endif %} {% endmacro %} + +{# similar to the release_summary above, but for CSL-JSON #} +{% macro csl_summary(csl) %} + {{ csl.title }} + {% if csl.title and csl.author %}
{% endif %} + {% if csl.author %} + {% for author in csl.author[:5] %} + {# TODO: other name variants? #} + {{ author.name }} + {%- if not loop.last %}, {% endif %} + {% endfor %} + {% if csl.author | length > 5 %} (+ more) {%endif %} + {% endif %} + + {% if csl.issued or csl["container-title"] %}
{% endif %} + {% if csl.issued and csl.issued.raw %}{{ csl.issued.raw }}  {% endif %} + {% if csl["container-title"] %} + {{ csl["container-title"] }} + {% endif %} +
+ {% if csl.volume %} + volume:{{ csl.volume}}  + {% endif %} + {% if csl.DOI %} + doi:{{ csl.DOI }}  + {% endif %} + {% if csl.URL %} + url:{{ csl.URL }}  + {% endif %} +{% endmacro %} diff --git a/python/fatcat_web/templates/refs_macros.html b/python/fatcat_web/templates/refs_macros.html new file mode 100644 index 00000000..405aca73 --- /dev/null +++ b/python/fatcat_web/templates/refs_macros.html @@ -0,0 +1,86 @@ +{% import "entity_macros.html" as entity_macros %} + +{% macro pagination_row(hits, direction) %} + + {% if hits.offset %} + « prev   + {% endif %} + Showing {{ hits.offset + 1 }} - {{ hits.offset + hits.count_returned }} of {{ hits.count_total}} references (in {{ hits.query_wall_time_ms }}ms) + {% if hits.count_total != hits.count_returned and hits.offset + hits.limit < hits.count_total %} +  next » + {% endif %} +{% endmacro %} + +{% macro refs_table(hits, direction) %} + + + + + +{% for row in hits.result_refs %} + {% set release = row.release %} + +{% if hits.count_total != hits.count_returned %} + + +{% endif %} +
+ {{ pagination_row(hits) }} +
+ {# TODO: ref_locator? #} + {% if direction == "out" %} + {% if row.ref.ref_key %} + [{{ row.ref.ref_key }}]
+ {% endif %} + {% endif %} + {{ row.ref.match_status }}
+ {% if row.ref.match_provenance %} + via {{ row.ref.match_provenance }} + {% endif %} +
+ {% if release %} + {{ entity_macros.release_summary(release) }} + {% elif row.ref.target_unstructured %} + {{ row.ref.target_unstructured }} + {% if row.ref.target_openlibrary_work %} +
openlibrary:{{ row.ref.target_openlibrary_work }}  + {% endif %} + {% elif row.ref.target_csl %} + {{ entity_macros.csl_summary(row.ref.target_csl) }} + {% else %} + blank + {% endif %} +
+ {% if row.access %} + {% for access in row.access %} + + {%- if access.access_type.name == "wayback" %} + web.archive.org + {%- elif access.access_type.name == "ia_file" -%} + archive.org + {%- else -%} + {{ access.access_type.name }} + {%- endif -%} + {%- if access.mimetype == "application/pdf" %} + [PDF] + {%- elif access.mimetype == "text/html" %} + [HTML] + {%- endif -%} + +
+ {% endfor %} + {% elif direction == "out" and row.ref.target_unstructured %} +
+ + + +
+ {% endif %} +{% endfor %} +
+ {{ pagination_row(hits) }} +
+{% endmacro %} + diff --git a/python/fatcat_web/templates/release_view_fuzzy_refs.html b/python/fatcat_web/templates/release_view_fuzzy_refs.html index 43860a31..ffca0bc9 100644 --- a/python/fatcat_web/templates/release_view_fuzzy_refs.html +++ b/python/fatcat_web/templates/release_view_fuzzy_refs.html @@ -1,19 +1,9 @@ {% set release = entity %} {% set entity_view = "refs-" + direction %} {% set entity_type = "release" %} -{% import "entity_macros.html" as entity_macros %} +{% import "refs_macros.html" as refs_macros %} {% extends "entity_base.html" %} -{% macro pagination_row(hits) %} - - {% if hits.offset %} - « prev   - {% endif %} - Showing {{ hits.offset + 1 }} - {{ hits.offset + hits.count_returned }} of {{ hits.count_total}} references (in {{ hits.query_wall_time_ms }}ms) - {% if hits.count_total != hits.count_returned and hits.offset + hits.limit < hits.count_total %} -  next » - {% endif %} -{% endmacro %} {% block entity_main %} @@ -25,66 +15,8 @@ NOTE: currently batch computed and may include additional references sources, or be missing recent changes, compared to entity reference list. {% endif %} -{% if enriched_refs %} - - - - -{% for row in enriched_refs %} - {% set release = row.release %} - -{% if hits.count_total != hits.count_returned %} - - -{% endif %} -
- {{ pagination_row(hits) }} -
- {# TODO: ref_locator? #} - {% if direction == "out" %} - {% if row.ref.ref_key %} - [{{ row.ref.ref_key }}]
- {% endif %} - {% endif %} - {{ row.ref.match_status }}
- {% if row.ref.match_provenance %} - via {{ row.ref.match_provenance }} - {% endif %} -
- {% if release %} - {{ entity_macros.release_summary(release) }} - {% elif row.ref.target_unstructured %} - {{ row.ref.target_unstructured }} - {% else %} - blank - {% endif %} - - {% if row.access %} - {% for access in row.access %} - {{ access.access_type.name }}
- {% endfor %} - {% elif row.ref.target_unstructured %} -
- - - -
- {% endif %} - - {# TODO: include these as access options instead #} - {% if row.ref.target_openlibrary_work %} - openlibrary.org - {% endif %} - {% if row.ref.target_url %} - web -
wayback (?) - {% endif %} -{% endfor %} -
- {{ pagination_row(hits) }} -
+{% if hits.result_refs %} + {{ refs_macros.refs_table(hits, direction) }} {% else %}

None found {% endif %} -- cgit v1.2.3 From fa2ba60834cf3cb3edea05af3c1830e6fc0d5bcc Mon Sep 17 00:00:00 2001 From: Bryan Newbold Date: Tue, 27 Jul 2021 18:48:14 -0700 Subject: refs: several small improvements to web UI --- python/fatcat_web/templates/entity_macros.html | 11 +++- .../templates/openlibrary_view_fuzzy_refs.html | 6 +- python/fatcat_web/templates/refs_macros.html | 71 ++++++++++++++++------ .../templates/release_view_fuzzy_refs.html | 12 ++-- .../templates/wikipedia_view_fuzzy_refs.html | 6 +- 5 files changed, 71 insertions(+), 35 deletions(-) (limited to 'python/fatcat_web/templates/release_view_fuzzy_refs.html') diff --git a/python/fatcat_web/templates/entity_macros.html b/python/fatcat_web/templates/entity_macros.html index 37bb2d90..562b99d3 100644 --- a/python/fatcat_web/templates/entity_macros.html +++ b/python/fatcat_web/templates/entity_macros.html @@ -391,7 +391,7 @@ yellow {# this is useful for things like showing lists of releases in tables #} {% macro release_summary(release) %} {{ release.title }} - {% if release.release_type not in ["article-journal", "conference-paper"] %} + {% if release.release_type not in ["article-journal", "paper-conference"] %} [{{ release.release_type or "unknown-type" }}] {% endif %} {% if release.contribs %}
{% endif %} @@ -405,7 +405,14 @@ yellow {% endfor %} {% if release.contribs | length > 8 %} (+ more) {%endif %} {% if release.release_year or release.container or (release.extra and release.extra.container_name) %}
{% endif %} - {% if release.release_year %}{{ release.release_year }}  {% endif %} + {% if release.release_year %} + {% if release.release_date %} + {{ release.release_year }} + {% else %} + {{ release.release_year }} + {% endif %} +   + {% endif %} {% if release.container %} {{ release.container.name }} {% elif release.extra and release.extra.container_name %} diff --git a/python/fatcat_web/templates/openlibrary_view_fuzzy_refs.html b/python/fatcat_web/templates/openlibrary_view_fuzzy_refs.html index 161a7b50..21bf76f2 100644 --- a/python/fatcat_web/templates/openlibrary_view_fuzzy_refs.html +++ b/python/fatcat_web/templates/openlibrary_view_fuzzy_refs.html @@ -19,11 +19,7 @@ Refernces from this book to other entities. {% endif %} -{% if hits.result_refs %} - {{ refs_macros.refs_table(hits, direction) }} -{% else %} -

None found -{% endif %} +{{ refs_macros.refs_table(hits, direction) }} {% endblock %} diff --git a/python/fatcat_web/templates/refs_macros.html b/python/fatcat_web/templates/refs_macros.html index ba4d18ad..3db47064 100644 --- a/python/fatcat_web/templates/refs_macros.html +++ b/python/fatcat_web/templates/refs_macros.html @@ -1,37 +1,67 @@ {% import "entity_macros.html" as entity_macros %} -{% macro pagination_row(hits, direction) %} - - {% if hits.offset %} +{% macro pagination_row(hits, with_links=False) %} + {% if with_links and hits.offset %} « prev   {% endif %} - Showing {{ hits.offset + 1 }} - {{ hits.offset + hits.count_returned }} of {{ hits.count_total}} references (in {{ hits.query_wall_time_ms }}ms) - {% if hits.count_total != hits.count_returned and hits.offset + hits.limit < hits.count_total %} + {% if hits.count_returned == 0 %} + Showing 0 references + {% else %} + Showing {{ hits.offset + 1 }} - {{ hits.offset + hits.count_returned }} of {{ hits.count_total}} references + {% endif %} + {% if with_links and hits.count_total != hits.count_returned and hits.offset + hits.limit < hits.count_total %}  next » {% endif %} {% endmacro %} {% macro refs_table(hits, direction) %} +

+
+ Fuzzy reference matching is a work in progress! +
+ Read more about quality, completeness, and caveats in the fatcat guide. +
+{% if hits.count_total == 0 %} + + -{% if hits.count_total != hits.count_returned %} - - -{% endif %} + +
- {{ pagination_row(hits) }} + {{ pagination_row(hits, with_links=False) }} + (in {{ hits.query_wall_time_ms }}ms)
+
+ + No References Found +
+{% endif %} {% for row in hits.result_refs %} {% set release = row.release %} -
+
{# TODO: ref_locator? #} {% if direction == "out" %} {% if row.ref.ref_key %} [{{ row.ref.ref_key }}]
{% endif %} {% endif %} - {{ row.ref.match_status }}
- {% if row.ref.match_provenance %} - via {{ row.ref.match_provenance }} + + {% if row.ref.match_status == "exact" %} + {% set match_icon = "linkify" %} + {% elif row.ref.match_status == "unmatched" %} + {% set match_icon = "question circle outline" %} + {% else %} + {% set match_icon = "magic" %} {% endif %} +
+ {% if row.ref.match_provenance and row.ref.match_provenance == "fatcat-pubmed" %} + {# this is a common case and making the column render wide #} + via pubmed + {% elif row.ref.match_provenance %} + via {{ row.ref.match_provenance }}
+ {% endif %} +
{% if release %} {{ entity_macros.release_summary(release) }} @@ -62,7 +92,7 @@ {% if row.access %} {% for access in row.access %} - + {%- if access.access_type.name == "wayback" %} web.archive.org {%- elif access.access_type.name == "ia_file" -%} @@ -83,18 +113,23 @@ {% endif %} {% endfor %}
- {{ pagination_row(hits) }} -
+
+ JSON +
+ {% if hits.count_returned != hits.count_total %} +
+ {{ pagination_row(hits, with_links=True) }} +
+ {% endif %} +
{% endmacro %} diff --git a/python/fatcat_web/templates/release_view_fuzzy_refs.html b/python/fatcat_web/templates/release_view_fuzzy_refs.html index ffca0bc9..8cba4f4e 100644 --- a/python/fatcat_web/templates/release_view_fuzzy_refs.html +++ b/python/fatcat_web/templates/release_view_fuzzy_refs.html @@ -13,13 +13,15 @@ {% elif direction == "out" %}

References

NOTE: currently batch computed and may include additional references sources, or be missing recent changes, compared to entity reference list. -{% endif %} -{% if hits.result_refs %} - {{ refs_macros.refs_table(hits, direction) }} -{% else %} -

None found + {% if hits.count_total == 0 and release.refs %} +

+

No fuzzy references found, but there are {{ release.refs|count }} legacy references +

+ {% endif %} {% endif %} +{{ refs_macros.refs_table(hits, direction) }} + {% endblock %} diff --git a/python/fatcat_web/templates/wikipedia_view_fuzzy_refs.html b/python/fatcat_web/templates/wikipedia_view_fuzzy_refs.html index 5b53d692..3e1453c1 100644 --- a/python/fatcat_web/templates/wikipedia_view_fuzzy_refs.html +++ b/python/fatcat_web/templates/wikipedia_view_fuzzy_refs.html @@ -17,11 +17,7 @@ Refernces from wikipedia article to other entities. {% endif %} -{% if hits.result_refs %} - {{ refs_macros.refs_table(hits, direction) }} -{% else %} -

None found -{% endif %} +{{ refs_macros.refs_table(hits, direction) }} {% endblock %} -- cgit v1.2.3