Replace env free-variable threading with IO-primitive auto-fetch macros
All checks were successful
Build and Deploy / build-and-deploy (push) Successful in 1m38s
All checks were successful
Build and Deploy / build-and-deploy (push) Successful in 1m38s
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:
@@ -3,9 +3,7 @@
|
||||
|
||||
;; Full page: root header + social header in header-child
|
||||
(defcomp ~social-layout-full ()
|
||||
(<> (~root-header :cart-mini cart-mini :blog-url blog-url :site-title site-title
|
||||
:app-label app-label :nav-tree nav-tree :auth-menu auth-menu
|
||||
:nav-panel nav-panel :settings-url settings-url :is-admin is-admin)
|
||||
(<> (~root-header-auto)
|
||||
(~header-child-sx
|
||||
:inner (~federation-social-header
|
||||
:nav (~federation-social-nav :actor actor)))))
|
||||
@@ -16,7 +14,4 @@
|
||||
:parent-id "root-header-child"
|
||||
:row (~federation-social-header
|
||||
:nav (~federation-social-nav :actor actor)))
|
||||
(~root-header :cart-mini cart-mini :blog-url blog-url :site-title site-title
|
||||
:app-label app-label :nav-tree nav-tree :auth-menu auth-menu
|
||||
:nav-panel nav-panel :settings-url settings-url :is-admin is-admin
|
||||
:oob true)))
|
||||
(~root-header-auto true)))
|
||||
|
||||
@@ -25,11 +25,10 @@ def _serialize_remote_actor(a) -> dict:
|
||||
async def _social_page(ctx: dict, actor, *, content: str,
|
||||
title: str = "Rose Ash", meta_html: str = "") -> str:
|
||||
"""Build a full social page with social header."""
|
||||
from shared.sx.helpers import render_to_sx_with_env, _ctx_to_env, full_page_sx
|
||||
from shared.sx.helpers import render_to_sx_with_env, full_page_sx
|
||||
from markupsafe import escape
|
||||
|
||||
env = _ctx_to_env(ctx)
|
||||
env["actor"] = _serialize_actor(actor) if actor else None
|
||||
env = {"actor": _serialize_actor(actor) if actor else None}
|
||||
header_rows = await render_to_sx_with_env("social-layout-full", env)
|
||||
return await full_page_sx(ctx, header_rows=header_rows, content=content,
|
||||
meta_html=meta_html or f'<title>{escape(title)}</title>')
|
||||
@@ -58,14 +57,12 @@ def _actor_data(ctx: dict) -> dict | None:
|
||||
|
||||
|
||||
async def _social_full(ctx: dict, **kw: Any) -> str:
|
||||
from shared.sx.helpers import render_to_sx_with_env, _ctx_to_env
|
||||
env = _ctx_to_env(ctx)
|
||||
env["actor"] = kw.get("actor") or _actor_data(ctx)
|
||||
from shared.sx.helpers import render_to_sx_with_env
|
||||
env = {"actor": kw.get("actor") or _actor_data(ctx)}
|
||||
return await render_to_sx_with_env("social-layout-full", env)
|
||||
|
||||
|
||||
async def _social_oob(ctx: dict, **kw: Any) -> str:
|
||||
from shared.sx.helpers import render_to_sx_with_env, _ctx_to_env
|
||||
env = _ctx_to_env(ctx, oob=True)
|
||||
env["actor"] = kw.get("actor") or _actor_data(ctx)
|
||||
from shared.sx.helpers import render_to_sx_with_env
|
||||
env = {"actor": kw.get("actor") or _actor_data(ctx)}
|
||||
return await render_to_sx_with_env("social-layout-oob", env)
|
||||
|
||||
Reference in New Issue
Block a user