{#- Pieces the pages on the Abilian Design System share. The mockups in `mockups/` draw them first; `notes/ux/design-principles.md` says why they look so. -#} {#- A person: their photo, or else their initials on a tint of their colour; their name on hover and for screen readers. `has_photo` is asked with the person, the photo itself only by the browser. -#} {% macro avatar(user, size_class="ads-avatar--sm") -%} {%- if user.has_photo %}{% else %}{{ initials(user.name) }}{% endif -%} {%- endmacro %} {#- A community: its image, or else its initial on its colour. Squares for places, circles for people. Without `image` for who is not a member, whom the image's address, inside the community, refuses. -#} {% macro tile(community, size_class="", image=true) -%} {%- endmacro %} {#- A moment: how long ago, the exact date on hover. -#} {% macro time(moment) -%} {%- endmacro %} {#- A file in a feed entry or a post: its name, its size, a link. -#} {% macro file(f) -%}
{{ file_icon(f.name or "") }} {{ f.name }} {{ f.size | filesize }}
{%- endmacro %} {#- What a person does, and where, as one line: "Treasurer, Acme"; either alone; or nothing. -#} {% macro job(user) -%} {{ [user.job_title, user.organization] | select | join(", ") }} {%- endmacro %} {#- Where to start a discussion, at the top of a feed: in `community`, with an event beside it, or, from Mon fil, in one of `communities`, chosen in a menu. Either opens the new thread's form. A tool turned off in a community is not offered. -#} {% macro composer(community=none, communities=()) %} {% if not community or community.has_forum or community.has_calendar %}
{{ avatar(current_user) }} {% if community %} {% if community.has_forum %}{{ _("Start a discussion in %(name)s…", name=community.name) }}{% endif %} {% if community.has_calendar %}{{ icon("calendar-plus") }}{{ _("Event") }}{% endif %} {% else %}
{{ _("Start a discussion in one of my communities…") }}
{{ start_in(communities) }}
{% endif %}
{% endif %} {% endmacro %} {#- A menu's list of `communities` to start a discussion in, each opening its form: those that have discussions. -#} {% macro start_in(communities) %}

{{ _("Start a discussion in…") }}

{% for c in communities | selectattr("has_forum") %} {{ tile(c, "sbe-tile--sm") }}{{ c.name }} {% else %}

{{ _("None of your communities has discussions.") if communities else _("You are not a member of any community yet.") }}

{% endfor %} {% endmacro %} {#- An entry of a feed (`abilian.sbe.apps.main.feed.FeedItem`): who did what, where and when, marked if `new`, then the thing itself. -#} {% macro feed_entry(item, show_community=true, new=false) %}
{{ avatar(item.actor) }}
{{ item.actor.name }} {{ item.action }} {%- if show_community and item.community %}{{ tile(item.community, "sbe-tile--sm") }}{{ item.community.name }} ·{% endif %} {% if item.section %}{{ item.section }} · {% endif %}{{ time(item.happened_at) }}
{% if new %}{{ _("New") }}{% endif %}
{% if item.title %}

{{ item.title }}

{% endif %} {% if item.excerpt %}

{{ item.excerpt }}

{% endif %} {% for f in item.files %}{{ file(f) }}{% endfor %}
{% endmacro %} {#- A community in a menu or a list: its tile and name; the one I am in, marked. -#} {% macro community_item(community, here=false, new=0) -%} {{ tile(community, "sbe-tile--sm") }}{{ community.name }}{% if here %}{{ _("here") }}{% elif new %}{{ new_badge(new) }}{% endif %} {%- endmacro %} {#- How many things are new: up to 99, then "99+"; the exact number said to screen readers. -#} {% macro new_badge(count) -%} {{ ngettext("%(num)d new", "%(num)d new", count) }} {%- endmacro %} {#- A thread as a row: the title, in bold with its count of new posts when some are unread; who started it and when, how many took part; replies; the last post. -#} {% macro thread_row(thread, new=0) %} {% set last = thread.posts[-1] %}
{% if new %}{{ thread.title }}{% else %}{{ thread.title }}{% endif %} {%- if new %} {{ ngettext("%(num)d new", "%(num)d new", new) }}{% endif %} {{- avatar(thread.creator, "ads-avatar--xs") }} {{ time(thread.created_at) }} · {{ ngettext("%(num)d participant", "%(num)d participants", thread.posts | map(attribute="creator") | unique | list | length) }} {%- if thread.closed %} · {{ icon("lock") }}{{ _("closed") }}{% endif %}
{{ thread.posts | length - 1 }} {{ avatar(last.creator, "ads-avatar--xs") }}{{ time(thread.last_post_at or thread.created_at) }} {% endmacro %} {#- A column a `abilian.web.listing.Listing` sorts by: a link that sorts by it, ascending first; the header says which way it is sorted. -#} {% macro sort_th(listing, key, label, class="") -%} {{ label }} {%- endmacro %} {#- The pages of a `Listing`, when there is more than one. -#} {% macro pagination(listing) %} {% if listing.pages > 1 %} {% endif %} {% endmacro %} {#- What the last action said (`flash()`): errors and warnings as alerts, the rest as a status, each in its tone. They go with the next page. `class` places the whole, when there is something to say. -#} {% macro flashes(class="") %} {% with messages = get_flashed_messages(with_categories=true) %} {% if messages %}
{% for category, message in messages %} {% set tone, glyph = {"error": ("ads-tone-danger", "alert-triangle"), "danger": ("ads-tone-danger", "alert-triangle"), "warning": ("ads-tone-warning", "alert-triangle"), "success": ("ads-tone-success", "circle-check")}.get(category, ("ads-tone-info", "info-circle")) %}
{{ icon(glyph) }}{{ message }} {#- Shown by `behaviors.js`, which makes it work: without it, no button that does nothing. -#}
{% endfor %}
{% endif %} {% endwith %} {% endmacro %} {#- A form's files (a wiki page's, an event's), applied when it is saved (`documents/form_files.py`): those it has, each to keep or, ticked, to remove, with no script; and a field for new ones. The form posts multipart. -#} {% macro files_field(attachments) %}
{% if attachments %} {% endif %}
{% endmacro %}