Merge pull request #169 from sharkykh/num-comments

Add number of comments to torrent lists
This commit is contained in:
Anna-Maria Meriniemi 2017-05-27 21:36:29 +03:00 committed by GitHub
commit ea17f2d4da
3 changed files with 43 additions and 8 deletions

View File

@ -25,6 +25,7 @@ def search_elastic(term='', user=None, sort='id', order='desc',
'id': 'id',
'size': 'filesize',
# 'name': 'display_name', # This is slow and buggy
'comments': 'comments_count',
'seeders': 'seed_count',
'leechers': 'leech_count',
'downloads': 'download_count'
@ -190,6 +191,7 @@ def search_db(term='', user=None, sort='id', order='desc', category='0_0',
'size': models.Torrent.filesize,
# Disable this because we disabled this in search_elastic, for the sake of consistency:
# 'name': models.Torrent.display_name,
'comments': models.Torrent.comment_count,
'seeders': models.Statistic.seed_count,
'leechers': models.Statistic.leech_count,
'downloads': models.Statistic.download_count

View File

@ -62,6 +62,30 @@ table.torrent-list tbody tr td a:visited {
color: #1d4568;
}
/* comments count */
table.torrent-list .hdr-comments {
border-left: hidden;
font-size: medium;
}
table.torrent-list .hdr-comments i {
margin-right: 6px;
}
table.torrent-list tbody .comments {
position: relative;
float: right;
border: 1px solid #d7d7d7;
border-radius: 3px;
color: #383838;
padding: 0 5px;
font-size: small;
background-color: #ffffff;
}
table.torrent-list tbody .comments i {
padding-right: 2px;
}
#torrent-description img {
max-width: 100%;
}

View File

@ -28,6 +28,9 @@
{% call render_column_header("hdr-name", "width:auto;") %}
<div>Name</div>
{% endcall %}
{% call render_column_header("hdr-comments", "width:50px;", center_text=True, sort_key="comments", header_title="Comments") %}
<i class="fa fa-comments-o"></i>
{% endcall %}
{% call render_column_header("hdr-link", "width:70px;", center_text=True) %}
<div>Link</div>
{% endcall %}
@ -44,12 +47,10 @@
{% endcall %}
{% call render_column_header("hdr-leechers", "width:50px;", center_text=True, sort_key="leechers", header_title="Leeches") %}
<i class="fa fa-arrow-down" aria-hidden="true"></i>
{% endcall %}
{% call render_column_header("hdr-downloads", "width:50px;", center_text=True, sort_key="downloads", header_title="Completed downloads") %}
<i class="fa fa-check" aria-hidden="true"></i>
{% endcall %}
{% endif %}
</tr>
</thead>
@ -68,12 +69,20 @@
<img src="/static/img/icons/{{ icon_dir }}/{{ cat_id }}.png" alt="{{ category_name(cat_id) }}">
</a>
</td>
{% if use_elastic %}
<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>
{% else %}
<td><a href="{{ url_for('view_torrent', torrent_id=torrent.id) }}" title="{{ torrent.display_name | escape }}">{{ torrent.display_name | escape }}</a></td>
{% endif %}
<td style="white-space: nowrap;text-align: center;">
<td colspan="2">
{% set com_count = torrent.comment_count %}
{% if com_count %}
<span class="comments" title="{{ '{c} comment{s}'.format(c=com_count, s='s' if com_count > 1 else '') }}">
<i class="fa fa-comments-o"></i>{{ com_count -}}
</span>
{% endif %}
{% if use_elastic %}
<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>
{% else %}
<a href="{{ url_for('view_torrent', torrent_id=torrent.id) }}" title="{{ torrent.display_name | escape }}">{{ torrent.display_name | escape }}</a>
{% endif %}
</td>
<td class="text-center" style="white-space: nowrap;">
{% if torrent.has_torrent %}<a href="{{ url_for('download_torrent', torrent_id=torrent.id) }}"><i class="fa fa-fw fa-download"></i></a>{% endif %}
{% if use_elastic %}
<a href="{{ create_magnet_from_es_info(torrent.display_name, torrent.info_hash) }}"><i class="fa fa-fw fa-magnet"></i></a>