diff options
-rw-r--r-- | python/fatcat_web/routes.py | 9 | ||||
-rw-r--r-- | python/fatcat_web/templates/container_view.html | 20 | ||||
-rw-r--r-- | python/fatcat_web/templates/file_view.html | 70 | ||||
-rw-r--r-- | python/fatcat_web/templates/release_view.html | 215 | ||||
-rw-r--r-- | python/fatcat_web/templates/stats.html | 24 | ||||
-rw-r--r-- | python/fatcat_web/templates/work_view.html | 55 |
6 files changed, 237 insertions, 156 deletions
diff --git a/python/fatcat_web/routes.py b/python/fatcat_web/routes.py index acc4b3e2..1eeab279 100644 --- a/python/fatcat_web/routes.py +++ b/python/fatcat_web/routes.py @@ -207,8 +207,15 @@ def file_view(ident): abort(ae.status) if entity.state == "redirect": return redirect('/file/{}'.format(entity.redirect)) - if entity.state == "deleted": + elif entity.state == "deleted": return render_template('deleted_entity.html', entity=entity) + else: + try: + entity.releases = [] + for r in entity.release_ids: + entity.releases.append(api.get_release(r)) + except ApiException as ae: + abort(ae.status) return render_template('file_view.html', file=entity) @app.route('/release/lookup', methods=['GET']) diff --git a/python/fatcat_web/templates/container_view.html b/python/fatcat_web/templates/container_view.html index 1d237023..c19d8c1c 100644 --- a/python/fatcat_web/templates/container_view.html +++ b/python/fatcat_web/templates/container_view.html @@ -39,7 +39,7 @@ <table class="ui definition single line fixed compact small unstackable table"> <tbody> {% for (key, value) in container.extra.items() %} - <tr><td class="three wide"><code>{{ key }}</code></td> + <tr><td class="three wide right aligned"><code>{{ key }}</code></td> <td class="seven wide"><code>{{ value }}</code> {% endfor %} </tbody> @@ -83,14 +83,16 @@ Raw Object: {% if container_stats %} <b>Release Counts</b><br> -{{ container_stats.total }} total -<br>{{ container_stats.is_preserved }} -(<b>{{ "%.1f"|format(container_stats.is_preserved/container_stats.total*100) }}%</b>) -preserved or archived -<br>{{ container_stats.in_web }} -(<b>{{ "%.1f"|format(container_stats.in_web/container_stats.total*100) }}%</b>) -fulltext available to read - </div><div class="ui segment attached"> + {{ "{:,}".format(container_stats.total) }} total + {% if container_stats.total >= 1 %} + <br>{{ "{:,}".format(container_stats.is_preserved) }} + (<b>{{ "{:.1f}".format(container_stats.is_preserved/container_stats.total*100) }}%</b>) + preserved or archived + <br>{{ "{:,}".format(container_stats.in_web) }} + (<b>{{ "{:.1f}".format(container_stats.in_web/container_stats.total*100) }}%</b>) + fulltext available to read + {% endif %} +</div><div class="ui segment attached"> {% endif %} {% if (container.es and container.es != None) %} diff --git a/python/fatcat_web/templates/file_view.html b/python/fatcat_web/templates/file_view.html index ccfb3ad2..532e29fb 100644 --- a/python/fatcat_web/templates/file_view.html +++ b/python/fatcat_web/templates/file_view.html @@ -13,53 +13,75 @@ <div class="one wide column"></div> <div class="ten wide column" style="font-size: 16px;"> -{% if file.extra != None %} +{% if file.extra %} <h3>Extra Metadata (raw JSON)</h3> +<table class="ui definition single line fixed compact small unstackable table"> +<tbody> {% for (key, value) in file.extra.items() %} -<code><b>{{ key }}:</b> {{ value }}</code><br> + <tr><td class="three wide right aligned"><code>{{ key }}</code></td> + <td class="seven wide"><code>{{ value }}</code> {% endfor %} +</tbody> +</table> {% endif %} <h3>Releases</h3> -{% if file.release_ids != None %} -<p>Releases associated with this file: -<ul> -{% for release_id in file.release_ids %} - <li><a href="/release/{{ release_id }}"><code>{{ release_id }}</code></a> +{% if file.releases != [] %} +<table class="ui very basic celled table"> +<tbody> +{% for release in file.releases %} + <tr><td class="two wide center aligned"> + {% if release.release_date %}{{ release.release_date }}{% elif release.release_year %}{{ release.release_year }}{% endif %} + <td class="five wide single line"> + <b><a href="/release/{{ release.ident }}">{{ release.title }}</a></b> + <br>{{ release.release_type or "unknown" }} - {{ release.release_status or "unknown" }} + {% if release.license_slug %} - {{ release.license_slug }}{% endif %} + {% if release.doi %} + <br><a href="https://doi.org/{{ release.doi }}" style="color:green;">doi:{{ release.doi }}</a> + {% endif %} {% endfor %} -</ul> +</tbody> +</table> {% else %} +<p> This file is not associated with any fatcat release. {% endif %} + <h3>URLs</h3> -{% if file.url != None %} -<p>Known locations of this file: -<ul> -{% for url in file.urls %} - <li><a href="{{ url.url }}">{{ url.url.split('/')[2] }}</a> ({{ url.rel }})<br> -{% endfor %} -</ul> +{% if file.urls != None %} +<table class="ui very basic compact single line fixed table"> +<tbody> + {% for url in file.urls %} + <tr><td class="two wide right aligned">{{ url.rel }} + <!-- <a href="{{ url.url }}">{{ url.url.split('/')[2] }}</a> - {{ url.rel }}<br> --> + <td class="eight wide"><small><code><a href="{{ url.url }}"> + {% if url.url.count('/') > 3 %} + {{ '/'.join(url.url.split('/')[0:2]) }}/<b>{{ ''.join(url.url.split('/')[2]) }}</b>/{{ '/'.join(url.url.split('/')[3:]) }} + {% else %} + {{ url.url }} + {% endif %} + </a></code></small> + {% endfor %} +</tbody> +</table> {% else %} No known public URL, mirror, or archive for this file. {% endif %} <h3>Checksums</h3> -<table class="ui compact table"> - <thead> - <tr><th>Algorithm - <th>Value +<table class="ui definition single line fixed compact small unstackable table"> <tbody> {% if file.sha1 != None %} - <tr><td>SHA-1 - <td><small><code>{{ file.sha1 }}</code></small> + <tr><td class="one wide right aligned">SHA-1 + <td class="four wide"><small><code>{{ file.sha1 }}</code></small> {% endif %} {% if file.sha256 != None %} - <tr><td>SHA-256 + <tr><td class="one wide right aligned">SHA-256 <td><small><code>{{ file.sha256 }}</code></small> {% endif %} {% if file.md5!= None %} - <tr><td>MD5 + <tr><td class="one wide right aligned">MD5 <td><small><code>{{ file.md5 }}</code></small> {% endif %} </table> @@ -81,7 +103,7 @@ Raw Object: <div class="ui segment attached"> {% if file.size != None %} -<p><b>Size</b> {{ file.size }} (bytes) +<p><b>Size</b> {{ file.size|filesizeformat }} (bytes) </div><div class="ui segment attached"> {% endif %} diff --git a/python/fatcat_web/templates/release_view.html b/python/fatcat_web/templates/release_view.html index 40e01239..6259f0e2 100644 --- a/python/fatcat_web/templates/release_view.html +++ b/python/fatcat_web/templates/release_view.html @@ -22,117 +22,136 @@ <div class="one wide column"></div> <div class="ten wide column" style="font-size: 16px;"> -{% if release.release_date != None %} - <p><b>Date (published):</b> {{ release.release_date }} -{% elif release.release_year != None %} - <p><b>Date (published):</b> {{ release.release_year }} -{% endif %} -{% if release.pmid != None %} -<br><b>PubMed:</b> <a href="https://www.ncbi.nlm.nih.gov/pubmed/{{ release.pmid }}"> <code>{{ release.pmid }}</code></a> -{% endif %} -{% if release.pmcid != None %} -<br><b>PubMed Central:</b> <a href="https://www.ncbi.nlm.nih.gov/pmc/articles/{{ release.pmcid }}"> <code>{{ release.pmcid }}</code></a> -{% endif %} -{% if release.wikidata_qid != None %} -<br><b>Wikidata Entity:</b> <a href="https://www.wikidata.org/wiki/{{ release.wikidata_qid }}"> <code>{{ release.wikidata_qid }}</code></a> -{% endif %} -{% if release.language != None %} -<br><b>Primary Language:</b> <code>{{ release.language }}</code> (<a href="https://www.loc.gov/standards/iso639-2/php/langcodes_name.php?iso_639_1={{ release.language }}">lookup ISO-639 code</a>) -{% endif %} -<br>This <i>{{ release.release_type or "unknown-type" }}</i> is a release -(version) of the work <a href="/work/{{ release.work_id }}"> <code>{{ -release.work_id }}</code></a>. There may be other releases (eg, pre-prints, -formal publications, etc) linked to the same work. - -{% if container != None %} -<div class="ui styled accordion"> +<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> {% else %} - Released in <i>{{ release.release_type }}</i> in <a href="/container/{{ container.ident }}">{{ container.name }}</a> + Released as a <i>{{ release.release_type }}</i> + {% if container %} in <a href="/container/{{ container.ident }}">{{ container.name }}</a> {% endif %} {% endif %} {% if release.publisher %} by {{ release.publisher }} {% endif %} </div><div class="content"> - {% if container != None and container.issnl != None %}<b>ISSN-L:</b> {{ container.issnl }}<br>{% endif %} - {% if release.volume != None %}<b>Volume:</b> {{ release.volume }}<br>{% endif %} - {% if release.issue != None %}<b>Issue:</b> {{ release.issue }}<br>{% endif %} - {% if release.pages != None %}<b>Page(s):</b> {{ release.pages }}<br>{% endif %} - {% if release.publisher != None %}<b>Publisher:</b> {{ release.publisher }}<br>{% endif %} - {% if release.release_status != None %}<b>Release Status:</b> {{ release.release_status }}<br>{% endif %} - {% if release.release_type != None %}<b>Release Type:</b> {{ release.release_type}}<br>{% endif %} + + <table class="ui definition single line fixed compact small collapsing unstackable table"> + <tbody> + {% if container != None and container.issnl != None %} + <tr><td class="right aligned">ISSN-L</td> + <td class="">{{ container.issnl }} + {% endif %} + {% if release.volume != None %} + <tr><td class="right aligned">Volume</td> + <td class="">{{ release.volume }} + {% endif %} + {% if release.issue != None %} + <tr><td class="right aligned">Issue</td> + <td class="">{{ release.issue }} + {% endif %} + {% if release.pages != None %} + <tr><td class="right aligned">Page(s)</td> + <td class="">{{ release.pages }} + {% endif %} + {% if release.release_date != None %} + <tr><td class="right aligned">Release Date</td> + <td class="">{{ release.release_date }} + {% elif release.release_year != None %} + <tr><td class="right aligned">Release Year</td> + <td class="">{{ release.release_year }} + {% endif %} + {% if container != None and container.container_type != None %} + <tr><td class="right aligned">Container Type</td> + <td class="">{{ container.container_type }} + {% endif %} + {% if release.publisher != None %} + <tr><td class="right aligned">Publisher</td> + <td class="">{{ release.publisher }} + {% endif %} + {% if release.language != None %} + <tr><td class="right aligned">Primary Language</td> + <td class=""><code>{{ release.language }}</code> + (<a href="https://www.loc.gov/standards/iso639-2/php/langcodes_name.php?iso_639_1={{ release.language }}">lookup</a>) + {% endif %} + + </tbody> + </table> </div> </div> -{% endif %} -{% if release.extra != None %} -<h3>Extra Metadata (raw JSON)</h3> -{% for (key, value) in release.extra.items() %} -<code><b>{{ key }}:</b> {% if key == "crossref" %} <truncated, see full JSON>{% else %} {{ value }} {% endif %}</code><br> +{% if release.contribs|length > 0 %} +<div class="ui accordion"> +<div class="title"> + <i class="dropdown icon"></i>All Contributors +</div><div class="content"> +<table class="ui basic compact fixed table"> +<tbody> +{% for contrib in release.contribs %} + <tr><td class="one wide">{% if contrib.index or contrib.index == 0 %} {{ contrib.index + 1 }}{% endif %} + <td> + {% if contrib.creator_id %} + <a href="/creator/{{contrib.creator_id}}">{{ contrib.raw_name or 'unknown' }}</a> + {% else %} + {{ contrib.raw_name or '' }} + {% endif %} + <br><i>{{ contrib.role or 'unknown' }}</i> {% endfor %} +</tbody> +</table> +</div> +</div> +{% else %} +<p>No known contributors (authors, translators, etc). {% endif %} -<!-- -Raw Object: -{{ release|safe }} ---> - -<br> -<h3>Abstracts</h3> {% if release.abstracts != [] %} - {% for abstract in release.abstracts %} - <b>Abstract (<code>{{ abstract.sha1 }}</code>, {{ abstract.mimetype }}):</b> {{ abstract.content }} - {% endfor %} -{% else %} -<p>No known abstracts. +<h3>Abstract</h3> +<p>{{ release.abstracts[0].content }} +<br><small><i>In <code>{{ release.abstracts[0].mimetype }}</code> format</i></small> {% endif %} -<br> -<h3>All Contributors</h3> -{% if release.contribs.size != 0 %} -<table class="ui compact table"> - <thead> - <tr><th>Attribution Order - <th>Name - <th>Role - </thead> - <tbody> - {% for contrib in release.contribs %} - <tr><td>{% if contrib.index or contrib.index == 0 %} {{ contrib.index + 1 }}{% endif %} - {% if contrib.creator_id %} - <td><a href="/creator/{{contrib.creator_id}}">{{ contrib.raw_name }}</a> - {% else %} - <td>{{ contrib.raw_name }} - {% endif %} - <td>{{ contrib.role or '' }} - {% endfor %} - </tbody> +{% if release.extra %} +<h3>Extra Metadata (raw JSON)</h3> +<table class="ui definition single line fixed compact small unstackable table"> +<tbody> +{% for (key, value) in release.extra.items() %} + <tr><td class="three wide right aligned"><code>{{ key }}</code></td> + <td class="seven wide"><code>{{ value }}</code> +{% endfor %} +</tbody> </table> -{% else %} -<p>Contributors (authors, translators, etc) not known. {% endif %} -<br> + <h3>Known Files and URLs</h3> {% if files != [] %} -<table class="ui compact table"> +<table class="ui compact fixed table"> +<!-- <thead> <tr><th>SHA-1 <th>Size (bytes) <th>File Type <th>Links </thead> +--> <tbody> {% for file in files %} - <tr><td><small><code><a href="/file/{{ file.ident }}">{% if file.sha1 != None %}{{ file.sha1[:16] + "..." }}{% else %}N/A{% endif %}</a></code></small> - <td>{% if file.size != None %}{{ file.size }}{% endif %} - <td>{% if file.mimetype != None %}{{ file.mimetype }}{% endif %} - <td>{% for url in file.urls %} - <a href="{{ url.url }}">{{ url.url.split('/')[2] }}</a> ({{ url.rel }})<br> - {% endfor %} + <tr><td>{% if file.mimetype != None %}{{ file.mimetype }} {% endif %} + {% if file.size != None %}{{ file.size|filesizeformat }}{% endif %} + <br><small><code><a href="/file/{{ file.ident }}"> + {% 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 %} + </a></code></small> + <td class="single line"> + {% for url in file.urls[:5] %} + <a href="{{ url.url }}">{{ url.url.split('/')[2] }}</a> ({{ url.rel }})<br> + {% endfor %} + {% if file.urls|length > 5 %} + <a href="/file/{{ file.ident }}">+ {{ file.urls|length - 5 }} more URLs</a> + {% endif %} {% endfor %} </tbody> </table> @@ -142,7 +161,6 @@ Raw Object: <a href="/work/{{ release.work_id }}">other releases for this work?</a>). {% endif %} -<br> {% if release.refs != None and release.refs.size != 0 %} <h3>References</h3> This release citing other releases. @@ -185,22 +203,38 @@ This release citing other releases. {% endif %} {% if release.release_type != None %} -<div class="ui segment attached"> -<b>Release Type</b> <code>{{ release.release_type }}</code> -</div> + <div class="ui segment attached"> + <b>Type</b> <code>{{ release.release_type }}</code> + <br><b>Status</b> <code>{{ release.release_status or 'unknown' }}</code> + {% if release.release_date != None %} + <br><b>Date</b> {{ release.release_date }} + {% elif release.release_year != None %} + <br><b>Year</b> {{ release.release_year }} + {% endif %} + </div> {% endif %} -{% if release.doi %} +{% if release.doi or release.pmid or release.pmcid or release.wikidata_qid %} <div class="ui segment attached" style="word-wrap: break-word;"> -<b>DOI </b> <a href="https://doi.org/{{ release.doi }}" title="{{ release.doi }}">{{ release.doi }}</a> -</div> +{% if release.doi %} + <b>DOI </b> <a href="https://doi.org/{{ release.doi }}" title="{{ release.doi }}">{{ release.doi }}</a><br> +{% endif %} +{% if release.pmid != None %} + <b>PubMed</b> <a href="https://www.ncbi.nlm.nih.gov/pubmed/{{ release.pmid }}"> <code>{{ release.pmid }}</code></a><br> +{% endif %} +{% if release.pmcid != None %} + <b>PMC</b> <a href="https://www.ncbi.nlm.nih.gov/pmc/articles/{{ release.pmcid }}"> <code>{{ release.pmcid }}</code></a><br> +{% endif %} +{% if release.wikidata_qid != None %} + <b>Wikidata</b> <a href="https://www.wikidata.org/wiki/{{ release.wikidata_qid }}"> <code>{{ release.wikidata_qid }}</code></a><br> {% endif %} {% if release.isbn13 != None %} -<div class="ui segment attached"> -<p><b>ISBN-13 </b> <code>{{ release.isbn13 }}</code> + <b>ISBN-13 </b> <code>{{ release.isbn13 }}</code> +{% endif %} </div> {% endif %} + {% if release.extra.is_oa == True %} <div class="ui segment attached"> <b><i class="ui icon unlock alternate green"></i> Open Access</b> @@ -245,6 +279,11 @@ This release citing other releases. {% endif %} <div class="ui segment attached accordion"> + <b><a href="/work/{{ release.work_id }}" title="work {{ release.work_id }}">Work Entity</a></b> + <br>grouping other versions (eg, pre-print) and variants of this release +</div> + +<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 %} diff --git a/python/fatcat_web/templates/stats.html b/python/fatcat_web/templates/stats.html index 92205b3d..f11ca820 100644 --- a/python/fatcat_web/templates/stats.html +++ b/python/fatcat_web/templates/stats.html @@ -7,38 +7,38 @@ You can also fetch these numbers <a href="./stats.json">as JSON</a>. <h3>Changelog</h3> -<p>Latest changelog index is {{ stats.changelog.latest.index }} ({{ stats.changelog.latest.timestamp}}). +<p>Latest changelog index is {{ stats.changelog.latest.index }} ({{ stats.changelog.latest.timestamp[:10] }}). <h3>Entities</h3> <table class="ui structured table"> <tbody> - <tr><td rowspan="5" class="active top aligned"><b>"Papers"</b></td> + <tr><td rowspan="5" class="active top aligned center aligned"><b>"Papers"</b></td> <td>Total</td> - <td class="right aligned">{{ stats.papers.total }}</td> + <td class="right aligned">{{ "{:,}".format(stats.papers.total) }}</td> <tr> <td>Fulltext on web</td> - <td class="right aligned">{{ stats.papers.in_web }}</td> + <td class="right aligned">{{ "{:,}".format(stats.papers.in_web) }}</td> <tr> <td>"Gold" Open Access</td> - <td class="right aligned">{{ stats.papers.is_oa }}</td> + <td class="right aligned">{{ "{:,}".format(stats.papers.is_oa) }}</td> <tr> <td>In a Keepers/KBART archive</td> - <td class="right aligned">{{ stats.papers.in_kbart }}</td> + <td class="right aligned">{{ "{:,}".format(stats.papers.in_kbart) }}</td> <tr> <td>On web, not in Keepers</td> - <td class="right aligned">{{ stats.papers.in_web_not_kbart }}</td> + <td class="right aligned">{{ "{:,}".format(stats.papers.in_web_not_kbart) }}</td> - <tr><td rowspan="2" class="active top aligned"><b>Releases</b></td> + <tr><td rowspan="2" class="active top aligned center aligned"><b>Releases</b></td> <td>Total</td> - <td class="right aligned">{{ stats.release.total }}</td> + <td class="right aligned">{{ "{:,}".format(stats.release.total) }}</td> <tr> <td>References (raw, unlinked)</td> - <td class="right aligned">{{ stats.release.refs_total }}</td> + <td class="right aligned">{{ "{:,}".format(stats.release.refs_total) }}</td> - <tr><td rowspan="1" class="active top aligned"><b>Containers</b></td> + <tr><td rowspan="1" class="active top aligned center aligned"><b>Containers</b></td> <td>Total</td> - <td class="right aligned">{{ stats.container.total }}</td> + <td class="right aligned">{{ "{:,}".format(stats.container.total) }}</td> </tbody> </table> diff --git a/python/fatcat_web/templates/work_view.html b/python/fatcat_web/templates/work_view.html index c767e1ba..9a560ae4 100644 --- a/python/fatcat_web/templates/work_view.html +++ b/python/fatcat_web/templates/work_view.html @@ -25,38 +25,49 @@ Raw Object: {{ work|safe }} --> -<p>A "work" is just a linking identifier between a set of releases. For -example, a pre-print and a published article may contain small differences, but -still reference the same underlying "work". - -<br> - +<h3>Releases</h3> {% if releases != [] %} -<ul> - {% for release in releases %} - <li>"{{ release.title }}", a {{ release.release_type }} published - {% if release.release_year != None %}in {{ release.release_year }}{% endif %} - as <code>{{ release.release_status or "(unknown)" }}</code>. - <br><a href="/release/{{ release.ident }}"><code>{{ release.ident }}</code></a> - {% endfor %} -</ul> +<table class="ui very basic celled table"> +<tbody> +{% for release in releases %} + <tr><td class="two wide center aligned"> + {% if release.release_date %}{{ release.release_date }}{% elif release.release_year %}{{ release.release_year }}{% endif %} + <td class="five wide single line"> + <b><a href="/release/{{ release.ident }}">{{ release.title }}</a></b> + <br>{{ release.release_type or "unknown" }} - {{ release.release_status or "unknown" }} + {% if release.license_slug %} - {{ release.license_slug }}{% endif %} + {% if release.doi %} + <br><a href="https://doi.org/{{ release.doi }}" style="color:green;">doi:{{ release.doi }}</a> + {% endif %} +{% endfor %} +</tbody> +</table> {% else %} <p>There are no known releases associated with this work. {% endif %} +{% if work.extra %} +<h3>Extra Metadata (raw JSON)</h3> +<table class="ui definition single line fixed compact small unstackable table"> +<tbody> +{% for (key, value) in work.extra.items() %} + <tr><td class="three wide right aligned"><code>{{ key }}</code></td> + <td class="seven wide"><code>{{ value }}</code> +{% endfor %} +</tbody> +</table> +{% endif %} + +<h3>What is a "Work"?</h3> +<p>A Fatcat "<code>work</code>" groups a set of releases that are all editings +or editing stages of the same intellectual contribution. For example, a +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>Work Type:</b> -{% if work.work_type != None %} - <code>{{ work.work_type }}</code> -{% else %} -<i>unkonwn</i> -{% endif %} -</div><div class="ui segment attached"> - <b>Fatcat Bits</b> <p>State is "{{ work.state }}". Revision: <br><small><code>{{ work.revision }}</code></small> |