Send all responses as sexp wire format with client-side rendering
All checks were successful
Build and Deploy / build-and-deploy (push) Successful in 5m35s
All checks were successful
Build and Deploy / build-and-deploy (push) Successful in 5m35s
- Server sends sexp source text, client (sexp.js) renders everything - SexpExpr marker class for nested sexp composition in serialize() - sexp_page() HTML shell with data-mount="body" for full page loads - sexp_response() returns text/sexp for OOB/partial responses - ~app-body layout component replaces ~app-layout (no raw!) - ~rich-text is the only component using raw! (for CMS HTML content) - Fragment endpoints return text/sexp, auto-wrapped in SexpExpr - All _*_html() helpers converted to _*_sexp() returning sexp source - Head auto-hoist: sexp.js moves meta/title/link/script[ld+json] from rendered body to document.head automatically - Unknown components render warning box instead of crashing page - Component kwargs preserve AST for lazy rendering (fixes <> in kwargs) - Fix unterminated paren in events/sexp/tickets.sexpr Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -19,6 +19,7 @@ from shared.browser.app.redis_cacher import cache_page, clear_cache
|
||||
from ..cart.services import total
|
||||
from shared.infrastructure.actions import call_action
|
||||
from .services.product_operations import massage_full_product
|
||||
from shared.sexp.helpers import sexp_response
|
||||
|
||||
|
||||
def register():
|
||||
@@ -115,10 +116,10 @@ def register():
|
||||
tctx["liked_by_current_user"] = item_data.get("liked", False)
|
||||
if not is_htmx_request():
|
||||
html = await render_product_page(tctx, d)
|
||||
return html
|
||||
else:
|
||||
html = await render_product_oob(tctx, d)
|
||||
|
||||
return html
|
||||
sexp_src = await render_product_oob(tctx, d)
|
||||
return sexp_response(sexp_src)
|
||||
|
||||
@bp.post("/like/toggle/")
|
||||
@clear_cache(tag="browse", tag_scope="user")
|
||||
@@ -128,9 +129,7 @@ def register():
|
||||
from sexp.sexp_components import render_like_toggle_button
|
||||
|
||||
if not g.user:
|
||||
html = render_like_toggle_button(product_slug, False)
|
||||
resp = make_response(html, 403)
|
||||
return resp
|
||||
return sexp_response(render_like_toggle_button(product_slug, False), status=403)
|
||||
|
||||
user_id = g.user.id
|
||||
|
||||
@@ -139,7 +138,7 @@ def register():
|
||||
})
|
||||
liked = result["liked"]
|
||||
|
||||
return render_like_toggle_button(product_slug, liked)
|
||||
return sexp_response(render_like_toggle_button(product_slug, liked))
|
||||
|
||||
|
||||
|
||||
@@ -156,10 +155,10 @@ def register():
|
||||
tctx["liked_by_current_user"] = item_data.get("liked", False)
|
||||
if not is_htmx_request():
|
||||
html = await render_product_admin_page(tctx, d)
|
||||
return await make_response(html)
|
||||
else:
|
||||
html = await render_product_admin_oob(tctx, d)
|
||||
|
||||
return await make_response(html)
|
||||
sexp_src = await render_product_admin_oob(tctx, d)
|
||||
return sexp_response(sexp_src)
|
||||
|
||||
|
||||
from bp.cart.services.identity import current_cart_identity
|
||||
@@ -254,11 +253,11 @@ def register():
|
||||
)
|
||||
|
||||
# htmx response: OOB-swap mini cart + product buttons
|
||||
if request.headers.get("HX-Request") == "true":
|
||||
if request.headers.get("SX-Request") == "true" or request.headers.get("HX-Request") == "true":
|
||||
from sexp.sexp_components import render_cart_added_response
|
||||
item_data = getattr(g, "item_data", {})
|
||||
d = item_data.get("d", {})
|
||||
return render_cart_added_response(g.cart, ci_ns, d)
|
||||
return sexp_response(render_cart_added_response(g.cart, ci_ns, d))
|
||||
|
||||
# normal POST: go to cart page
|
||||
from shared.infrastructure.urls import cart_url
|
||||
|
||||
Reference in New Issue
Block a user