Replace env free-variable threading with IO-primitive auto-fetch macros
Layout components now self-resolve context (cart-mini, auth-menu, nav-tree, rights, URLs) via new IO primitives (root-header-ctx, select-colours, account-nav-ctx, app-rights) and defmacro wrappers (~root-header-auto, ~auth-header-row-auto, ~root-mobile-auto). This eliminates _ctx_to_env(), HELPER_CSS_CLASSES, and verbose :key threading across all 10 services. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -2,7 +2,7 @@
|
||||
from __future__ import annotations
|
||||
|
||||
from shared.sx.helpers import (
|
||||
render_to_sx_with_env, _ctx_to_env,
|
||||
render_to_sx_with_env,
|
||||
post_admin_header_sx, oob_header_sx,
|
||||
header_child_sx, full_page_sx, oob_page_sx,
|
||||
)
|
||||
@@ -44,7 +44,7 @@ async def render_all_events_page(ctx: dict, entries, has_more, pending_tickets,
|
||||
ctx, entries, has_more, pending_tickets, page_info,
|
||||
page, view, ticket_url, next_url, events_url,
|
||||
)
|
||||
hdr = await render_to_sx_with_env("layout-root-full", _ctx_to_env(ctx))
|
||||
hdr = await render_to_sx_with_env("layout-root-full", {})
|
||||
return await full_page_sx(ctx, header_rows=hdr, content=content)
|
||||
|
||||
|
||||
@@ -105,7 +105,7 @@ async def render_page_summary_page(ctx: dict, entries, has_more, pending_tickets
|
||||
is_page_scoped=True, post=post,
|
||||
)
|
||||
|
||||
hdr = await render_to_sx_with_env("layout-root-full", _ctx_to_env(ctx))
|
||||
hdr = await render_to_sx_with_env("layout-root-full", {})
|
||||
hdr += await header_child_sx(await _post_header_sx(ctx))
|
||||
return await full_page_sx(ctx, header_rows=hdr, content=content)
|
||||
|
||||
@@ -160,7 +160,7 @@ async def render_calendars_page(ctx: dict) -> str:
|
||||
content = await _calendars_main_panel_sx(ctx)
|
||||
ctx = await _ensure_container_nav(ctx)
|
||||
slug = (ctx.get("post") or {}).get("slug", "")
|
||||
root_hdr = await render_to_sx_with_env("layout-root-full", _ctx_to_env(ctx))
|
||||
root_hdr = await render_to_sx_with_env("layout-root-full", {})
|
||||
post_hdr = await _post_header_sx(ctx)
|
||||
admin_hdr = await post_admin_header_sx(ctx, slug, selected="calendars")
|
||||
return await full_page_sx(ctx, header_rows=root_hdr + post_hdr + admin_hdr, content=content)
|
||||
@@ -184,7 +184,7 @@ async def render_calendars_oob(ctx: dict) -> str:
|
||||
async def render_calendar_page(ctx: dict) -> str:
|
||||
"""Full page: calendar month view."""
|
||||
content = await _calendar_main_panel_html(ctx)
|
||||
hdr = await render_to_sx_with_env("layout-root-full", _ctx_to_env(ctx))
|
||||
hdr = await render_to_sx_with_env("layout-root-full", {})
|
||||
child = await _post_header_sx(ctx) + await _calendar_header_sx(ctx)
|
||||
hdr += await header_child_sx(child)
|
||||
return await full_page_sx(ctx, header_rows=hdr, content=content)
|
||||
@@ -208,7 +208,7 @@ async def render_calendar_oob(ctx: dict) -> str:
|
||||
async def render_day_page(ctx: dict) -> str:
|
||||
"""Full page: day detail."""
|
||||
content = await _day_main_panel_html(ctx)
|
||||
hdr = await render_to_sx_with_env("layout-root-full", _ctx_to_env(ctx))
|
||||
hdr = await render_to_sx_with_env("layout-root-full", {})
|
||||
child = (await _post_header_sx(ctx)
|
||||
+ await _calendar_header_sx(ctx) + await _day_header_sx(ctx))
|
||||
hdr += await header_child_sx(child)
|
||||
|
||||
Reference in New Issue
Block a user