Skip to content

Commit

Permalink
global: final changes for v3.2
Browse files Browse the repository at this point in the history
  • Loading branch information
lnielsen committed Dec 20, 2019
1 parent 5b73251 commit 7ce93c0
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 83 deletions.
12 changes: 6 additions & 6 deletions {{cookiecutter.project_shortname}}/Pipfile
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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/<pid_value>/preview/<path:filename>',
view_imp='invenio_previewer.views.preview',
Expand Down Expand Up @@ -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."""
Original file line number Diff line number Diff line change
@@ -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 %}
Expand Down Expand Up @@ -30,56 +32,6 @@
{% endfor %}
{%- endmacro %}

{%- macro file_list(files) -%}
<div class="panel files-box" id="files">
<div class="panel-heading">
<a class="panel-toggle" data-toggle="collapse" href="#collapsableFiles">
{{ _("Files") }}
<span class="pull-right show-on-collapsed"><i class="fa fa-chevron-right"></i></span>
<span class="pull-right hide-on-collapsed"><i class="fa fa-chevron-down"></i></span>
</a>
<small class="text-muted">{% if files %} ({{files|sum(attribute='size')|filesizeformat}}){% endif %}</small>
</div>
<div class="collapse in" id="collapsableFiles">
<table class="table table-striped" >
<thead>
<tr class="">
<th>{{_('Name')}}</th>
<th>{{_('Size')}}</th>
</tr>
</thead>
<tbody>
{%- 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) %}
<tr>
<td>
<a class="filename preview-link" href="#preview" data-url="{{file_url_preview}}">{{ file.key }}</a>
<br/><small class="text-muted nowrap">{{file.checksum}} <i class="fa fa-question-circle text-muted" data-toggle="tooltip" tooltip data-placement="top" title="{{_('This is the file fingerprint (MD5 checksum), which can be used to verify the file integrity.')}}"></i></small>
</td>
<td class="nowrap">{{ file.size|filesizeformat }}</td>
<td class="nowrap">
<span class="pull-right">
{% set file_type = file.key.split('.')[-1] %}
{% if file_type is previewable %}
<button class="btn preview-link btn-xs btn-default" data-url="{{file_url_preview}}">
<i class="fa fa-eye"></i> {{_("Preview")}}
</button>
{% endif %}
<a class="btn btn-xs btn-default" href="{{file_url_download}}">
<i class="fa fa-download"></i> {{_("Download")}}
</a>
</span>
</td>
</tr>
{%- endfor -%}
</tbody>
</table>
</div>
</div>
{%- endmacro %}


{% macro preview(files) %}
{% set selected_file = files|select_preview_file %}
{%- if selected_file -%}
Expand All @@ -92,23 +44,12 @@
</a>
</div>
<div id="collapsablePreview" class="collapse in">
{{- 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) }}
</div>
</div>
{%- endif %}
{%- endmacro %}


{%- macro preview_file(preview_endpoint, pid, filename, id='preview-iframe', width='100%', height='400') %}
<iframe
class="preview-iframe"
id="{{id}}"
width="{{width}}"
height="{{height}}"
src="{{ url_for(preview_endpoint, pid_value=pid.pid_value, filename=filename) }}"></iframe>
{%- endmacro %}


{%- block page_body %}
<div class="container">
<h2>{{record.title}}</h2>
Expand All @@ -120,7 +61,7 @@ <h2>{{record.title}}</h2>
{% set files = record._files %}
{{ preview(files) }}
{%- if files -%}
{{ file_list(files) }}
{{ file_list(files, pid) }}
{%- endif %}
</div>
{{ webpack['{%- endraw %}{{cookiecutter.project_shortname}}{%- raw %}-preview.js'] }}
Expand Down

0 comments on commit 7ce93c0

Please sign in to comment.