feat: enhance compatibility table with file name handling and UI updates
This commit is contained in:
@@ -17,8 +17,10 @@
|
||||
<div class="panel-title">
|
||||
Gry / wersje
|
||||
<span class="panel-actions">
|
||||
<a id="dl-compat" class="mini-btn" href="/compat?format=md" download="compat.md"
|
||||
title="Pobierz tablicę kompatybilności (Markdown) — grupowaną po nazwie biblioteki">⬇ kompat</a>
|
||||
<a id="dl-compat-md" class="mini-btn" href="/compat?format=md" download="compat.md"
|
||||
title="Tablica kompatybilności — Markdown (grupowana po nazwie biblioteki)">⬇ md</a>
|
||||
<a id="dl-compat-json" class="mini-btn" href="/compat?format=json" download="compat.json"
|
||||
title="Tablica kompatybilności — JSON (grupy + warianty + diffy)">⬇ json</a>
|
||||
<button id="upload-toggle" class="mini-btn" title="Wgraj grę (ISO / ZIP / DLL)">+ wgraj</button>
|
||||
</span>
|
||||
</div>
|
||||
|
||||
@@ -17,6 +17,7 @@ from __future__ import annotations
|
||||
|
||||
import hashlib
|
||||
import json
|
||||
import re
|
||||
from collections import Counter
|
||||
from dataclasses import dataclass
|
||||
from datetime import datetime, timezone
|
||||
@@ -77,8 +78,19 @@ def _vs_reference(reference: Snapshot, variant: Snapshot) -> dict[str, Any]:
|
||||
|
||||
|
||||
# --- table builder -----------------------------------------------------------------------------
|
||||
# Stored binaries are prefixed with the first 8 hex of their sha256 to keep filenames unique on
|
||||
# disk (e.g. ``333ab0c4_PIKLIB8.dll``). That prefix is per-file, so it must be stripped before
|
||||
# grouping — otherwise every copy of PIKLIB8.dll lands in its own row and nothing ever clusters.
|
||||
_HASH_PREFIX = re.compile(r"^[0-9a-fA-F]{8}_")
|
||||
|
||||
|
||||
def library_name(raw: str) -> str:
|
||||
"""The display/grouping name: the stored binary name with any ``<sha8>_`` prefix removed."""
|
||||
return _HASH_PREFIX.sub("", raw)
|
||||
|
||||
|
||||
def _library_name(snap: Snapshot) -> str:
|
||||
return snap.binary.get("name") or "?"
|
||||
return library_name(snap.binary.get("name") or "?")
|
||||
|
||||
|
||||
def _variant_id(index: int) -> str:
|
||||
@@ -115,6 +127,7 @@ def _build_library(name: str, entries: list[Entry]) -> dict[str, Any]:
|
||||
members = [
|
||||
{
|
||||
"game": e.game,
|
||||
"file": e.snapshot.binary.get("name"), # stored name, incl. the <sha8>_ prefix
|
||||
"engine": e.snapshot.binary.get("engine"),
|
||||
"compiler": e.snapshot.binary.get("compiler"),
|
||||
"sha256": e.snapshot.binary.get("sha256"),
|
||||
|
||||
Reference in New Issue
Block a user