chore: add one-time admin UI normalization script
This commit is contained in:
1 parent
117b026c70
commit
787460ce35
1 file changed
+255
@@ -0,0 +1,255 @@
|
|||||||
|
from pathlib import Path
|
||||||
|
|
||||||
|
BASE = Path("web/assets/admin-v36.css")
|
||||||
|
TARGET = Path("web/assets/admin-v37.css")
|
||||||
|
MARKER = "/* v1.5.65: einheitliches Admin-Buttonsystem */"
|
||||||
|
|
||||||
|
OVERRIDE = r'''
|
||||||
|
|
||||||
|
/* v1.5.65: einheitliches Admin-Buttonsystem */
|
||||||
|
.admin-dashboard-page .admin-primary-button,
|
||||||
|
.admin-dashboard-page .admin-secondary-button,
|
||||||
|
.admin-dashboard-page .admin-danger-button{
|
||||||
|
display:inline-flex!important;
|
||||||
|
align-items:center!important;
|
||||||
|
justify-content:center!important;
|
||||||
|
gap:8px!important;
|
||||||
|
min-height:42px!important;
|
||||||
|
height:auto!important;
|
||||||
|
margin:0!important;
|
||||||
|
padding:10px 16px!important;
|
||||||
|
border-radius:10px!important;
|
||||||
|
font:inherit!important;
|
||||||
|
font-size:.84rem!important;
|
||||||
|
line-height:1.2!important;
|
||||||
|
font-weight:800!important;
|
||||||
|
text-decoration:none!important;
|
||||||
|
cursor:pointer!important;
|
||||||
|
box-shadow:none!important;
|
||||||
|
transition:background .16s ease,border-color .16s ease,color .16s ease,box-shadow .16s ease,transform .16s ease!important;
|
||||||
|
}
|
||||||
|
.admin-dashboard-page .admin-primary-button{
|
||||||
|
border:1px solid #128d3d!important;
|
||||||
|
background:linear-gradient(135deg,var(--lw-green),var(--lw-green-dark))!important;
|
||||||
|
color:#fff!important;
|
||||||
|
}
|
||||||
|
.admin-dashboard-page .admin-primary-button:hover:not(:disabled){
|
||||||
|
background:linear-gradient(135deg,#149d46,#076f2f)!important;
|
||||||
|
border-color:#087b34!important;
|
||||||
|
transform:translateY(-1px)!important;
|
||||||
|
box-shadow:0 7px 18px rgba(14,126,53,.18)!important;
|
||||||
|
}
|
||||||
|
.admin-dashboard-page .admin-secondary-button{
|
||||||
|
border:1px solid #cfd9d1!important;
|
||||||
|
background:#fff!important;
|
||||||
|
color:#26352a!important;
|
||||||
|
}
|
||||||
|
.admin-dashboard-page .admin-secondary-button:hover:not(:disabled){
|
||||||
|
border-color:#9fb4a4!important;
|
||||||
|
background:#f3f7f4!important;
|
||||||
|
color:#153b22!important;
|
||||||
|
}
|
||||||
|
.admin-dashboard-page .admin-danger-button{
|
||||||
|
border:1px solid #e8c3c0!important;
|
||||||
|
background:#fff5f4!important;
|
||||||
|
color:#a3312d!important;
|
||||||
|
}
|
||||||
|
.admin-dashboard-page .admin-danger-button:hover:not(:disabled){
|
||||||
|
border-color:#d99590!important;
|
||||||
|
background:#fce7e5!important;
|
||||||
|
color:#84231f!important;
|
||||||
|
}
|
||||||
|
.admin-dashboard-page .admin-primary-button:disabled,
|
||||||
|
.admin-dashboard-page .admin-secondary-button:disabled,
|
||||||
|
.admin-dashboard-page .admin-danger-button:disabled{
|
||||||
|
cursor:not-allowed!important;
|
||||||
|
opacity:.5!important;
|
||||||
|
transform:none!important;
|
||||||
|
box-shadow:none!important;
|
||||||
|
}
|
||||||
|
.admin-dashboard-page button:focus-visible,
|
||||||
|
.admin-dashboard-page a[class*="button"]:focus-visible,
|
||||||
|
.admin-login-page button:focus-visible{
|
||||||
|
outline:3px solid rgba(24,168,75,.24)!important;
|
||||||
|
outline-offset:2px!important;
|
||||||
|
}
|
||||||
|
.admin-login-page .admin-primary-button{
|
||||||
|
display:flex!important;
|
||||||
|
width:100%!important;
|
||||||
|
align-items:center!important;
|
||||||
|
justify-content:space-between!important;
|
||||||
|
height:57px!important;
|
||||||
|
min-height:57px!important;
|
||||||
|
margin-top:5px!important;
|
||||||
|
padding:0 22px!important;
|
||||||
|
border:0!important;
|
||||||
|
border-radius:14px!important;
|
||||||
|
background:linear-gradient(135deg,var(--lw-green),#0d8d3d)!important;
|
||||||
|
color:#fff!important;
|
||||||
|
font-weight:850!important;
|
||||||
|
box-shadow:0 12px 25px rgba(17,150,62,.25)!important;
|
||||||
|
}
|
||||||
|
.admin-login-page .admin-primary-button:hover:not(:disabled){
|
||||||
|
transform:translateY(-2px)!important;
|
||||||
|
box-shadow:0 16px 30px rgba(17,150,62,.31)!important;
|
||||||
|
}
|
||||||
|
.admin-dashboard-page .admin-event-heading-actions button,
|
||||||
|
.admin-dashboard-page .event-admin-summary button,
|
||||||
|
.admin-dashboard-page .admin-event-form-actions button,
|
||||||
|
.admin-dashboard-page .admin-event-category-row button,
|
||||||
|
.admin-dashboard-page .admin-event-category-create button{
|
||||||
|
min-height:42px;
|
||||||
|
border:1px solid #128d3d;
|
||||||
|
border-radius:10px;
|
||||||
|
padding:10px 16px;
|
||||||
|
background:linear-gradient(135deg,var(--lw-green),var(--lw-green-dark));
|
||||||
|
color:#fff;
|
||||||
|
font:inherit;
|
||||||
|
font-size:.84rem;
|
||||||
|
line-height:1.2;
|
||||||
|
font-weight:800;
|
||||||
|
cursor:pointer;
|
||||||
|
box-shadow:none;
|
||||||
|
}
|
||||||
|
.admin-dashboard-page .admin-event-heading-actions .is-secondary,
|
||||||
|
.admin-dashboard-page .admin-event-form-actions .is-secondary{
|
||||||
|
border-color:#cfd9d1;
|
||||||
|
background:#fff;
|
||||||
|
color:#26352a;
|
||||||
|
}
|
||||||
|
'''
|
||||||
|
|
||||||
|
base = BASE.read_text(encoding="utf-8").rstrip()
|
||||||
|
if MARKER in base:
|
||||||
|
raise SystemExit("v1.5.65 marker unexpectedly present in admin-v36.css")
|
||||||
|
TARGET.write_text(base + OVERRIDE + "\n", encoding="utf-8")
|
||||||
|
|
||||||
|
admin_templates = sorted(Path("web/admin").glob("*.html"))
|
||||||
|
if not admin_templates:
|
||||||
|
raise SystemExit("no admin templates found")
|
||||||
|
missing = []
|
||||||
|
for path in admin_templates:
|
||||||
|
text = path.read_text(encoding="utf-8")
|
||||||
|
if "/assets/admin-v36.css" not in text:
|
||||||
|
missing.append(str(path))
|
||||||
|
continue
|
||||||
|
path.write_text(text.replace("/assets/admin-v36.css", "/assets/admin-v37.css"), encoding="utf-8")
|
||||||
|
if missing:
|
||||||
|
raise SystemExit("admin templates without admin-v36.css: " + ", ".join(missing))
|
||||||
|
|
||||||
|
for path in Path(".").glob("*.go"):
|
||||||
|
text = path.read_text(encoding="utf-8")
|
||||||
|
if "admin-v36.css" in text:
|
||||||
|
path.write_text(text.replace("admin-v36.css", "admin-v37.css"), encoding="utf-8")
|
||||||
|
|
||||||
|
main = Path("main.go")
|
||||||
|
text = main.read_text(encoding="utf-8")
|
||||||
|
if 'applicationVersion = "1.5.64"' not in text:
|
||||||
|
raise SystemExit("unexpected application version before v1.5.65")
|
||||||
|
main.write_text(text.replace('applicationVersion = "1.5.64"', 'applicationVersion = "1.5.65"', 1), encoding="utf-8")
|
||||||
|
|
||||||
|
main_test = Path("main_test.go")
|
||||||
|
text = main_test.read_text(encoding="utf-8")
|
||||||
|
if 'applicationVersion != "1.5.64"' not in text:
|
||||||
|
raise SystemExit("main_test.go does not expect v1.5.64")
|
||||||
|
main_test.write_text(text.replace('applicationVersion != "1.5.64"', 'applicationVersion != "1.5.65"', 1), encoding="utf-8")
|
||||||
|
|
||||||
|
TEST = r'''package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"os"
|
||||||
|
"path/filepath"
|
||||||
|
"regexp"
|
||||||
|
"strings"
|
||||||
|
"testing"
|
||||||
|
)
|
||||||
|
|
||||||
|
func TestAdminTemplatesUseCurrentBaseCSSAndExistingAssets(t *testing.T) {
|
||||||
|
assetPattern := regexp.MustCompile(`(?:href|src)="(/assets/[^"?#]+\.(?:css|js))`)
|
||||||
|
entries, err := os.ReadDir("web/admin")
|
||||||
|
if err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
for _, entry := range entries {
|
||||||
|
if entry.IsDir() || !strings.HasSuffix(entry.Name(), ".html") {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
path := filepath.Join("web/admin", entry.Name())
|
||||||
|
raw, err := os.ReadFile(path)
|
||||||
|
if err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
html := string(raw)
|
||||||
|
if !strings.Contains(html, `/assets/admin-v37.css`) {
|
||||||
|
t.Fatalf("%s lädt nicht das aktuelle Admin-Basis-CSS", path)
|
||||||
|
}
|
||||||
|
if strings.Contains(html, `/assets/admin-v35.css`) || strings.Contains(html, `/assets/admin-v36.css`) {
|
||||||
|
t.Fatalf("%s referenziert ein veraltetes Admin-Basis-CSS", path)
|
||||||
|
}
|
||||||
|
for _, match := range assetPattern.FindAllStringSubmatch(html, -1) {
|
||||||
|
asset := filepath.Join("web", strings.TrimPrefix(match[1], "/"))
|
||||||
|
if _, err := os.Stat(asset); err != nil {
|
||||||
|
t.Fatalf("%s referenziert fehlendes Asset %s: %v", path, match[1], err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestAdminButtonSystemHasFinalNormalizedRules(t *testing.T) {
|
||||||
|
raw, err := os.ReadFile("web/assets/admin-v37.css")
|
||||||
|
if err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
css := string(raw)
|
||||||
|
for _, expected := range []string{
|
||||||
|
"v1.5.65: einheitliches Admin-Buttonsystem",
|
||||||
|
".admin-dashboard-page .admin-primary-button",
|
||||||
|
".admin-dashboard-page .admin-secondary-button",
|
||||||
|
".admin-dashboard-page .admin-danger-button",
|
||||||
|
".admin-login-page .admin-primary-button",
|
||||||
|
".admin-dashboard-page button:focus-visible",
|
||||||
|
} {
|
||||||
|
if !strings.Contains(css, expected) {
|
||||||
|
t.Fatalf("admin-v37.css fehlt %q", expected)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
marker := strings.LastIndex(css, "v1.5.65: einheitliches Admin-Buttonsystem")
|
||||||
|
legacy := strings.Index(css, ".admin-secondary-button{")
|
||||||
|
if marker < 0 || legacy < 0 || marker <= legacy {
|
||||||
|
t.Fatal("normalisierte Button-Regeln stehen nicht nach den Legacy-Regeln")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
'''
|
||||||
|
Path("admin_ui_regression_test.go").write_text(TEST, encoding="utf-8")
|
||||||
|
|
||||||
|
changelog = Path("CHANGELOG.md")
|
||||||
|
text = changelog.read_text(encoding="utf-8")
|
||||||
|
section = """## v1.5.65 – Einheitliches Admin-Design
|
||||||
|
|
||||||
|
- Admin-Basis-CSS auf `admin-v37.css` angehoben und alle Admin-Templates sowie dynamisch erzeugten Adminseiten darauf umgestellt.
|
||||||
|
- Widersprüchliche Legacy-Regeln für Primär-, Sekundär- und Löschbuttons durch ein abschließendes, einheitliches Button-System neutralisiert.
|
||||||
|
- Hover-, Fokus- und Disabled-Zustände vereinheitlicht; Login-Button und Veranstaltungsaktionen an dieselbe Designsprache angepasst.
|
||||||
|
- Regressionstest prüft künftig für jede Admin-Template-Datei das aktuelle Basis-CSS und die Existenz aller referenzierten CSS-/JS-Assets.
|
||||||
|
- Keine neue Datenbankmigration.
|
||||||
|
|
||||||
|
"""
|
||||||
|
if not text.startswith("## v1.5.65"):
|
||||||
|
changelog.write_text(section + text, encoding="utf-8")
|
||||||
|
|
||||||
|
readme = Path("README.md")
|
||||||
|
text = readme.read_text(encoding="utf-8")
|
||||||
|
text = text.replace("**Aktueller Stand: Landwelle v1.5.64 – 24. September 2026**", "**Aktueller Stand: Landwelle v1.5.65 – 24. September 2026**", 1)
|
||||||
|
needle = "Version 1.5.64 korrigiert den Abschlussstatus der KI-Audio-Module:"
|
||||||
|
if "Version 1.5.65 vereinheitlicht das Admin-Design" not in text and needle in text:
|
||||||
|
paragraph = "Version 1.5.65 vereinheitlicht das Admin-Design: Alle Adminseiten verwenden `admin-v37.css`; widersprüchliche ältere Button-Regeln werden durch ein gemeinsames Primär-/Sekundär-/Gefahr-Design mit konsistenten Hover-, Fokus- und Disabled-Zuständen ersetzt. Ein Regressionstest prüft zusätzlich alle Admin-CSS-/JS-Referenzen.\n\n"
|
||||||
|
text = text.replace(needle, paragraph + needle, 1)
|
||||||
|
text = text.replace("Erwartete Version: `Landwelle v1.5.64`.", "Erwartete Version: `Landwelle v1.5.65`.", 1)
|
||||||
|
readme.write_text(text, encoding="utf-8")
|
||||||
|
|
||||||
|
handover = Path("CHATUEBERGABE.md")
|
||||||
|
if handover.exists():
|
||||||
|
text = handover.read_text(encoding="utf-8")
|
||||||
|
text = text.replace("v1.5.64", "v1.5.65", 1)
|
||||||
|
if "## v1.5.65" not in text:
|
||||||
|
text += "\n\n## v1.5.65 – Admin-UI\n- Alle Adminseiten verwenden `admin-v37.css`.\n- Primär-, Sekundär- und Löschbuttons besitzen wieder ein einheitliches Design.\n- Admin-Asset-Referenzen werden durch Regressionstests geprüft.\n"
|
||||||
|
handover.write_text(text, encoding="utf-8")
|
||||||
Reference in new issue
Block a user