Migrate all apps to defpage declarative page routes
Replace Python GET page handlers with declarative defpage definitions in .sx files across all 8 apps (sx docs, orders, account, market, cart, federation, events, blog). Each app now has sxc/pages/ with setup functions, layout registrations, page helpers, and .sx defpage declarations. Core infrastructure: add g I/O primitive, PageDef support for auth/layout/ data/content/filter/aside/menu slots, post_author auth level, and custom layout registration. Remove ~1400 lines of render_*_page/render_*_oob boilerplate. Update all endpoint references in routes, sx_components, and templates to defpage_* naming. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -587,56 +587,6 @@ def _order_filter_sx(order: Any, list_url: str, recheck_url: str,
|
||||
# Public API: Cart overview
|
||||
# ---------------------------------------------------------------------------
|
||||
|
||||
async def render_overview_page(ctx: dict, page_groups: list) -> str:
|
||||
"""Full page: cart overview."""
|
||||
main = _overview_main_panel_sx(page_groups, ctx)
|
||||
hdr = root_header_sx(ctx)
|
||||
return full_page_sx(ctx, header_rows=hdr, content=main)
|
||||
|
||||
|
||||
async def render_overview_oob(ctx: dict, page_groups: list) -> str:
|
||||
"""OOB response for cart overview."""
|
||||
main = _overview_main_panel_sx(page_groups, ctx)
|
||||
oobs = root_header_sx(ctx, oob=True)
|
||||
return oob_page_sx(oobs=oobs, content=main)
|
||||
|
||||
|
||||
# ---------------------------------------------------------------------------
|
||||
# Public API: Page cart
|
||||
# ---------------------------------------------------------------------------
|
||||
|
||||
async def render_page_cart_page(ctx: dict, page_post: Any,
|
||||
cart: list, cal_entries: list, tickets: list,
|
||||
ticket_groups: list, total_fn: Any,
|
||||
cal_total_fn: Any, ticket_total_fn: Any) -> str:
|
||||
"""Full page: page-specific cart."""
|
||||
main = _page_cart_main_panel_sx(ctx, cart, cal_entries, tickets, ticket_groups,
|
||||
total_fn, cal_total_fn, ticket_total_fn)
|
||||
hdr = root_header_sx(ctx)
|
||||
child = _cart_header_sx(ctx)
|
||||
page_hdr = _page_cart_header_sx(ctx, page_post)
|
||||
nested = sx_call(
|
||||
"header-child-sx",
|
||||
inner=SxExpr("(<> " + child + " " + sx_call("header-child-sx", id="cart-header-child", inner=SxExpr(page_hdr)) + ")"),
|
||||
)
|
||||
header_rows = "(<> " + hdr + " " + nested + ")"
|
||||
return full_page_sx(ctx, header_rows=header_rows, content=main)
|
||||
|
||||
|
||||
async def render_page_cart_oob(ctx: dict, page_post: Any,
|
||||
cart: list, cal_entries: list, tickets: list,
|
||||
ticket_groups: list, total_fn: Any,
|
||||
cal_total_fn: Any, ticket_total_fn: Any) -> str:
|
||||
"""OOB response for page cart."""
|
||||
main = _page_cart_main_panel_sx(ctx, cart, cal_entries, tickets, ticket_groups,
|
||||
total_fn, cal_total_fn, ticket_total_fn)
|
||||
child_oob = sx_call("oob-header-sx",
|
||||
parent_id="cart-header-child",
|
||||
row=SxExpr(_page_cart_header_sx(ctx, page_post)))
|
||||
cart_hdr_oob = _cart_header_sx(ctx, oob=True)
|
||||
root_hdr_oob = root_header_sx(ctx, oob=True)
|
||||
oobs = "(<> " + child_oob + " " + cart_hdr_oob + " " + root_hdr_oob + ")"
|
||||
return oob_page_sx(oobs=oobs, content=main)
|
||||
|
||||
|
||||
# ---------------------------------------------------------------------------
|
||||
@@ -821,7 +771,7 @@ def _cart_page_admin_header_sx(ctx: dict, page_post: Any, *, oob: bool = False,
|
||||
def _cart_admin_main_panel_sx(ctx: dict) -> str:
|
||||
"""Admin overview panel -- links to sub-admin pages."""
|
||||
from quart import url_for
|
||||
payments_href = url_for("page_admin.payments")
|
||||
payments_href = url_for("page_admin.defpage_cart_payments")
|
||||
return (
|
||||
'(div :id "main-panel"'
|
||||
' (div :class "flex items-center justify-between p-3 border-b"'
|
||||
@@ -851,47 +801,6 @@ def _cart_payments_main_panel_sx(ctx: dict) -> str:
|
||||
checkout_prefix=checkout_prefix)
|
||||
|
||||
|
||||
# ---------------------------------------------------------------------------
|
||||
# Public API: Cart page admin
|
||||
# ---------------------------------------------------------------------------
|
||||
|
||||
async def render_cart_admin_page(ctx: dict, page_post: Any) -> str:
|
||||
"""Full page: cart page admin overview."""
|
||||
content = _cart_admin_main_panel_sx(ctx)
|
||||
root_hdr = root_header_sx(ctx)
|
||||
post_hdr = await _post_header_sx(ctx, page_post)
|
||||
admin_hdr = _cart_page_admin_header_sx(ctx, page_post)
|
||||
header_rows = "(<> " + root_hdr + " " + post_hdr + " " + admin_hdr + ")"
|
||||
return full_page_sx(ctx, header_rows=header_rows, content=content)
|
||||
|
||||
|
||||
async def render_cart_admin_oob(ctx: dict, page_post: Any) -> str:
|
||||
"""OOB response: cart page admin overview."""
|
||||
content = _cart_admin_main_panel_sx(ctx)
|
||||
oobs = _cart_page_admin_header_sx(ctx, page_post, oob=True)
|
||||
return oob_page_sx(oobs=oobs, content=content)
|
||||
|
||||
|
||||
# ---------------------------------------------------------------------------
|
||||
# Public API: Cart payments admin
|
||||
# ---------------------------------------------------------------------------
|
||||
|
||||
async def render_cart_payments_page(ctx: dict, page_post: Any) -> str:
|
||||
"""Full page: payments config."""
|
||||
content = _cart_payments_main_panel_sx(ctx)
|
||||
root_hdr = root_header_sx(ctx)
|
||||
post_hdr = await _post_header_sx(ctx, page_post)
|
||||
admin_hdr = _cart_page_admin_header_sx(ctx, page_post, selected="payments")
|
||||
header_rows = "(<> " + root_hdr + " " + post_hdr + " " + admin_hdr + ")"
|
||||
return full_page_sx(ctx, header_rows=header_rows, content=content)
|
||||
|
||||
|
||||
async def render_cart_payments_oob(ctx: dict, page_post: Any) -> str:
|
||||
"""OOB response: payments config."""
|
||||
content = _cart_payments_main_panel_sx(ctx)
|
||||
oobs = _cart_page_admin_header_sx(ctx, page_post, oob=True, selected="payments")
|
||||
return oob_page_sx(oobs=oobs, content=content)
|
||||
|
||||
|
||||
def render_cart_payments_panel(ctx: dict) -> str:
|
||||
"""Render the payments config panel for PUT response."""
|
||||
|
||||
Reference in New Issue
Block a user