File tree Expand file tree Collapse file tree 4 files changed +39
-2
lines changed
Expand file tree Collapse file tree 4 files changed +39
-2
lines changed Original file line number Diff line number Diff line change 55from django import template
66from django .core .cache import cache
77from django .utils .html import format_html
8+ from django .utils .safestring import mark_safe
89
910from downloads .models import Release
1011
@@ -90,6 +91,31 @@ def has_sha256(files):
9091 return any (f .sha256_sum for f in files )
9192
9293
94+ @register .filter
95+ def wbr_wrap (value : str | None ) -> str :
96+ """
97+ Insert <wbr> tags for optional line breaking, prioritising halfway break.
98+
99+ Uses inline-block spans for halves so the browser prefers breaking
100+ at the midpoint first, then within each half if still too wide.
101+ """
102+ if not value :
103+ return value or ""
104+
105+ interval = 16
106+ chunks = [value [i : i + interval ] for i in range (0 , len (value ), interval )]
107+
108+ # Split into two halves, each half has internal <wbr> breaks
109+ midpoint = len (chunks ) // 2
110+ first_half = "<wbr>" .join (chunks [:midpoint ])
111+ second_half = "<wbr>" .join (chunks [midpoint :])
112+
113+ return mark_safe (
114+ f'<span class="checksum-half">{ first_half } </span><wbr>'
115+ f'<span class="checksum-half">{ second_half } </span>'
116+ )
117+
118+
93119@register .filter
94120def sort_windows (files ):
95121 if not files :
Original file line number Diff line number Diff line change @@ -1899,6 +1899,10 @@ table th, table td {
18991899 border-left : none; }
19001900table tfoot {
19011901 border-top : 1px solid # dddddd ; }
1902+ table .checksum {
1903+ font-size : 0.85em ; }
1904+ table .checksum .checksum-half {
1905+ display : inline-block; }
19021906
19031907.row-title {
19041908 border-top : 5px solid # d4dbe1 ;
Original file line number Diff line number Diff line change @@ -1012,6 +1012,12 @@ table {
10121012 }
10131013
10141014 tfoot { border-top : 1px solid $grey-lighterer ; }
1015+
1016+ .checksum {
1017+ font-size : 0.85em ;
1018+
1019+ .checksum-half { display : inline-block ; }
1020+ }
10151021}
10161022
10171023.documentation-help { }
Original file line number Diff line number Diff line change 88{% load has_sha256 from download_tags %}
99{% load sort_windows from download_tags %}
1010{% load get_eol_info from download_tags %}
11+ {% load wbr_wrap from download_tags %}
1112
1213{% block body_attributes %}class="python downloads"{% endblock %}
1314
@@ -126,9 +127,9 @@ <h3>{{ f.os.name }}</h3>
126127 < td > {% if f.gpg_signature_file %}< a href ="{{ f.gpg_signature_file }} "> SIG</ a > {% endif %}</ td >
127128 {% endif %}
128129 {% if release_files|has_sha256 %}
129- < td > {{ f.sha256_sum }}</ td >
130+ < td > < code class =" checksum " > {{ f.sha256_sum|wbr_wrap }}</ code > </ td >
130131 {% elif release_files|has_md5 %}
131- < td > {{ f.md5_sum }}</ td >
132+ < td > < code class =" checksum " > {{ f.md5_sum|wbr_wrap }}</ code > </ td >
132133 {% endif %}
133134 </ tr >
134135 {% endfor %}
You can’t perform that action at this time.
0 commit comments