{#- What the bar's search suggests as one types: the first matches of each kind, the words found marked, where each is; what is elsewhere than the community searched, in one line; all the results and the keys at the foot. On an empty field, what one searched and opened lately, or nothing. A piece of a page: the bar's script (`vite/src/suggest.js`) puts it under the field, and moves among the options. Drawn in `mockups/templates/search-suggest.html` and `search-recent.html`. -#} {% import "ads_macros.html" as m with context %} {% set results_url = url_for("search.search_main", q=q, community=scope or none) %} {% set opened = [] if q else recently_opened(user) %} {#- On an empty field with nothing searched or opened yet, nothing: the script opens no panel. -#} {% if q or recent_searches or opened %}
{#- The options in the listbox, which the arrows move through; the foot after it. -#}
{% if not q %} {% if recent_searches %}
{% for search in recent_searches %} {{ icon("history") }}{{ search }} {% endfor %}
{% endif %} {% if opened %}
{% for entity in opened %} {% set kind = entity.__class__.__name__ %} {% if kind == "Document" %}{{ file_icon(entity.name) }}{% else %}{{ icon({"Thread": "messages", "WikiPage": "book"}.get(kind, "file-text")) }}{% endif %} {{ entity.name }}{{ entity.community.name }} {% endfor %}
{% endif %}
{{ _("Type to search everywhere") }}
{% else %} {% for label, kind, hits in groups %}
{% for hit in hits %} {% set href = url_for_hit(hit) %} {% if href %} {% set community = communities.get(hit.get("community_id")) %} {% if kind == "Document" %}{{ file_icon(hit["name"]) }} {% elif kind == "Folder" %}{{ folder_icon() }} {% else %}{{ icon({"Thread": "messages", "WikiPage": "book", "User": "user", "Community": "users"}.get(kind, "file-text")) }}{% endif %} {{ hit.highlights("name") | safe or hit["name"] }} {% if community or hit.get("updated_at") %}{{ community.name if community }}{% if community and hit.get("updated_at") %} · {% endif %}{% if hit.get("updated_at") %}{{ m.time(hit["updated_at"]) }}{% endif %}{% endif %} {% endif %} {% endfor %}
{% else %}

{{ _("Nothing matches “%(q)s”.", q=q) }}

{% endfor %} {% if elsewhere %} {{ icon("world") }}{{ ngettext("%(num)d result in your other communities", "%(num)d results in your other communities", elsewhere) }}{{ icon("chevron-right") }} {% endif %}
{{ icon("search") }}{{ _("All the results for “%(q)s”", q=q) }}{% if total %} ({{ total }}){% endif %}
{% endif %} {% endif %}