From 2d3ae4e04fdc945146be0a4ee92505d735b4892b Mon Sep 17 00:00:00 2001 From: Claude Date: Sat, 13 Jun 2026 07:32:35 +0000 Subject: [PATCH] Phase 4: Page() collects component media; drop manual scripts= threading MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Page() now calls collect_media(content) and emits the ModuleScript / StaticScript tags itself, so views no longer thread scripts= for component-owned JS. The list views (game/session/purchase/device/ platform/playevent) compose with Fragment(filter_bar, content) instead of mark_safe(str(filter_bar) + str(content)) — keeping the node tree intact so the filter bar's media (filter_bar.js + search_select.js + range_slider.js, and date_range_picker.js on purchases) reaches Page(). The stats views drop _STATS_SCRIPTS; YearPicker's datepicker.umd.js is collected from its declared media. The scripts= argument remains for page-specific glue not owned by a component (the add-form helpers add_game.js / add_purchase.js / add_session.js, alongside search_select.js for their form widgets). Adds regression tests asserting the list and stats pages auto-load their widget scripts with no scripts= in the view, and documents the node/ media model in CLAUDE.md. https://claude.ai/code/session_01BKurBhE3Qj25p7Bfsg7EeK --- CLAUDE.md | 11 ++++++----- common/layout.py | 18 ++++++++++++++++-- games/views/device.py | 8 ++------ games/views/game.py | 6 ++---- games/views/general.py | 14 ++++---------- games/views/platform.py | 8 ++------ games/views/playevent.py | 7 ++----- games/views/purchase.py | 9 +++------ games/views/session.py | 6 ++---- tests/test_rendered_pages.py | 23 ++++++++++++++++++----- 10 files changed, 57 insertions(+), 53 deletions(-) diff --git a/CLAUDE.md b/CLAUDE.md index 5a19d87..443180e 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -58,12 +58,12 @@ docs/ — Additional documentation ### Key patterns -**Layout system** (`common/layout.py`): Views call `render_page(request, content, title=...)` instead of Django's `render()`. This assembles a full HTML document via `Page()` — analogous to FastHTML's `fast_app()`. `Page()` handles the ``, navbar, toast container, JS includes, and FOUC-prevention script. The navbar shows today's playtime and last-7-days playtime from the `model_counts` context processor. +**Layout system** (`common/layout.py`): Views call `render_page(request, content, title=...)` instead of Django's `render()`. This assembles a full HTML document via `Page()` — analogous to FastHTML's `fast_app()`. `Page()` handles the ``, navbar, toast container, FOUC-prevention script, and **JS includes**: it calls `collect_media(content)` to gather every component's declared `Media` and emits the `