{% extends 'stdgrid.html.twig' %}
{% import '/cards/note/view.html.twig' as noteView %}

{% block title %}{% if page_title is defined %}{{ page_title | trans }}{% endif %}{% endblock %}

{% block stylesheets %}
    {{ parent() }}
    <link rel="stylesheet" href="{{ asset('assets/default_theme/css/pages/feeds.css') }}" type="text/css">
{% endblock stylesheets %}

{% block body %}
    {% if error is defined %}
        <label class="alert alert-danger">
            {{ error.getMessage() }}
        </label>
    {% endif %}

    <div class="section-widget-padded">
        {{ form_start(search_form) }}
        <div>
            {{ form_row(search_form.search_query) }}
            {{ form_row(search_form.submit_search) }}
        </div>
        <details class="section-widget">
            <summary>
                <h3>
                    {% trans %}Save this search as a feed{% endtrans %}
                    {{ icon('arrow-down', 'icon icon-details-open') | raw }}
                </h3>
            </summary>
            {{ form_row(search_form.title) }}
            {{ form_row(search_form.subscribe_to_search) }}
        </details>
        {{ form_end(search_form)}}
        <hr>
        <details class="section-widget">
            <summary>
                <h3>
                    {% trans %}Build a search query{% endtrans %}
                    {{ icon('arrow-down', 'icon icon-details-open') | raw }}
                </h3>
            </summary>

            {{ form_start(search_builder_form) }}

            {# actor options, display if first checked, with checkbox trick #}
            <details class="section-widget">
                <summary>
                    <h3>
                        {% trans %}People search options{% endtrans %}
                        {{ icon('arrow-down', 'icon icon-details-open') | raw }}
                    </h3>
                </summary>
                {{ form_row(search_builder_form.include_actors) }}
                {{ form_row(search_builder_form.include_actors_people) }}
                {{ form_row(search_builder_form.include_actors_groups) }}
                {{ form_row(search_builder_form.include_actors_lists) }}
                {{ form_row(search_builder_form.include_actors_businesses) }}
                {{ form_row(search_builder_form.include_actors_organizations) }}
                {{ form_row(search_builder_form.include_actors_bots) }}
                {{ form_row(search_builder_form.actor_langs) }}
                {{ form_row(search_builder_form.actor_tags) }}
            </details>

            <details class="section-widget">
                <summary>
                    <h3>
                        {% trans %}Note search options{% endtrans %}
                        {{ icon('arrow-down', 'icon icon-details-open') | raw }}
                    </h3>
                </summary>
                {{ form_row(search_builder_form.include_notes) }}
                {{ form_row(search_builder_form.include_notes_text) }}
                {{ form_row(search_builder_form.include_notes_media) }}
                {{ form_row(search_builder_form.include_notes_polls) }}
                {{ form_row(search_builder_form.include_notes_bookmarks) }}
                {{ form_row(search_builder_form.note_langs) }}
                {{ form_row(search_builder_form.note_tags) }}
                {{ form_row(search_builder_form.note_actor_langs) }}
                {{ form_row(search_builder_form.note_actor_tags) }}
            </details>
            {{ form_end(search_builder_form) }}
        </details>
        <hr>
    </div>

    {# Backwards compatibility with hAtom 0.1 #}
    <main class="feed" tabindex="0" role="feed">
        <div class="h-feed hfeed notes">
            {% if notes is defined and notes is not empty %}
                {% for note in notes %}
                    {% block current_note %} 
                        <div class="section-widget">
                            {{ noteView.macro_note(note['note'], []) }}
                        </div>
                    {% endblock current_note %} 
                {% endfor %}
            {% else %}
                <div id="empty-notes"><h1>{% trans %}No notes here.{% endtrans %}</h1></div>
            {% endif %}
        </div>
    </main>

    {% for actor in actors %}
        {% include 'cards/profile/view.html.twig' with {'actor': actor} %}
    {% endfor %}

    {{ "Page: " ~ page }}
{% endblock body %}