From 210f39a845e676e162eaa73d7ca401a8d3d89bcf Mon Sep 17 00:00:00 2001 From: Bryan Newbold Date: Mon, 10 Jun 2019 17:46:47 -0700 Subject: entity view tweaks --- python/fatcat_web/routes.py | 10 +- python/fatcat_web/templates/entity_base.html | 12 +-- python/fatcat_web/templates/entity_macros.html | 2 +- python/fatcat_web/templates/entity_metadata.html | 3 + python/fatcat_web/templates/release_contribs.html | 34 +++++++ python/fatcat_web/templates/release_files.html | 91 ------------------- python/fatcat_web/templates/release_view.html | 106 ++++++++++++++++------ 7 files changed, 129 insertions(+), 129 deletions(-) create mode 100644 python/fatcat_web/templates/release_contribs.html delete mode 100644 python/fatcat_web/templates/release_files.html diff --git a/python/fatcat_web/routes.py b/python/fatcat_web/routes.py index e44f4f9b..ebb70d90 100644 --- a/python/fatcat_web/routes.py +++ b/python/fatcat_web/routes.py @@ -198,6 +198,10 @@ def generic_entity_view(entity_type, ident, view_template): elif entity.state == "deleted": return render_template('deleted_entity.html', entity_type=entity_type, entity=entity) + metadata = entity.to_dict() + metadata.pop('extra') + entity._metadata = metadata + return render_template(view_template, entity=entity, editgroup_id=None) def generic_editgroup_entity_view(editgroup_id, entity_type, ident, view_template): @@ -285,9 +289,9 @@ def webcapture_editgroup_view(editgroup_id, ident): def release_view(ident): return generic_entity_view('release', ident, 'release_view.html') -@app.route('/release//files', methods=['GET']) -def release_view_files(ident): - return generic_entity_view('release', ident, 'release_files.html') +@app.route('/release//contribs', methods=['GET']) +def release_view_contribs(ident): + return generic_entity_view('release', ident, 'release_contribs.html') @app.route('/release//references', methods=['GET']) def release_view_references(ident): diff --git a/python/fatcat_web/templates/entity_base.html b/python/fatcat_web/templates/entity_base.html index aa32ac3b..6b64dfdf 100644 --- a/python/fatcat_web/templates/entity_base.html +++ b/python/fatcat_web/templates/entity_base.html @@ -1,14 +1,14 @@ {% extends "base.html" %} -{% macro entity_tab(name, text, url_suffix) %} -{{ text }} +{% macro entity_tab(name, text, url_suffix, count=None) %} +{{ text }}{% if count != None %} ({{ count }}){% endif %} {% endmacro %} {% block fullmain %}
-
+

{% if entity_type == "release" %} {{ entity.title }} @@ -39,8 +39,8 @@ @@ -56,7 +56,7 @@
-
+
{% block entity_main %}{% endblock %}
diff --git a/python/fatcat_web/templates/entity_macros.html b/python/fatcat_web/templates/entity_macros.html index 77d4ff81..1d798dfb 100644 --- a/python/fatcat_web/templates/entity_macros.html +++ b/python/fatcat_web/templates/entity_macros.html @@ -55,7 +55,7 @@ {% else %} {{ key }} - {{ value }} + {% if value != None %}{{ value }}{% endif %} {% endif %} {% endfor %} diff --git a/python/fatcat_web/templates/entity_metadata.html b/python/fatcat_web/templates/entity_metadata.html index 7812a6e3..5ce97d10 100644 --- a/python/fatcat_web/templates/entity_metadata.html +++ b/python/fatcat_web/templates/entity_metadata.html @@ -9,5 +9,8 @@ {{ entity_macros.extra_metadata(entity.extra) }} {% endif %} +

Entity Metadata (schema)

+{{ entity_macros.extra_metadata(entity._metadata) }} + {% endblock %} diff --git a/python/fatcat_web/templates/release_contribs.html b/python/fatcat_web/templates/release_contribs.html new file mode 100644 index 00000000..21df2339 --- /dev/null +++ b/python/fatcat_web/templates/release_contribs.html @@ -0,0 +1,34 @@ +{% set entity = release %} +{% set entity_view = "contribs" %} +{% set entity_type = "release" %} +{% import "entity_macros.html" as entity_macros %} +{% extends "entity_base.html" %} + +{% block entity_main %} + +{% if release.contribs|length > 0 %} + + +{% for contrib in release.contribs %} + +
{% if contrib.index or contrib.index == 0 %} {{ contrib.index + 1 }}{% endif %} +
{{ contrib.role or 'unknown' }} +{% endfor %} +
+{% else %} +

