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"]) %}
2017-05-13 08:17:22 +03:00
< th { % if th_classes % } class = "{{ ' '.join(th_classes) }}" { % endif % } { % if header_title % } title = "{{ header_title }}" { % endif % } style = "{{ header_style }}" >
2017-05-12 22:24:45 +03:00
{% if sort_key %}
< a href = "{% if class_suffix == '_desc' %}{{ modify_query(s=sort_key, o=" asc " ) } } { % else % } { { modify_query ( s = sort_key, o = "desc" ) } } { % endif % } " > < / a >
{% endif %}
{{ caller() }}
< / 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-05-24 17:18:44 +03:00
< a href = "/user/{{ 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 %}
2017-05-15 23:51:58 -07:00
{% if (use_elastic and torrent_query.hits.total > 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 >
2017-05-14 11:19:58 +03:00
{% call render_column_header("hdr-category", "width:80px;", center_text=True) %}
2017-05-12 22:24:45 +03:00
< div > Category< / div >
{% endcall %}
2017-05-15 23:51:58 -07:00
{% call render_column_header("hdr-name", "width:auto;") %}
2017-05-12 22:24:45 +03:00
< div > Name< / div >
{% endcall %}
2017-05-15 11:54:28 +03:00
{% call render_column_header("hdr-link", "width:70px;", center_text=True) %}
2017-05-12 22:24:45 +03:00
< div > Link< / div >
{% endcall %}
2017-05-14 11:19:58 +03:00
{% call render_column_header("hdr-size", "width:100px;", center_text=True, sort_key="size") %}
2017-05-12 22:24:45 +03:00
< div > Size< / div >
{% endcall %}
2017-05-14 11:19:58 +03:00
{% call render_column_header("hdr-date", "width:140px;", center_text=True, sort_key="id", header_title="In UTC") %}
2017-05-13 02:23:02 +03:00
< div > Date< / div >
{% endcall %}
2017-05-13 01:59:52 +02:00
2017-05-12 20:51:49 +02:00
{% if config.ENABLE_SHOW_STATS %}
2017-05-14 11:19:58 +03:00
{% call render_column_header("hdr-seeders", "width:50px;", center_text=True, sort_key="seeders", header_title="Seeds") %}
2017-05-12 22:24:45 +03:00
< i class = "fa fa-arrow-up" aria-hidden = "true" > < / i >
{% endcall %}
2017-05-14 11:19:58 +03:00
{% call render_column_header("hdr-leechers", "width:50px;", center_text=True, sort_key="leechers", header_title="Leeches") %}
2017-05-12 20:51:49 +02:00
< i class = "fa fa-arrow-down" aria-hidden = "true" > < / i >
2017-05-13 01:59:52 +02:00
2017-05-12 22:24:45 +03:00
{% endcall %}
2017-05-14 11:19:58 +03:00
{% 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 >
2017-05-12 22:24:45 +03:00
{% endcall %}
2017-05-13 01:59:52 +02:00
2017-05-12 20:51:49 +02:00
{% endif %}
< / tr >
< / thead >
< tbody >
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 %}
2017-05-13 02:23:02 +03:00
{% set icon_dir = config.SITE_FLAVOR %}
2017-05-12 20:51:49 +02:00
< td style = "padding:0 4px;" >
2017-05-15 23:51:58 -07:00
{% if use_elastic %}
2017-05-19 15:24:09 +03:00
< a href = "/?c={{ cat_id }}" title = "{{ category_name(cat_id) }}" >
2017-05-15 23:51:58 -07:00
{% else %}
2017-05-13 08:17:22 +03:00
< a href = "/?c={{ cat_id }}" title = "{{ torrent.main_category.name }} - {{ torrent.sub_category.name }}" >
2017-05-15 23:51:58 -07:00
{% endif %}
2017-05-24 06:06:39 +00:00
< img src = "/static/img/icons/{{ icon_dir }}/{{ cat_id }}.png" alt = "{{ category_name(cat_id) }}" >
2017-05-13 08:17:22 +03:00
< / a >
2017-05-13 02:23:02 +03:00
< / td >
2017-05-15 23:51:58 -07:00
{% if use_elastic %}
2017-05-16 15:08:47 +01:00
< td > < a href = "{{ url_for('view_torrent', torrent_id=torrent.meta.id) }}" title = "{{ torrent.display_name | escape }}" > {%if "highlight" in torrent.meta %}{{ torrent.meta.highlight.display_name[0] | safe }}{% else %}{{torrent.display_name}}{%endif%}< / a > < / td >
2017-05-15 23:51:58 -07:00
{% else %}
2017-05-16 14:49:15 +01:00
< td > < a href = "{{ url_for('view_torrent', torrent_id=torrent.id) }}" title = "{{ torrent.display_name | escape }}" > {{ torrent.display_name | escape }}< / a > < / td >
2017-05-15 23:51:58 -07:00
{% endif %}
2017-05-13 02:30:39 +03:00
< td style = "white-space: nowrap;text-align: center;" >
2017-05-13 01:59:52 +02:00
{% if torrent.has_torrent %}< a href = "{{ url_for('download_torrent', 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 %}
< a href = "{{ create_magnet_from_info(torrent.display_name, torrent.info_hash) }}" > < i class = "fa fa-fw fa-magnet" > < / i > < / a >
{% 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-13 02:30:39 +03: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-05-12 20:51:49 +02:00
{% if config.ENABLE_SHOW_STATS %}
2017-05-15 23:51:58 -07:00
{% if use_elastic %}
2017-05-14 02:01:26 -06:00
< td class = "text-center" style = "color: green;" > {{ torrent.seed_count }}< / td >
< td class = "text-center" style = "color: red;" > {{ torrent.leech_count }}< / td >
< td class = "text-center" > {{ torrent.download_count }}< / td >
2017-05-15 23:51:58 -07:00
{% else %}
2017-05-12 20:51:49 +02:00
< td class = "text-center" style = "color: green;" > {{ torrent.stats.seed_count }}< / td >
< td class = "text-center" style = "color: red;" > {{ torrent.stats.leech_count }}< / td >
< 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 >