All checks were successful
Build and Deploy / build-and-deploy (push) Successful in 1m4s
- New all_markets blueprint at / with paginated grid and HTMX infinite scroll - New page_markets blueprint at /<slug>/ for page-scoped market listing - list_marketplaces service method (via shared submodule update) - Updated slug preprocessor to handle both /<slug>/ and /<page_slug>/<market_slug>/ - Removed inline markets_listing() route (replaced by all_markets blueprint) Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
66 lines
1.9 KiB
Python
66 lines
1.9 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,
|
|
)
|
|
|
|
if is_htmx_request():
|
|
html = await render_template("_types/page_markets/_main_panel.html", **ctx)
|
|
else:
|
|
html = await render_template("_types/page_markets/index.html", **ctx)
|
|
|
|
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)
|
|
|
|
html = await render_template(
|
|
"_types/page_markets/_cards.html",
|
|
markets=markets,
|
|
has_more=has_more,
|
|
page_info={},
|
|
page=page,
|
|
)
|
|
return await make_response(html, 200)
|
|
|
|
return bp
|