From 20ad70b437df59d9564704b655afab53237b8ce0 Mon Sep 17 00:00:00 2001 From: Bryan Newbold Date: Sat, 2 Mar 2019 17:26:07 -0800 Subject: include filesets and webcaptures in release view --- python/fatcat_web/routes.py | 14 +++---- python/fatcat_web/templates/release_view.html | 56 ++++++++++++++++++++++++--- 2 files changed, 55 insertions(+), 15 deletions(-) diff --git a/python/fatcat_web/routes.py b/python/fatcat_web/routes.py index 5ccfe238..59f7d1db 100644 --- a/python/fatcat_web/routes.py +++ b/python/fatcat_web/routes.py @@ -363,8 +363,8 @@ def release_edit_view(ident): def release_view(ident): try: entity = api.get_release(ident, expand="container,files,filesets,webcaptures") - files = entity.files container = entity.container + filesets = entity.filesets except ApiException as ae: abort(ae.status) if entity.state == "redirect": @@ -375,17 +375,13 @@ def release_view(ident): entity.container.es = container_to_elasticsearch(entity.container, force_bool=False) if entity.state == "active": entity.es = release_to_elasticsearch(entity, force_bool=False) + for fs in filesets: + fs.total_size = sum([f.size for f in fs.manifest]) + entity.filesets = filesets authors = [c for c in entity.contribs if c.role in ('author', None)] authors = sorted(authors, key=lambda c: c.index) - for fe in files: - # crudely filter out exact duplicates - kept = [] - for u in fe.urls: - if not u in kept: - kept.append(u) - fe.urls = [u for u in kept if not '/web/None/' in u.url] return render_template('release_view.html', release=entity, - authors=authors, files=files, container=container) + authors=authors, container=container) @app.route('/work/create', methods=['GET']) def work_create_view(): diff --git a/python/fatcat_web/templates/release_view.html b/python/fatcat_web/templates/release_view.html index 684c71ab..0e09e6ab 100644 --- a/python/fatcat_web/templates/release_view.html +++ b/python/fatcat_web/templates/release_view.html @@ -127,7 +127,7 @@

Known Files and URLs

-{% if files != [] %} +{% if entity.files != [] %} - {% for file in files %} + {% for file in entity.files %}
{% if file.mimetype != None %}{{ file.mimetype }}  {% endif %} {% if file.size != None %}{{ file.size|filesizeformat }}{% endif %}
@@ -163,10 +163,54 @@ other releases for this work?). {% endif %} + +{% if entity.filesets != [] %} +

File Sets

+ + + {% for fileset in entity.filesets %} + +
{{ fileset.manifest|count }} files  {{ fileset.total_size|filesizeformat }} +
fileset:{{ fileset.ident }} +
+ {% for url in fileset.urls[:5] %} + {{ url.url.split('/')[2] }} ({{ url.rel }})
+ {% endfor %} + {% if fileset.urls|length > 5 %} + + {{ file.urls|length - 5 }} more URLs + {% endif %} + {% endfor %} +
+ +{% endif %} + + +{% if entity.webcaptures != [] %} +

Web Captures

+ + + {% for webcapture in entity.webcaptures %} + +
{{ webcapture.original_url }} +
{{ webcapture.timestamp }} | {{ webcapture.cdx|count }} resources +
webcapture:{{ webcapture.ident }} +
+ {% for url in webcapture.archive_urls[:5] %} + {{ url.url.split('/')[2] }} ({{ url.rel }})
+ {% endfor %} + {% if webcapture.urls|length > 5 %} + + {{ file.urls|length - 5 }} more URLs + {% endif %} + {% endfor %} +
+ +{% endif %} + + {% if release.refs != None and release.refs.size != 0 %}

References

-This release citing other releases. -
    +This release citing other releases +
      {% for ref in release.refs %}
    1. {% if ref.title %} @@ -198,8 +242,8 @@ This release citing other releases.
      -{% if files != [] and files[0].urls != [] %} -Download Full Text +{% if entity.files != [] and entity.files[0].urls != [] %} +Download Full Text {% else %} No Full Text Available {% endif %} -- cgit v1.2.3