<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
    <head th:replace="~{admin/include::head}">
    </head>
    <link rel="stylesheet" th:href="@{/admin/layuiadmin/style/admin.css}" media="all"/>

<body style="background-color: #f2f2f2">
    <ul th:replace="~{admin/include::nav}">
    </ul>   
    <div class="manage-body layui-row">
        <div class="layui-col-md12">
            <div class="layui-card-header">网站概要</div>
            <div class="layui-card-body">
                <p class="overview">目前有
                <em th:text="${@statisticsService.totalReleasedPostsCount()}">0</em>
                篇已发布文章, 并有
                <em th:text="${@statisticsService.totalCommentsCount(
                    CommentStatusEnum.RELEASED
                )}">0</em>
                条已审核评论.</p>
                <ul id="start-link" class="clearfix">
                    <li><a th:href="@{/admin/v2/tweet/edit}">撰写新说说</a></li>
                    <li><a th:href="@{/admin/v2/post/edit}">撰写新文章</a></li>
                    <li><a th:href="@{/admin/v2/comment#WAITING}">待审评论</a>
                        <th:block th:with="waitingCount=${@statisticsService.totalCommentsCount(
                            CommentStatusEnum.WAITING)}">
                            <span th:if="${waitingCount > 0}" th:text="${waitingCount}" class="layui-badge">0</span>
                        </th:block>
                    </li>
                    <li><a th:href="@{/admin/v2/themes}">更换外观</a></li>
                    <li><a href="#">插件管理</a></li>
                    <li><a th:href="@{/admin/v2/config/site}">站点设置</a></li>
                </ul>
            </div>
        </div>
        
        <div class="layui-col-md6">
            <div class="layui-card-header">最新发布文章</div>
            <div class="layui-card-body">
                <ul class="start-list">
                    <th:block th:with="newPosts = ${@postService.getLatestPosts(10L)}">
                        <th:block th:each="post : ${newPosts}">
                            <li>
                                <span th:text="${#temporals.format(post.createTime, 'MM/dd')}">
                                </span>
                                <a th:href="${post.link}" th:text="${post.postTitle}">
                                </a>
                            </li>
                        </th:block>
                    </th:block>
                </ul>
                    
            </div>
        </div>
        
        <div class="layui-col-md6">
            <div class="layui-card-header">最近得到回复</div>
            <div class="layui-card-body">
                <ul class="start-list">
                    <th:block th:with="newComments = ${@commentService.getLatestComments(10L)}">
                        <th:block th:each="comment : ${newComments}">
                            <li>
                                <span th:text="${#temporals.format(comment.createTime, 'MM/dd')}">
                                </span>
                                <a th:href="${'/admin/v2/comment/jumpTo?id='+comment.id}"
                                    th:text="${@markdownService.getCommentContentText(comment)}">
                                </a>
                            </li>
                        </th:block>
                    </th:block>
                </ul>
                    
            </div>
        </div>
    </div>
    <th:block th:replace="~{admin/include::head-script}"></th:block>
        <div th:replace="~{admin/include::feet}"></div>
    <script>
        let base = document.querySelector('meta[name="base"]').getAttribute('content')
        layui.config({
          base: base + 'admin/layuiadmin/' //静态资源所在路径
        }).extend({
          index: 'lib/index' //主入口模块
        }).use(['index', 'console']);
        
        </script>
</body>

</html>