{# Attributes of an element that keeps itself up to date: 750ms after it appears it fetches url and replaces itself with the response. The response repeats these attributes while there's more to show, and leaves them out to stop. htmx skips the request once the element has left the page. hx-target is explicit, otherwise elements in #dialog inherit the dialog. #} {% macro self_polling(url) -%} hx-get="{{ url }}" hx-trigger="load delay:750ms" hx-target="this" hx-swap="outerHTML" {%- endmacro %} {% macro render_series_timeline(series) %} {% endmacro %} {% macro render_series_grid(series) %}
{% for s in series %}
{% if loop.changed(s.added_on_date) %}

{{s.added_on_date|to_date|timeline_date}}

{% else %}
 
{% endif %} {% set episode_hash = 'e' ~ s.episode.id %}

{{s.episode.season_episode_id}}

{{ s.episode.name }}

{{ "{:,}".format(s.release_count)}} new torrents

{% endfor %}
{% endmacro %} {% macro render_series_card(series) %}
Poster for {{series.name}}

{{series.name}}

{% endmacro %} {% macro air_date(value, today) %} {% if value %} {% if value <= today %} {{value | human_date}} {% else %} Will air {{value | human_date}} {% endif %} {% else %}   {% endif %} {% endmacro %} {# A release's download cell in the episode list #} {% macro torrent_download_status(release, status, transfer=None) %} {% if status == 'D' %}
{{icon("#icon-check-bold", width=16, height=16, class="text-success mr-1")}}Downloaded
{% elif status in ('A', 'M', 'd') %} {# Until the BitTorrent session knows the torrent there's no progress to show yet #} {%- if transfer %}{{transfer.progress}}%{% else %}…{% endif -%} {% else %} {% set request_url = url_for('main.download_torrent', release_id=release.id, template="_download-button") %} {% endif %} {% endmacro %} {# A release's download progress in its dialog #} {% macro torrent_download_progress(release, transfer=None) %}
{% if transfer %}
{{transfer.stats}}
{% else %}
Checking download status…
{% endif %}
{% endmacro %} {% macro torrent_files(torrent) %}
{% endmacro %} {% macro icon(id, width=30, height=30, class="") %} {% endmacro %} {% macro tracker_status_icon(value) %} {% if value == 'K' %} {{icon("#icon-check-bold", width=16, height=16, class="text-success")}} {% elif value == 'N' %} {{icon("#icon-hourglass-bold", width=16, height=16, class="text-info")}} {% else %} {{icon("#icon-warning-bold", width=16, height=16, class="text-warning")}} {% endif %} {% endmacro %} {% macro tracker_status_description(value) %} {% if value == 'K' %} {% elif value == 'N' %} (not contacted yet) {% elif value == 'T' %} (timed out) {% elif value == 'P' %} (protocol error) {% elif value == 'D' %} (DNS error) {% else %} (error) {% endif %} {% endmacro %}