generated from coulomb/repo-seed
Integrate whynot-design into Economic Observatory UI
Vendor whynot-design Layer 1 (tokens, CSS) and Layer 2 (<wn-*> components) via scripts/sync-whynot-design.sh with a pinned ref. Migrate the observatory shell to canonical web components, keep observatory-specific layout in styles.css, and add vendor integrity tests plus correct JS MIME types on the dev server.
This commit is contained in:
@@ -11,6 +11,13 @@ from .api import build_dashboard_payload
|
||||
ROOT = Path(__file__).resolve().parent.parent
|
||||
UI_DIR = ROOT / "ui"
|
||||
|
||||
UI_CONTENT_TYPES = {
|
||||
".css": "text/css",
|
||||
".js": "application/javascript",
|
||||
".json": "application/json",
|
||||
".html": "text/html; charset=utf-8",
|
||||
}
|
||||
|
||||
|
||||
class ObservatoryHandler(BaseHTTPRequestHandler):
|
||||
data_dir: Path = ROOT / "data"
|
||||
@@ -38,8 +45,10 @@ class ObservatoryHandler(BaseHTTPRequestHandler):
|
||||
relative = parsed.path.removeprefix("/ui/")
|
||||
target = UI_DIR / relative
|
||||
if target.exists() and target.is_file():
|
||||
content_type = "text/css" if target.suffix == ".css" else "application/javascript"
|
||||
return self._serve_file(target, f"{content_type}; charset=utf-8")
|
||||
content_type = UI_CONTENT_TYPES.get(target.suffix, "application/octet-stream")
|
||||
if "charset" not in content_type:
|
||||
content_type = f"{content_type}; charset=utf-8"
|
||||
return self._serve_file(target, content_type)
|
||||
|
||||
self._send(404, b"Not found", "text/plain")
|
||||
|
||||
|
||||
Reference in New Issue
Block a user