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/refs_macros.html | 86 ++++++++++++++++++++++++++++ 1 file changed, 86 insertions(+) create mode 100644 python/fatcat_web/templates/refs_macros.html (limited to 'python/fatcat_web/templates/refs_macros.html') 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 %} + -- cgit v1.2.3