factor out file size display code

This commit is contained in:
xenofem 2022-11-10 12:41:51 -05:00
parent 920b28f5f5
commit d80180956f
3 changed files with 20 additions and 5 deletions

View file

@ -4,7 +4,7 @@
{% block og_title %}{{ info.file.name }}{% endblock %}
{% block og_description -%}
{% let formatted_total_size = bytesize::to_string(info.file.size.clone(), false).replace(" ", "") -%}
{% let formatted_total_size = info.file.formatted_size() -%}
{% match info.file.contents -%}
{% when Some with (files) -%}
{{ files.files.len() }} files, {{ formatted_total_size }} total
@ -26,7 +26,7 @@
{% block body %}
<div id="download_toplevel" class="section">
<div class="file_name">{{ info.file.name }}</div>
<div class="file_size">{{ bytesize::to_string(info.file.size.clone(), false).replace(" ", "") }}</div>
<div class="file_size">{{ info.file.formatted_size() }}</div>
<div class="file_download"><a class="download_button" href="download?code={{ info.code }}&download=all"></a></div>
<div class="file_expiry">Expires {{ info.file.expiry.format(DATE_DISPLAY_FORMAT).unwrap() }}</div>
</div>
@ -39,7 +39,7 @@
{% let offsets = info.offsets.as_ref().unwrap() %}
{% for f in files.files %}
<tr class="{% if offsets.get(loop.index0.clone()).unwrap().clone() > info.available %}unavailable{% endif %}">
<td class="file_size">{{ bytesize::to_string(f.size.clone(), false).replace(" ", "") }}</td>
<td class="file_size">{{ f.formatted_size() }}</td>
<td class="file_name">{{ f.name }}</td>
<td class="file_download"><a class="download_button" href="download?code={{ info.code }}&download={{ loop.index0 }}"></a></td>
<td class="file_unavailable"></td>