implement files counter

This commit is contained in:
yggverse 2025-08-05 19:49:58 +03:00
parent 5c167f4852
commit 11a398e90c
2 changed files with 9 additions and 3 deletions

View file

@ -43,6 +43,7 @@ fn index(
indexed: String, indexed: String,
magnet: String, magnet: String,
size: String, size: String,
files: String,
torrent: Torrent, torrent: Torrent,
} }
let (total, torrents) = storage let (total, torrents) = storage
@ -68,6 +69,10 @@ fn index(
indexed: torrent.time.format(&meta.format_time).to_string(), indexed: torrent.time.format(&meta.format_time).to_string(),
magnet: format::magnet(&torrent.info_hash, meta.trackers.as_ref()), magnet: format::magnet(&torrent.info_hash, meta.trackers.as_ref()),
size: format::bytes(torrent.size), size: format::bytes(torrent.size),
files: torrent.files.as_ref().map_or("1 file".into(), |f| {
let l = f.len();
format!("{l} {}", l.plurify(&["file", "files", "files"]))
}),
torrent, torrent,
}) })
.collect::<Vec<Row>>(), .collect::<Vec<Row>>(),

View file

@ -8,9 +8,10 @@
{% if row.torrent.comment %}<p>{{ row.torrent.comment }}</p>{% endif %} {% if row.torrent.comment %}<p>{{ row.torrent.comment }}</p>{% endif %}
<div> <div>
<ul> <ul>
<li><span title="Indexed">{{ row.indexed }}</span>{% <li><span title="Indexed">{{ row.indexed }}</span></li>
if row.created %} <span title="Created">({{ row.created }})</span>{% endif %}</li>{% {% if row.created %}<li><span title="Created">({{ row.created }})</span></li>{% endif %}
if row.size %}<li><span title="Size">{{ row.size }}</span></li>{% endif %} {% if row.size %}<li><span title="Size">{{ row.size }}</span></li>{% endif %}
<li><span title="Files">{{ row.files }}</span></li>
</ul> </ul>
<a rel="nofollow" href="{{ row.magnet }}" title="Magnet"> <a rel="nofollow" href="{{ row.magnet }}" title="Magnet">
<svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" fill="currentColor" viewBox="0 0 16 16"> <svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" fill="currentColor" viewBox="0 0 16 16">