From 11a398e90ca76ca7057c3f6a62736769efc7e29b Mon Sep 17 00:00:00 2001 From: yggverse Date: Tue, 5 Aug 2025 19:49:58 +0300 Subject: [PATCH] implement files counter --- src/main.rs | 5 +++++ templates/index.html.tera | 7 ++++--- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/src/main.rs b/src/main.rs index 87d47ce..dba35ba 100644 --- a/src/main.rs +++ b/src/main.rs @@ -43,6 +43,7 @@ fn index( indexed: String, magnet: String, size: String, + files: String, torrent: Torrent, } let (total, torrents) = storage @@ -68,6 +69,10 @@ fn index( indexed: torrent.time.format(&meta.format_time).to_string(), magnet: format::magnet(&torrent.info_hash, meta.trackers.as_ref()), 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, }) .collect::>(), diff --git a/templates/index.html.tera b/templates/index.html.tera index cff4e5f..8b4ea08 100644 --- a/templates/index.html.tera +++ b/templates/index.html.tera @@ -8,9 +8,10 @@ {% if row.torrent.comment %}

{{ row.torrent.comment }}

{% endif %}
    -
  • {{ row.indexed }}{% - if row.created %} ({{ row.created }}){% endif %}
  • {% - if row.size %}
  • {{ row.size }}
  • {% endif %} +
  • {{ row.indexed }}
  • + {% if row.created %}
  • ({{ row.created }})
  • {% endif %} + {% if row.size %}
  • {{ row.size }}
  • {% endif %} +
  • {{ row.files }}