diff options
Diffstat (limited to 'python/fatcat_web')
-rw-r--r-- | python/fatcat_web/templates/entity_macros.html | 41 | ||||
-rw-r--r-- | python/fatcat_web/templates/refs_macros.html | 86 | ||||
-rw-r--r-- | python/fatcat_web/templates/release_view_fuzzy_refs.html | 74 |
3 files changed, 127 insertions, 74 deletions
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) %} -<b><a href="/release/{{ release.ident }}">{{ release.title }}</a></b> + <b><a href="/release/{{ release.ident }}">{{ release.title }}</a></b> {% if release.release_type not in ["article-journal", "conference-paper"] %} <b>[{{ release.release_type or "unknown-type" }}]</b> {% endif %} @@ -411,8 +411,13 @@ yellow {% elif release.extra and release.extra.container_name %} <i>{{ release.extra.container_name }}</i> {% endif %} - {% if release.release_stage != "published" %} - <span style="color: brown; font-weight: bold;">{{ release.release_stage or "unpublished" }}</span> + + {% if release.release_stage == "submitted" %} + <b style="color: brown; text-transform: uppercase;">pre-print</b> + {% elif release.release_stage and release.release_stage != "published" %} + <b style="color: brown; text-transform: uppercase;">{{ release.release_stage }} version</b> + {% elif not release.release_stage %} + <b style="color: brown; text-transform: uppercase;">unpublished</b> {% endif %} <br> {% if release.version %} @@ -438,3 +443,33 @@ yellow <a href="#" style="color:green;">dblp:{{ release.ext_ids.dblp }}</a> {% endif %} {% endmacro %} + +{# similar to the release_summary above, but for CSL-JSON #} +{% macro csl_summary(csl) %} + <b>{{ csl.title }}</b> + {% if csl.title and csl.author %}<br>{% 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 %} <i>(+ more)</i> {%endif %} + {% endif %} + + {% if csl.issued or csl["container-title"] %}<br>{% endif %} + {% if csl.issued and csl.issued.raw %}{{ csl.issued.raw }} {% endif %} + {% if csl["container-title"] %} + <i>{{ csl["container-title"] }}</i> + {% endif %} + <br> + {% if csl.volume %} + <span style="color:green">volume:{{ csl.volume}}</span> + {% endif %} + {% if csl.DOI %} + <a href="https://doi.org/{{ csl.DOI }}" style="color:green;">doi:{{ csl.DOI }}</a> + {% endif %} + {% if csl.URL %} + <a href="{{ csl.URL }}" style="color:green;">url:{{ csl.URL }}</a> + {% 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 %} + <a href="?offset={{ hits.offset - hits.limit }}">« prev</a> + {% 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 %} + <a href="?offset={{ hits.offset + hits.limit }}">next »</a> + {% endif %} +{% endmacro %} + +{% macro refs_table(hits, direction) %} + +<table class="ui table"> +<thead> + <tr><th colspan="3"> + {{ pagination_row(hits) }} +</thead> +<tbody> +{% for row in hits.result_refs %} + {% set release = row.release %} + <tr><td class="collapsing left aligned top aligned"> + {# TODO: ref_locator? #} + {% if direction == "out" %} + {% if row.ref.ref_key %} + <code title="index={{ row.ref.ref_index }}">[{{ row.ref.ref_key }}]</code><br> + {% endif %} + {% endif %} + <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 row.ref.target_unstructured %} + <code>{{ row.ref.target_unstructured }}</code> + {% if row.ref.target_openlibrary_work %} + <br><a href="https://openlibrary.org/{{ row.ref.target_openlibrary_work }}" style="color:green;">openlibrary:{{ row.ref.target_openlibrary_work }}</a> + {% endif %} + {% elif row.ref.target_csl %} + {{ entity_macros.csl_summary(row.ref.target_csl) }} + {% else %} + <i>blank</i> + {% endif %} + <td class="center aligned"> + {% if row.access %} + {% for access in row.access %} + <a href="{{ access.access_url}}" class="ui tiny green active button"> + {%- 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 -%} + </a> + <br> + {% endfor %} + {% elif direction == "out" and 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 %} +{% endfor %} +</tbody> +{% if hits.count_total != hits.count_returned %} + <tfoot> + <tr><th colspan="3"> + {{ pagination_row(hits) }} + </tfoot> +{% endif %} +</table> +{% 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 %} - <a href="?offset={{ hits.offset - hits.limit }}">« prev</a> - {% 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 %} - <a href="?offset={{ hits.offset + hits.limit }}">next »</a> - {% endif %} -{% endmacro %} {% block entity_main %} @@ -25,66 +15,8 @@ <i>NOTE: currently batch computed and may include additional references sources, or be missing recent changes, compared to entity reference list.</i> {% endif %} -{% if enriched_refs %} -<table class="ui table"> -<thead> - <tr><th colspan="3"> - {{ pagination_row(hits) }} -</thead> -<tbody> -{% for row in enriched_refs %} - {% set release = row.release %} - <tr><td class="collapsing left aligned top aligned"> - {# TODO: ref_locator? #} - {% if direction == "out" %} - {% if row.ref.ref_key %} - <code>[{{ row.ref.ref_key }}]</code><br> - {% endif %} - {% endif %} - <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 row.ref.target_unstructured %} - <code>{{ row.ref.target_unstructured }}</code> - {% else %} - <i>blank</i> - {% 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> +{% if hits.result_refs %} + {{ refs_macros.refs_table(hits, direction) }} {% else %} <br><br><p><b>None found</b> {% endif %} |