<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org"
      xmlns:layout="http://www.ultraq.net.nz/thymeleaf/layout"
      layout:decorate="~{layout/default_layout}">

<th:block layout:fragment="content">
    <section class="wrapper style1">
        <div class="container">
            <header class="major">
                <h2 th:text="${pageTitle}">게시물 수정 히스토리</h2>
                <p><strong>원본글 ID:</strong> <span th:text="${currentPost.id}"></span></p>
            </header>

            <div class="box">
                <h4>현재 버전</h4>
                <p><strong>수정일:</strong> <span th:text="${#dates.format(currentPost.modifyTime, 'yyyy-MM-dd HH:mm')}"></span></p>
                <a th:href="@{/blog/viewer/{postId}(postId=${currentPost.id})}" class="button small">현재 글 보기</a>
                <a th:href="@{/blog/edit/{postId}(postId=${currentPost.id})}" class="button small alt">현재 글 수정</a>
            </div>

            <div class="box" style="margin-top: 2em;">
                <h4>과거 버전 (히스토리)</h4>
                <div class="table-wrapper">
                    <table>
                        <thead>
                        <tr>
                            <th>보관된 시간</th>
                            <th>제목</th>
                            <th>작성자</th>
                            <th>상태</th>
                            <th>관리</th>
                        </tr>
                        </thead>
                        <tbody>
                        <tr th:each="h : ${historyList}">
                            <td th:text="${#dates.format(h.archivedAt, 'yyyy-MM-dd HH:mm:ss')}"></td>
                            <td th:text="${h.title}"></td>
                            <td th:text="${h.writer}"></td>
                            <td>
                                <span th:if="${h.posting}" class="tag-item" style="background: #a8dadc;">공개</span>
                                <span th:unless="${h.posting}" class="tag-item" style="background: #f1faee;">비공개</span>
                            </td>
                            <td>
                                <a href="#" class="button small primary">내용 보기</a>
                                <a href="#" class="button small alt">이 버전으로 복구</a>
                            </td>
                        </tr>
                        <tr th:if="${#lists.isEmpty(historyList)}">
                            <td colspan="5" style="text-align: center;">저장된 히스토리가 없습니다.</td>
                        </tr>
                        </tbody>
                    </table>
                </div>
            </div>
        </div>
    </section>
</th:block>
</html>