misuzu/templates/home/search.twig

129 lines
5.5 KiB
Twig
Raw Normal View History

2022-09-13 13:14:49 +00:00
{% extends 'home/master.twig' %}
{% from 'macros.twig' import container_title %}
{% from '_layout/input.twig' import input_text %}
{% from 'user/macros.twig' import user_card %}
{% from 'forum/macros.twig' import forum_topic_listing, forum_post_listing %}
{% from 'news/macros.twig' import news_preview %}
{% set title = search_query|length < 1 ? 'Search' : 'Looking for ' ~ search_query %}
{% set canonical_url = url('search-query', {'query': search_query}) %}
{% block content %}
<div class="search__header">
<form class="search__input" method="get" action="{{ url('search-index') }}">
<div class="search__input__background"></div>
<div class="search__input__container">
{{ input_text('q', 'search__input__text', search_query, 'text', 'What are you looking for?', false, null, 1, true, true) }}
<button class="search__input__button" tabindex="2"><i class="fas fa-search fa-fw"></i></button>
</div>
</form>
{% if forum_topics|length > 0 or forum_posts|length > 0 or users|length > 0 or news_posts|length > 0 %}
<div class="search__categories">
{% if forum_topics|length > 0 %}
<a href="#topics" class="search__category">
<div class="search__category__background"></div>
<div class="search__category__content">
2023-08-28 01:17:34 +00:00
Topics
2022-09-13 13:14:49 +00:00
</div>
</a>
{% endif %}
{% if forum_posts|length > 0 %}
<a href="#posts" class="search__category">
<div class="search__category__background"></div>
<div class="search__category__content">
2023-08-28 01:17:34 +00:00
Posts
2022-09-13 13:14:49 +00:00
</div>
</a>
{% endif %}
{% if users|length > 0 %}
<a href="#users" class="search__category">
<div class="search__category__background"></div>
<div class="search__category__content">
2023-08-28 01:17:34 +00:00
Members
2022-09-13 13:14:49 +00:00
</div>
</a>
{% endif %}
{% if news_posts|length > 0 %}
<a href="#news" class="search__category">
<div class="search__category__background"></div>
<div class="search__category__content">
2023-08-28 01:17:34 +00:00
News
2022-09-13 13:14:49 +00:00
</div>
</a>
{% endif %}
</div>
{% endif %}
</div>
{% if search_query is not empty and not (
forum_topics|length > 0 or forum_posts|length > 0 or users|length > 0 or news_posts|length > 0
) %}
<div class="container search__container search__none">
<div class="search__none__icon">
<i class="fas fa-search-minus fa-fw"></i>
</div>
<div class="search__none__content">
<div class="search__none__title">
Nothing found!
</div>
<div class="search__none__details">
No results found using that query, try something else!
</div>
</div>
</div>
{% endif %}
{% if forum_topics|length > 0 %}
<div class="search__anchor" id="topics"></div>
{{ forum_topic_listing(forum_topics, 'Topics (%d)'|format(forum_topics|length)) }}
2023-08-28 01:17:34 +00:00
{% if forum_topics|length >= 20 %}
<div style="text-align: center; padding: 10px;">
<a href="{{ url('search-query', {'section': 'topics', 'query': search_merge_query({'type': 'forum:topic', 'after': forum_topics|last.info.id})}) }}" class="input__button">Load next 20 topics...</a>
</div>
{% endif %}
2022-09-13 13:14:49 +00:00
{% endif %}
{% if forum_posts|length > 0 %}
<div class="search__anchor" id="posts"></div>
<div class="container search__container">
{{ container_title('<i class="fas fa-comment fa-fw"></i> Posts (%s)'|format(forum_posts|length|number_format)) }}
{{ forum_post_listing(forum_posts) }}
</div>
2023-08-28 01:17:34 +00:00
{% if forum_posts|length >= 20 %}
<div style="text-align: center; padding: 10px;">
<a href="{{ url('search-query', {'section': 'posts', 'query': search_merge_query({'type': 'forum:post', 'after': forum_posts|last.info.id})}) }}" class="input__button">Load next 20 posts...</a>
</div>
{% endif %}
2022-09-13 13:14:49 +00:00
{% endif %}
{% if users|length > 0 %}
<div class="search__anchor" id="users"></div>
<div class="container search__container">
2023-08-28 01:17:34 +00:00
{{ container_title('<i class="fas fa-users fa-fw"></i> Members (%s)'|format(users|length|number_format)) }}
2022-09-13 13:14:49 +00:00
2023-07-19 18:14:04 +00:00
<div class="userlist userlist--search">
2022-09-13 13:14:49 +00:00
{% for user in users %}
<div class="userlist__item">
{{ user_card(user) }}
</div>
{% endfor %}
</div>
</div>
{% endif %}
{% if news_posts|length > 0 %}
<div class="search__anchor" id="news"></div>
<div class="container search__container">
{{ container_title('<i class="fas fa-newspaper fa-fw"></i> News (%s)'|format(news_posts|length|number_format)) }}
{% for post in news_posts %}
{{ news_preview(post, true) }}
2022-09-13 13:14:49 +00:00
{% endfor %}
</div>
{% endif %}
{% endblock %}