###############################################################################
import logging
+import os.path
import sqlalchemy
from sqlalchemy import Column, ForeignKey
path = Column(Text, nullable=False)
+ # Filename
+
+ @property
+ def filename(self):
+ return os.path.basename(self.path)
+
# Link
@property
size = Column(BigInteger, nullable=False)
+ # Checksums
+
+ @property
+ def checksums(self):
+ """
+ A dictionary with all available checksums
+ """
+ checksums = {
+ "sha3-512" : self.checksum_sha3_512,
+ "sha3-256" : self.checksum_sha3_256,
+ "blake2b512" : self.checksum_blake2b512,
+ "blake2s256" : self.checksum_blake2s256,
+ "sha2-512" : self.checksum_sha2_512,
+ "sha2-256" : self.checksum_sha2_256,
+ }
+
+ # Filter out any empty checksums
+ return { algo : checksums[algo] for algo in checksums if checksums[algo] }
+
# Checksum SHA3-512
checksum_sha3_512 = Column(LargeBinary, nullable=False)
</a>
</small>
</div>
+
+ {# Checksums Link #}
+ <div class="level-item">
+ <small>
+ <a href="#" class="modal-toggle" data-target="image-{{ image.type }}-{{ image.arch }}">
+ <span class="icon-text">
+ <span class="icon">
+ <i class="fa-solid fa-hashtag"></i>
+ </span>
+ </span>
+ </a>
+ </small>
+ </div>
</nav>
</div>
+
+ {# Modal with the checksums #}
+ <div class="modal" id="image-{{ image.type }}-{{ image.arch }}">
+ <div class="modal-background"></div>
+ <div class="modal-content">
+ <section class="modal-card-body">
+ <div class="content">
+ <h4 class="title is-4">
+ {{ _("Checksums for %s") % image.filename }}
+ </h4>
+
+ <p>
+ {{ _("To ensure your downloaded file is complete and unmodified, "
+ "use the checksums below to verify its integrity. "
+ "Compare the checksum of your downloaded file with the one "
+ "listed here. If they match, your file is intact.") }}
+ </p>
+
+ <ul>
+ {% for algo, checksum in image.checksums.items() %}
+ <li>
+ <strong>
+ {% if algo == "sha3-512" %}
+ {{ _("SHA3-512" )}}
+ {% elif algo == "sha3-256" %}
+ {{ _("SHA3-256") }}
+ {% elif algo == "blake2b512" %}
+ {{ _("BLAKE2b512") }}
+ {% elif algo == "blake2b256" %}
+ {{ _("BLAKE2s256") }}
+ {% elif algo == "sha2-512" %}
+ {{ _("SHA2-512") }}
+ {% elif algo == "sha2-256" %}
+ {{ _("SHA2-256") }}
+ {% else %}
+ {{ algo }}
+ {% endif %}
+ </strong>
+
+ <br>
+
+ <code>
+ {{ checksum.hex() }}
+ </code>
+ </li>
+ {% endfor %}
+ </li>
+ </div>
+ </section>
+ </div>
+
+ {# Close Button #}
+ <button class="modal-close is-large" aria-label="close"></button>
+ </div>
{% endfor %}
</div>
</div>