aboutsummaryrefslogtreecommitdiffstats
path: root/python/fatcat_web
diff options
context:
space:
mode:
Diffstat (limited to 'python/fatcat_web')
-rw-r--r--python/fatcat_web/routes.py19
-rw-r--r--python/fatcat_web/search.py3
-rw-r--r--python/fatcat_web/templates/entity_macros.html8
-rw-r--r--python/fatcat_web/templates/fileset_view.html81
-rw-r--r--python/fatcat_web/templates/release_view.html29
5 files changed, 109 insertions, 31 deletions
diff --git a/python/fatcat_web/routes.py b/python/fatcat_web/routes.py
index 1f6602d4..4ceeac49 100644
--- a/python/fatcat_web/routes.py
+++ b/python/fatcat_web/routes.py
@@ -3,6 +3,7 @@ import os
from typing import Any, Callable, Dict, List, Optional
import citeproc_styles
+import sentry_sdk
from fatcat_openapi_client import EditgroupAnnotation
from fatcat_openapi_client.rest import ApiException, ApiValueError
from flask import (
@@ -1450,7 +1451,14 @@ def release_bibtex(ident: str) -> AnyResponse:
entity = api.get_release(ident)
except ApiException as ae:
raise ae
- csl = release_to_csl(entity)
+ try:
+ csl = release_to_csl(entity)
+ except ValueError as e:
+ # "handle" the missing author/surname path, so we don't get exception
+ # reports about it. these are not linked to, only show up from bots.
+ sentry_sdk.set_level("warning")
+ sentry_sdk.capture_exception(e)
+ abort(400, e)
bibtex = citeproc_csl(csl, "bibtex")
return Response(bibtex, mimetype="text/plain")
@@ -1468,7 +1476,14 @@ def release_citeproc(ident: str) -> AnyResponse:
entity = api.get_release(ident)
except ApiException as ae:
raise ae
- csl = release_to_csl(entity)
+ try:
+ csl = release_to_csl(entity)
+ except ValueError as e:
+ # "handle" the missing author/surname path, so we don't get exception
+ # reports about it. these are not linked to, only show up from bots.
+ sentry_sdk.set_level("warning")
+ sentry_sdk.capture_exception(e)
+ abort(400, e)
try:
cite = citeproc_csl(csl, style, is_html)
except citeproc_styles.StyleNotFoundError as e:
diff --git a/python/fatcat_web/search.py b/python/fatcat_web/search.py
index 913d6696..f85f6c89 100644
--- a/python/fatcat_web/search.py
+++ b/python/fatcat_web/search.py
@@ -636,7 +636,8 @@ def get_elastic_preservation_by_year(query: ReleaseQuery) -> List[Dict[str, Any]
"biblio",
],
)
- search = search.filter("term", container_id=query.container_id)
+ if query.container_id:
+ search = search.filter("term", container_id=query.container_id)
if query.exclude_stubs:
search = search.query(
"bool",
diff --git a/python/fatcat_web/templates/entity_macros.html b/python/fatcat_web/templates/entity_macros.html
index 5f8f6e0a..4386e698 100644
--- a/python/fatcat_web/templates/entity_macros.html
+++ b/python/fatcat_web/templates/entity_macros.html
@@ -75,6 +75,14 @@
<a href="{{ u }}">{{ u }}</a><br>
{% endfor %}
</code>
+ {% elif key in ("manifest", "abstracts", "refs", "releases", "files", "webcaptures", "filesets", "urls", "archive_urls", "cdx", "contribs") and value and value is iterable and value is not string %}
+ <tr><td class="three wide right aligned"><code>{{ key }}[]</code></td>
+ <td class="seven wide">
+ <code>
+ {% for m in value %}
+ {% if m != None %}{{ m }}{% endif %}<br>
+ {% endfor %}
+ </code>
{% else %}
<tr><td class="three wide right aligned"><code>{{ key }}</code></td>
<td class="seven wide"><code>{% if value != None %}{{ value }}{% endif %}</code>
diff --git a/python/fatcat_web/templates/fileset_view.html b/python/fatcat_web/templates/fileset_view.html
index 4e8bfbad..6f3f802e 100644
--- a/python/fatcat_web/templates/fileset_view.html
+++ b/python/fatcat_web/templates/fileset_view.html
@@ -3,6 +3,21 @@
{% import "entity_macros.html" as entity_macros %}
{% extends "entity_base.html" %}
+{% macro file_mimetype_icon(mimetype) -%}
+ {%- if not mimetype -%}file outline
+ {%- elif mimetype in ["application/pdf"] -%}file pdf outline
+ {%- elif mimetype in ["application/x-hdf"] -%}database
+ {%- elif mimetype in ["text/csv", "text/tab-separated-values"] -%}table
+ {%- elif mimetype in ["application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"] -%}table
+ {%- elif mimetype in ["application/vnd.openxmlformats-officedocument.wordprocessingml.document"] -%}file alternate outline
+ {%- elif mimetype in ["application/zip", "application/gzip", "application/x-tar", "application/x-rar", "application/x-bzip2"] -%}file archive outline
+ {%- elif mimetype in ["application/octet-stream"] -%}save outline
+ {%- elif mimetype.startswith("text/") -%}file alternate outline
+ {%- elif mimetype.startswith("image/") -%}file image outline
+ {%- elif mimetype.startswith("video/") -%}film
+ {%- else -%}file outline{% endif %}
+{%- endmacro %}
+
{% block entity_main %}
<div class="ui stackable mobile reversed grid centered">
@@ -23,26 +38,64 @@
No known public URL, mirror, or archive for this File Set.
{% endif %}
+{% set fileset_vars = namespace(archiveorg_base=None, webarchiveorg_base=None) %}
+{% for u in (entity.urls or []) %}
+ {% if u.rel in ["archive-base"] %}
+ {% set fileset_vars.archiveorg_base = u.url %}
+ {% elif u.rel in ["webarchive-base"] %}
+ {% set fileset_vars.webarchiveorg_base = u.url %}
+ {% endif %}
+{% endfor %}
+
<h3>File Manifest ({{ fileset.manifest|count }})</h3>
{% if fileset.manifest %}
- <div class="ui celled list">
+<div style="overflow-x: auto;">
+<table class="ui compact single line table">
+ <thead>
+ <tr>
+ <th class="collapsing"></th>
+ <th>Path</th>
+ <th>Type</th>
+ <th>Size</th>
+ <th class="collapsing"></th>
+ </tr>
+ </thead>
+ <tbody>
{% for file in fileset.manifest %}
- <div class="item">
- <div class="content"><code>
- <div class="header">
- <i class="file outline icon"></i> {{ file.path }} ({{ file.size|filesizeformat }}{% if file.extra.mimetype %}, {{ file.extra.mimetype }}{% endif %})
- </div>
- <div style="color: #666; margin-left: 1em;"><small>
- {% if file.md5 %} md5:{{ file.md5 }}<br>{% endif %}
- {% if file.sha1 %} sha1:{{ file.sha1 }}<br>{% endif %}
- {% if file.sha256 %}sha256:{{ file.sha256 }}<br>{% endif %}
+ <tr>
+ <td><i class="{{ file_mimetype_icon(file.mimetype) }} icon" style="font-size: x-large;"></i></td>
+ <td>
+ <b><code>{{ file.path }}</code></b>
+ <br><div style="color: #666; margin-left: 0em;"><small>
+ {% if file.sha1 %} sha1:{{ file.sha1 }}<br>
+ {% elif file.sha256 %}sha256:{{ file.sha256 }}<br>
+ {% elif file.md5 %} md5:{{ file.md5 }}<br>
+ {% endif %}
</small></div>
- </code></div>
- </div>
+ </td>
+ <td>{% if file.mimetype %}<code style="font-size: smaller;">{{ file.mimetype }}</code>{% endif %}</td>
+ <td>{{ file.size|filesizeformat }}</td>
+ <td>
+ {% if fileset_vars.archiveorg_base %}
+ <a href="{{ fileset_vars.archiveorg_base }}/{{ file.path }}">[archive.org]</a><br>
+ {% endif %}
+ {% if fileset_vars.webarchiveorg_base %}
+ <a href="{{ fileset_vars.webarchiveorg_base }}/{{ file.path }}">[web.archive.org]</a><br>
+ {% endif %}
+ {% if file.extra and file.extra.original_url %}
+ <a href="{{ file.extra.original_url }}">[platform]</a><br>
+ {% endif %}
+ {% if file.extra and file.extra.webarchive_url%}
+ <a href="{{ file.extra.webarchive_url }}">[web.archive.org]</a><br>
+ {% endif %}
+ </td>
+ </tr>
{% endfor %}
- </div>
+ </tbody>
+</table>
+</div>
{% else %}
-This File Set is empty (contains no files).
+<p>This File Set is empty (contains no files).
{% endif %}
diff --git a/python/fatcat_web/templates/release_view.html b/python/fatcat_web/templates/release_view.html
index f2e3f670..53ac3703 100644
--- a/python/fatcat_web/templates/release_view.html
+++ b/python/fatcat_web/templates/release_view.html
@@ -131,8 +131,9 @@
{% endif %}
{% if entity.state == 'active' %}
+
+{% if entity.files != [] and entity.files != None %}
<h3>Archived Files and Locations</h3>
-{% if entity.files != [] %}
<table class="ui compact fixed table">
<tbody>
{% for file in entity.files %}
@@ -151,15 +152,9 @@
{% endfor %}
</tbody>
</table>
-{% else %}
-<p>There are no accessible files associated with this release. You could check
-<a href="/work/{{ release.work_id }}">other releases for this work</a> for an
-accessible version.
-{% endif %}
{% endif %}
-{% if entity.state == 'active' %}
-{% if entity.filesets != [] %}
+{% if entity.filesets != [] and entity.filesets != None %}
<h3>File Sets</h3>
<table class="ui compact fixed table">
<tbody>
@@ -181,10 +176,8 @@ accessible version.
</tbody>
</table>
{% endif %}
-{% endif %}
-{% if entity.state == 'active' %}
-{% if entity.webcaptures != [] %}
+{% if entity.webcaptures != [] and entity.webcaptures != None %}
<h3>Web Captures</h3>
<table class="ui single line compact fixed table">
<tbody>
@@ -203,9 +196,17 @@ accessible version.
</tbody>
</table>
{% endif %}
+
+{% if not (entity.files or entity.filesets or entity.webcaptures) %}
+<h3>Archived Content</h3>
+<p>There are no accessible files associated with this release. You could check
+<a href="/work/{{ release.work_id }}">other releases for this work</a> for an
+accessible version.
+{% endif %}
+
{% endif %}
-</div>
+</div>
<div class="column" style="flex: 0 0 24em;">
@@ -213,7 +214,7 @@ accessible version.
<a href="{{ entity._es.ia_pdf_url }}" class="ui fluid huge black button" style="text-decoration: underline;">
<i class="file pdf outline icon"></i>Read Archived PDF
</a>
-{% elif entity.state == 'active' and entity.webcaptures != [] and entity.webcaptures[0].archive_urls != [] and entity.webcaptures[0].archive_urls[0].rel == "wayback" %}
+{% elif entity.state == 'active' and entity.webcaptures != None and entity.webcaptures != [] and entity.webcaptures[0].archive_urls != [] and entity.webcaptures[0].archive_urls[0].rel == "wayback" %}
<a href="{{ entity.webcaptures[0].archive_urls[0].url }}{{ entity.webcaptures[0]._wayback_suffix }}" class="ui fluid huge black button" style="text-decoration: underline;">
<i class="university icon"></i>Visit Web Archive
</a>
@@ -354,7 +355,7 @@ accessible version.
#}
{% endif %}
{% if release.container._es.any_kbart == True %}
- <i class="icon check green"></i> In <a href="https://keepers.issn.org/?q=api/search&search[]=MUST=allissn={{ release.container.issnl }}&search[]=MUST_EXIST=keepers">Keepers Registery</a><br>
+ <i class="icon check green"></i> In <a href="https://keepers.issn.org/?q=api/search&search[]=MUST=allissn={{ release.container.issnl }}&search[]=MUST_EXIST=keepers">Keepers Registry</a><br>
{% elif release.container._es.any_kbart == False %} <i class="icon times grey"></i> Not in <a href="https://keepers.issn.org/?q=api/search&search[]=MUST=allissn={{ release.container.issnl }}&search[]=MUST_EXIST=keepers">Keepers Registry</a><br>
{% endif %}
{% endif %}