From 7ce93c094c131fee35737cec88b08257efaf1894 Mon Sep 17 00:00:00 2001 From: Lars Holm Nielsen Date: Fri, 20 Dec 2019 16:21:28 +0100 Subject: [PATCH] global: final changes for v3.2 --- {{cookiecutter.project_shortname}}/Pipfile | 12 ++-- .../{{cookiecutter.package_name}}/config.py | 6 ++ .../records/config.py | 15 +---- .../records/templates/records/record.html | 67 ++----------------- 4 files changed, 17 insertions(+), 83 deletions(-) diff --git a/{{cookiecutter.project_shortname}}/Pipfile b/{{cookiecutter.project_shortname}}/Pipfile index f3b2a65..3861d23 100644 --- a/{{cookiecutter.project_shortname}}/Pipfile +++ b/{{cookiecutter.project_shortname}}/Pipfile @@ -6,20 +6,19 @@ name = "pypi" [packages] Babel = ">=2.4.0" Flask-BabelEx = ">=0.9.3" -invenio = { version = "==3.2.0a9", extras = ["base", "auth", "metadata", "files", "{{ cookiecutter.database }}", "elasticsearch{{ cookiecutter.elasticsearch }}" ]} +invenio = { version = ">=3.2.0,<3.3.0", extras = ["base", "auth", "metadata", "files", "{{ cookiecutter.database }}", "elasticsearch{{ cookiecutter.elasticsearch }}" ]} +lxml = ">=3.5.0,<4.2.6" +marshmallow = ">=3.0.0,<4.0.0" uwsgi = ">=2.0" -uwsgitop = ">=0.11" uwsgi-tools = ">=1.1.1" -lxml = ">=3.5.0,<4.2.6" +uwsgitop = ">=0.11" [dev-packages] -Flask-Debugtoolbar = ">=0.10.1" -Sphinx = ">=1.5.1" check-manifest = ">=0.35" coverage = ">=4.4.1" +Flask-Debugtoolbar = ">=0.10.1" isort = ">=4.3" mock = ">=2.0.0" -marshmallow = ">=2.15.1,<3.0.0" pydocstyle = ">=2.0.0" pytest = ">=3.3.1" pytest-cov = ">=2.5.1" @@ -28,6 +27,7 @@ pytest-mock = ">=1.6.0" pytest-pep8 = ">=1.0.6" pytest-random-order = ">=0.5.4" pytest-runner = ">=3.0.0,<5" +Sphinx = ">=1.5.1" [requires] python_version = "3.6" diff --git a/{{cookiecutter.project_shortname}}/{{cookiecutter.package_name}}/config.py b/{{cookiecutter.project_shortname}}/{{cookiecutter.package_name}}/config.py index 5e7d265..1f606f0 100644 --- a/{{cookiecutter.project_shortname}}/{{cookiecutter.package_name}}/config.py +++ b/{{cookiecutter.project_shortname}}/{{cookiecutter.package_name}}/config.py @@ -12,6 +12,7 @@ from datetime import timedelta from invenio_app.config import APP_DEFAULT_SECURE_HEADERS +from invenio_previewer.config import PREVIEWER_PREFERENCE as BASE_PREFERENCE def _(x): @@ -149,6 +150,11 @@ def _(x): # ======= OAISERVER_ID_PREFIX = 'oai:{{cookiecutter.project_site}}:' +# Previewers +# ========== +#: Include IIIF preview for images. +PREVIEWER_PREFERENCE = ['iiif_image'] + BASE_PREFERENCE + # Debug # ===== # Flask-DebugToolbar is by default enabled when the application is running in diff --git a/{{cookiecutter.project_shortname}}/{{cookiecutter.package_name}}/records/config.py b/{{cookiecutter.project_shortname}}/{{cookiecutter.package_name}}/records/config.py index b52795e..0aa8c55 100644 --- a/{{cookiecutter.project_shortname}}/{{cookiecutter.package_name}}/records/config.py +++ b/{{cookiecutter.project_shortname}}/{{cookiecutter.package_name}}/records/config.py @@ -63,7 +63,7 @@ def _(x): template='records/record.html', record_class='invenio_records_files.api:Record', ), - recid_preview=dict( + recid_previewer=dict( pid_type='recid', route='/records//preview/', view_imp='invenio_previewer.views.preview', @@ -139,16 +139,3 @@ def _(x): FILES_REST_PERMISSION_FACTORY = \ '{{ cookiecutter.package_name }}.records.permissions:files_permission_factory' """Files-REST permissions factory.""" - -PREVIEWER_PREFERENCE = [ - 'csv_dthreejs', - 'iiif_image', - 'simple_image', - 'json_prismjs', - 'xml_prismjs', - 'mistune', - 'pdfjs', - 'ipynb', - 'zip', -] -"""IIIF previewer preferences.""" diff --git a/{{cookiecutter.project_shortname}}/{{cookiecutter.package_name}}/records/templates/records/record.html b/{{cookiecutter.project_shortname}}/{{cookiecutter.package_name}}/records/templates/records/record.html index f101904..181dc81 100644 --- a/{{cookiecutter.project_shortname}}/{{cookiecutter.package_name}}/records/templates/records/record.html +++ b/{{cookiecutter.project_shortname}}/{{cookiecutter.package_name}}/records/templates/records/record.html @@ -1,6 +1,8 @@ {% include 'misc/header.tpl' -%}{% raw %} {%- extends config.RECORDS_UI_BASE_TEMPLATE %} +{% from 'invenio_previewer/macros.html' import file_list, preview_file %} + {%- macro record_content(data) %} {% set ignore_list = ['_bucket', '$schema'] %} {% for key, value in data.items() if key not in ignore_list recursive %} @@ -30,56 +32,6 @@ {% endfor %} {%- endmacro %} -{%- macro file_list(files) -%} -
-
- - {{ _("Files") }} - - - - {% if files %} ({{files|sum(attribute='size')|filesizeformat}}){% endif %} -
-
- - - - - - - - - {%- for file in files|sort(attribute='key') -%} - {%- set file_url_download = url_for('invenio_records_ui.recid_files', pid_value=pid.pid_value, filename=file.key, download=1) %} - {%- set file_url_preview = url_for('invenio_records_ui.recid_preview', pid_value=pid.pid_value, filename=file.key) %} - - - - - - {%- endfor -%} - -
{{_('Name')}}{{_('Size')}}
- {{ file.key }} -
{{file.checksum}} -
{{ file.size|filesizeformat }} - - {% set file_type = file.key.split('.')[-1] %} - {% if file_type is previewable %} - - {% endif %} - - {{_("Download")}} - - -
-
-
-{%- endmacro %} - - {% macro preview(files) %} {% set selected_file = files|select_preview_file %} {%- if selected_file -%} @@ -92,23 +44,12 @@
- {{- preview_file('invenio_records_ui.recid_preview', pid=pid, filename=selected_file.key) }} + {{- preview_file('invenio_records_ui.recid_previewer', pid=pid, filename=selected_file.key) }}
{%- endif %} {%- endmacro %} - -{%- macro preview_file(preview_endpoint, pid, filename, id='preview-iframe', width='100%', height='400') %} - -{%- endmacro %} - - {%- block page_body %}

{{record.title}}

@@ -120,7 +61,7 @@

{{record.title}}

{% set files = record._files %} {{ preview(files) }} {%- if files -%} - {{ file_list(files) }} + {{ file_list(files, pid) }} {%- endif %}
{{ webpack['{%- endraw %}{{cookiecutter.project_shortname}}{%- raw %}-preview.js'] }}