<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org"
    th:with="theme=${CookieUtils.getCookieValue(request, 'theme')}"
    th:class="${#arrays.contains({'dark', 'bright', 'auto'}, theme) ? theme : 'auto'}">
<head th:replace="~{blog/bleaching/header::head-fragment}"></head>
<body>
    <div class="side-click-mask"></div>
    <div th:replace="~{blog/bleaching/header::header}"></div>
    <div class="move-block">
        <div class="main-and-side">
            <main>
                <article class="post">
                    <div class="archives" th:with="
                    posts=${@postService.getLatestPosts(null)},
                    cates=${@metaService.listMetaCount(MetaTypeEnum.CATEGORY, null)},
                    tags=${@metaService.listMetaCount(MetaTypeEnum.TAG, null, PostTypeEnum.POST)}">
                        
                        <div class="archive-header">
                            <span class="widget-title">
                            Timeline
                            </span>
                        </div>
                        
                        <th:block th:switch="${posts == null || posts.size() == 0}">
                            
                            <header th:case="true">
                                <div class="post-content">啊这，这个人还没有任何公开文章<br/>Oops, there's no any released post yet.
                                </div>
                            </header>
                            <th:block th:case="false">
                                <th:block th:each="post, i : ${posts}">
                                    <th:block th:with="postYear=${post.createTime.year}">
                                        <th:block th:if="${i.first or postYear != posts[i.index - 1].createTime.year}" >
                                            <div class="year" th:with="year=${postYear}" th:text="${postYear}"></div>
                                            <th:block th:utext="'<ul class=\'archives-timeline-year\'>'"></th:block>
                                        </th:block>
                                        <li>
                                            <table><tbody><tr><td>
                                            <span th:text="${#temporals.format(post.createTime, 'MM/dd')}"></span></td>
                                            <td>
                                                <th:block th:with="
                                                    passwordCorrect=${PostPassJar.validFromSession(request.session, post)},
                                                    title=${passwordCorrect ? post.postTitle : ('加密文章' + post.postId)}">
                                                    
                                                    <th:block th:if="${!passwordCorrect}">
                                                        <a th:href="@{${post.link}}" th:attr="title=${title}">[[${title}]]</a>
                                                        <span class="comment-count" style="float: right">🔒</span>
                                                    </th:block>
                                                    <th:block th:if="${passwordCorrect}">
                                                        <a th:href="@{${post.link}}" th:attr="title=${title}">[[${title}]]</a>
                                                        <a th:if="${post.commentCount > 0}" th:href="@{${post.link + '#comment-page'}}" class="comment-count" th:title="${post.commentCount + '条评论'}" style="float: right">[[${post.commentCount}]]</a>
                                                    </th:block>
                                                    
                                                </th:block>
                                            </td>
                                            </tr></tbody></table>
                                        </li>
                                        <th:block th:if="${i.last or postYear != posts[i.index + 1].createTime.year}" th:utext="'</ul>'"></th:block>
                                    </th:block>
                                </th:block>
                            </th:block>
                        </th:block>
                        
                        <th:block th:switch="${(cates == null || cates.size() == 0) and (tags == null || tags.size() == 0)}">
                            <th:block th:case="true">
                            </th:block>
                            <th:block th:case="false">
                                <ul class="archives-cates">
                                    <th:block th:each="cate : ${cates}">
                                        <li>
                                            <a class="widget-cate" rel="cate" th:href="@{'/category/' + ${cate.urlEncodedFriendlyName}}">
                                                <th:block th:text="${cate.name}"></th:block>
                                                <span th:text="${cate.postCount}"></span>
                                            </a>
                                        </li>
                                    </th:block>
                                </ul>
                                <ul class="archives-tags">
                                    <th:block th:each="tag, i : ${tags}">
                                        <li>
                                            <a 
                                            th:classappend="'macaron-tag-' + ${i.index % 8}"
                                            class="widget-tag" rel="tag" th:href="@{'/tag/' + ${tag.urlEncodedFriendlyName}}">
                                                <th:block th:text="${'#'+tag.name}"></th:block>
                                                <span th:text="${tag.postCount}"></span>
                                            </a>
                                        </li>
                                    </th:block>
                                </ul>
                            </th:block>
                        </th:block>
                        
                    </div>
                </article>
                <footer th:replace="~{blog/bleaching/footer::footer}"></footer>
            </main>
            <div th:replace="~{blog/bleaching/header::sidebar-container}"></div>
        </div>
    </div>
</body>
</html>