From 743940ce6075c1a1b547915a33ad8874094ae762 Mon Sep 17 00:00:00 2001 From: bnewbold Date: Thu, 6 Jun 2019 00:17:16 -0700 Subject: experiment with entity view tabs --- python/fatcat_web/routes.py | 12 ++ python/fatcat_web/templates/entity_base.html | 70 +++++++++++ python/fatcat_web/templates/entity_history.html | 13 +- python/fatcat_web/templates/entity_metadata.html | 13 ++ python/fatcat_web/templates/release_files.html | 91 ++++++++++++++ .../fatcat_web/templates/release_references.html | 44 +++++++ python/fatcat_web/templates/release_view.html | 134 +++++++-------------- 7 files changed, 279 insertions(+), 98 deletions(-) create mode 100644 python/fatcat_web/templates/entity_base.html create mode 100644 python/fatcat_web/templates/entity_metadata.html create mode 100644 python/fatcat_web/templates/release_files.html create mode 100644 python/fatcat_web/templates/release_references.html diff --git a/python/fatcat_web/routes.py b/python/fatcat_web/routes.py index 9af0724e..e44f4f9b 100644 --- a/python/fatcat_web/routes.py +++ b/python/fatcat_web/routes.py @@ -285,6 +285,18 @@ 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//references', methods=['GET']) +def release_view_references(ident): + return generic_entity_view('release', ident, 'release_references.html') + +@app.route('/release//metadata', methods=['GET']) +def release_view_metadata(ident): + return generic_entity_view('release', ident, 'entity_metadata.html') + @app.route('/release/rev/', methods=['GET']) def release_revision_view(revision_id): entity = generic_get_entity_revision('release', revision_id) diff --git a/python/fatcat_web/templates/entity_base.html b/python/fatcat_web/templates/entity_base.html new file mode 100644 index 00000000..aa32ac3b --- /dev/null +++ b/python/fatcat_web/templates/entity_base.html @@ -0,0 +1,70 @@ +{% extends "base.html" %} + +{% macro entity_tab(name, text, url_suffix) %} +{{ text }} +{% endmacro %} + +{% block fullmain %} +
+
+
+
+

+ {% if entity_type == "release" %} + {{ entity.title }} + {% if entity.subtitle %} +
{{ entity.subtitle }} + {% endif %} + {% endif %} + + {{ entity_type }}_{{ entity.ident }} + +

+ {% if entity_type == "release" %} +

+ {% if authors and authors != [] %} by + {% for contrib in authors[:12] %} + {% if contrib.creator_id %} + {{ contrib.raw_name }}{% if not loop.last %}, {% endif %} + {% else %} + {% if contrib.raw_name != None %}{{ contrib.raw_name }}{% else %}Unknown{% endif %}{% if not loop.last %}, {% endif %} + {% endif %} + {% endfor %} + {% if authors|count > 12 %} (+{{ authors|length - 12 }} others) + {% endif %} +
+ {% endif %} + {% endif %} +

+ + +
+
+
+
+
+ +
+
+
+ {% block entity_main %}{% endblock %} +
+
+
+{% endblock %} + +{% block postscript %} + +{% endblock %} diff --git a/python/fatcat_web/templates/entity_history.html b/python/fatcat_web/templates/entity_history.html index eee87487..73a3df92 100644 --- a/python/fatcat_web/templates/entity_history.html +++ b/python/fatcat_web/templates/entity_history.html @@ -1,13 +1,8 @@ -{% extends "base.html" %} -{% block body %} +{% set entity_view = "history" %} +{% set entity_type = "release" %} +{% extends "entity_base.html" %} -

{% if page_title != None %}{{ page_title }}{% endif %} - -

+{% block entity_main %}

Edit History

diff --git a/python/fatcat_web/templates/entity_metadata.html b/python/fatcat_web/templates/entity_metadata.html new file mode 100644 index 00000000..7812a6e3 --- /dev/null +++ b/python/fatcat_web/templates/entity_metadata.html @@ -0,0 +1,13 @@ +{% set entity_view = "metadata" %} +{% import "entity_macros.html" as entity_macros %} +{% extends "entity_base.html" %} + +{% block entity_main %} + +{% if entity.extra %} +

Extra Metadata (raw JSON)

