Phase 4: add container-nav/cards fragment handlers, use market fragment
All checks were successful
Build and Deploy / build-and-deploy (push) Successful in 1m4s

Events provides container-nav (calendar entries + links) and
container-cards (batch entries for blog listing) as fragments.
Day and entry routes fetch market container-nav via fragment instead
of widget registry.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
giles
2026-02-24 13:33:25 +00:00
parent de80c393e4
commit 503f7ca7d8
7 changed files with 165 additions and 47 deletions

View File

@@ -11,7 +11,7 @@ from bp.calendar_entries.routes import register as register_calendar_entries
from .admin.routes import register as register_admin
from shared.browser.app.redis_cacher import cache_page
from shared.services.widget_registry import widgets
from shared.infrastructure.fragments import fetch_fragment
from models.calendars import CalendarSlot # add this import
@@ -78,25 +78,17 @@ def register():
result = await g.s.execute(stmt)
day_slots = list(result.scalars())
# Widget-driven container nav (market links, etc.)
container_nav_loaded = []
# Fetch container nav from market (skip calendar — we're on a calendar page)
container_nav_html = ""
post_data = getattr(g, "post_data", None)
if post_data:
post_id = post_data["post"]["id"]
post_slug = post_data["post"]["slug"]
for w in widgets.container_nav:
if w.domain.startswith("calendar"):
continue # skip — we're already on a calendar page
try:
wctx = await w.context_fn(
g.s, container_type="page", container_id=post_id,
post_slug=post_slug,
)
has_data = any(v for v in wctx.values() if isinstance(v, list) and v)
if has_data:
container_nav_loaded.append({"widget": w, "ctx": wctx})
except Exception:
pass
container_nav_html = await fetch_fragment("market", "container-nav", params={
"container_type": "page",
"container_id": str(post_id),
"post_slug": post_slug,
})
return {
"qsession": qsession,
@@ -108,7 +100,7 @@ def register():
"user_entries": visible.user_entries,
"confirmed_entries": visible.confirmed_entries,
"day_slots": day_slots,
"container_nav_widgets": container_nav_loaded,
"container_nav_html": container_nav_html,
}
@@ -142,23 +134,21 @@ def register():
@bp.get("/w/<widget_domain>/")
async def widget_paginate(widget_domain: str, **kwargs):
"""Generic paginated widget endpoint for infinite scroll."""
"""Proxies paginated widget requests to the appropriate fragment provider."""
page = int(request.args.get("page", 1))
post_data = getattr(g, "post_data", None)
if not post_data:
abort(404)
post_id = post_data["post"]["id"]
post_slug = post_data["post"]["slug"]
for w in widgets.container_nav:
if w.domain == widget_domain:
ctx = await w.context_fn(
g.s, container_type="page", container_id=post_id,
post_slug=post_slug, page=page,
)
html = await render_template(
w.template, ctx=ctx, post=post_data["post"],
)
return await make_response(html)
if widget_domain == "market":
html = await fetch_fragment("market", "container-nav", params={
"container_type": "page",
"container_id": str(post_id),
"post_slug": post_slug,
})
return await make_response(html or "")
abort(404)
return bp