Add Phase 5: link-card fragments, oEmbed endpoints, OG meta
All checks were successful
Build and Deploy / build-and-deploy (push) Successful in 4m48s
All checks were successful
Build and Deploy / build-and-deploy (push) Successful in 4m48s
- fetch_fragment_batch() for N+1 avoidance with per-key Redis cache - link-card fragment handlers in blog, market, events, federation (single + batch mode) - link_card.html templates per app with content-specific previews - shared/infrastructure/oembed.py: build_oembed_response, build_og_meta, build_oembed_link_tag - GET /oembed routes on blog, market, events - og_meta + oembed_link rendering in base template <head> - INTERNAL_URL_ARTDAG in docker-compose.yml for cross-stack fragment fetches Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -195,6 +195,44 @@ def create_app() -> "Quart":
|
||||
return {}
|
||||
return {**post_data}
|
||||
|
||||
# --- oEmbed endpoint ---
|
||||
@app.get("/oembed")
|
||||
async def oembed():
|
||||
from urllib.parse import urlparse
|
||||
from quart import jsonify
|
||||
from shared.models.market import Product
|
||||
from shared.infrastructure.urls import market_url
|
||||
from shared.infrastructure.oembed import build_oembed_response
|
||||
|
||||
url = request.args.get("url", "")
|
||||
if not url:
|
||||
return jsonify({"error": "url parameter required"}), 400
|
||||
|
||||
parsed = urlparse(url)
|
||||
# Market product URLs: /.../<page_slug>/<market_slug>/product/<slug>/
|
||||
parts = [p for p in parsed.path.strip("/").split("/") if p]
|
||||
slug = ""
|
||||
for i, part in enumerate(parts):
|
||||
if part == "product" and i + 1 < len(parts):
|
||||
slug = parts[i + 1]
|
||||
break
|
||||
if not slug:
|
||||
return jsonify({"error": "could not extract product slug"}), 404
|
||||
|
||||
product = (
|
||||
await g.s.execute(select(Product).where(Product.slug == slug))
|
||||
).scalar_one_or_none()
|
||||
if not product:
|
||||
return jsonify({"error": "not found"}), 404
|
||||
|
||||
resp = build_oembed_response(
|
||||
title=product.title or slug,
|
||||
oembed_type="link",
|
||||
thumbnail_url=product.image,
|
||||
url=market_url(f"/product/{product.slug}/"),
|
||||
)
|
||||
return jsonify(resp)
|
||||
|
||||
return app
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user