]> git.ipfire.org Git - ipfire.org.git/commitdiff
downloads: Bring back links to torrent downloads
authorMichael Tremer <michael.tremer@ipfire.org>
Wed, 4 Mar 2026 13:55:09 +0000 (13:55 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Wed, 4 Mar 2026 13:55:09 +0000 (13:55 +0000)
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
src/backend/releases.py
src/templates/downloads/release.html

index 895c6ca300690dad5f4f9d4ab84fe129195b36ce..cfa08eb4b147910c199b51509440277abe6c5c85 100644 (file)
@@ -155,6 +155,12 @@ class File(Object):
 
                return "N/A"
 
+       def is_torrent(self):
+               """
+                       Returns True is this is a torrent file
+               """
+               return self.filename.endswith(".torrent")
+
 
 class Release(Object):
        def __init__(self, backend, id, data=None):
@@ -221,11 +227,12 @@ class Release(Object):
        @property
        def files(self):
                if not self.__files:
-                       files = self.db.query("SELECT * FROM files WHERE releases = %s \
-                               AND NOT filename LIKE '%%.torrent'", self.id)
+                       files = [
+                               File(self.backend, self, row.id, row) for row in \
+                                       self.db.query("SELECT * FROM files WHERE releases = %s", self.id)
+                       ]
 
-                       self.__files = [File(self.backend, self, f.id, f) for f in files]
-                       self.__files.sort()
+                       self.__files = sorted(files)
 
                return self.__files
 
@@ -234,6 +241,11 @@ class Release(Object):
                        if f.arch == arch:
                                yield f
 
+       def find_torrent(self, file):
+               for f in self.files:
+                       if f.filename == "%s.torrent" % file.filename:
+                               return f
+
        @property
        def name(self):
                return self.__data.name
index d788762aefe1150a58aeb9b31b0284de94f6e95a..b3ca25e08c04115e60fc05b7dd89f02788d0ca6b 100644 (file)
 
                                <div class="columns is-multiline">
                                        {% for arch in release.arches %}
-                                               <div class="column is-half is-one-quarter-widescreen is-one-fifth-fullhd">
+                                               <div class="column is-half is-one-third-widescreen is-one-quarter-fullhd">
                                                        <div class="block p-5">
                                                                <h5 class="title is-5">{{ arch }}</h5>
 
                                                                <ul>
                                                                        {% for file in release.get_files_by_arch(arch) %}
+                                                                               {% if file.is_torrent() %}{% continue %}{% end %}
+
+                                                                               {# Fetch the corresponding torrent file #}
+                                                                               {% set torrent = release.find_torrent(file) %}
+
                                                                                <li>
-                                                                                       <a class="download-splash" href="{{ file.url }}">
-                                                                                               <span class="icon-text">
-                                                                                                       <span class="icon">
-                                                                                                               <i class="fas fa-download"></i>
-                                                                                                       </span>
-                                                                                                       <span>
-                                                                                                               {{ _(file.desc) }}
-                                                                                                               ({{ format_size(file.size) }})
-                                                                                                       </span>
-                                                                                               </span>
-                                                                                       </a>
+                                                                                       <div class="dropdown is-right">
+                                                                                               <div class="dropdown-trigger">
+                                                                                                       <button class="button is-link" aria-haspopup="true" aria-controls="dropdown-menu">
+                                                                                                               <span class="icon">
+                                                                                                                       <i class="fas fa-download"></i>
+                                                                                                               </span>
+
+                                                                                                               <span>
+                                                                                                                       {{ _(file.desc) }}
+                                                                                                                       ({{ format_size(file.size) }})
+                                                                                                               </span>
+                                                                                                       </button>
+                                                                                               </div>
+
+                                                                                               <div class="dropdown-menu" id="dropdown-menu" role="menu">
+                                                                                                       <div class="dropdown-content">
+                                                                                                               <a class="dropdown-item download-splash" href="{{ file.url }}">
+                                                                                                                       {{ _("Direct Download") }}
+                                                                                                               </a>
+
+                                                                                                               {% if torrent %}
+                                                                                                                       <a class="dropdown-item download-splash" href="{{ torrent.url }}">
+                                                                                                                               {{ _("Torrent Download") }}
+                                                                                                                       </a>
+                                                                                                               {% end %}
+                                                                                                       </div>
+                                                                                               </div>
+                                                                                       </div>
                                                                                </li>
                                                                        {% end %}
                                                                </ul>