Consolidate post header/menu system into shared infrastructure
All checks were successful
Build and Deploy / build-and-deploy (push) Successful in 1m29s
All checks were successful
Build and Deploy / build-and-deploy (push) Successful in 1m29s
Replace duplicated _post_header_html, _oob_header_html, and header-child components across blog/events/market/errors with shared sexpr components (~post-label, ~page-cart-badge, ~oob-header, ~header-child, ~error-content) and shared Python helpers (post_header_html, oob_header_html, header_child_html, error_content_html). App-specific logic (blog container-nav wrapping, admin cog, events calendar links) preserved via thin wrappers. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -83,8 +83,7 @@ async def _rich_error_page(errnum: str, message: str, image: str | None = None)
|
||||
return None
|
||||
|
||||
try:
|
||||
from shared.sexp.jinja_bridge import render
|
||||
from shared.sexp.helpers import full_page, call_url
|
||||
from shared.sexp.helpers import full_page
|
||||
|
||||
# Build a minimal context — avoid get_template_context() which
|
||||
# calls cross-service fragment fetches that may fail.
|
||||
@@ -150,44 +149,22 @@ async def _rich_error_page(errnum: str, message: str, image: str | None = None)
|
||||
pass
|
||||
|
||||
# Root header (site nav bar)
|
||||
from shared.sexp.helpers import root_header_html
|
||||
from shared.sexp.helpers import (
|
||||
root_header_html, post_header_html,
|
||||
header_child_html, error_content_html,
|
||||
)
|
||||
hdr = root_header_html(ctx)
|
||||
|
||||
# Post breadcrumb if we resolved a post
|
||||
post = (post_data or {}).get("post") or ctx.get("post") or {}
|
||||
if post.get("slug"):
|
||||
title = (post.get("title") or "")[:160]
|
||||
feature_image = post.get("feature_image")
|
||||
label_html = ""
|
||||
if feature_image:
|
||||
label_html += (
|
||||
f'<img src="{feature_image}" '
|
||||
f'class="h-8 w-8 rounded-full object-cover border border-stone-300 flex-shrink-0">'
|
||||
)
|
||||
label_html += f"<span>{escape(title)}</span>"
|
||||
post_row = render(
|
||||
"menu-row",
|
||||
id="post-row", level=1,
|
||||
link_href=call_url(ctx, "blog_url", f"/{post['slug']}/"),
|
||||
link_label_html=label_html,
|
||||
child_id="post-header-child",
|
||||
external=True,
|
||||
)
|
||||
hdr += (
|
||||
f'<div id="root-header-child" class="w-full">'
|
||||
f'{post_row}'
|
||||
f'</div>'
|
||||
)
|
||||
ctx["post"] = post
|
||||
post_row = post_header_html(ctx)
|
||||
if post_row:
|
||||
hdr += header_child_html(post_row)
|
||||
|
||||
# Error content
|
||||
error_html = (
|
||||
'<div class="text-center p-8 max-w-lg mx-auto">'
|
||||
f'<div class="font-bold text-2xl md:text-4xl text-red-500 mb-4">{errnum}</div>'
|
||||
f'<div class="text-stone-600 mb-4">{escape(message)}</div>'
|
||||
)
|
||||
if image:
|
||||
error_html += f'<div class="flex justify-center"><img src="{image}" width="300" height="300"></div>'
|
||||
error_html += "</div>"
|
||||
error_html = error_content_html(errnum, message, image)
|
||||
|
||||
return full_page(ctx, header_rows_html=hdr, content_html=error_html)
|
||||
except Exception:
|
||||
|
||||
Reference in New Issue
Block a user