3232
3333
3434{% macro preview_file_box(file, pid, is_preview, record, include_deleted) %}
35+ {%- set is_remote_file = file.transfer.type == 'R' %}
3536 < div class ="ui accordion panel mb-10 {{record.ui.access_status.id}} " href ="#files-preview-accordion-panel ">
3637 < h3 class ="active title panel-heading {{ record.ui.access_status.id }} m-0 ">
3738 < div
@@ -53,9 +54,22 @@ <h3 class="active title panel-heading {{ record.ui.access_status.id }} m-0">
5354 aria-labelledby ="files-preview-accordion-trigger "
5455 class ="active content preview-container pt-0 {{record.ui.access_status.id}} "
5556 >
57+ {%- if is_remote_file %}
58+ < div class ="ui info message ">
59+ < div class ="header ">
60+ {{ _('This file cannot be previewed') }}
61+ </ div >
62+ < ul class ="list ">
63+ < li > {{ _('This file is an external reference and not stored directly in this repository.
64+ To access its content, please download it and open it locally.') }}
65+ </ li >
66+ </ ul >
67+ </ div >
68+ {%- else %}
5669 < div >
5770 {{ preview_file('invenio_app_rdm_records.record_file_preview', pid_value=pid, filename=file.key, is_preview=is_preview, include_deleted=include_deleted) }}
5871 </ div >
72+ {%- endif %}
5973 </ div >
6074 </ div >
6175{%- endmacro %}
@@ -92,6 +106,7 @@ <h3 class="active title panel-heading {{ record.ui.access_status.id }} m-0">
92106 {%- set include_deleted_value = 1 -%}
93107 {% endif %}
94108 {% for file in files %}
109+ {%- set is_remote_file = file.transfer.type == 'R' %}
95110 {% if not file.access.hidden %}
96111 {% if is_preview %}
97112 {%- set file_url_download = url_for(download_endpoint, pid_value=pid, filename=file.key, download=1, preview=1) %}
@@ -107,16 +122,20 @@ <h3 class="active title panel-heading {{ record.ui.access_status.id }} m-0">
107122 < div >
108123 < a href ="{{ file_url_download }} "> {{ file.key }}</ a >
109124 </ div >
125+ {% if file.checksum is defined %}
110126 < small class ="ui text-muted font-tiny "> {{ file.checksum }}
111127 < div class ="ui icon inline-block " data-tooltip ="{{_('This is the file fingerprint (checksum), which can be used to verify the file integrity.')}} ">
112128 < i class ="question circle checksum icon "> </ i >
113129 </ div >
114130 </ small >
131+ {% endif %}
115132 </ td >
133+ {% if file.size is defined %}
116134 < td > {{ file.size|filesizeformat(binary=binary_sizes) }}</ td >
135+ {% endif %}
117136 < td class ="right aligned ">
118137 < span >
119- {% if with_preview and file_type|lower is previewable %}
138+ {% if with_preview and file_type|lower is previewable and not is_remote_file %}
120139 < a role ="button " class ="ui compact mini button preview-link " href ="{{ file_url_preview }} " target ="preview-iframe " data-file-key ="{{file.key}} ">
121140 < i class ="eye icon " aria-hidden ="true "> </ i > {{_("Preview")}}
122141 </ a >
@@ -140,7 +159,7 @@ <h3 class="active title panel-heading {{ record.ui.access_status.id }} m-0">
140159 < h3 class ="active title panel-heading {{ record.ui.access_status.id }} m-0 ">
141160 < div role ="button " id ="files-list-accordion-trigger " aria-controls ="files-list-accordion-panel " aria-expanded ="true " tabindex ="0 " class ="trigger ">
142161 {{ _("Files") }}
143- < small class ="text-muted "> {% if files %} ({{files|sum (attribute='size')|filesizeformat(binary=binary_sizes)}}){% endif %}</ small >
162+ < small class ="text-muted "> {% if files %} ({{files|map (attribute='size', default=0)|sum( )|filesizeformat(binary=binary_sizes)}}){% endif %}</ small >
144163 < i class ="angle right icon " aria-hidden ="true "> </ i >
145164 </ div >
146165 </ h3 >
0 commit comments