Skip to content

Commit

Permalink
global: review fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
slint committed Apr 15, 2024
1 parent a32996d commit 07cb201
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 30 deletions.
5 changes: 0 additions & 5 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,3 @@ InvenioRDM Research Data Management

Further documentation is available on
https://inveniordm.docs.cern.ch

For Mirador Previewer
---------------
- The asset files under invenio_app_rdm/theme/static/js/m3/dist should be under the global static/js/m3/dist folder

25 changes: 22 additions & 3 deletions invenio_app_rdm/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -977,9 +977,6 @@ def github_link_render(record):
IIIF_PREVIEW_TEMPLATE = "invenio_app_rdm/records/iiif_preview.html"
"""Template for IIIF image preview."""

MIRADOR_PREVIEW_TEMPLATE = "invenio_app_rdm/records/mirador_preview.html"
"""Template for Mirador image preview."""

IIIF_API_DECORATOR_HANDLER = None

# Invenio-Previewer
Expand Down Expand Up @@ -1031,6 +1028,28 @@ def github_link_render(record):
"tiff": "tiff",
}

# Invenio-Previewer
# =================
# See https://github.com/inveniosoftware/invenio-previewer/blob/master/invenio_previewer/config.py # noqa

PREVIEWER_PREFERENCE = [
"csv_papaparsejs",
"mirador",
"iiif_simple",
"simple_image",
"json_prismjs",
"xml_prismjs",
"mistune",
"pdfjs",
"ipynb",
"zip",
"txt",
]
"""Preferred previewers."""

MIRADOR_PREVIEW_EXTENSIONS = list(IIIF_FORMATS.keys())


# Invenio-Pages
# =============
# See https://invenio-pages.readthedocs.io/en/latest/configuration.html
Expand Down
11 changes: 3 additions & 8 deletions invenio_app_rdm/records_ui/previewer/mirador.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,7 @@

"""Mirador preview."""

from os.path import splitext

from flask import current_app, render_template
from werkzeug.local import LocalProxy

previewable_extensions = LocalProxy(lambda: current_app.config["IIIF_FORMATS"].keys())

def can_preview(file):
"""Check if file can be previewed by this previewer.
Expand All @@ -22,15 +17,15 @@ def can_preview(file):
:returns: Boolean
"""
# supported_extensions list needs . prefixed -
supported_extensions = ["." + ext for ext in previewable_extensions]
preview_extensions = current_app.config["MIRADOR_PREVIEW_EXTENSIONS"]
supported_extensions = ["." + ext for ext in preview_extensions]
return file.has_extensions(*supported_extensions)


def preview(file):
"""Render template.
"""
return render_template(
current_app.config["MIRADOR_PREVIEW_TEMPLATE"],
html_tags='dir="ltr" mozdisallowselectionprint moznomarginboxes',
"invenio_app_rdm/records/mirador_preview.html",
file=file,
)
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
{#
Copyright (C) 2020 CERN.
Copyright (C) 2020 Northwestern University.
Copyright (C) 2023-2024 CERN.

Invenio-App-RDM is free software; you can redistribute it and/or modify
it under the terms of the MIT License; see LICENSE file for more details.
Expand All @@ -9,16 +8,9 @@
{%- extends config.PREVIEWER_ABSTRACT_TEMPLATE %}

{% block panel %}
<div class="mirador-preview">
<p>loading...</p>
<div class="ui container">
<div class="ui grid column">
<div class="column">
<div id="demo">
<script src="/static/js/m3/dist/main.js"></script>
</div>
</div>
</div>
</div>
</div>
<div id="demo"><p>{{ _("Loading...") }}</p></div>
{% endblock %}

{% block javascript %}
<script src="{{ url_for('static', filename='js/m3/dist/main.js') }}"></script>
{% endblock javascript %}

0 comments on commit 07cb201

Please sign in to comment.