2017-03-04 06:50:36 +00:00
|
|
|
{# Specific extensions, then specific mimetypes, then general mimtypes #}
|
2016-11-06 04:24:43 +00:00
|
|
|
{% set thumbnails =
|
2016-10-10 03:50:13 +00:00
|
|
|
{
|
2017-03-04 06:50:36 +00:00
|
|
|
"svg": "svg",
|
|
|
|
|
2017-02-28 07:39:06 +00:00
|
|
|
"application/zip": "archive",
|
|
|
|
"application/x-tar": "archive",
|
2017-03-04 06:50:36 +00:00
|
|
|
|
2017-02-28 07:05:43 +00:00
|
|
|
"archive": "archive",
|
2017-03-04 06:50:36 +00:00
|
|
|
"audio": "audio",
|
2017-06-19 23:13:42 +00:00
|
|
|
"image": "image",
|
2016-10-10 03:50:13 +00:00
|
|
|
"video": "video",
|
2017-03-04 06:50:36 +00:00
|
|
|
"text": "txt",
|
|
|
|
|
2016-10-10 03:50:13 +00:00
|
|
|
}
|
|
|
|
%}
|
2016-11-07 02:00:30 +00:00
|
|
|
{% macro create_photo_card(photo, view="grid") %}
|
|
|
|
|
|
|
|
{% if view == "list" %}
|
2017-12-10 01:48:56 +00:00
|
|
|
<div class="photo_card photo_card_list" data-id="{{photo.id}}">
|
|
|
|
<input type="checkbox" class="photo_card_selector_checkbox" onclick="on_photo_select(event)"/>
|
2017-08-02 01:25:28 +00:00
|
|
|
<span class="photo_card_filename"><a target="_blank" href="/photo/{{photo.id}}">{{photo.basename}}</a></span>
|
2018-03-18 07:19:30 +00:00
|
|
|
<a class="photo_card_metadata" target="_blank" href="/file/{{photo.id + photo.dot_extension}}">{{photo.bytestring}}</a>
|
2016-11-07 02:00:30 +00:00
|
|
|
</div>
|
|
|
|
{% else %}
|
2017-12-10 01:48:56 +00:00
|
|
|
|
2017-08-02 01:25:28 +00:00
|
|
|
{% if photo.thumbnail %}
|
|
|
|
{% set thumbnail_src = "/thumbnail/" + photo.id + ".jpg" %}
|
|
|
|
{% else %}
|
|
|
|
{% set thumbnail_src =
|
|
|
|
thumbnails.get(photo.extension, "") or
|
|
|
|
thumbnails.get(photo.mimetype, "") or
|
|
|
|
thumbnails.get(photo.simple_mimetype, "") or
|
|
|
|
"other"
|
|
|
|
%}
|
|
|
|
{% set thumbnail_src = "/static/basic_thumbnails/" + thumbnail_src + ".png" %}
|
|
|
|
{% endif %}
|
|
|
|
|
|
|
|
{% set tag_names_title = [] %}
|
2018-02-17 07:07:21 +00:00
|
|
|
{% for tag in photo.get_tags() %}
|
2017-12-10 01:48:56 +00:00
|
|
|
{% do tag_names_title.append(tag.name) %}
|
2017-08-02 01:25:28 +00:00
|
|
|
{% endfor %}
|
2017-12-10 01:48:56 +00:00
|
|
|
|
2017-08-02 01:25:28 +00:00
|
|
|
{% set tag_names_title = ", ".join(tag_names_title) %}
|
|
|
|
{% if tag_names_title %}
|
|
|
|
{% set tag_names_inner = "T" %}
|
|
|
|
{% else %}
|
|
|
|
{% set tag_names_inner = "" %}
|
|
|
|
{% endif %}
|
|
|
|
|
|
|
|
{% set metadata_inner = "" %}
|
|
|
|
{% if photo.width %}
|
|
|
|
{% set metadata_inner = "{m}{w}×{h}, ".format(m=metadata_inner, w=photo.width, h=photo.height) %}
|
|
|
|
{% endif %}
|
|
|
|
{% if photo.duration %}
|
|
|
|
{% set metadata_inner = "{m}{d}, ".format(m=metadata_inner, d=photo.duration_string) %}
|
|
|
|
{% endif %}
|
|
|
|
|
2017-12-10 01:48:56 +00:00
|
|
|
<div class="photo_card photo_card_grid" data-id="{{photo.id}}">
|
2017-08-02 01:25:28 +00:00
|
|
|
<a class="photo_card_thumbnail" target="_blank" href="/photo/{{photo.id}}">
|
2018-03-11 03:53:29 +00:00
|
|
|
<img src="{{thumbnail_src}}">
|
2017-08-02 01:25:28 +00:00
|
|
|
</a>
|
|
|
|
|
|
|
|
<div class="photo_card_filename">
|
|
|
|
<a target="_blank" href="/photo/{{photo.id}}">{{photo.basename}}</a>
|
2016-09-18 08:33:46 +00:00
|
|
|
</div>
|
2017-08-02 01:25:28 +00:00
|
|
|
|
|
|
|
<span class="photo_card_tags" title="{{tag_names_title}}">{{tag_names_inner}}</span>
|
|
|
|
|
|
|
|
<span class="photo_card_metadata">
|
|
|
|
{{- metadata_inner|safe -}}
|
2018-03-18 07:19:30 +00:00
|
|
|
<a target="_blank" href="/file/{{photo.id + photo.dot_extension}}">{{photo.bytestring}}</a>
|
2017-08-02 01:25:28 +00:00
|
|
|
</span>
|
2017-12-10 01:48:56 +00:00
|
|
|
|
|
|
|
<input type="checkbox" class="photo_card_selector_checkbox" onclick="on_photo_select(event)"/>
|
2016-09-18 08:33:46 +00:00
|
|
|
</div>
|
2016-11-07 02:00:30 +00:00
|
|
|
{% endif %}
|
2016-12-14 21:26:42 +00:00
|
|
|
{% endmacro %}
|