From daea61a48199725470de2f5462fb1a02d3fdfaed Mon Sep 17 00:00:00 2001 From: giles Date: Tue, 24 Feb 2026 13:58:10 +0000 Subject: [PATCH] Replace widget registry with fragment fetches (Phase 5) Account nav and page panels now fetched from events/cart fragments instead of using shared widget registry. Co-Authored-By: Claude Opus 4.6 --- bp/account/routes.py | 34 ++++++++++++++++++++-------------- shared | 2 +- 2 files changed, 21 insertions(+), 15 deletions(-) diff --git a/bp/account/routes.py b/bp/account/routes.py index ed94c7a..23b3cae 100644 --- a/bp/account/routes.py +++ b/bp/account/routes.py @@ -1,6 +1,6 @@ """Account pages blueprint. -Moved from federation/bp/auth — newsletters, widget pages (tickets, bookings). +Moved from federation/bp/auth — newsletters, fragment pages (tickets, bookings). Mounted at root /. """ from __future__ import annotations @@ -17,8 +17,8 @@ from sqlalchemy import select from shared.models import UserNewsletter from shared.models.ghost_membership_entities import GhostNewsletter -from shared.services.widget_registry import widgets from shared.infrastructure.urls import login_url +from shared.infrastructure.fragments import fetch_fragment, fetch_fragments oob = { "oob_extends": "oob_elements.html", @@ -36,8 +36,12 @@ def register(url_prefix="/"): account_bp = Blueprint("account", __name__, url_prefix=url_prefix) @account_bp.context_processor - def context(): - return {"oob": oob, "account_nav_links": widgets.account_nav} + async def context(): + events_nav, cart_nav = await fetch_fragments([ + ("events", "account-nav-item", {}), + ("cart", "account-nav-item", {}), + ]) + return {"oob": oob, "account_nav_html": events_nav + cart_nav} @account_bp.get("/") async def account(): @@ -128,33 +132,35 @@ def register(url_prefix="/"): un=un, ) - # Catch-all for widget pages — must be last + # Catch-all for fragment-provided pages — must be last @account_bp.get("//") - async def widget_page(slug): + async def fragment_page(slug): from shared.browser.app.utils.htmx import is_htmx_request from quart import abort - widget = widgets.account_page_by_slug(slug) - if not widget: - abort(404) - if not g.get("user"): return redirect(login_url(f"/{slug}/")) - ctx = await widget.context_fn(g.s, user_id=g.user.id) - w_oob = {**oob, "main": widget.template} + fragment_html = await fetch_fragment( + "events", "account-page", + params={"slug": slug, "user_id": str(g.user.id)}, + ) + if not fragment_html: + abort(404) + + w_oob = {**oob, "main": "_types/auth/_fragment_panel.html"} if not is_htmx_request(): html = await render_template( "_types/auth/index.html", oob=w_oob, - **ctx, + page_fragment_html=fragment_html, ) else: html = await render_template( "_types/auth/_oob_elements.html", oob=w_oob, - **ctx, + page_fragment_html=fragment_html, ) return await make_response(html) diff --git a/shared b/shared index d2e07e0..65c4989 160000 --- a/shared +++ b/shared @@ -1 +1 @@ -Subproject commit d2e07e047eb161dc7cffbc215b728d5556dae82b +Subproject commit 65c4989d08b85a821a0932e4376f2ab088f50d0c