diff options
author | Bryan Newbold <bnewbold@robocracy.org> | 2019-03-01 15:48:10 -0800 |
---|---|---|
committer | Bryan Newbold <bnewbold@robocracy.org> | 2019-03-01 15:48:10 -0800 |
commit | ec0d7f3b50390c2b9140ea954787d365b8d225ae (patch) | |
tree | f95261e7ace1898abf9256d520b086f54e257bdc /python/fatcat_web | |
parent | ddd5912a825ef42670cf164cf64989072bb57e5f (diff) | |
download | fatcat-ec0d7f3b50390c2b9140ea954787d365b8d225ae.tar.gz fatcat-ec0d7f3b50390c2b9140ea954787d365b8d225ae.zip |
make 'Fatcat Bits' a macro
Diffstat (limited to 'python/fatcat_web')
-rw-r--r-- | python/fatcat_web/templates/container_view.html | 16 | ||||
-rw-r--r-- | python/fatcat_web/templates/creator_view.html | 16 | ||||
-rw-r--r-- | python/fatcat_web/templates/entity_macros.html | 14 | ||||
-rw-r--r-- | python/fatcat_web/templates/file_view.html | 26 | ||||
-rw-r--r-- | python/fatcat_web/templates/release_view.html | 62 | ||||
-rw-r--r-- | python/fatcat_web/templates/work_view.html | 16 |
6 files changed, 65 insertions, 85 deletions
diff --git a/python/fatcat_web/templates/container_view.html b/python/fatcat_web/templates/container_view.html index c19d8c1c..3e69be34 100644 --- a/python/fatcat_web/templates/container_view.html +++ b/python/fatcat_web/templates/container_view.html @@ -1,4 +1,7 @@ +{% set entity = container %} +{% import "entity_macros.html" as entity_macros %} {% extends "base.html" %} + {% block fullbody %} <div class="ui stackable mobile reversed grid centered"> @@ -126,19 +129,10 @@ Raw Object: {% if not container.wikidata_qid %} <br><a href="https://www.wikidata.org/w/index.php?search={{ container.name }}">wikidata.org</a> {% endif %} -</div><div class="ui segment attached"> - -<b>Fatcat Bits</b> -<p>State is "{{ container.state }}". Revision: -<br><small><code>{{ container.revision }}</code></small> -<br><a href="https://api.{{ config.FATCAT_DOMAIN }}/v0/container/{{ container.ident }}">As JSON object via API</a> - -</div> -<div class="two ui buttons bottom attached"> - <a href="/container/{{ container.ident }}/edit" class="ui blue button">Edit Metadata</a> - <a href="/container/{{ container.ident }}/history" class="ui button">View History</a> </div> +{{ entity_macros.fatcat_bits(entity, "container", "") }} + </div> </div> diff --git a/python/fatcat_web/templates/creator_view.html b/python/fatcat_web/templates/creator_view.html index e66fe927..03fcfc74 100644 --- a/python/fatcat_web/templates/creator_view.html +++ b/python/fatcat_web/templates/creator_view.html @@ -1,4 +1,7 @@ +{% set entity = creator %} +{% import "entity_macros.html" as entity_macros %} {% extends "base.html" %} + {% block fullbody %} <div class="ui stackable mobile reversed grid centered"> @@ -89,19 +92,10 @@ Raw Object: <br><a href="https://viaf.org/viaf/search?query=local.personalNames%20all%20%22{{ creator.display_name }}">VIAF</a> <br><a href="http://dblp.uni-trier.de/search?q={{ creator.display_name }}">dblp</a> (CS) <br><a href="https://scholar.google.com/scholar?q={{ creator.display_name }}">Google Scholar</a> -</div><div class="ui segment attached"> - -<b>Fatcat Bits</b> -<p>State is "{{ creator.state }}". Revision: -<br><small><code>{{ creator.revision }}</code></small> -<br><a href="https://api.{{ config.FATCAT_DOMAIN }}/v0/creator/{{ creator.ident }}">As JSON object via API</a> - -</div> -<div class="two ui buttons bottom attached"> - <a href="/creator/{{ creator.ident }}/edit" class="ui blue button">Edit Metadata</a> - <a href="/creator/{{ creator.ident }}/history" class="ui button">View History</a> </div> +{{ entity_macros.fatcat_bits(entity, "creator", "") }} + </div> </div> diff --git a/python/fatcat_web/templates/entity_macros.html b/python/fatcat_web/templates/entity_macros.html new file mode 100644 index 00000000..f714a63a --- /dev/null +++ b/python/fatcat_web/templates/entity_macros.html @@ -0,0 +1,14 @@ + +{% macro fatcat_bits(entity, entity_type, expand="") -%} +<div class="ui segment attached"> + <b>Fatcat Bits</b> + <p>State is "{{ entity.state }}". Revision: + <br><small><code>{{ entity.revision }}</code></small> + <br><a href="https://api.{{ config.FATCAT_DOMAIN }}/v0/release/{{ entity.ident }}{% if expand %}?expand={{ expand}}{% endif %}">As JSON object via API</a> +</div> + +<div class="two ui buttons bottom attached"> + <a href="/{{ entity_type }}/{{ entity.ident }}/edit" class="ui blue button">Edit Metadata</a> + <a href="/{{ entity_type }}/{{ entity.ident }}/history" class="ui button">View History</a> +</div> +{%- endmacro %} diff --git a/python/fatcat_web/templates/file_view.html b/python/fatcat_web/templates/file_view.html index 77ecae4e..c2497040 100644 --- a/python/fatcat_web/templates/file_view.html +++ b/python/fatcat_web/templates/file_view.html @@ -1,4 +1,7 @@ +{% set entity = file %} +{% import "entity_macros.html" as entity_macros %} {% extends "base.html" %} + {% block fullbody %} <div class="ui stackable mobile reversed grid centered"> @@ -99,28 +102,19 @@ Raw Object: <span class="ui top attached fluid huge grey button"><i class="file cross icon"></i>No Download Available</span> {% endif %} -<div class="ui segment attached"> - {% if file.size != None %} -<p><b>Size</b> {{ file.size|filesizeformat }} (bytes) -</div><div class="ui segment attached"> +<div class="ui segment attached"> + <p><b>Size</b> {{ file.size|filesizeformat }} (bytes) +</div> {% endif %} {% if file.mimetype != None %} -<p><b>File Type</b> <code>{{ file.mimetype }}</code> -</div><div class="ui segment attached"> +<div class="ui segment attached"> + <p><b>File Type</b> <code>{{ file.mimetype }}</code> +</div> {% endif %} -<b>Fatcat Bits</b> -<p>State is "{{ file.state }}". Revision: -<br><small><code>{{ file.revision }}</code></small> -<br><a href="https://api.{{ config.FATCAT_DOMAIN }}/v0/file/{{ file.ident }}">As JSON object via API</a> - -</div> -<div class="two ui buttons bottom attached"> - <a href="/file/{{ file.ident }}/edit" class="ui blue button">Edit Metadata</a> - <a href="/file/{{ file.ident }}/history" class="ui button">View History</a> -</div> +{{ entity_macros.fatcat_bits(entity, "file", "") }} </div> </div> diff --git a/python/fatcat_web/templates/release_view.html b/python/fatcat_web/templates/release_view.html index 6259f0e2..5b4236cf 100644 --- a/python/fatcat_web/templates/release_view.html +++ b/python/fatcat_web/templates/release_view.html @@ -1,4 +1,7 @@ +{% set entity = release %} +{% import "entity_macros.html" as entity_macros %} {% extends "base.html" %} + {% block fullbody %} <div class="ui stackable mobile reversed grid centered"> @@ -24,11 +27,10 @@ <div class="ui accordion"> <div class="title"> - <i class="dropdown icon"></i> {% if release.release_status == 'published' %} - Published in <a href="/container/{{ container.ident }}">{{ container.name }}</a> + <i class="dropdown icon"></i>Published in <a href="/container/{{ container.ident }}">{{ container.name }}</a> {% else %} - Released as a <i>{{ release.release_type }}</i> + <i class="dropdown icon"></i>Released as a <i>{{ release.release_type }}</i> {% if container %} in <a href="/container/{{ container.ident }}">{{ container.name }}</a> {% endif %} {% endif %} {% if release.publisher %} @@ -286,39 +288,29 @@ This release citing other releases. <div class="ui segment attached accordion"> <div class="title" style="padding: 0px;"><i class="dropdown icon"></i><b>Lookup Links</b></div> <div class="content"> -{% if container != None and container.issnl != None %} - <a href="http://www.sherpa.ac.uk/romeo/issn/{{ container.issnl }}/">SHERPA/RoMEO</a> (journal policies)<br/> -{% endif %} -{% if container != None and container.doi != None %} - <a href="https://oadoi.org/{{ release.doi }}">oaDOI/unpaywall</a><br/> -{% endif %} -{% if release.isbn13 != None %} - <a href="https://openlibrary.org/search?isbn={{ release.isbn13 }}">Open Library</a><br> - <a href="http://www.worldcat.org/search?q=bn%3A{{ release.isbn13 }}">Worldcat</a><br> -{% else %} - <a href="http://www.worldcat.org/search?qt=worldcat_org_art&q={{ release.title }}">Worldcat</a><br> -{% endif %} -{% if release.doi %} -<a href="https://api.crossref.org/v1/works/http://dx.doi.org/{{ release.doi }}">Crossref Metadata</a> (via API)<br> -{% endif %} -<a href="https://www.wikidata.org/w/index.php?search={{ release.title }}">wikidata.org</a><br> -<a href="https://core.ac.uk/search?q={{ release.title }}">CORE.ac.uk</a><br> -<a href="https://www.semanticscholar.org/search?q={{ release.title }}">Semantic Scholar</a> (CS, neuro)<br> -<a href="https://scholar.google.com/scholar?q={{ release.title }}">Google Scholar</a><br> + {% if container != None and container.issnl != None %} + <a href="http://www.sherpa.ac.uk/romeo/issn/{{ container.issnl }}/">SHERPA/RoMEO</a> (journal policies)<br/> + {% endif %} + {% if container != None and container.doi != None %} + <a href="https://oadoi.org/{{ release.doi }}">oaDOI/unpaywall</a><br/> + {% endif %} + {% if release.isbn13 != None %} + <a href="https://openlibrary.org/search?isbn={{ release.isbn13 }}">Open Library</a><br> + <a href="http://www.worldcat.org/search?q=bn%3A{{ release.isbn13 }}">Worldcat</a><br> + {% else %} + <a href="http://www.worldcat.org/search?qt=worldcat_org_art&q={{ release.title }}">Worldcat</a><br> + {% endif %} + {% if release.doi %} + <a href="https://api.crossref.org/v1/works/http://dx.doi.org/{{ release.doi }}">Crossref Metadata</a> (via API)<br> + {% endif %} + <a href="https://www.wikidata.org/w/index.php?search={{ release.title }}">wikidata.org</a><br> + <a href="https://core.ac.uk/search?q={{ release.title }}">CORE.ac.uk</a><br> + <a href="https://www.semanticscholar.org/search?q={{ release.title }}">Semantic Scholar</a> (CS, neuro)<br> + <a href="https://scholar.google.com/scholar?q={{ release.title }}">Google Scholar</a><br> </div> </div> -<div class="ui segment attached"> -<b>Fatcat Bits</b> -<p>State is "{{ release.state }}". Revision: -<br><small><code>{{ release.revision }}</code></small> -<br><a href="https://api.{{ config.FATCAT_DOMAIN }}/v0/release/{{ release.ident }}?expand=container,files,filesets,webcaptures">As JSON object via API</a> - -</div> -<div class="two ui buttons bottom attached"> - <a href="/release/{{ release.ident }}/edit" class="ui blue button">Edit Metadata</a> - <a href="/release/{{ release.ident }}/history" class="ui button">View History</a> -</div> +{{ entity_macros.fatcat_bits(entity, "release", "container,files,filesets,webcaptures") }} </div> </div> @@ -326,8 +318,6 @@ This release citing other releases. {% block postscript %} <script> -$('.ui.accordion') - .accordion() -; + $('.ui.accordion').accordion(); </script> {% endblock %} diff --git a/python/fatcat_web/templates/work_view.html b/python/fatcat_web/templates/work_view.html index 9a560ae4..b81293ce 100644 --- a/python/fatcat_web/templates/work_view.html +++ b/python/fatcat_web/templates/work_view.html @@ -1,4 +1,7 @@ +{% set entity = work %} +{% import "entity_macros.html" as entity_macros %} {% extends "base.html" %} + {% block fullbody %} <div class="ui stackable mobile reversed grid centered"> @@ -65,19 +68,10 @@ pre-print and a published article may contain small differences, but still reference the same underlying "work". </div> -<div class="five wide column"> -<div class="ui segment top attached"> -<b>Fatcat Bits</b> -<p>State is "{{ work.state }}". Revision: -<br><small><code>{{ work.revision }}</code></small> -<br><a href="https://api.{{ config.FATCAT_DOMAIN }}/v0/work/{{ work.ident }}">As JSON object via API</a> +<div class="five wide column"> -</div> -<div class="two ui buttons bottom attached"> - <a href="/work/{{ work.ident }}/edit" class="ui blue button">Edit Metadata</a> - <a href="/work/{{ work.ident }}/history" class="ui button">View History</a> -</div> +{{ entity_macros.fatcat_bits(entity, "work", "") }} </div> </div> |