diff --git a/editor.py b/editor.py index 5f70167..eaba2d8 100644 --- a/editor.py +++ b/editor.py @@ -46,13 +46,13 @@ DEFAULT_SETTINGS = { } BASE_THEME = { - "background": "#111111", "surface": "#181818", "text": "#eeeeee", + "background": "#111111", "surface": "#181818", "surface_dark": "#0b0b0b", "text": "#eeeeee", "text_secondary": "#cccccc", "primary": "#1769aa", "accent": "#ffcc33", "success": "#2e7d32", "warning": "#ed6c02", "danger": "#d32f2f", } BASE_COLOR_LABELS = { - "background": "Hintergrund", "surface": "Flächen", "text": "Text", + "background": "Hintergrund", "surface_dark": "Dunkle Fläche", "surface": "Flächen", "text": "Text", "text_secondary": "Sekundärtext", "primary": "Primärfarbe", "accent": "Akzentfarbe", "success": "Erfolg", "warning": "Warnung", "danger": "Fehler / Gefahr", } @@ -72,81 +72,28 @@ def _mix(a, b, amount): def _lighten(value, amount): return _mix(value, "#ffffff", amount) def _darken(value, amount): return _mix(value, "#000000", amount) -def _luminance(value): - rgb = _hex_rgb(value) - if rgb is None: - return 0.0 - channels = [c / 255.0 for c in rgb] - linear = [c / 12.92 if c <= 0.04045 else ((c + 0.055) / 1.055) ** 2.4 for c in channels] - return 0.2126 * linear[0] + 0.7152 * linear[1] + 0.0722 * linear[2] - -def _contrast_ratio(a, b): - return (max(_luminance(a), _luminance(b)) + 0.05) / (min(_luminance(a), _luminance(b)) + 0.05) - -def _contrast_text(background): - return "#ffffff" if _contrast_ratio("#ffffff", background) >= _contrast_ratio("#000000", background) else "#000000" - -def _ensure_contrast(foreground, background, minimum=4.5): - if _contrast_ratio(foreground, background) >= minimum: - return foreground - target = "#ffffff" if _contrast_ratio("#ffffff", background) > _contrast_ratio("#000000", background) else "#000000" - lo, hi = 0.0, 1.0 - for _ in range(12): - mid = (lo + hi) / 2 - candidate = _mix(foreground, target, mid) - if _contrast_ratio(candidate, background) >= minimum: - hi = mid - else: - lo = mid - return _mix(foreground, target, hi) - -def _surface_step(value, background, amount): - return _lighten(value, amount) if _luminance(background) < 0.5 else _darken(value, amount) - def derive_theme(base): c = dict(BASE_THEME) if isinstance(base, dict): for key in BASE_THEME: value = base.get(key) - if isinstance(value, str) and re.fullmatch(r"#[0-9a-fA-F]{6}", value.strip()): - c[key] = value.strip() - - bg = c["background"] - surface = c["surface"] - # User-selected text colors are kept as close as possible to the chosen - # color, but are automatically corrected when they would become unreadable. - text = _ensure_contrast(c["text"], bg, 4.5) - secondary = _ensure_contrast(c["text_secondary"], bg, 4.5) - surface_alt = _surface_step(surface, bg, 0.14) - control = _surface_step(surface, bg, 0.10) - control_hover = _surface_step(surface, bg, 0.20) - primary = c["primary"] - accent = c["accent"] - primary_hover = _surface_step(primary, bg, 0.14) - success = c["success"] - warning = c["warning"] - danger = c["danger"] - + if isinstance(value, str) and re.fullmatch(r"#[0-9a-fA-F]{6}", value.strip()): c[key] = value.strip() + bg, surface, surface_dark = c["background"], c["surface"], c["surface_dark"] + text, secondary = c["text"], c["text_secondary"] + primary, accent = c["primary"], c["accent"] + success, warning, danger = c["success"], c["warning"], c["danger"] return { - "background": bg, "surface": surface, "surface_alt": surface_alt, "surface_dark": _darken(bg,.22), - "text": text, "text_secondary": secondary, - "text_muted": _ensure_contrast(_mix(secondary,bg,.35), bg, 3.0), - "text_faint": _ensure_contrast(_mix(secondary,bg,.58), bg, 2.2), - "border": _surface_step(surface,bg,.28), "border_subtle": _surface_step(surface,bg,.16), - "control": control, "control_hover": control_hover, - "primary": primary, "primary_hover": primary_hover, "primary_text": _contrast_text(primary), - "accent": accent, - "success": success, "success_text": _contrast_text(success), - "warning": warning, "warning_text": _contrast_text(warning), - "danger": danger, "danger_soft": _mix(danger,bg,.82), "danger_soft_hover": _mix(danger,bg,.70), - "error": _mix(danger,bg,.72), "error_text": _contrast_text(_mix(danger,bg,.72)), - "recording": danger, "recording_border": _mix(danger,bg,.55), "recording_text": _contrast_text(danger), - "selection": _mix(primary,bg,.84), "shadow": "#000000", - "scroll_thumb": _mix(secondary,bg,.35), "scroll_thumb_hover": _mix(secondary,bg,.18), - "scroll_thumb_active": secondary, "live_surface": _mix(danger,bg,.84), - "table_header": _surface_step(surface,bg,.08), "table_text": _ensure_contrast(text,surface,4.5), - "footer": _ensure_contrast(_mix(secondary,bg,.50), bg, 2.2), "white": "#ffffff", - "surface_modal": _surface_step(surface,bg,.05), "overlay": "rgba(0,0,0,.78)", + "background": bg, "surface": surface, "surface_alt": _lighten(surface,.12), "surface_dark": surface_dark, + "text": text, "text_secondary": secondary, "text_muted": _mix(secondary,bg,.35), "text_faint": _mix(secondary,bg,.58), + "border": _lighten(surface,.28), "border_subtle": _lighten(surface,.16), "control": _lighten(surface,.12), "control_hover": _lighten(surface,.24), + "primary": primary, "primary_hover": _lighten(primary,.16), "accent": accent, + "success": _darken(success,.42), "success_text": _lighten(success,.68), "warning": _darken(warning,.48), + "danger": danger, "danger_soft": _darken(danger,.58), "danger_soft_hover": _darken(danger,.42), + "error": _darken(danger,.62), "error_text": _lighten(danger,.70), "recording": _darken(danger,.08), "recording_border": _darken(danger,.52), + "selection": "rgba(80,150,255,.16)", "shadow": "#000000", "scroll_thumb": _mix(secondary,bg,.35), + "scroll_thumb_hover": _mix(secondary,bg,.18), "scroll_thumb_active": secondary, "live_surface": _mix(danger,bg,.84), + "table_header": _lighten(surface,.08), "table_text": text, "footer": _mix(secondary,bg,.50), "white": "#ffffff", + "surface_modal": _lighten(surface,.05), "overlay": "rgba(0,0,0,.78)", } DEFAULT_THEME = derive_theme(BASE_THEME) @@ -2033,7 +1980,7 @@ a { color:var(--color-text-secondary); } .color-field input[type=color] { width:48px; height:40px; padding:3px; background:var(--color-control); border:1px solid var(--color-control-hover); border-radius:5px; cursor:pointer; } .theme-intro { margin:-4px 0 16px; color:var(--color-text-muted); font-size:14px; line-height:1.45; } .actions { display:flex; gap:10px; flex-wrap:wrap; margin-top:20px; } -button { border:0; border-radius:5px; padding:10px 16px; background:var(--color-primary); color:var(--color-primary-text); font-size:15px; cursor:pointer; } +button { border:0; border-radius:5px; padding:10px 16px; background:var(--color-primary); color:var(--color-white); font-size:15px; cursor:pointer; } button:hover { background:var(--color-primary-hover); } .note { color:var(--color-text-muted); font-size:13px; margin-top:8px; } .message { padding:10px 12px; border-radius:6px; margin-bottom:16px; background:var(--color-success); color:var(--color-success-text); } diff --git a/recorder.py b/recorder.py index ba5ba63..5973a05 100644 --- a/recorder.py +++ b/recorder.py @@ -6,6 +6,7 @@ import json import re import time from datetime import datetime +from urllib.parse import quote from pathlib import Path from zoneinfo import ZoneInfo @@ -76,13 +77,13 @@ DEFAULT_SETTINGS = { } BASE_THEME = { - "background": "#111111", "surface": "#181818", "text": "#eeeeee", + "background": "#111111", "surface": "#181818", "surface_dark": "#0b0b0b", "text": "#eeeeee", "text_secondary": "#cccccc", "primary": "#1769aa", "accent": "#ffcc33", "success": "#2e7d32", "warning": "#ed6c02", "danger": "#d32f2f", } BASE_COLOR_LABELS = { - "background": "Hintergrund", "surface": "Flächen", "text": "Text", + "background": "Hintergrund", "surface_dark": "Dunkle Fläche", "surface": "Flächen", "text": "Text", "text_secondary": "Sekundärtext", "primary": "Primärfarbe", "accent": "Akzentfarbe", "success": "Erfolg", "warning": "Warnung", "danger": "Fehler / Gefahr", } @@ -102,81 +103,28 @@ def _mix(a, b, amount): def _lighten(value, amount): return _mix(value, "#ffffff", amount) def _darken(value, amount): return _mix(value, "#000000", amount) -def _luminance(value): - rgb = _hex_rgb(value) - if rgb is None: - return 0.0 - channels = [c / 255.0 for c in rgb] - linear = [c / 12.92 if c <= 0.04045 else ((c + 0.055) / 1.055) ** 2.4 for c in channels] - return 0.2126 * linear[0] + 0.7152 * linear[1] + 0.0722 * linear[2] - -def _contrast_ratio(a, b): - return (max(_luminance(a), _luminance(b)) + 0.05) / (min(_luminance(a), _luminance(b)) + 0.05) - -def _contrast_text(background): - return "#ffffff" if _contrast_ratio("#ffffff", background) >= _contrast_ratio("#000000", background) else "#000000" - -def _ensure_contrast(foreground, background, minimum=4.5): - if _contrast_ratio(foreground, background) >= minimum: - return foreground - target = "#ffffff" if _contrast_ratio("#ffffff", background) > _contrast_ratio("#000000", background) else "#000000" - lo, hi = 0.0, 1.0 - for _ in range(12): - mid = (lo + hi) / 2 - candidate = _mix(foreground, target, mid) - if _contrast_ratio(candidate, background) >= minimum: - hi = mid - else: - lo = mid - return _mix(foreground, target, hi) - -def _surface_step(value, background, amount): - return _lighten(value, amount) if _luminance(background) < 0.5 else _darken(value, amount) - def derive_theme(base): c = dict(BASE_THEME) if isinstance(base, dict): for key in BASE_THEME: value = base.get(key) - if isinstance(value, str) and re.fullmatch(r"#[0-9a-fA-F]{6}", value.strip()): - c[key] = value.strip() - - bg = c["background"] - surface = c["surface"] - # User-selected text colors are kept as close as possible to the chosen - # color, but are automatically corrected when they would become unreadable. - text = _ensure_contrast(c["text"], bg, 4.5) - secondary = _ensure_contrast(c["text_secondary"], bg, 4.5) - surface_alt = _surface_step(surface, bg, 0.14) - control = _surface_step(surface, bg, 0.10) - control_hover = _surface_step(surface, bg, 0.20) - primary = c["primary"] - accent = c["accent"] - primary_hover = _surface_step(primary, bg, 0.14) - success = c["success"] - warning = c["warning"] - danger = c["danger"] - + if isinstance(value, str) and re.fullmatch(r"#[0-9a-fA-F]{6}", value.strip()): c[key] = value.strip() + bg, surface, surface_dark = c["background"], c["surface"], c["surface_dark"] + text, secondary = c["text"], c["text_secondary"] + primary, accent = c["primary"], c["accent"] + success, warning, danger = c["success"], c["warning"], c["danger"] return { - "background": bg, "surface": surface, "surface_alt": surface_alt, "surface_dark": _darken(bg,.22), - "text": text, "text_secondary": secondary, - "text_muted": _ensure_contrast(_mix(secondary,bg,.35), bg, 3.0), - "text_faint": _ensure_contrast(_mix(secondary,bg,.58), bg, 2.2), - "border": _surface_step(surface,bg,.28), "border_subtle": _surface_step(surface,bg,.16), - "control": control, "control_hover": control_hover, - "primary": primary, "primary_hover": primary_hover, "primary_text": _contrast_text(primary), - "accent": accent, - "success": success, "success_text": _contrast_text(success), - "warning": warning, "warning_text": _contrast_text(warning), - "danger": danger, "danger_soft": _mix(danger,bg,.82), "danger_soft_hover": _mix(danger,bg,.70), - "error": _mix(danger,bg,.72), "error_text": _contrast_text(_mix(danger,bg,.72)), - "recording": danger, "recording_border": _mix(danger,bg,.55), "recording_text": _contrast_text(danger), - "selection": _mix(primary,bg,.84), "shadow": "#000000", - "scroll_thumb": _mix(secondary,bg,.35), "scroll_thumb_hover": _mix(secondary,bg,.18), - "scroll_thumb_active": secondary, "live_surface": _mix(danger,bg,.84), - "table_header": _surface_step(surface,bg,.08), "table_text": _ensure_contrast(text,surface,4.5), - "footer": _ensure_contrast(_mix(secondary,bg,.50), bg, 2.2), "white": "#ffffff", - "surface_modal": _surface_step(surface,bg,.05), "overlay": "rgba(0,0,0,.78)", + "background": bg, "surface": surface, "surface_alt": _lighten(surface,.12), "surface_dark": surface_dark, + "text": text, "text_secondary": secondary, "text_muted": _mix(secondary,bg,.35), "text_faint": _mix(secondary,bg,.58), + "border": _lighten(surface,.28), "border_subtle": _lighten(surface,.16), "control": _lighten(surface,.12), "control_hover": _lighten(surface,.24), + "primary": primary, "primary_hover": _lighten(primary,.16), "accent": accent, + "success": _darken(success,.42), "success_text": _lighten(success,.68), "warning": _darken(warning,.48), + "danger": danger, "danger_soft": _darken(danger,.58), "danger_soft_hover": _darken(danger,.42), + "error": _darken(danger,.62), "error_text": _lighten(danger,.70), "recording": _darken(danger,.08), "recording_border": _darken(danger,.52), + "selection": "rgba(80,150,255,.16)", "shadow": "#000000", "scroll_thumb": _mix(secondary,bg,.35), + "scroll_thumb_hover": _mix(secondary,bg,.18), "scroll_thumb_active": secondary, "live_surface": _mix(danger,bg,.84), + "table_header": _lighten(surface,.08), "table_text": text, "footer": _mix(secondary,bg,.50), "white": "#ffffff", + "surface_modal": _lighten(surface,.05), "overlay": "rgba(0,0,0,.78)", } DEFAULT_THEME = derive_theme(BASE_THEME) @@ -770,9 +718,7 @@ HTML = """ .site-header { display:flex; align-items:center; gap:18px; margin-bottom:24px; } .site-logo { max-width:140px; max-height:48px; object-fit:contain; display:block; flex:0 0 auto; } -.site-header h1 { margin:0; flex:1; } -.header-link { color:var(--color-primary); text-decoration:none; font-weight:700; padding:8px 12px; border:1px solid var(--color-border); border-radius:6px; } -.header-link:hover { background:var(--color-control-hover); color:var(--color-text); } +.site-header h1 { margin:0; } body { margin: 0; @@ -802,7 +748,7 @@ h1 { .status.recording { background: var(--color-danger); - color:var(--color-recording-text); + color:var(--color-white); } .status.idle { @@ -812,7 +758,7 @@ h1 { .status.error { background: var(--color-warning); - color:var(--color-warning-text); + color:var(--color-white); } .recording { @@ -1021,7 +967,6 @@ a.button:hover {
{{ site_subtitle }}
@@ -1143,7 +1088,10 @@ a.button:hover { - + + {% if item.edit_url %} + ✂ Bearbeiten + {% endif %} @@ -1363,6 +1311,7 @@ def render_index(): global normalizing_filename files = [] + editor_base_url = load_settings().get("editor_url", "") FINISHED_DIR.mkdir(parents=True, exist_ok=True) @@ -1385,6 +1334,10 @@ def render_index(): for item in files: item["sort_ts"] = item["sort_date"] + item["edit_url"] = ( + f"{editor_base_url.rstrip('/')}/edit/{quote(item['filename'])}" + if editor_base_url else "" + ) files.sort(key=lambda item: item["sort_date"], reverse=True) artists = sorted({item["artist"] for item in files if item["artist"]})