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:
@@ -46,6 +46,49 @@ def register():
|
||||
|
||||
_handlers["nav-tree"] = _nav_tree_handler
|
||||
|
||||
# --- link-card fragment ---
|
||||
async def _link_card_handler():
|
||||
from shared.services.registry import services
|
||||
from shared.infrastructure.urls import blog_url
|
||||
|
||||
slug = request.args.get("slug", "")
|
||||
keys_raw = request.args.get("keys", "")
|
||||
|
||||
# Batch mode
|
||||
if keys_raw:
|
||||
slugs = [k.strip() for k in keys_raw.split(",") if k.strip()]
|
||||
parts = []
|
||||
for s in slugs:
|
||||
parts.append(f"<!-- fragment:{s} -->")
|
||||
post = await services.blog.get_post_by_slug(g.s, s)
|
||||
if post:
|
||||
parts.append(await render_template(
|
||||
"fragments/link_card.html",
|
||||
title=post.title,
|
||||
feature_image=post.feature_image,
|
||||
excerpt=post.custom_excerpt or post.excerpt,
|
||||
published_at=post.published_at,
|
||||
link=blog_url(f"/{post.slug}"),
|
||||
))
|
||||
return "\n".join(parts)
|
||||
|
||||
# Single mode
|
||||
if not slug:
|
||||
return ""
|
||||
post = await services.blog.get_post_by_slug(g.s, slug)
|
||||
if not post:
|
||||
return ""
|
||||
return await render_template(
|
||||
"fragments/link_card.html",
|
||||
title=post.title,
|
||||
feature_image=post.feature_image,
|
||||
excerpt=post.custom_excerpt or post.excerpt,
|
||||
published_at=post.published_at,
|
||||
link=blog_url(f"/{post.slug}"),
|
||||
)
|
||||
|
||||
_handlers["link-card"] = _link_card_handler
|
||||
|
||||
# Store handlers dict on blueprint so app code can register handlers
|
||||
bp._fragment_handlers = _handlers
|
||||
|
||||
|
||||
Reference in New Issue
Block a user