2017-05-14 11:19:58 +03:00
{% macro render_column_header(header_class, header_style, center_text=False, sort_key=None, header_title=None) %}
2017-05-12 22:24:45 +03:00
{% set class_suffix = (search.sort == sort_key) and ("_" + search.order) or "" %}
2017-05-14 11:19:58 +03:00
{% set th_classes = filter_truthy([header_class, sort_key and "sorting" + class_suffix, center_text and "text-center"]) %}
2019-04-09 21:16:12 +02:00
< th { % if th_classes % } class = "{{ ' '.join(th_classes) }}" { % endif % } { % if header_title % } title = "{{ header_title }}" { % endif % } style = "{{ header_style }}" >
{%- if sort_key -%}
2017-05-12 22:24:45 +03:00
< a href = "{% if class_suffix == '_desc' %}{{ modify_query(s=sort_key, o=" asc " ) } } { % else % } { { modify_query ( s = sort_key, o = "desc" ) } } { % endif % } " > < / a >
2019-04-09 21:16:12 +02:00
{%- endif -%}
{{- caller() -}}
2017-05-12 22:24:45 +03:00
< / th >
{% endmacro %}
2017-05-24 08:23:04 +00:00
2017-05-24 17:18:44 +03:00
{% if special_results is defined and not search.user %}
{% if special_results.first_word_user %}
2017-05-24 08:23:04 +00:00
< div class = "alert alert-info" >
2017-07-08 00:50:55 +03:00
< a href = "{{ url_for('users.view_user', user_name=special_results.first_word_user.username) }}{{ modify_query(q=special_results.query_sans_user)[1:] }}" > Click here to see only results uploaded by {{ special_results.first_word_user.username }}< / a >
2017-05-24 08:23:04 +00:00
< / div >
{% endif %}
{% endif %}
2020-07-12 01:10:47 -06:00
{% if (use_elastic and torrent_query.hits.total.value > 0) or (torrent_query.items) %}
2017-05-12 20:51:49 +02:00
< div class = "table-responsive" >
< table class = "table table-bordered table-hover table-striped torrent-list" >
< thead >
< tr >
2019-04-09 21:16:12 +02:00
{%+ call render_column_header("hdr-category", "width:80px;", center_text=True) -%}
Category
{%- endcall %}
{%+ call render_column_header("hdr-name", "width:auto;") -%}
Name
{%- endcall %}
{%+ call render_column_header("hdr-comments", "width:50px;", center_text=True, sort_key="comments", header_title="Comments") -%}
2017-05-25 17:56:06 +03:00
< i class = "fa fa-comments-o" > < / i >
2019-04-09 21:16:12 +02:00
{%- endcall %}
{%+ call render_column_header("hdr-link", "width:70px;", center_text=True) -%}
Link
{%- endcall %}
{%+ call render_column_header("hdr-size", "width:100px;", center_text=True, sort_key="size") -%}
Size
{%- endcall %}
{%+ call render_column_header("hdr-date", "width:140px;", center_text=True, sort_key="id", header_title="In UTC") -%}
Date
{%- endcall %}
2017-05-13 01:59:52 +02:00
2017-05-12 20:51:49 +02:00
{% if config.ENABLE_SHOW_STATS %}
2019-04-09 21:16:12 +02:00
{%+ call render_column_header("hdr-seeders", "width:50px;", center_text=True, sort_key="seeders", header_title="Seeders") -%}
2017-05-12 22:24:45 +03:00
< i class = "fa fa-arrow-up" aria-hidden = "true" > < / i >
2019-04-09 21:16:12 +02:00
{%- endcall %}
{%+ call render_column_header("hdr-leechers", "width:50px;", center_text=True, sort_key="leechers", header_title="Leechers") -%}
2017-05-12 20:51:49 +02:00
< i class = "fa fa-arrow-down" aria-hidden = "true" > < / i >
2019-04-09 21:16:12 +02:00
{%- endcall %}
{%+ call render_column_header("hdr-downloads", "width:50px;", center_text=True, sort_key="downloads", header_title="Completed downloads") -%}
2017-05-12 20:51:49 +02:00
< i class = "fa fa-check" aria-hidden = "true" > < / i >
2019-04-09 21:16:12 +02:00
{%- endcall %}
2017-05-12 20:51:49 +02:00
{% endif %}
< / tr >
< / thead >
< tbody >
2019-01-12 20:11:15 +01:00
{% set icon_dir = config.SITE_FLAVOR %}
2017-05-15 23:51:58 -07:00
{% set torrents = torrent_query if use_elastic else torrent_query.items %}
{% for torrent in torrents %}
2017-05-12 20:51:49 +02:00
< tr class = "{% if torrent.deleted %}deleted{% elif torrent.hidden %}warning{% elif torrent.remake %}danger{% elif torrent.trusted %}success{% else %}default{% endif %}" >
2017-05-19 15:24:09 +03:00
{% set cat_id = use_elastic and ((torrent.main_category_id|string) + '_' + (torrent.sub_category_id|string)) or torrent.sub_category.id_as_string %}
2019-04-09 21:16:12 +02:00
< td >
{% if use_elastic %}
< a href = "{{ url_for('main.home', c=cat_id) }}" title = "{{ category_name(cat_id) }}" >
{% else %}
< a href = "{{ url_for('main.home', c=cat_id) }}" title = "{{ torrent.main_category.name }} - {{ torrent.sub_category.name }}" >
{% endif %}
< img src = "{{ url_for('static', filename='img/icons/%s/%s.png'|format(icon_dir, cat_id)) }}" alt = "{{ category_name(cat_id) }}" class = "category-icon" >
< / a >
2017-05-13 02:23:02 +03:00
< / td >
2017-05-25 17:56:06 +03:00
< td colspan = "2" >
2017-05-28 02:46:04 +03:00
{% set torrent_id = torrent.meta.id if use_elastic else torrent.id %}
2017-05-25 17:56:06 +03:00
{% set com_count = torrent.comment_count %}
{% if com_count %}
2017-07-11 01:00:03 +03:00
< a href = "{{ url_for('torrents.view', torrent_id=torrent_id, _anchor='comments') }}" class = "comments" title = "{{ '{c} comment{s}'.format(c=com_count, s='s' if com_count > 1 else '') }}" >
2017-05-25 17:56:06 +03:00
< i class = "fa fa-comments-o" > < / i > {{ com_count -}}
2017-05-28 02:46:04 +03:00
< / a >
2017-05-25 17:56:06 +03:00
{% endif %}
2017-05-23 10:51:28 +03:00
{% if use_elastic %}
2019-04-09 21:16:12 +02:00
< a href = "{{ url_for('torrents.view', torrent_id=torrent_id) }}" title = "{{ torrent.display_name | escape }}" > {%if "highlight" in torrent.meta %}{{ torrent.meta.highlight.display_name[0] | safe }}{% else %}{{torrent.display_name}}{% endif %}< / a >
2017-05-23 10:51:28 +03:00
{% else %}
2017-07-11 01:00:03 +03:00
< a href = "{{ url_for('torrents.view', torrent_id=torrent_id) }}" title = "{{ torrent.display_name | escape }}" > {{ torrent.display_name | escape }}< / a >
2017-05-23 10:51:28 +03:00
{% endif %}
< / td >
2019-04-09 21:16:12 +02:00
< td class = "text-center" >
{% if torrent.has_torrent %}
< a href = "{{ url_for('torrents.download', torrent_id=torrent_id) }}" > < i class = "fa fa-fw fa-download" > < / i > < / a >
{% endif %}
2017-05-16 00:46:25 -07:00
{% if use_elastic %}
2018-07-21 22:01:19 +03:00
< a href = "{{ create_magnet_from_es_torrent(torrent) }}" > < i class = "fa fa-fw fa-magnet" > < / i > < / a >
2017-05-16 00:46:25 -07:00
{% else %}
2017-05-13 02:30:39 +03:00
< a href = "{{ torrent.magnet_uri }}" > < i class = "fa fa-fw fa-magnet" > < / i > < / a >
2017-05-16 00:46:25 -07:00
{% endif %}
2017-05-13 02:30:39 +03:00
< / td >
< td class = "text-center" > {{ torrent.filesize | filesizeformat(True) }}< / td >
2017-05-15 23:51:58 -07:00
{% if use_elastic %}
2017-05-16 15:08:47 +01:00
< td class = "text-center" data-timestamp = "{{ torrent.created_time | utc_time }}" > {{ torrent.created_time | display_time }}< / td >
2017-05-15 23:51:58 -07:00
{% else %}
2017-05-24 23:19:08 -07:00
< td class = "text-center" data-timestamp = "{{ torrent.created_utc_timestamp | int }}" > {{ torrent.created_time.strftime('%Y-%m-%d %H:%M') }}< / td >
2017-05-15 23:51:58 -07:00
{% endif %}
2017-08-31 14:19:22 +02:00
2017-05-12 20:51:49 +02:00
{% if config.ENABLE_SHOW_STATS %}
2017-05-15 23:51:58 -07:00
{% if use_elastic %}
2019-04-09 21:16:12 +02:00
< td class = "text-center" > {{ torrent.seed_count }}< / td >
< td class = "text-center" > {{ torrent.leech_count }}< / td >
2017-05-14 02:01:26 -06:00
< td class = "text-center" > {{ torrent.download_count }}< / td >
2017-05-15 23:51:58 -07:00
{% else %}
2019-04-09 21:16:12 +02:00
< td class = "text-center" > {{ torrent.stats.seed_count }}< / td >
< td class = "text-center" > {{ torrent.stats.leech_count }}< / td >
2017-05-12 20:51:49 +02:00
< td class = "text-center" > {{ torrent.stats.download_count }}< / td >
{% endif %}
{% endif %}
< / tr >
{% endfor %}
< / tbody >
< / table >
< / div >
{% else %}
< h3 > No results found< / h3 >
{% endif %}
2017-05-24 06:06:39 +00:00
< div class = "center" >
2017-05-15 23:51:58 -07:00
{% if use_elastic %}
{{ pagination.info }}
{{ pagination.links }}
{% else %}
2017-05-12 20:51:49 +02:00
{% from "bootstrap/pagination.html" import render_pagination %}
{{ render_pagination(torrent_query) }}
2017-05-15 23:51:58 -07:00
{% endif %}
2017-05-24 06:06:39 +00:00
< / div >