Fix Python string-form component name references
The rename script only matched ~prefixed names in .sx files.
Python render calls use bare strings like render_to_html("name")
which also need updating: 37 replacements across 8 files.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -69,7 +69,7 @@ async def root_header_sx(ctx: dict, *, oob: bool = False) -> str:
|
||||
rights = ctx.get("rights") or {}
|
||||
is_admin = rights.get("admin") if isinstance(rights, dict) else getattr(rights, "admin", False)
|
||||
settings_url = call_url(ctx, "blog_url", "/settings/") if is_admin else ""
|
||||
return await _render_to_sx("header-row-sx",
|
||||
return await _render_to_sx("shared:layout/header-row-sx",
|
||||
cart_mini=_as_sx(ctx.get("cart_mini")),
|
||||
blog_url=call_url(ctx, "blog_url", ""),
|
||||
site_title=ctx.get("base_title", ""),
|
||||
@@ -95,7 +95,7 @@ async def mobile_root_nav_sx(ctx: dict) -> str:
|
||||
auth_menu = ctx.get("auth_menu") or ""
|
||||
if not nav_tree and not auth_menu:
|
||||
return ""
|
||||
return await _render_to_sx("mobile-root-nav",
|
||||
return await _render_to_sx("shared:layout/mobile-root-nav",
|
||||
nav_tree=_as_sx(nav_tree),
|
||||
auth_menu=_as_sx(auth_menu),
|
||||
)
|
||||
@@ -116,13 +116,13 @@ async def _post_nav_items_sx(ctx: dict) -> SxExpr:
|
||||
page_cart_count = ctx.get("page_cart_count", 0)
|
||||
if page_cart_count and page_cart_count > 0:
|
||||
cart_href = call_url(ctx, "cart_url", f"/{slug}/")
|
||||
parts.append(await _render_to_sx("page-cart-badge", href=cart_href,
|
||||
parts.append(await _render_to_sx("shared:layout/page-cart-badge", href=cart_href,
|
||||
count=str(page_cart_count)))
|
||||
|
||||
container_nav = str(ctx.get("container_nav") or "").strip()
|
||||
# Skip empty fragment wrappers like "(<> )"
|
||||
if container_nav and container_nav.replace("(<>", "").replace(")", "").strip():
|
||||
parts.append(await _render_to_sx("container-nav-wrapper",
|
||||
parts.append(await _render_to_sx("shared:layout/container-nav-wrapper",
|
||||
content=SxExpr(container_nav)))
|
||||
|
||||
# Admin cog
|
||||
@@ -134,7 +134,7 @@ async def _post_nav_items_sx(ctx: dict) -> SxExpr:
|
||||
from quart import request
|
||||
admin_href = call_url(ctx, "blog_url", f"/{slug}/admin/")
|
||||
is_admin_page = ctx.get("is_admin_section") or "/admin" in request.path
|
||||
admin_nav = await _render_to_sx("admin-cog-button",
|
||||
admin_nav = await _render_to_sx("shared:layout/admin-cog-button",
|
||||
href=admin_href,
|
||||
is_admin_page=is_admin_page or None)
|
||||
if admin_nav:
|
||||
@@ -164,7 +164,7 @@ async def _post_admin_nav_items_sx(ctx: dict, slug: str,
|
||||
continue
|
||||
href = url_fn(path)
|
||||
is_sel = label == selected
|
||||
parts.append(await _render_to_sx("nav-link", href=href, label=label,
|
||||
parts.append(await _render_to_sx("shared:layout/nav-link", href=href, label=label,
|
||||
select_colours=select_colours,
|
||||
is_selected=is_sel or None))
|
||||
return _sx_fragment(*parts) if parts else SxExpr("")
|
||||
@@ -182,7 +182,7 @@ async def post_mobile_nav_sx(ctx: dict) -> str:
|
||||
post = ctx.get("post") or {}
|
||||
slug = post.get("slug", "")
|
||||
title = (post.get("title") or slug)[:40]
|
||||
return await _render_to_sx("mobile-menu-section",
|
||||
return await _render_to_sx("shared:layout/mobile-menu-section",
|
||||
label=title,
|
||||
href=call_url(ctx, "blog_url", f"/{slug}/"),
|
||||
level=1,
|
||||
@@ -193,7 +193,7 @@ async def post_mobile_nav_sx(ctx: dict) -> str:
|
||||
|
||||
async def search_mobile_sx(ctx: dict) -> str:
|
||||
"""Build mobile search input as sx wire format."""
|
||||
return await _render_to_sx("search-mobile",
|
||||
return await _render_to_sx("shared:controls/search-mobile",
|
||||
current_local_href=ctx.get("current_local_href", "/"),
|
||||
search=ctx.get("search", ""),
|
||||
search_count=ctx.get("search_count", ""),
|
||||
@@ -204,7 +204,7 @@ async def search_mobile_sx(ctx: dict) -> str:
|
||||
|
||||
async def search_desktop_sx(ctx: dict) -> str:
|
||||
"""Build desktop search input as sx wire format."""
|
||||
return await _render_to_sx("search-desktop",
|
||||
return await _render_to_sx("shared:controls/search-desktop",
|
||||
current_local_href=ctx.get("current_local_href", "/"),
|
||||
search=ctx.get("search", ""),
|
||||
search_count=ctx.get("search_count", ""),
|
||||
@@ -222,11 +222,11 @@ async def post_header_sx(ctx: dict, *, oob: bool = False, child: str = "") -> st
|
||||
title = (post.get("title") or "")[:160]
|
||||
feature_image = post.get("feature_image")
|
||||
|
||||
label_sx = await _render_to_sx("post-label", feature_image=feature_image, title=title)
|
||||
label_sx = await _render_to_sx("shared:layout/post-label", feature_image=feature_image, title=title)
|
||||
nav_sx = await _post_nav_items_sx(ctx) or None
|
||||
link_href = call_url(ctx, "blog_url", f"/{slug}/")
|
||||
|
||||
return await _render_to_sx("menu-row-sx",
|
||||
return await _render_to_sx("shared:layout/menu-row-sx",
|
||||
id="post-row", level=1,
|
||||
link_href=link_href,
|
||||
link_label_content=label_sx,
|
||||
@@ -241,7 +241,7 @@ async def post_admin_header_sx(ctx: dict, slug: str, *, oob: bool = False,
|
||||
selected: str = "", admin_href: str = "") -> str:
|
||||
"""Post admin header row as sx wire format."""
|
||||
# Label
|
||||
label_sx = await _render_to_sx("post-admin-label",
|
||||
label_sx = await _render_to_sx("shared:layout/post-admin-label",
|
||||
selected=str(escape(selected)) if selected else None)
|
||||
|
||||
nav_sx = await _post_admin_nav_items_sx(ctx, slug, selected) or None
|
||||
@@ -250,7 +250,7 @@ async def post_admin_header_sx(ctx: dict, slug: str, *, oob: bool = False,
|
||||
blog_fn = ctx.get("blog_url")
|
||||
admin_href = blog_fn(f"/{slug}/admin/") if callable(blog_fn) else f"/{slug}/admin/"
|
||||
|
||||
return await _render_to_sx("menu-row-sx",
|
||||
return await _render_to_sx("shared:layout/menu-row-sx",
|
||||
id="post-admin-row", level=2,
|
||||
link_href=admin_href,
|
||||
link_label_content=label_sx,
|
||||
@@ -265,7 +265,7 @@ async def oob_header_sx(parent_id: str, child_id: str, row_sx: str) -> str:
|
||||
child_id is accepted for call-site compatibility but no longer used —
|
||||
the child placeholder is created by ~shared:layout/menu-row-sx itself.
|
||||
"""
|
||||
return await _render_to_sx("oob-header-sx",
|
||||
return await _render_to_sx("shared:layout/oob-header-sx",
|
||||
parent_id=parent_id,
|
||||
row=SxExpr(row_sx),
|
||||
)
|
||||
@@ -273,7 +273,7 @@ async def oob_header_sx(parent_id: str, child_id: str, row_sx: str) -> str:
|
||||
|
||||
async def header_child_sx(inner_sx: str, *, id: str = "root-header-child") -> str:
|
||||
"""Wrap inner sx in a header-child div."""
|
||||
return await _render_to_sx("header-child-sx",
|
||||
return await _render_to_sx("shared:layout/header-child-sx",
|
||||
id=id, inner=_sx_fragment(inner_sx),
|
||||
)
|
||||
|
||||
@@ -281,7 +281,7 @@ async def header_child_sx(inner_sx: str, *, id: str = "root-header-child") -> st
|
||||
async def oob_page_sx(*, oobs: str = "", filter: str = "", aside: str = "",
|
||||
content: str = "", menu: str = "") -> str:
|
||||
"""Build OOB response as sx wire format."""
|
||||
return await _render_to_sx("oob-sx",
|
||||
return await _render_to_sx("shared:layout/oob-sx",
|
||||
oobs=_sx_fragment(oobs) if oobs else None,
|
||||
filter=SxExpr(filter) if filter else None,
|
||||
aside=SxExpr(aside) if aside else None,
|
||||
@@ -307,7 +307,7 @@ async def full_page_sx(ctx: dict, *, header_rows: str,
|
||||
# Auto-generate mobile nav from context when no menu provided
|
||||
if not menu:
|
||||
menu = await mobile_root_nav_sx(ctx)
|
||||
body_sx = await _render_to_sx("app-body",
|
||||
body_sx = await _render_to_sx("shared:layout/app-body",
|
||||
header_rows=_sx_fragment(header_rows) if header_rows else None,
|
||||
filter=SxExpr(filter) if filter else None,
|
||||
aside=SxExpr(aside) if aside else None,
|
||||
@@ -876,7 +876,7 @@ async def sx_page(ctx: dict, page_sx: str, *,
|
||||
shell_kwargs["init_sx"] = init_sx
|
||||
if body_scripts is not None:
|
||||
shell_kwargs["body_scripts"] = body_scripts
|
||||
return await render_to_html("sx-page-shell", **shell_kwargs)
|
||||
return await render_to_html("shared:shell/sx-page-shell", **shell_kwargs)
|
||||
|
||||
|
||||
_SX_STREAMING_RESOLVE = """\
|
||||
|
||||
@@ -545,7 +545,7 @@ async def execute_page_streaming(
|
||||
else:
|
||||
suspense_content_sx = f'(~shared:pages/suspense :id "stream-content" :fallback {fallback_sx})'
|
||||
|
||||
initial_page_html = await _helpers_render_to_html("app-body",
|
||||
initial_page_html = await _helpers_render_to_html("shared:layout/app-body",
|
||||
header_rows=SxExpr(suspense_header_sx),
|
||||
content=SxExpr(suspense_content_sx),
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user