Phase 4: add container-nav fragment handler for market links
All checks were successful
Build and Deploy / build-and-deploy (push) Successful in 54s
All checks were successful
Build and Deploy / build-and-deploy (push) Successful in 54s
Market app serves marketplace links as a fragment at /internal/fragments/container-nav for consumption by blog and events. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -6,9 +6,10 @@ by other coop apps via the fragment client.
|
|||||||
|
|
||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
from quart import Blueprint, Response, request
|
from quart import Blueprint, Response, g, render_template, request
|
||||||
|
|
||||||
from shared.infrastructure.fragments import FRAGMENT_HEADER
|
from shared.infrastructure.fragments import FRAGMENT_HEADER
|
||||||
|
from shared.services.registry import services
|
||||||
|
|
||||||
|
|
||||||
def register():
|
def register():
|
||||||
@@ -29,6 +30,25 @@ def register():
|
|||||||
html = await handler()
|
html = await handler()
|
||||||
return Response(html, status=200, content_type="text/html")
|
return Response(html, status=200, content_type="text/html")
|
||||||
|
|
||||||
|
# --- container-nav fragment: market links --------------------------------
|
||||||
|
|
||||||
|
async def _container_nav_handler():
|
||||||
|
container_type = request.args.get("container_type", "page")
|
||||||
|
container_id = int(request.args.get("container_id", 0))
|
||||||
|
post_slug = request.args.get("post_slug", "")
|
||||||
|
|
||||||
|
markets = await services.market.marketplaces_for_container(
|
||||||
|
g.s, container_type, container_id,
|
||||||
|
)
|
||||||
|
if not markets:
|
||||||
|
return ""
|
||||||
|
return await render_template(
|
||||||
|
"fragments/container_nav_markets.html",
|
||||||
|
markets=markets, post_slug=post_slug,
|
||||||
|
)
|
||||||
|
|
||||||
|
_handlers["container-nav"] = _container_nav_handler
|
||||||
|
|
||||||
bp._fragment_handlers = _handlers
|
bp._fragment_handlers = _handlers
|
||||||
|
|
||||||
return bp
|
return bp
|
||||||
|
|||||||
2
shared
2
shared
Submodule shared updated: ab674ada31...d2e07e047e
9
templates/fragments/container_nav_markets.html
Normal file
9
templates/fragments/container_nav_markets.html
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
{# Market links nav — served as fragment from market app #}
|
||||||
|
{% for m in markets %}
|
||||||
|
<a
|
||||||
|
href="{{ market_url('/' + post_slug + '/' + m.slug + '/') }}"
|
||||||
|
class="{{styles.nav_button_less_pad}}">
|
||||||
|
<i class="fa fa-shopping-bag" aria-hidden="true"></i>
|
||||||
|
<div>{{m.name}}</div>
|
||||||
|
</a>
|
||||||
|
{% endfor %}
|
||||||
Reference in New Issue
Block a user