+ {{ entity_macros.extra_metadata(entity.extra) }} +{% endif %} + +{% endblock %} + diff --git a/python/fatcat_web/templates/release_files.html b/python/fatcat_web/templates/release_files.html new file mode 100644 index 00000000..c8432cb5 --- /dev/null +++ b/python/fatcat_web/templates/release_files.html @@ -0,0 +1,91 @@ +{% 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_references.html b/python/fatcat_web/templates/release_references.html new file mode 100644 index 00000000..0bf58482 --- /dev/null +++ b/python/fatcat_web/templates/release_references.html @@ -0,0 +1,44 @@ +{% set entity = release %} +{% set entity_view = "references" %} +{% set entity_type = "release" %} +{% import "entity_macros.html" as entity_macros %} +{% extends "entity_base.html" %} + +{% block entity_main %} + +{% if release.refs != None and release.refs.size != 0 %} +

References

+This release citing other releases +{# see https://github.com/Semantic-Org/Semantic-UI/issues/2639 #} +
    + {% for ref in release.refs %} +
  1. + {% if ref.title %} + {{ ref.title }} + {% if ref.container_name %}{{ ref.container_name }}.{% endif %} + {% if ref.year %}{{ ref.year }}{% endif %} + {% if ref.locator %}{{ ref.locator }}{% endif %} + {% elif ref.extra != None %} + {% if ref.extra.get('author') %}{{ ref.extra['author'] }}.{% endif %} + {% if ref.extra.get('article-title') %}{{ ref.extra['article-title'] }}.{% endif %} + {% if ref.container_name %}{{ ref.container_name }}.{% endif %} + {% if ref.year %}{{ ref.year }}.{% endif %} + {% if ref.extra.unstructured %}{{ ref.extra.unstructured }}{% endif %} + {% else %} + unknown + {% endif %} + {% if ref.target_release_id != None %} + (fatcat entry) + {% endif %} + {% if ref.extra != None and ref.extra.doi %} + (DOI: {{ ref.extra.doi }}) + {% endif %} +
  2. + {% endfor %} +
+{% else %} +

No reference list available. +{% endif %} + +{% endblock %} + diff --git a/python/fatcat_web/templates/release_view.html b/python/fatcat_web/templates/release_view.html index 5fdc2244..a5fb0962 100644 --- a/python/fatcat_web/templates/release_view.html +++ b/python/fatcat_web/templates/release_view.html @@ -1,6 +1,7 @@ -{% set release = entity %} +{% set entity = release %} +{% set entity_view = "overview" %} {% import "entity_macros.html" as entity_macros %} -{% extends "base.html" %} +{% extends "entity_base.html" %} {# HTML metadata embeddings #} {% if release and release.status == "active" %} @@ -19,7 +20,7 @@ {% endif %} - {% for author in release._authors %} + {% for author in authors %} {% endfor %} @@ -89,16 +90,15 @@

- {% if release._authors != [] %} by {% endif %} - {% for contrib in release._authors[:12] %} + {% if authors != [] %} by {% endif %} + {% for contrib in authors[:12] %} {% if contrib.creator_id %} {{ contrib.raw_name }}{% if not loop.last %}, {% endif %} {% else %} {% if contrib.raw_name != None %}{{ contrib.raw_name }}{% else %}Unknown{% endif %}{% if not loop.last %}, {% endif %} {% endif %} {% endfor %} - {% if release._authors|count > 12 %} - (+{{ release._authors|length - 12 }} others) + {% if authors|count > 12 %} (+{{ authors|length - 12 }} others) {% endif %} @@ -107,13 +107,19 @@

+{% if release.abstracts != [] %} +

Abstract

+

{{ release.abstracts[0].content }} +
In {{ release.abstracts[0].mimetype }} format +{% endif %} +

{% if release.release_stage == 'published' %} - Published in {{ release.container.name }} + Published in {{ container.name }} {% else %} Released as a {{ release.release_type }} - {% if release.container %} in {{ release.container.name }} {% endif %} + {% if container %} in {{ container.name }} {% endif %} {% endif %} {% if release.publisher %} by {{ release.publisher }} @@ -129,9 +135,9 @@ Version {{ release.version }} {% endif %} - {% if release.container != None and release.container.issnl != None %} + {% if container != None and container.issnl != None %} ISSN-L - {{ release.container.issnl }} + {{ container.issnl }} {% endif %} {% if release.volume != None %} @@ -155,9 +161,9 @@ Release Year {{ release.release_year }} {% endif %} - {% if release.container != None and release.container.container_type != None %} + {% if container != None and container.container_type != None %} Container Type - {{ release.container.container_type }} + {{ container.container_type }} {% endif %} {% if release.publisher != None %} Publisher @@ -204,19 +210,6 @@

No known contributors (authors, translators, etc). {% endif %} -{% if release.abstracts != [] %} -

Abstract

-

{{ release.abstracts[0].content }} -
In {{ release.abstracts[0].mimetype }} format -{% endif %} - - -{% if entity.extra %} -

Extra Metadata (raw JSON)

- {{ entity_macros.extra_metadata(entity.extra) }} -{% endif %} - -{% if entity.status == 'active' %}

Known Files and URLs

{% if entity.files != [] %} @@ -252,15 +245,14 @@

There are no known files associated with this release (you could try other releases for this work?). {% endif %} -{% endif %} -{% if entity.status == 'active' %} + {% if entity.filesets != [] %}

File Sets

{% for fileset in entity.filesets %} -
{{ fileset.manifest|count }} files  {{ fileset._total_size|filesizeformat }} +
{{ fileset.manifest|count }} files  {{ fileset.total_size|filesizeformat }}
fileset:{{ fileset.ident }}
{% for url in fileset.urls[:5] %} @@ -277,9 +269,8 @@
{% endif %} -{% endif %} -{% if entity.status == 'active' %} + {% if entity.webcaptures != [] %}

Web Captures

@@ -290,7 +281,7 @@
webcapture:{{ webcapture.ident }}
{% for url in webcapture.archive_urls[:5] %} - {{ url.url.split('/')[2] }} ({{ url.rel }})
+ {{ url.url.split('/')[2] }} ({{ url.rel }})
{% endfor %} {% if webcapture.urls|length > 5 %} + {{ file.urls|length - 5 }} more URLs @@ -299,50 +290,15 @@
{% endif %} -{% endif %} - -{% if release.refs != None and release.refs.size != 0 %} -

References

-This release citing other releases -{# see https://github.com/Semantic-Org/Semantic-UI/issues/2639 #} -
    - {% for ref in release.refs %} -
  1. - {% if ref.title %} - {{ ref.title }} - {% if ref.container_name %}{{ ref.container_name }}.{% endif %} - {% if ref.year %}{{ ref.year }}{% endif %} - {% if ref.locator %}{{ ref.locator }}{% endif %} - {% elif ref.extra != None %} - {% if ref.extra.get('author') %}{{ ref.extra['author'] }}.{% endif %} - {% if ref.extra.get('article-title') %}{{ ref.extra['article-title'] }}.{% endif %} - {% if ref.container_name %}{{ ref.container_name }}.{% endif %} - {% if ref.year %}{{ ref.year }}.{% endif %} - {% if ref.extra.unstructured %}{{ ref.extra.unstructured }}{% endif %} - {% else %} - unknown - {% endif %} - {% if ref.target_release_id != None %} - (fatcat entry) - {% endif %} - {% if ref.extra != None and ref.extra.doi %} - (DOI: {{ ref.extra.doi }}) - {% endif %} -
  2. - {% endfor %} -
-{% else %} -

No reference list available. -{% endif %}

-{% if entity.status == 'active' and entity.files != [] and entity.files[0].urls != [] %} +{% if entity.files != [] and entity.files[0].urls != [] %} Download Full Text -{% elif entity.status == 'active' and entity.webcaptures != [] and entity.webcaptures[0].archive_urls != [] and entity.webcaptures[0].archive_urls[0].rel == "wayback" %} -View Web Archive +{% elif entity.webcaptures != [] and entity.webcaptures[0].archive_urls != [] and entity.webcaptures[0].archive_urls[0].rel == "wayback" %} +View Web Archive {% else %} No Full Text Available {% endif %} @@ -405,36 +361,36 @@
{% endif %} -{% if release.container != None and release.container._es %} +{% if container != None and container.es %}
Container Metadata
-{% if release.container._es.is_oa == True %} +{% if container.es.is_oa == True %} Open Access Publication
-{% elif release.container._es.is_oa == False %} +{% elif container.es.is_oa == False %} Not Open Access
{% else %} Unknown OA Status
{% endif %} -{% if (release.container._es != None) %} - {% if release.container._es.in_doaj == True %} - In DOAJ
- {% elif release.container._es.in_doaj == False %} +{% if (container.es != None) %} + {% if container.es.in_doaj == True %} + In DOAJ
+ {% elif container.es.in_doaj == False %} Not in DOAJ
{% endif %} - {% if release.container._es.in_road == True %} - In ISSN ROAD
- {% elif release.container._es.in_road == False %} + {% if container.es.in_road == True %} + In ISSN ROAD
+ {% elif container.es.in_road == False %} Not in ISSN ROAD
{% endif %} - {% if release.container._es.in_kbart == True %} - In Keepers Registery
- {% elif release.container._es.in_kbart == False %} Not in Keepers Registry
+ {% if container.es.in_kbart == True %} + In Keepers Registery
+ {% elif container.es.in_kbart == False %} Not in Keepers Registry
{% endif %} {% endif %} -{% if release.container.issnl != None %} - ISSN-L:  {{ release.container.issnl }}
+{% if container.issnl != None %} + ISSN-L:  {{ container.issnl }}
{% endif %} - Fatcat Entry + Fatcat Entry
{% endif %} @@ -461,8 +417,8 @@
Lookup Links
- {% if release.container != None and release.container.issnl != None %} - SHERPA/RoMEO (journal policies)
+ {% if container != None and container.issnl != None %} + SHERPA/RoMEO (journal policies)
{% endif %} {% if release != None and release.ext_ids.doi != None %} oaDOI/unpaywall
@@ -483,7 +439,7 @@
-{{ entity_macros.fatcat_bits(entity, "release", "container,files,filesets,webcaptures", editgroup) }} +{{ entity_macros.fatcat_bits(entity, "release", "container,files,filesets,webcaptures") }}
-- cgit v1.2.3