From 31ee19561be6edce9a438bff215824a53f602bfe Mon Sep 17 00:00:00 2001 From: sky Date: Mon, 24 Aug 2026 10:37:11 +0800 Subject: [PATCH] fix(web): restore styling under CSP, and give KB articles a page (#12) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Two defects made the web UI unusable for its Knowledge Base. First, every page rendered with no styling. All CSS is one inline " + f"{esc(title)} · engram" + f"{_CSS}" '
' f'' f"
{body_html}
" diff --git a/cli/engram/web/server.py b/cli/engram/web/server.py index c3a071b..17e98d2 100644 --- a/cli/engram/web/server.py +++ b/cli/engram/web/server.py @@ -27,6 +27,7 @@ DEFAULT_HOST = "127.0.0.1" DEFAULT_PORT = 8787 _LOOPBACK = {"127.0.0.1", "::1", "localhost"} +_CSP_BASE = "default-src 'self'" @dataclass(frozen=True, slots=True) @@ -34,10 +35,24 @@ class Response: status: int body: str content_type: str = "text/html; charset=utf-8" + csp: str = _CSP_BASE def _page(title: str, body: str, active: str, status: int = 200) -> Response: - return Response(status=status, body=layout(title, body, active=active)) + """Render a page and pair it with a CSP that admits exactly its own style block. + + All styling is a single inline ``