quintodrome.quineglobal.com/sites/quintodrome/assets.go
Philip Peterson 450d38c6da Extract shared site framework into internal/site and internal/component
Reduces sites/quintodrome and sites/hyper to their genuinely site-specific
parts: a Config (branding, GitHub repo, Linux download-format list),
classifyAsset, and landing-page content/mockup. Everything else — the HTTP
server, routes, release cache, update-check protocol, and page chrome —
now lives once in internal/site and internal/component.

The Linux format toggle's button list, order, and per-format arch
availability is now driven entirely by Config.LinuxFormats, reproducing
each site's current behavior as data (quintodrome shows Snap on both
arches; hyper hides it on arm64) rather than as forked logic. The one
deliberate behavior change: platformLabel's "linux-*" normalization
(previously only applied to linux-rpm on hyper's side) now applies to all
linux-* formats, fixing a cosmetic label bug on hyper's deb/pacman/flatpak
download rows ("linux-deb · x64.deb" -> "Linux · x64.deb").

Also unifies top-level tooling: a single SITE-parameterized Makefile and
Dockerfile, a single tailwind.config.js scanning internal/** and sites/**,
and a shared public/ with both product logos.

Verified: go build/vet/test pass for both sites, and `make dev
SITE=quintodrome` / `SITE=hyper` were run and curl-checked against /,
/download (including each site's Linux format toggle and arch-filtering),
and /api/update-check, matching pre-refactor behavior.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
2026-09-26 03:55:36 -08:00

56 lines
1.9 KiB
Go

package quintodrome
import "strings"
// classifyAsset maps an asset filename to an OS and architecture.
func classifyAsset(name string) (os, arch string, ok bool) {
l := strings.ToLower(name)
isArm64 := strings.Contains(l, "arm64") || strings.Contains(l, "aarch64")
isArmv7l := strings.Contains(l, "armv7l")
switch {
case strings.HasSuffix(l, ".exe"):
return "windows", "x64", true
case isArm64 && strings.HasSuffix(l, ".dmg"):
return "mac", "arm64", true
case strings.HasSuffix(l, ".dmg"):
return "mac", "x64", true
case isArm64 && strings.HasSuffix(l, ".appimage"):
return "linux", "arm64", true
case isArmv7l && strings.HasSuffix(l, ".appimage"):
return "", "", false
case strings.HasSuffix(l, ".appimage"):
return "linux", "x64", true
case isArm64 && strings.HasSuffix(l, ".rpm"):
return "linux-rpm", "arm64", true
case isArmv7l && strings.HasSuffix(l, ".rpm"):
return "", "", false
case strings.HasSuffix(l, ".rpm"):
return "linux-rpm", "x64", true
case isArm64 && strings.HasSuffix(l, ".deb"):
return "linux-deb", "arm64", true
case isArmv7l && strings.HasSuffix(l, ".deb"):
return "", "", false
case strings.HasSuffix(l, ".deb"):
return "linux-deb", "x64", true
case isArmv7l && strings.HasSuffix(l, ".snap"):
return "", "", false
case isArm64 && strings.HasSuffix(l, ".snap"):
return "linux-snap", "arm64", true
case strings.HasSuffix(l, ".snap"):
return "linux-snap", "x64", true
case isArm64 && strings.HasSuffix(l, ".pacman"):
return "linux-pacman", "arm64", true
case isArmv7l && strings.HasSuffix(l, ".pacman"):
return "", "", false
case strings.HasSuffix(l, ".pacman"):
return "linux-pacman", "x64", true
case isArm64 && strings.HasSuffix(l, ".flatpak"):
return "linux-flatpak", "arm64", true
case isArmv7l && strings.HasSuffix(l, ".flatpak"):
return "", "", false
case strings.HasSuffix(l, ".flatpak"):
return "linux-flatpak", "x64", true
default:
return "", "", false
}
}