From 28d310d8bc77cfb37deca5fd343cf857c34c3938 Mon Sep 17 00:00:00 2001 From: Abdessamad Derraz <3028866+Abdess@users.noreply.github.com> Date: Fri, 6 Nov 2026 04:02:14 +0100 Subject: [PATCH] fix: preselect RetroArch in a system's install box The box showed the first setup by name, AmberELEC on 17 system pages, under Windows tabs. It now selects RetroArch, which runs on every system the box has a tab for, else a setup the release publishes a ZIP for. --- scripts/generate_site.py | 22 +++++++++++++++++++--- tests/test_site_density_cards.py | 16 ++++++++++++++-- website/src/scripts/site.ts | 2 +- 3 files changed, 34 insertions(+), 6 deletions(-) diff --git a/scripts/generate_site.py b/scripts/generate_site.py index ccd8e4a05..7a1787e76 100644 --- a/scripts/generate_site.py +++ b/scripts/generate_site.py @@ -9114,6 +9114,21 @@ def _install_args(platform: str, system: str, shell: str) -> str: return f"--platform {platform} --system {quoted}" +def _default_setup(declared: list[tuple[str, str]]) -> tuple[str, str]: + """The setup an install box shows before the reader picks one. + + The first in alphabetical order was AmberELEC on 17 system pages, a + handheld system under a Windows tab. RetroArch runs on every OS the box + has a tab for. Without it, a setup the release publishes a ZIP for, + the ones most people download (`release_pack`). + """ + for wanted in (lambda p: p == "retroarch", has_release_pack): + chosen = next((pair for pair in declared if wanted(pair[0])), None) + if chosen: + return chosen + return declared[0] + + def _install_picker(declared: list[tuple[str, str]]) -> list[str]: """One command, for the setup the reader picks, under the OS tabs. @@ -9128,15 +9143,16 @@ def _install_picker(declared: list[tuple[str, str]]) -> list[str]: return html.escape(text, quote=False).replace('"', """) names = Counter(platform for platform, _system in declared) + lead = _default_setup(declared) options = "".join( - f'" for platform, system in declared) - lead = declared[0] args = {key: _install_args(*lead, TERMINALS[key][2]) for key in INSTALL_PICKER_OSES} return [ "Each platform names the system its own way.", diff --git a/tests/test_site_density_cards.py b/tests/test_site_density_cards.py index 9c031adec..6bea1ba41 100644 --- a/tests/test_site_density_cards.py +++ b/tests/test_site_density_cards.py @@ -193,11 +193,23 @@ class AnInstallBoxShowsOneCommand(unittest.TestCase): self.assertEqual(re.findall(r' None: + """AmberELEC led 17 system pages, a handheld system under the + Windows tab, for being first in alphabetical order.""" + self.assertEqual(gs._default_setup([("amberelec", "psx"), ("retroarch", "Sony - PlayStation")]), + ("retroarch", "Sony - PlayStation")) + self.assertEqual(gs._default_setup([("amberelec", "x"), ("batocera", "x")]), ("batocera", "x")) + self.assertEqual(gs._default_setup([("amberelec", "x"), ("knulli", "x")]), ("amberelec", "x")) + select = re.search(r"", self.text).group(1) + self.assertEqual(re.findall(r'