media-rip/backend/app/routers/system.py
xpltd 02c5e7bc1f Admin-controlled themes with visitor dark/light toggle
Admin Settings:
- Theme section: pick Dark Theme, Light Theme, and Default Mode
- 5 dark options (Cyberpunk/Dark/Midnight/Hacker/Neon)
- 4 light options (Light/Paper/Arctic/Solarized)
- Persisted in SQLite — survives container rebuilds
- Served via /api/config/public so frontend loads admin defaults

Visitor behavior:
- Page loads with admin's chosen default (dark or light theme)
- Sun/moon icon toggles between admin's dark and light pair
- Preference stored in cookie — persists within browser session
- No theme dropdown for visitors — admin controls the pair

Header icon simplified back to clean dark/light toggle
2026-03-22 15:58:49 -05:00

37 lines
1.4 KiB
Python

"""System endpoints — public (non-sensitive) configuration for the frontend."""
from __future__ import annotations
import logging
from fastapi import APIRouter, Request
logger = logging.getLogger("mediarip.system")
router = APIRouter(tags=["system"])
@router.get("/config/public")
async def public_config(request: Request) -> dict:
"""Return the safe subset of application config for the frontend.
Reads from the live AppConfig which includes persisted admin settings.
"""
config = request.app.state.config
return {
"session_mode": config.session.mode,
"default_theme": config.ui.default_theme,
"theme_dark": config.ui.theme_dark,
"theme_light": config.ui.theme_light,
"theme_default_mode": config.ui.theme_default_mode,
"welcome_message": config.ui.welcome_message,
"purge_enabled": config.purge.enabled,
"max_concurrent_downloads": config.downloads.max_concurrent,
"default_video_format": getattr(request.app.state, "_default_video_format", "auto"),
"default_audio_format": getattr(request.app.state, "_default_audio_format", "auto"),
"privacy_mode": config.purge.privacy_mode,
"privacy_retention_minutes": config.purge.privacy_retention_minutes,
"admin_enabled": config.admin.enabled,
"admin_setup_complete": bool(config.admin.password_hash),
}