Make post header row generic: admin cog + container_nav in shared helper
Move admin cog generation and container_nav border wrapping from blog-specific wrapper into shared post_header_html so all services render identical post header rows. Blog, events, cart all delegate to the shared helper now. Cart admin pages fetch container_nav_html via fragments. Village Hall always links to blog. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -89,9 +89,31 @@ def post_header_html(ctx: dict, *, oob: bool = False) -> str:
|
||||
|
||||
container_nav = ctx.get("container_nav_html", "")
|
||||
if container_nav:
|
||||
nav_parts.append(container_nav)
|
||||
nav_parts.append(
|
||||
'<div class="flex flex-col sm:flex-row sm:items-center gap-2'
|
||||
' border-r border-stone-200 mr-2 sm:max-w-2xl"'
|
||||
' id="entries-calendars-nav-wrapper">'
|
||||
f'{container_nav}</div>'
|
||||
)
|
||||
|
||||
# Admin cog — external link to blog admin (generic across all services)
|
||||
admin_nav = ctx.get("post_admin_nav_html", "")
|
||||
if not admin_nav:
|
||||
rights = ctx.get("rights") or {}
|
||||
has_admin = rights.get("admin") if isinstance(rights, dict) else getattr(rights, "admin", False)
|
||||
if has_admin and slug:
|
||||
from quart import request
|
||||
admin_href = call_url(ctx, "blog_url", f"/{slug}/admin/")
|
||||
is_admin_page = "/admin" in request.path
|
||||
sel_cls = "!bg-stone-500 !text-white" if is_admin_page else ""
|
||||
base_cls = ("justify-center cursor-pointer flex flex-row"
|
||||
" items-center gap-2 rounded bg-stone-200 text-black p-3")
|
||||
admin_nav = (
|
||||
f'<div class="relative nav-group">'
|
||||
f'<a href="{escape(admin_href)}"'
|
||||
f' class="{base_cls} {sel_cls}">'
|
||||
f'<i class="fa fa-cog" aria-hidden="true"></i></a></div>'
|
||||
)
|
||||
if admin_nav:
|
||||
nav_parts.append(admin_nav)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user