aboutsummaryrefslogtreecommitdiffstats
path: root/python
diff options
context:
space:
mode:
authorBryan Newbold <bnewbold@robocracy.org>2021-06-24 18:45:08 -0700
committerBryan Newbold <bnewbold@robocracy.org>2021-07-23 10:55:09 -0700
commit61ed521cc40c1ee76692e9c4054e89fa63320600 (patch)
tree348857292b2c4d67ac181a9976b4c950ede8fbaa /python
parentc2395869ff7860bb2c7f080fd6c097e299ea58bf (diff)
downloadfatcat-61ed521cc40c1ee76692e9c4054e89fa63320600.tar.gz
fatcat-61ed521cc40c1ee76692e9c4054e89fa63320600.zip
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
Diffstat (limited to 'python')
-rw-r--r--python/fatcat_web/ref_routes.py12
-rw-r--r--python/fatcat_web/templates/entity_macros.html17
-rw-r--r--python/fatcat_web/templates/release_view_fuzzy_refs.html93
3 files changed, 75 insertions, 47 deletions
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/<string(length=26):ident>/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/<string(length=26):ident>/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"] %}
<b>[{{ release.release_type or "unknown-type" }}]</b>
{% endif %}
-<br>
+ {% if release.contribs %}<br>{% endif %}
{% for contrib in release.contribs[:5] %}
{% if contrib.creator %}
- {{ contrib.creator.display_name }}
+ <a href="/contib/{{ contrib.creator.ident }}" style="color: black;">{{ contrib.creator.display_name }}</a>
{% else %}
{{ contrib.raw_name }}
- {% endif %}
- {% if not loop.last %}, {% endif %}
+ {%- endif %}
+ {%- if not loop.last %}, {% endif %}
{% endfor %}
- {% if release.contribs | length > 5 %}(+ more) {%endif %}
-<br>
+ {% if release.contribs | length > 5 %} <i>(+ more)</i> {%endif %}
+ {% if release.release_year or release.container or (release.extra and release.extra.container_name) %}<br>{% endif %}
{% if release.release_year %}{{ release.release_year }} &nbsp;{% endif %}
{% if release.container %}
- <i>{{ release.container.name }}</i>
+ <a href="/container/{{ release.container.ident }}" style="color: black;"><i>{{ release.container.name }}</i></a>
{% elif release.extra and release.extra.container_name %}
<i>{{ release.extra.container_name }}</i>
{% endif %}
{% if release.release_stage != "published" %}
&nbsp;<span style="color: brown; font-weight: bold;">{{ release.release_stage or "unpublished" }}</span>
{% endif %}
-</small>
<br>
{% if release.version %}
- <span style="color:green">version:{{ release.release_year }}</span>&nbsp;
+ <span style="color:green">version:{{ release.version }}</span>&nbsp;
{% endif %}
{% if release.number %}
<span style="color:green">number:{{ release.number }}</span>&nbsp;
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 %}
+ <a href="?offset={{ hits.offset - hits.limit }}">&laquo; prev</a> &nbsp;
+ {% 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 %}
+ &nbsp;<a href="?offset={{ hits.offset + hits.limit }}">next &raquo;</a>
+ {% endif %}
+{% endmacro %}
+
{% block entity_main %}
{% if direction == "inbound" %}
- <h3>Inbound Matched References</h3>
- <i>Other releases citing this one</i>
+ <h3>Referenced By</h3>
+ <i>Citations to this release by other works.</i>
{% elif direction == "outbound" %}
- <h3>Outbound Matched References</h3>
- <i>This release citing other releases</i>
-{% endif %}
-
-<p>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 %}
- &nbsp;<a href="?offset={{ hits.offset + hits.limit }}">next...</a>
- {% endif %}
+ <h3>References</h3>
+ <i>NOTE: currently batch computed and may include additional references sources, or be missing recent changes, compared to entity reference list.</i>
{% endif %}
-<table class="ui very basic celled table">
+{% if enriched_refs %}
+<table class="ui table">
+<thead>
+ <tr><th colspan="3">
+ {{ pagination_row(hits) }}
+</thead>
<tbody>
-{% for ref in enriched_refs %}
- {% set release = ref.release %}
- <tr><td class="collapsing center aligned">
+{% for row in enriched_refs %}
+ {% set release = row.release %}
+ <tr><td class="collapsing left aligned top aligned">
+ {# TODO: ref_locator? #}
{% if direction == "outbound" %}
- {% if ref.ref.ref_key %}
- <code>[{{ ref.ref.ref_key }}]</code>
+ {% if row.ref.ref_key %}
+ <code>[{{ row.ref.ref_key }}]</code><br>
{% endif %}
{% endif %}
- <br><b>{{ ref.ref.match_status }}</b>
- {% if ref.ref.match_provenance %}
- <br>{{ ref.ref.match_provenance }}
+ <b>{{ row.ref.match_status }}</b><br>
+ {% if row.ref.match_provenance %}
+ via {{ row.ref.match_provenance }}
{% endif %}
<td class="">
{% if release %}
- {% entity_macros.release_summary(release) %}
- {% elif ref.ref.target_unstructured %}
- <code>{{ ref.ref.target_unstructured }}</code>
+ {{ entity_macros.release_summary(release) }}
+ {% elif row.ref.target_unstructured %}
+ <code>{{ row.ref.target_unstructured }}</code>
{% else %}
<i>blank</i>
{% endif %}
- <td class="">
- {% if ref.access %}
- <a href="{{ ref.access[0].access_url}}" class="ui tiny green active button">{{ ref.access[0].access_type.name }}</a>
- {% endif %}
+ <td class="center aligned">
+ {% if row.access %}
+ {% for access in row.access %}
+ <a href="{{ access.access_url}}" class="ui tiny green active button">{{ access.access_type.name }}</a><br>
+ {% endfor %}
+ {% elif row.ref.target_unstructured %}
+ <form class="ui form" id="reference_match" method="POST" action="/reference/match">
+ <input type="hidden" name="csrf_token" value="{{ csrf_token() }}"/>
+ <input type="hidden" name="raw_citation" value="{{ row.ref.target_unstructured }}">
+ <button class="ui tiny primary submit button" type="submit" name="submit_type" value="parse">
+ parse
+ </button>
+ </form>
+ {% endif %}
+
+ {# TODO: include these as access options instead #}
+ {% if row.ref.target_openlibrary_work %}
+ <a href="https://openlibrary.org/work/{{ row.ref.target_openlibrary_work }}" class="ui tiny green active button">openlibrary.org</a>
+ {% endif %}
+ {% if row.ref.target_url %}
+ <a href="{{ ref.target_url | safe }}" class="ui tiny green active button">web</a>
+ <br><a href="https://web.archive.org/web/*/{{ row.ref.target_url | safe }}" class="ui tiny green active button">wayback (?)</a>
+ {% endif %}
{% endfor %}
</tbody>
+{% if hits.count_total != hits.count_returned %}
+ <tfoot>
+ <tr><th colspan="3">
+ {{ pagination_row(hits) }}
+ </tfoot>
+{% endif %}
</table>
+{% else %}
+ <br><br><p><b>None found</b>
+{% endif %}
{% endblock %}