{# ALBUM ######################################################################} {% macro create_album_card(album, view="grid", unlink_parent=none, draggable=false) %} {% set id = "album_card_root" if album == "root" else "album_card_" ~ album.id %} {% set view = (view if view in ("list", "grid") else "grid") %} {% set viewparam = "?view=list" if view == "list" else "" %}
{% if album == "root" %} {% else %} {% endif %} {% if album.thumbnail_photo %} {% set thumbnail_src = "/photo/" ~ album.thumbnail_photo.id ~ "/thumbnail/" ~ album.thumbnail_photo.id ~ ".jpg" %} {% else %} {% set thumbnail_src = "/static/basic_thumbnails/album.png" %} {% endif %}
{% if album == "root" %} Albums {% else %} {{album.display_name}} {% endif %}
{% if album != "root" %} {% set child_count = album.sum_children(recurse=False) %} {% set photo_count = album.sum_photos(recurse=False) %} {{child_count}} {{-' | '-}} {{photo_count}} {% endif %}
{% if unlink_parent is not none %} {% endif %}
{% endmacro %} {# PHOTO ######################################################################} {# Priority: specific extensions > specific mimetypes > general mimtypes #} {% set thumbnails = { "svg": "svg", "application/zip": "archive", "application/x-tar": "archive", "archive": "archive", "audio": "audio", "image": "image", "video": "video", "text": "txt", } %} {% macro create_photo_card(photo, view="grid") %} {% set view = (view if view in ("list", "grid") else "grid") %} {% set metadatas = [] %} {% if photo.width %} {% do metadatas.append("{w}×{h}".format(w=photo.width, h=photo.height)) %} {% endif %} {% if photo.duration %} {% do metadatas.append("{d}".format(d=photo.duration_string)) %} {% endif -%} {% set tag_names_title = photo.get_tag_names()|sort|comma_join %} {% set tag_names_inner = "T" if tag_names_title else "" %}
{{photo.basename}}
{{- metadatas|join_and_trail(", ")|safe -}} {{photo.bytes_string}} {% if view == "grid" %} {% if photo.has_thumbnail() %} {% set thumbnail_src = "/photo/" ~ photo.id ~ "/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 -%}{# if thumbnail #} {% endif %}{# if grid #} {{tag_names_inner}}
{% endmacro %} {# TAG ########################################################################} {%- macro create_tag_card( tag, photo_tag_rel_id=None, extra_classes="", innertext=None, innertext_safe=None, link='info', onclick=None, with_alt_description=False ) -%} {%- set href = { "search": "/search?tag_musts=" ~ (tag.name|urlencode), "search_musts": "/search?tag_musts=" ~ (tag.name|urlencode), "search_mays": "/search?tag_mays=" ~ (tag.name|urlencode), "search_forbids": "/search?tag_forbids=" ~ (tag.name|urlencode), "info": "/tag/" ~ tag.name, None: None, }.get(link, link) -%} {%- set class = ("tag_card" ~ " " ~ extra_classes).strip() -%} {%- set title = (with_alt_description and tag.description) or None -%} {%- set innertext = innertext_safe or (innertext or tag.name)|e -%} {%- set element = "a" if (link or onclick) else "span" -%} <{{element}} {{make_attributes(data_id=photo_tag_rel_id, class=class, title=title, href=href, onclick=onclick, **kwargs)|safe}}>{{innertext|safe}} {{-''-}} {%- endmacro -%}