Files
rose-ash/market/bp/page_markets/routes.py
giles f42042ccb7
All checks were successful
Build and Deploy / build-and-deploy (push) Successful in 1m5s
Monorepo: consolidate 7 repos into one
Combines shared, blog, market, cart, events, federation, and account
into a single repository. Eliminates submodule sync, sibling model
copying at build time, and per-app CI orchestration.

Changes:
- Remove per-app .git, .gitmodules, .gitea, submodule shared/ dirs
- Remove stale sibling model copies from each app
- Update all 6 Dockerfiles for monorepo build context (root = .)
- Add build directives to docker-compose.yml
- Add single .gitea/workflows/ci.yml with change detection
- Add .dockerignore for monorepo build context
- Create __init__.py for federation and account (cross-app imports)
2026-02-24 19:44:17 +00:00

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