Remove cross-domain template copies, use shared macros
All checks were successful
Build and Deploy / build-and-deploy (push) Successful in 56s

- Cart mini: use macros/cart_icon.html for ticket OOB updates
- Post header: use blog_url() instead of url_for('blog.post.post_detail')

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
giles
2026-02-24 17:33:14 +00:00
parent bc4d332157
commit 0f8dd636af
5 changed files with 6 additions and 51 deletions

2
shared

Submodule shared updated: 5518c95237...cf2e2ba1db

View File

@@ -1,45 +0,0 @@
{% macro mini(oob=False, count=None) %}
<div id="cart-mini" {% if oob %}hx-swap-oob="{{oob}}"{% endif %} >
{# cart_count is set by the context processor in all apps.
Cart app computes it from g.cart + calendar_cart_entries;
other apps get it from the cart internal API.
count param allows explicit override when macro is imported without context. #}
{% if count is not none %}
{% set _count = count %}
{% elif cart_count is defined and cart_count is not none %}
{% set _count = cart_count %}
{% elif cart is defined and cart is not none %}
{% set _count = (cart | sum(attribute="quantity")) + ((calendar_cart_entries | length) if calendar_cart_entries else 0) %}
{% else %}
{% set _count = 0 %}
{% endif %}
{% if _count == 0 %}
<div class="h-12 w-12 rounded-full overflow-hidden border border-stone-300 flex-shrink-0">
<a
href="{{ blog_url('/') }}"
class="h-full w-full font-bold text-5xl flex-shrink-0 flex flex-row items-center gap-1"
>
<img
src="{{ site().logo }}"
class="h-full w-full rounded-full object-cover border border-stone-300 flex-shrink-0"
>
</a>
</div>
{% else %}
<a
href="{{ cart_url('/') }}"
class="relative inline-flex items-center justify-center text-stone-700 hover:text-emerald-700"
>
<i class="fa fa-shopping-cart text-5xl" aria-hidden="true"></i>
<span
class="absolute top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2 inline-flex items-center justify-center rounded-full bg-emerald-600 text-white text-sm w-5 h-5"
>
{{ _count }}
</span>
</a>
{% endif %}
</div>
{% endmacro %}

View File

@@ -1,7 +1,7 @@
{% import 'macros/links.html' as links %}
{% macro header_row(oob=False) %}
{% call links.menu_row(id='post-row', oob=oob) %}
{% call links.link(url_for('blog.post.post_detail', slug=post.slug), hx_select_search ) %}
{% call links.link(blog_url('/' + post.slug + '/'), hx_select_search ) %}
{% if post.feature_image %}
<img
src="{{ post.feature_image }}"

View File

@@ -1,4 +1,4 @@
{# Response for ticket adjust — buy form + OOB cart-mini update #}
{% from '_types/cart/_mini.html' import mini %}
{{ mini(oob='true', count=cart_count) }}
{% from 'macros/cart_icon.html' import cart_icon %}
{{ cart_icon(count=cart_count, oob='true') }}
{% include '_types/tickets/_buy_form.html' %}

View File

@@ -1,7 +1,7 @@
{# Shown after ticket purchase — replaces the buy form #}
{# OOB: refresh cart badge to reflect new ticket count #}
{% from '_types/cart/_mini.html' import mini with context %}
{{ mini(oob='true') }}
{% from 'macros/cart_icon.html' import cart_icon %}
{{ cart_icon(count=cart_count|default(0), oob='true') }}
<div id="ticket-buy-{{ entry.id }}" class="rounded-xl border border-emerald-200 bg-emerald-50 p-4">
<div class="flex items-center gap-2 mb-3">