{#
Shared template macros.
Import at the top of any template that needs them:
{% from "_macros.html" import icon, brandlink, mark %}
#}
{# An icon from the inlined sprite. `name` omits the "i-" prefix. #}
{% macro icon(name, cls="") -%}
{%- endmacro %}
{#
The leaf-and-wafer mark, inlined rather than referenced as so it can
scale with the surrounding font size. Gradient ids are suffixed with `uid`
because ids are document-global: two marks on one page with the same ids
means the second silently reuses the first one's gradients.
#}
{#
An uploaded logo replaces it, the same way `model_avatar` branches. The branch
is inside the macro rather than at each of the six call sites, so a logo
reaches the sidebar, the sign-in page, the offline page and every empty state
at once -- and so the one place that has to know the fallback exists is here.
`brand` is a Jinja global, so it is available inside a macro with nothing
passed in. That is the whole reason it is a global: a macro has no context.
#}
{% macro mark(cls="brand-mark", uid="a") -%}
{% if brand.logo_path %}
{% else %}
{% endif %}
{%- endmacro %}
{#
The wordmark as live text rather than the outlined SVG: it stays selectable,
searchable and readable to a screen reader, and scales with the user's font
size.
The accent on the capitals spelling LLM is only meaningful for the shipped
name, so it is applied only when the name *is* the shipped one. Guessing which
letters of somebody else's name to highlight would produce "InTernal AI" —
worse than plain text, and worse in a way nobody would think to look for.
#}
{% macro wordmark() -%}
{% if brand.name == "LLeMbas" %}
LLeMbas
{%- else -%}
{{ brand.name }}
{%- endif %}
{%- endmacro %}
{#
A model's avatar: the uploaded image, or a generated initial.
The fallback colour is derived from the model id, so every model gets a
stable, distinct-looking badge without an administrator having to upload
anything. Hue only -- saturation and lightness are fixed so the result always
sits legibly against both themes.
#}
{% macro model_avatar(model, cls="model-avatar") -%}
{% if model.image_path %}
{% else %}
{{ model.initial }}
{% endif %}
{%- endmacro %}
{#
The brand link in a sidebar. Named `brandlink` and not `brand`, because
`brand` is the Jinja global holding this instance's identity -- and a macro
imported under that name shadows it for the whole template, which took out
every page that imports this one at once.
#}
{% macro brandlink(href="/", uid="a") -%}
{{ mark(uid=uid) }}
{{ wordmark() }}
{%- endmacro %}