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>
67 lines
2.1 KiB
Python
67 lines
2.1 KiB
Python
"""
|
|
Page-markets blueprint — shows markets for a single page.
|
|
|
|
Mounted at /<slug> (page-scoped). Requires g.post_data from hydrate_post.
|
|
|
|
Routes:
|
|
GET /<slug>/ — full page scoped to this page
|
|
GET /<slug>/page-markets — HTMX fragment for infinite scroll
|
|
"""
|
|
from __future__ import annotations
|
|
|
|
from quart import Blueprint, g, request, render_template, make_response
|
|
|
|
from shared.browser.app.utils.htmx import is_htmx_request
|
|
from shared.services.registry import services
|
|
|
|
|
|
def register() -> Blueprint:
|
|
bp = Blueprint("page_markets", __name__)
|
|
|
|
async def _load_markets(post_id, page, per_page=20):
|
|
"""Load markets for this page's container."""
|
|
markets, has_more = await services.market.list_marketplaces(
|
|
g.s, "page", post_id, page=page, per_page=per_page,
|
|
)
|
|
return markets, has_more
|
|
|
|
@bp.get("/")
|
|
async def index():
|
|
post = g.post_data["post"]
|
|
page = int(request.args.get("page", 1))
|
|
|
|
markets, has_more = await _load_markets(post["id"], page)
|
|
|
|
ctx = dict(
|
|
markets=markets,
|
|
has_more=has_more,
|
|
page_info={},
|
|
page=page,
|
|
)
|
|
|
|
from shared.sexp.page import get_template_context
|
|
from sexp_components import render_page_markets_page, render_page_markets_oob
|
|
|
|
tctx = await get_template_context()
|
|
tctx["post"] = post
|
|
if is_htmx_request():
|
|
html = await render_page_markets_oob(tctx, markets, has_more, page)
|
|
else:
|
|
html = await render_page_markets_page(tctx, markets, has_more, page)
|
|
|
|
return await make_response(html, 200)
|
|
|
|
@bp.get("/page-markets")
|
|
async def markets_fragment():
|
|
post = g.post_data["post"]
|
|
page = int(request.args.get("page", 1))
|
|
|
|
markets, has_more = await _load_markets(post["id"], page)
|
|
|
|
from sexp_components import render_page_markets_cards
|
|
post_slug = post.get("slug", "")
|
|
html = await render_page_markets_cards(markets, has_more, page, post_slug)
|
|
return await make_response(html, 200)
|
|
|
|
return bp
|