{% load static %}
{% load i18n %}
{% load admin_url %}
<form method="get" action="{% url 'catalog:search' %}">
<section id="navbar">
    <nav class="navbar">
        <div class="grid">
            <div class="navbar__wrapper">
                <a href="{% url 'common:home' %}" class="navbar__logo">
                    <img src="{% static 'img/logo.svg' %}" alt="" class="navbar__logo-img">
                </a>
                <div class="navbar__search-box">
                    <!-- <input type="search" class="" name="q" id="searchInput" required="true" value="{% for v in request.GET.values %}{{ v }}{% endfor %}" -->
                    <input type="search" class="" name="q" id="searchInput" required="true" value="{% if request.GET.q %}{{ request.GET.q }}{% endif %}"
                        placeholder="搜索书影音游戏播客，或输入站外条目链接如 https://movie.douban.com/subject/1297880/ 支持站点列表见页底公告栏">
                    <select class="navbar__search-dropdown" id="searchCategory" name="c">
                        <option value="all" {% if request.GET.c and request.GET.c == 'all' or not request.GET.c %}selected{% endif %}>{% trans '任意' %}</option>
                        <option value="book" {% if request.GET.c and request.GET.c == 'book' or '/books/' in request.path %}selected{% endif %}>{% trans '书籍' %}</option>
                        <option value="movie" {% if request.GET.c and request.GET.c == 'movie' or '/movies/' in request.path  %}selected{% endif %}>{% trans '电影' %}</option>
                        <option value="tv" {% if request.GET.c and request.GET.c == 'tv' or '/tv/' in request.path  %}selected{% endif %}>{% trans '剧集' %}</option>
                        <option value="music" {% if request.GET.c and request.GET.c == 'music' or '/music/' in request.path  %}selected{% endif %}>{% trans '音乐' %}</option>
                        <option value="game" {% if request.GET.c and request.GET.c == 'game' or '/games/' in request.path  %}selected{% endif %}>{% trans '游戏' %}</option>
                        <option value="podcast" {% if request.GET.c and request.GET.c == 'podcast' or '/podcast/' in request.path  %}selected{% endif %}>{% trans '播客' %}</option>

                    </select>
                </div>
                <button class="navbar__dropdown-btn">• • •</button>
                <ul class="navbar__link-list">

                    {% if request.user.is_authenticated %}

                        <a class="navbar__link {% if current == 'home' %}current{% endif %}" href="{% url 'journal:user_profile' request.user.mastodon_username %}">{% trans '主页' %}</a>
                        <a class="navbar__link {% if current == 'timeline' %}current{% endif %}" href="{% url 'social:feed' %}">{% trans '动态' %}</a>
                        <a class="navbar__link {% if current == 'data' %}current{% endif %}" href="{% url 'users:data' %}">{% trans '数据' %}</a>
                        <a class="navbar__link {% if current == 'preferences' %}current{% endif %}" href="{% url 'users:preferences' %}">{% trans '设置' %}</a>
                        <a class="navbar__link" id="logoutLink" href="{% url 'users:logout' %}">{% trans '登出' %}</a>
                        {% if request.user.is_superuser %}
                        <a class="navbar__link" href="{% admin_url %}">{% trans '后台' %}</a>
                        {% endif %}

                    {% else %}
                        <a class="navbar__link" href="{% url 'users:login' %}?next={{ request.path }}">{% trans '登录' %}</a>
                    {% endif %}
                </ul>
            </div>

        </div>
    </nav>
</section>
</form>

{% if messages %}
<div class="main-section-wrapper" style="margin-bottom: 10px; text-align:center;">
    <ul class="messages">
        {% for message in messages %}
        <li{% if message.tags %} class="{{ message.tags }}"{% endif %}>{{ message }}</li>
        {% endfor %}
    </ul>
</div>
{% endif %}
