Phase 6: Replace render_template() with s-expression rendering in all GET routes
All checks were successful
Build and Deploy / build-and-deploy (push) Successful in 1m15s
All checks were successful
Build and Deploy / build-and-deploy (push) Successful in 1m15s
Migrate ~52 GET route handlers across all 7 services from Jinja render_template() to s-expression component rendering. Each service gets a sexp_components.py with page/oob/cards render functions. - Add per-service sexp_components.py (account, blog, cart, events, federation, market, orders) with full page, OOB, and pagination card rendering - Add shared/sexp/helpers.py with call_url, root_header_html, full_page, oob_page utilities - Update all GET routes to use get_template_context() + render fns - Fix get_template_context() to inject Jinja globals (URL helpers) - Add qs_filter to base_context for sexp filter URL building - Mount sexp_components.py in docker-compose.dev.yml for all services - Import sexp_components in app.py for Hypercorn --reload watching - Fix route_prefix import (shared.utils not shared.infrastructure.urls) - Fix federation choose-username missing actor in context - Fix market page_markets missing post in context Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -42,12 +42,15 @@ def register():
|
||||
p_data = getattr(g, "post_data", None) or {}
|
||||
|
||||
# Determine which template to use based on request type
|
||||
from shared.sexp.page import get_template_context
|
||||
from sexp_components import render_market_home_page, render_market_home_oob
|
||||
|
||||
ctx = await get_template_context()
|
||||
ctx.update(p_data)
|
||||
if not is_htmx_request():
|
||||
# Normal browser request: full page with layout
|
||||
html = await render_template("_types/market/index.html", **p_data)
|
||||
html = await render_market_home_page(ctx)
|
||||
else:
|
||||
# HTMX request: main panel + OOB elements
|
||||
html = await render_template("_types/market/_oob_elements.html", **p_data)
|
||||
html = await render_market_home_oob(ctx)
|
||||
|
||||
return await make_response(html)
|
||||
|
||||
@@ -70,16 +73,18 @@ def register():
|
||||
product_info = await _productInfo()
|
||||
full_context = {**product_info, **ctx}
|
||||
|
||||
# Determine which template to use based on request type and pagination
|
||||
from shared.sexp.page import get_template_context
|
||||
from sexp_components import render_browse_page, render_browse_oob, render_browse_cards
|
||||
|
||||
tctx = await get_template_context()
|
||||
tctx.update(full_context)
|
||||
if not is_htmx_request():
|
||||
# Normal browser request: full page with layout
|
||||
html = await render_template("_types/browse/index.html", **full_context)
|
||||
html = await render_browse_page(tctx)
|
||||
elif product_info["page"] > 1:
|
||||
# HTMX pagination: just product cards + sentinel
|
||||
html = await render_template("_types/browse/_product_cards.html", **product_info)
|
||||
tctx.update(product_info)
|
||||
html = await render_browse_cards(tctx)
|
||||
else:
|
||||
# HTMX navigation (page 1): main panel + OOB elements
|
||||
html = await render_template("_types/browse/_oob_elements.html", **full_context)
|
||||
html = await render_browse_oob(tctx)
|
||||
|
||||
resp = await make_response(html)
|
||||
resp.headers["Hx-Push-Url"] = _current_url_without_page()
|
||||
@@ -107,15 +112,18 @@ def register():
|
||||
product_info = await _productInfo(top_slug)
|
||||
full_context = {**product_info, **ctx}
|
||||
|
||||
# Determine which template to use based on request type and pagination
|
||||
from shared.sexp.page import get_template_context
|
||||
from sexp_components import render_browse_page, render_browse_oob, render_browse_cards
|
||||
|
||||
tctx = await get_template_context()
|
||||
tctx.update(full_context)
|
||||
if not is_htmx_request():
|
||||
# Normal browser request: full page with layout
|
||||
html = await render_template("_types/browse/index.html", **full_context)
|
||||
html = await render_browse_page(tctx)
|
||||
elif product_info["page"] > 1:
|
||||
# HTMX pagination: just product cards + sentinel
|
||||
html = await render_template("_types/browse/_product_cards.html", **product_info)
|
||||
tctx.update(product_info)
|
||||
html = await render_browse_cards(tctx)
|
||||
else:
|
||||
html = await render_template("_types/browse/_oob_elements.html", **full_context)
|
||||
html = await render_browse_oob(tctx)
|
||||
|
||||
resp = await make_response(html)
|
||||
resp.headers["Hx-Push-Url"] = _current_url_without_page()
|
||||
@@ -143,16 +151,18 @@ def register():
|
||||
product_info = await _productInfo(top_slug, sub_slug)
|
||||
full_context = {**product_info, **ctx}
|
||||
|
||||
# Determine which template to use based on request type and pagination
|
||||
from shared.sexp.page import get_template_context
|
||||
from sexp_components import render_browse_page, render_browse_oob, render_browse_cards
|
||||
|
||||
tctx = await get_template_context()
|
||||
tctx.update(full_context)
|
||||
if not is_htmx_request():
|
||||
# Normal browser request: full page with layout
|
||||
html = await render_template("_types/browse/index.html", **full_context)
|
||||
html = await render_browse_page(tctx)
|
||||
elif product_info["page"] > 1:
|
||||
# HTMX pagination: just product cards + sentinel
|
||||
html = await render_template("_types/browse/_product_cards.html", **product_info)
|
||||
tctx.update(product_info)
|
||||
html = await render_browse_cards(tctx)
|
||||
else:
|
||||
# HTMX navigation (page 1): main panel + OOB elements
|
||||
html = await render_template("_types/browse/_oob_elements.html", **full_context)
|
||||
html = await render_browse_oob(tctx)
|
||||
|
||||
resp = await make_response(html)
|
||||
resp.headers["Hx-Push-Url"] = _current_url_without_page()
|
||||
|
||||
Reference in New Issue
Block a user