From eb1c59c6b234938d7ee1cbfe77b8bd6e19ab8515 Mon Sep 17 00:00:00 2001 From: Bryan Newbold Date: Sat, 2 Mar 2019 16:07:10 -0800 Subject: macro-ify more entity view; fix release lists --- python/fatcat_web/templates/creator_view.html | 28 ++------------ python/fatcat_web/templates/entity_macros.html | 51 ++++++++++++++++++++++++++ python/fatcat_web/templates/file_view.html | 49 ++++--------------------- python/fatcat_web/templates/release_view.html | 3 +- python/fatcat_web/templates/work_view.html | 35 +++--------------- 5 files changed, 67 insertions(+), 99 deletions(-) (limited to 'python/fatcat_web/templates') diff --git a/python/fatcat_web/templates/creator_view.html b/python/fatcat_web/templates/creator_view.html index 16f74f0a..0ddb6899 100644 --- a/python/fatcat_web/templates/creator_view.html +++ b/python/fatcat_web/templates/creator_view.html @@ -31,37 +31,15 @@ {% endif %} -{% if creator.extra != None %} -

Extra Metadata (raw JSON)

- - - {% for (key, value) in release.extra.items() %} - - -
{{ key }}{{ value }} - {% endfor %} -
+{% if entity.extra != None %} + {{ entity_macros.extra_metadata(entity.extra) }} {% endif %}

Releases

{% if releases != [] %}

This creator has contributed to: - - - {% for release in releases %} - -
- {% if release.release_date %}{{ release.release_date }}{% elif release.release_year %}{{ release.release_year }}{% endif %} - - {{ release.title }} -
{{ release.release_type or "unknown" }} - {{ release.release_status or "unknown" }} - {% if release.license_slug %} - {{ release.license_slug }}{% endif %} - {% if release.doi %} -
doi:{{ release.doi }} - {% endif %} - {% endfor %} -
+ {{ entity_macros.release_list(releases) }} {% else %} This creator has not contributed to any releases. {% endif %} diff --git a/python/fatcat_web/templates/entity_macros.html b/python/fatcat_web/templates/entity_macros.html index f714a63a..2a4752f2 100644 --- a/python/fatcat_web/templates/entity_macros.html +++ b/python/fatcat_web/templates/entity_macros.html @@ -12,3 +12,54 @@ View History {%- endmacro %} + + +{% macro extra_metadata(extra) -%} +

Extra Metadata (raw JSON)

+ + +{% for (key, value) in extra.items() %} + + +
{{ key }}{{ value }} +{% endfor %} +
+{%- endmacro %} + + +{% macro release_list(releases) -%} + + +{% for release in releases %} + +
+ {% if release.release_date %}{{ release.release_date }}{% elif release.release_year %}{{ release.release_year }}{% endif %} + + {{ release.title }} +
{{ release.release_status or "unknown status" }} + | {{ release.release_type or "unknown type" }} + {% if release.license_slug %} | {{ release.license_slug }}{% endif %} + {% if release.doi %} +
doi:{{ release.doi }} + {% endif %} +{% endfor %} +
+{%- endmacro %} + + +{% macro url_list(urls) -%} + + + {% for url in urls %} + +
{{ url.rel }} + + {% if url.url.count('/') >= 3 %} + {{ '/'.join(url.url.split('/')[0:2]) }}/{{ ''.join(url.url.split('/')[2]) }}/{{ '/'.join(url.url.split('/')[3:]) }} + {% else %} + {{ url.url }} + {% endif %} + + {% endfor %} +
+{%- endmacro %} diff --git a/python/fatcat_web/templates/file_view.html b/python/fatcat_web/templates/file_view.html index 4bb6d75a..7f516e01 100644 --- a/python/fatcat_web/templates/file_view.html +++ b/python/fatcat_web/templates/file_view.html @@ -16,57 +16,22 @@
-{% if file.extra %} -

Extra Metadata (raw JSON)

- - -{% for (key, value) in file.extra.items() %} - - -
{{ key }}{{ value }} -{% endfor %} -
+{% if entity.extra %} + {{ entity_macros.extra_metadata(entity.extra) }} {% endif %}

Releases

-{% if file.releases != [] %} - - -{% for release in file.releases %} - -
- {% if release.release_date %}{{ release.release_date }}{% elif release.release_year %}{{ release.release_year }}{% endif %} - - {{ release.title }} -
{{ release.release_type or "unknown" }} - {{ release.release_status or "unknown" }} - {% if release.license_slug %} - {{ release.license_slug }}{% endif %} - {% if release.doi %} -
doi:{{ release.doi }} - {% endif %} -{% endfor %} -
+{% if entity.releases != [] %} + {{ entity_macros.release_list(entity.releases) }} {% else %} -

-This file is not associated with any fatcat release. +

+ This file is not associated with any fatcat release. {% endif %}

URLs

{% if file.urls != None %} - - - {% for url in file.urls %} - -
{{ url.rel }} - - {% if url.url.count('/') >= 3 %} - {{ '/'.join(url.url.split('/')[0:2]) }}/{{ ''.join(url.url.split('/')[2]) }}/{{ '/'.join(url.url.split('/')[3:]) }} - {% else %} - {{ url.url }} - {% endif %} - - {% endfor %} -
+ {{ entity_macros.url_list(file.urls) }} {% else %} No known public URL, mirror, or archive for this file. {% endif %} diff --git a/python/fatcat_web/templates/release_view.html b/python/fatcat_web/templates/release_view.html index 5b4236cf..ca09f1b9 100644 --- a/python/fatcat_web/templates/release_view.html +++ b/python/fatcat_web/templates/release_view.html @@ -269,8 +269,7 @@ This release citing other releases. {% endif %} {% if container.es.in_kbart == True %} In Keepers Registery
- {% elif container.es.in_kbart == False %} - Not in Keepers Registry
+ {% elif container.es.in_kbart == False %} Not in Keepers Registry
{% endif %} {% endif %} {% if container.issnl != None %} diff --git a/python/fatcat_web/templates/work_view.html b/python/fatcat_web/templates/work_view.html index 6a409542..7fd2bbb2 100644 --- a/python/fatcat_web/templates/work_view.html +++ b/python/fatcat_web/templates/work_view.html @@ -16,44 +16,19 @@
-{% if work.extra != None %} -

Extra Metadata (raw JSON)

-{% for (key, value) in work.extra.items() %} -{{ key }}: {{ value }}
-{% endfor %} +{% if entity.extra != None %} + {{ entity_macros.extra_metadata(entity.extra) }} {% endif %}

Releases

{% if releases != [] %} - - -{% for release in releases %} - -
- {% if release.release_date %}{{ release.release_date }}{% elif release.release_year %}{{ release.release_year }}{% endif %} - - {{ release.title }} -
{{ release.release_type or "unknown" }} - {{ release.release_status or "unknown" }} - {% if release.license_slug %} - {{ release.license_slug }}{% endif %} - {% if release.doi %} -
doi:{{ release.doi }} - {% endif %} -{% endfor %} -
+ {{ entity_macros.release_list(releases) }} {% else %}

There are no known releases associated with this work. {% endif %} -{% if work.extra %} -

Extra Metadata (raw JSON)

- - -{% for (key, value) in work.extra.items() %} - - -
{{ key }}{{ value }} -{% endfor %} -
+{% if entity.extra %} + {{ entity_macros.extra_metadata(entity.extra) }} {% endif %}

What is a "Work"?

-- cgit v1.2.3