diff options
Diffstat (limited to 'python/fatcat_web')
-rw-r--r-- | python/fatcat_web/templates/entity_macros.html | 8 | ||||
-rw-r--r-- | python/fatcat_web/templates/fileset_view.html | 81 | ||||
-rw-r--r-- | python/fatcat_web/templates/release_view.html | 25 |
3 files changed, 88 insertions, 26 deletions
diff --git a/python/fatcat_web/templates/entity_macros.html b/python/fatcat_web/templates/entity_macros.html index 5f8f6e0a..4386e698 100644 --- a/python/fatcat_web/templates/entity_macros.html +++ b/python/fatcat_web/templates/entity_macros.html @@ -75,6 +75,14 @@ <a href="{{ u }}">{{ u }}</a><br> {% endfor %} </code> + {% elif key in ("manifest", "abstracts", "refs", "releases", "files", "webcaptures", "filesets", "urls", "archive_urls", "cdx", "contribs") and value and value is iterable and value is not string %} + <tr><td class="three wide right aligned"><code>{{ key }}[]</code></td> + <td class="seven wide"> + <code> + {% for m in value %} + {% if m != None %}{{ m }}{% endif %}<br> + {% endfor %} + </code> {% else %} <tr><td class="three wide right aligned"><code>{{ key }}</code></td> <td class="seven wide"><code>{% if value != None %}{{ value }}{% endif %}</code> diff --git a/python/fatcat_web/templates/fileset_view.html b/python/fatcat_web/templates/fileset_view.html index 4e8bfbad..6f3f802e 100644 --- a/python/fatcat_web/templates/fileset_view.html +++ b/python/fatcat_web/templates/fileset_view.html @@ -3,6 +3,21 @@ {% import "entity_macros.html" as entity_macros %} {% extends "entity_base.html" %} +{% macro file_mimetype_icon(mimetype) -%} + {%- if not mimetype -%}file outline + {%- elif mimetype in ["application/pdf"] -%}file pdf outline + {%- elif mimetype in ["application/x-hdf"] -%}database + {%- elif mimetype in ["text/csv", "text/tab-separated-values"] -%}table + {%- elif mimetype in ["application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"] -%}table + {%- elif mimetype in ["application/vnd.openxmlformats-officedocument.wordprocessingml.document"] -%}file alternate outline + {%- elif mimetype in ["application/zip", "application/gzip", "application/x-tar", "application/x-rar", "application/x-bzip2"] -%}file archive outline + {%- elif mimetype in ["application/octet-stream"] -%}save outline + {%- elif mimetype.startswith("text/") -%}file alternate outline + {%- elif mimetype.startswith("image/") -%}file image outline + {%- elif mimetype.startswith("video/") -%}film + {%- else -%}file outline{% endif %} +{%- endmacro %} + {% block entity_main %} <div class="ui stackable mobile reversed grid centered"> @@ -23,26 +38,64 @@ No known public URL, mirror, or archive for this File Set. {% endif %} +{% set fileset_vars = namespace(archiveorg_base=None, webarchiveorg_base=None) %} +{% for u in (entity.urls or []) %} + {% if u.rel in ["archive-base"] %} + {% set fileset_vars.archiveorg_base = u.url %} + {% elif u.rel in ["webarchive-base"] %} + {% set fileset_vars.webarchiveorg_base = u.url %} + {% endif %} +{% endfor %} + <h3>File Manifest ({{ fileset.manifest|count }})</h3> {% if fileset.manifest %} - <div class="ui celled list"> +<div style="overflow-x: auto;"> +<table class="ui compact single line table"> + <thead> + <tr> + <th class="collapsing"></th> + <th>Path</th> + <th>Type</th> + <th>Size</th> + <th class="collapsing"></th> + </tr> + </thead> + <tbody> {% for file in fileset.manifest %} - <div class="item"> - <div class="content"><code> - <div class="header"> - <i class="file outline icon"></i> {{ file.path }} ({{ file.size|filesizeformat }}{% if file.extra.mimetype %}, {{ file.extra.mimetype }}{% endif %}) - </div> - <div style="color: #666; margin-left: 1em;"><small> - {% if file.md5 %} md5:{{ file.md5 }}<br>{% endif %} - {% if file.sha1 %} sha1:{{ file.sha1 }}<br>{% endif %} - {% if file.sha256 %}sha256:{{ file.sha256 }}<br>{% endif %} + <tr> + <td><i class="{{ file_mimetype_icon(file.mimetype) }} icon" style="font-size: x-large;"></i></td> + <td> + <b><code>{{ file.path }}</code></b> + <br><div style="color: #666; margin-left: 0em;"><small> + {% if file.sha1 %} sha1:{{ file.sha1 }}<br> + {% elif file.sha256 %}sha256:{{ file.sha256 }}<br> + {% elif file.md5 %} md5:{{ file.md5 }}<br> + {% endif %} </small></div> - </code></div> - </div> + </td> + <td>{% if file.mimetype %}<code style="font-size: smaller;">{{ file.mimetype }}</code>{% endif %}</td> + <td>{{ file.size|filesizeformat }}</td> + <td> + {% if fileset_vars.archiveorg_base %} + <a href="{{ fileset_vars.archiveorg_base }}/{{ file.path }}">[archive.org]</a><br> + {% endif %} + {% if fileset_vars.webarchiveorg_base %} + <a href="{{ fileset_vars.webarchiveorg_base }}/{{ file.path }}">[web.archive.org]</a><br> + {% endif %} + {% if file.extra and file.extra.original_url %} + <a href="{{ file.extra.original_url }}">[platform]</a><br> + {% endif %} + {% if file.extra and file.extra.webarchive_url%} + <a href="{{ file.extra.webarchive_url }}">[web.archive.org]</a><br> + {% endif %} + </td> + </tr> {% endfor %} - </div> + </tbody> +</table> +</div> {% else %} -This File Set is empty (contains no files). +<p>This File Set is empty (contains no files). {% endif %} diff --git a/python/fatcat_web/templates/release_view.html b/python/fatcat_web/templates/release_view.html index 89973e35..5e64d7e0 100644 --- a/python/fatcat_web/templates/release_view.html +++ b/python/fatcat_web/templates/release_view.html @@ -131,8 +131,9 @@ {% endif %} {% if entity.state == 'active' %} + +{% if entity.files != [] and entity.files != None %} <h3>Archived Files and Locations</h3> -{% if entity.files != [] %} <table class="ui compact fixed table"> <tbody> {% for file in entity.files %} @@ -151,15 +152,9 @@ {% endfor %} </tbody> </table> -{% else %} -<p>There are no accessible files associated with this release. You could check -<a href="/work/{{ release.work_id }}">other releases for this work</a> for an -accessible version. -{% endif %} {% endif %} -{% if entity.state == 'active' %} -{% if entity.filesets != [] %} +{% if entity.filesets != [] and entity.filesets != None %} <h3>File Sets</h3> <table class="ui compact fixed table"> <tbody> @@ -181,10 +176,8 @@ accessible version. </tbody> </table> {% endif %} -{% endif %} -{% if entity.state == 'active' %} -{% if entity.webcaptures != [] %} +{% if entity.webcaptures != [] and entity.webcaptures != None %} <h3>Web Captures</h3> <table class="ui single line compact fixed table"> <tbody> @@ -203,9 +196,17 @@ accessible version. </tbody> </table> {% endif %} + +{% if not (entity.files or entity.filesets or entity.webcaptures) %} +<h3>Archived Content</h3> +<p>There are no accessible files associated with this release. You could check +<a href="/work/{{ release.work_id }}">other releases for this work</a> for an +accessible version. +{% endif %} + {% endif %} -</div> +</div> <div class="column" style="flex: 0 0 24em;"> |