{# The parts every page is built from. A page has no markup of its own for a card, a field, a source badge, a tag, a notice, the CSRF field or an action with a question before it. Imported "with context", so the CSRF field finds the session's token. #} {# A card with a heading. ``meta``: the small line beside it, ``group``: the group the script ticks within, ``actions``: the caller is asked twice, for "actions" beside the heading and for "body". #} {% macro card(title=None, meta=None, id=None, group=None, actions=False) %}
{% if title %}

{{ title }}

{% if meta %}{{ meta }}{% endif %}{% if actions %}{{ caller("actions") }}{% endif %}
{% endif %}
{{ caller("body") if actions else caller() }}
{% endmacro %} {# A card folded behind its heading, open when ``open`` says so. #} {% macro fold(title, meta=None, open=False, id=None) %}

{{ title }}

{% if meta %} {{ meta }}{% endif %}
{{ caller() }}
{% endmacro %} {# A remark in a box: ``ok``, ``warn`` or ``err``. #} {% macro notice(kind="warn") %}
{{ caller() }}
{% endmacro %} {# A small mark: ``accent``, ``ok``, ``warn``, ``err``, or plain. #} {% macro tag(text, kind="", title=None) %}{{ text }}{% endmacro %} {# Where a value came from, marked when the file lost. #} {% macro badge(badge) %}{{ tag("aus: " ~ badge.source, "warn" if badge.loud else "", badge.detail or None) }}{% endmacro %} {# The account a connection test found, and what else it learned. #} {% macro account(label, facts=()) %}{{ label }}{% for fact in facts %} ยท {{ fact }}{% endfor %}{% endmacro %} {# What a field's label says: the label, the variable's name beside it as ``code``, and where its value came from as ``source``. #} {% macro label_text(label, code=None, source=None) %}{{ label }}{% if code %} {{ code }}{% endif %}{% if source %} {{ badge(source) }}{% endif %}{% endmacro %} {# The hidden field every form that changes something carries. #} {% macro csrf_field() %}{% endmacro %} {# A labelled input. ``code``: the variable's name beside the label, ``source``: where its value came from, ``enter``: the value of the action button Enter in this field presses, where it is not the form's first. #} {% macro field(name, label, value="", type="text", placeholder="", hint=None, code=None, source=None, autocomplete=None, maxlength=None, enter=None) %}
{% if hint %}{{ hint }}{% endif %}
{% endmacro %} {# A choice of fixed values. ``options``: (value, text) pairs. #} {% macro choice(name, label, options, value="", code=None, source=None) %}
{% endmacro %} {# A value set where no form here reaches it, shown rather than offered. #} {% macro held(label, value, code=None, source=None, hint=None) %}
{{ label_text(label, code, source) }} {{ value }} {% if hint %}{{ hint }}{% endif %}
{% endmacro %} {# A form that is only a button, with a question before it when ``confirm`` says one. #} {% macro action(url, label, confirm=None, cls="", fields={}) %}
{{ csrf_field() }} {% for name, value in fields.items() %}{% endfor %} {{ label }} {% endmacro %}