<!DOCTYPE html>
<html xmlns:th="https://www.thymeleaf.org"
    th:replace="~{modules/layouts/layout :: layout(_head = null,_content = ~{::content},_title = ${title + ' - ' + site.title})}">

<th:block th:fragment="content">

    <div class="page_main uk-width-2-3@m">

        <th:block th:replace="~{modules/header}" />

        <div id="pjax-container" th:with="
            page = ${#lists.isEmpty(param.page) or #strings.isEmpty(param.page[0]) ? 1 : param.page[0]},
            selectedTag = ${#lists.isEmpty(param.tag) ? null : param.tag[0]},
            doubanPage = ${doubanFinder.list(page, 10, selectedTag, null)}
        ">

            <div class="blog_list douban_page">
                <div class="blog_list_inner" uk-height-viewport="offset-top: true">

                    <div class="friends_cat_nav douban_cat_nav">
                        <ul id="cat_nav_items">
                            <li>
                                <a th:attr="data-href=@{/books}"
                                    th:classappend="${#strings.isEmpty(selectedTag) ? 'active' : ''}"
                                    class="cat-link">
                                    全部<span></span>
                                </a>
                            </li>
                            <li th:each="type : ${types}">
                                <a th:attr="data-href=@{/books(tag=${type.key})}"
                                    th:classappend="${#strings.equals(selectedTag, type.key) ? 'active' : ''}"
                                    class="cat-link">
                                    <span th:text="${#strings.isEmpty(type.name) ? type.key : type.name}">类型</span>
                                </a>
                            </li>
                        </ul>
                    </div>

                    <div id="post_item" class="moment_list douban_list">
                        <th:block th:each="doubanItem : ${doubanPage.items}">
                            <th:block th:replace="~{macro/douban-item :: douban-item(${doubanItem})}"></th:block>
                        </th:block>

                        <th:block th:if="${#lists.isEmpty(doubanPage.items)}">
                            <th:block th:replace="~{macro/tpl/content-none}" />
                        </th:block>

                    </div>

                    <th:block th:if="${doubanPage.totalPages > 1}">
                        <div id="t_pagination">
                            <div class="post-paging" th:with="_page = ${doubanPage.page + 1}">
                                <a th:if="${doubanPage.hasNext() and #strings.isEmpty(selectedTag)}"
                                    th:attr="data=@{/books(page=${_page})}"
                                    th:text="${theme.config.base_set.site_page}"></a>
                                <a th:if="${doubanPage.hasNext() and not #strings.isEmpty(selectedTag)}"
                                    th:attr="data=@{/books(tag=${selectedTag},page=${_page})}"
                                    th:text="${theme.config.base_set.site_page}"></a>
                                <form class="page-jump-form" method="get" action="/books">
                                    <span class="page-jump-label">转到</span>
                                    <input th:if="${not #strings.isEmpty(selectedTag)}" type="hidden" name="tag"
                                        th:value="${selectedTag}" />
                                    <span class="page-jump-input-wrap">
                                        <button class="page-jump-step page-jump-step-down" type="button"
                                            title="减少页码" aria-label="减少页码">
                                            <i class="ri-subtract-line" aria-hidden="true"></i>
                                        </button>
                                        <input class="page-jump-input" type="number" name="page" min="1"
                                            th:max="${doubanPage.totalPages}" th:value="${doubanPage.page}"
                                            inputmode="numeric" aria-label="页码" autocomplete="off" required />
                                        <button class="page-jump-step page-jump-step-up" type="button"
                                            title="增加页码" aria-label="增加页码">
                                            <i class="ri-add-line" aria-hidden="true"></i>
                                        </button>
                                    </span>
                                    <span class="page-jump-total">/ [[${doubanPage.totalPages}]]</span>
                                    <button class="page-jump-submit" type="submit" title="跳转到指定页"
                                        aria-label="跳转到指定页">
                                        <i class="ri-arrow-right-line" aria-hidden="true"></i>
                                    </button>
                                </form>

                            </div>
                        </div>
                    </th:block>

                    <div id="comment_form_reset"></div>

                </div>
            </div>

        </div>

        <th:block th:replace="~{modules/footer-main}" />

    </div>
</th:block>

</html>
