UI: Improve multi OS display #205

Merged
Oleg-Komarov merged 40 commits from ui/multi-os into main 2024-07-16 07:24:07 +02:00
4 changed files with 16 additions and 47 deletions
Showing only changes of commit e4737770a1 - Show all commits

View File

@ -64,6 +64,18 @@ class Platform(CreatedModifiedMixin, models.Model):
def get_by_slug(cls, slug: str):
return cls.objects.filter(slug=slug).first()
def name_first_word(self):
"""Used for presentation in download_list."""
return self.name.split(None, 1)[0]
def name_rest(self):
"""Used for presentation in download_list."""
parts = self.name.split(None, 1)
if len(parts) > 1:
return parts[1]
else:
return ''
class ExtensionManager(models.Manager):
@property

View File

@ -7,19 +7,7 @@
<dd>
<ul class="list-style-none mb-0 ps-0">
{% for p in version.platforms.all|dictsort:"slug" %}
{% with slug=p.slug %}
{% if slug == "linux-x64" %}
<li><i class="i-linux"></i> Linux</li>
{% elif slug == "macos-arm64" %}
<li><i class="i-macos"></i> macOS <span class="text-muted">Apple Silicon</span></li>
{% elif slug == "macos-x64" %}
<li><i class="i-macos"></i> macOS <span class="text-muted">Intel</span></li>
{% elif slug == "windows-arm64" %}
<li><i class="i-windows"></i> Windows <span class="text-muted">ARM</span></li>
{% elif slug == "windows-x64" %}
<li><i class="i-windows"></i> Windows</li>
{% endif %}
{% endwith %}
<li><i class="i-{{ p.name_first_word|lower }}"></i> {{p.name_first_word}} <span class="text-muted">{{ p.name_rest }}</span></li>
{% endfor %}
</ul>
</dd>

View File

@ -288,17 +288,7 @@
<div class="text-center">
<strong>
{% with platform=download_item.platform %}
{% if platform.slug == "linux-x64" %}
Linux
{% elif platform.slug == "macos-arm64" %}
macOS <span class="fw-normal"> - Apple Silicon</span>
{% elif platform.slug == "macos-x64" %}
macOS <span class="fw-normal"> - Intel</span>
{% elif platform.slug == "windows-arm64" %}
Windows <span class="fw-normal"> - ARM</span>
{% elif platform.slug == "windows-x64" %}
Windows
{% endif %}
{{platform.name_first_word}} <span class="fw-normal"> - {{ platform.name_rest }}</span>
{% endwith %}
</strong> {{ download_item.size|filesizeformat }}
</div>
@ -321,17 +311,7 @@
<a class="d-flex dropdown-item justify-content-between" download="{{ download_item.name }}" href="{{ request.scheme }}://{{ request.get_host }}{{ download_item.url }}">
<span>
{% with platform=download_item.platform %}
{% if platform.slug == "linux-x64" %}
<i class="i-linux"></i> Linux
{% elif platform.slug == "macos-arm64" %}
<i class="i-macos"></i> macOS <span class="ms-2 text-muted">Apple Silicon</span>
{% elif platform.slug == "macos-x64" %}
<i class="i-macos"></i> macOS <span class="ms-2 text-muted">Intel</span>
{% elif platform.slug == "windows-arm64" %}
<i class="i-windows"></i> Windows <span class="ms-2 text-muted">ARM</span>
{% elif platform.slug == "windows-x64" %}
<i class="i-windows"></i> Windows
{% endif %}
<i class="i-{{ platform.name_first_word|lower }}"></i> {{ platform.name_first_word|lower }} <span class="ms-2 text-muted">{{ platform.name_rest}}</span>
{% endwith %}
</span>
<span class="text-muted">{{ download_item.size|filesizeformat }}</span>

View File

@ -118,19 +118,8 @@
<a href="{{ download_item.url }}" download="{{ download_item.name }}" class="btn btn-primary btn-block d-flex justify-content-between text-start">
<span>
{% with platform=download_item.platform %}
{% if platform.slug == "linux-x64" %}
<i class="i-linux me-1"></i> Linux
{% elif platform.slug == "macos-arm64" %}
<i class="i-macos me-1"></i> macOS Apple Silicon
{% elif platform.slug == "macos-x64" %}
<i class="i-macos me-1"></i> macOS Intel
{% elif platform.slug == "windows-arm64" %}
<i class="i-windows me-1"></i> Windows ARM
{% elif platform.slug == "windows-x64" %}
<i class="i-windows me-1"></i> Windows
{% endif %}
<i class="i-{{ platform.name_first_word|lower }} me-1"></i> {{ platform.name }}
{% endwith %}
v{{ version.version }}
</span>
<span>{{ download_item.size|filesizeformat }}</span>