No known contributors (authors, translators, etc). +{% endif %} + +{% endblock %} + diff --git a/python/fatcat_web/templates/release_files.html b/python/fatcat_web/templates/release_files.html deleted file mode 100644 index c8432cb5..00000000 --- a/python/fatcat_web/templates/release_files.html +++ /dev/null @@ -1,91 +0,0 @@ -{% set entity = release %} -{% set entity_view = "files" %} -{% set entity_type = "release" %} -{% import "entity_macros.html" as entity_macros %} -{% extends "entity_base.html" %} - -{% block entity_main %} - -

Known Files and URLs

-{% if entity.files != [] %} - - - - {% for file in entity.files %} - -
{% if file.mimetype != None %}{{ file.mimetype }}  {% endif %} - {% if file.size != None %}{{ file.size|filesizeformat }}{% endif %} -
- {% if file.sha1 != None %}sha1:{{ file.sha1[:20] + "..." }} - {% elif file.sha256!= None %}sha256:{{ file.md5[:20] + "..." }} - {% elif file.md5 != None %}md5:{{ file.md5[:20] + "..." }} - {% endif %} - -
- {% for url in file.urls[:5] %} - {{ url.url.split('/')[2] }} ({{ url.rel }})
- {% endfor %} - {% if file.urls|length > 5 %} - + {{ file.urls|length - 5 }} more URLs - {% endif %} - {% endfor %} -
-{% else %} -

There are no known files associated with this release (you could try -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] %} - {% if url.rel == "dweb" %} - {{ url.url }} ({{ url.rel }})
- {% else %} - {{ url.url.split('/')[2] }} ({{ url.rel }})
- {% endif %} - {% 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.strftime("%Y-%m-%d %H:%M:%S") }} | {{ 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 %} - -{% endblock %} - diff --git a/python/fatcat_web/templates/release_view.html b/python/fatcat_web/templates/release_view.html index a5fb0962..ad863a64 100644 --- a/python/fatcat_web/templates/release_view.html +++ b/python/fatcat_web/templates/release_view.html @@ -104,7 +104,6 @@
-
{% if release.abstracts != [] %} @@ -180,34 +179,85 @@
-{% if release.contribs|length > 0 %} -
-
- All Contributors ({{ release.contribs|length }}) -
- - -{% for contrib in release.contribs %} - +

Known Files and URLs

+{% if entity.files != [] %} +
{% if contrib.index or contrib.index == 0 %} {{ contrib.index + 1 }}{% endif %} -
{{ contrib.role or 'unknown' }} -{% endfor %} -
+ + + {% for file in entity.files %} +
{% if file.mimetype != None %}{{ file.mimetype }}  {% endif %} + {% if file.size != None %}{{ file.size|filesizeformat }}{% endif %} +
+ {% if file.sha1 != None %}sha1:{{ file.sha1[:20] + "..." }} + {% elif file.sha256!= None %}sha256:{{ file.md5[:20] + "..." }} + {% elif file.md5 != None %}md5:{{ file.md5[:20] + "..." }} + {% endif %} + +
+ {% for url in file.urls[:5] %} + {{ url.url.split('/')[2] }} ({{ url.rel }})
+ {% endfor %} + {% if file.urls|length > 5 %} + + {{ file.urls|length - 5 }} more URLs + {% endif %} + {% endfor %} +
-
-
{% else %} -

No known contributors (authors, translators, etc). +

There are no known files associated with this release (you could try +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] %} + {% if url.rel == "dweb" %} + {{ url.url }} ({{ url.rel }})
+ {% else %} + {{ url.url.split('/')[2] }} ({{ url.rel }})
+ {% endif %} + {% 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.strftime("%Y-%m-%d %H:%M:%S") }} | {{ 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 %}

Known Files and URLs

@@ -293,7 +343,7 @@
-
+
{% if entity.files != [] and entity.files[0].urls != [] %} Download Full Text -- cgit v1.2.3