<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
    <head th:replace="~{admin/include::head}">
    </head>
    <link rel="stylesheet" th:href="@{/blog/plugins/editormd/css/editormd.css}"/>
    <link rel="stylesheet" th:href="@{/admin/iconfont/iconfont.css}"/>
    <link rel="stylesheet" th:href="@{/admin/css/inputTag.css}" media="all">
    <style>
    #editorTab .layui-tab-content {
    padding: 15px 0 0 0;}
    </style>
    <body style="background-color: #f2f2f2">
        <ul th:replace="~{admin/include::nav}"></ul>
        
        <div class="manage-body">
            <div>
            <h2 class="manage-title"><b>[[${title==null?'新增文章':title}]]</b>
            <a th:if="${post != null}" class="operate" target="_blank" 
               th:href="@{${post.link}}" th:text="${post.link}" th:attr="title=${'浏览 ' + post.postTitle}"></a></h2>
            
            </div>
            <form class="layui-form layui-row layui-col-space10" lay-filter="editForm" method="post" th:action="${request.requestURI + (request.queryString==null?'':'?'+request.queryString)}">
                <div id="editArea" class="layui-col-sm9 layui-col-xs12 admin-row-space10">
                    <input class="layui-input input-bold" name="postTitle" lay-verify="required" placeholder="标题" autocomplete="off"
                    th:value="${post != null ? post.postTitle:''}"/>
                    <input class="layui-input" name="postPageName" placeholder="页面名称，可选"  
                        th:value="${post != null && post.postPageName != null ? post.postPageName: ''}" autocomplete="off"/>
                    
                    <div class="layui-tab layui-tab-brief" id="editorTab" lay-filter="editorTab">
                        <ul class="layui-tab-title">
                            <li class="layui-this" editor="blog-editormd">正文</li>
                            <li editor="blog-preface-editormd">前言</li>
                        </ul>
                        <div class="layui-tab-content">
                            <div class="form-group layui-tab-item layui-show" id="blog-editormd">
                                <textarea name="postContent" style="display:none;"
                                    th:utext="${post!=null && post.postContent !=null ? post.postContent : ''}"></textarea>
                            </div>
                            <div class="form-group layui-tab-item" id="blog-preface-editormd">
                                <textarea name="postPreface" style="display:none;"
                                    th:text="${post!=null && post.postPreface !=null ? post.postPreface : ''}"></textarea>
                            </div>
                        </div>
                    </div>
                    
                    <button type="button" class="layui-btn" lay-submit lay-filter="submitBtn" style="float: right;">提交</button>
                
                </div>
                <div class="layui-col-sm3 layui-col-xs12">
                    <div class="layui-tab layui-tab-brief" id="docTabBrief" lay-filter="docTabBrief">
                      <ul class="layui-tab-title">
                        <li class="layui-this">常规</li>
                        <li>附件 & 链接</li>
                      </ul>
                      <div class="layui-tab-content">
                        <div class="layui-tab-item layui-show admin-row-space10" th:with="hasPassword=${post != null and !#strings.isEmpty(post.password)}">
                            <div><b>发布时间</b></div>
                            <input type="text" class="layui-input" name="createTime" id="createTime" placeholder="yyyy-MM-dd HH:mm:ss" autocomplete="off"
                                th:value="${post!=null && post.createTime !=null? #temporals.format(post.createTime ,'yyyy-MM-dd HH:mm:ss'): ''}">
                            
                            <div>
                                <b>文章分类</b>
                                <a target="_blank" th:href="@{/admin/v2/category}">管理</a>
                                <a class="refresh-categories" href="#">刷新</a>
                            </div>
                            <div id="categoryTree" class="demo-tree-more"></div>
                            <div>
                                <table class="layui-table" id="categories" lay-filter="categories"></table>
                            </div>
                            <input type="hidden" name="categoriesId" th:value="${post != null && !#strings.isEmpty(post.categoriesId)?post.categoriesId:''}"/>
                            
                            <div><b>文章标签</b></div>
                            <div class="fairy-tag-container">
                                <input type="text" class="fairy-tag-input" id="tagsDisplay" autocomplete="off" placeholder="输入文章标签">
                                <input type="hidden" name="tagsName" autocomplete="off">
                            </div>
                            
                            <div><b>公开度</b></div>
                            <select name="postStatus" lay-verify="required">
                                <option value="RELEASED" th:selected="${post == null || post.postStatus.status == 0}">公开</option>
                                <option value="DRAFT" th:selected="${post != null && post.postStatus.status == 1}">草稿</option>
                                <option value="HIDDEN" th:selected="${post != null && post.postStatus.status == 2}">隐藏</option>
                                <option value="PRIVATE" th:selected="${post != null && post.postStatus.status == 3}">私密</option>
                            </select>
                            
                            <input type="text" tabindex=-1 class="outside-the-view" name="fakeUsername" autocomplete="username"/>
                            <input type="password" tabindex=-1 class="outside-the-view" name="fakePassword" autocomplete="new-password"/>
                            <div><b>文章密码(留空则不加密)</b></div>
                            <input class="layui-input" autocomplete="off" name="password" placeholder="输入文章密码"
                                th:value="${hasPassword? post.password : ''}"
                                th:attr="type=${hasPassword?'password':'text'}">
                            
                            <div><b>开启/关闭评论</b></div>
                            <input lay-filter="enableComment" type="checkbox"
                            th:checked="${post == null || post.enableComment}" lay-skin="switch" lay-text="开启评论|关闭评论">
                            <input type="hidden"
                            th:value="${post == null || post.enableComment}?'TRUE':'FALSE'"
                            name="enableComment">
                        </div>
                        
                        <div id="fileContext" class="layui-tab-item admin-row-space10">
                            <div class="layui-upload-drag" id="uploadFile">
                              <i class="layui-icon"></i>
                              <p>点击或拖拽上传文件</p>
                            </div>
                            
                            <div><b>文章关联文件</b><a class="file-list-question" href="#"><i class="fa fa-question-circle-o"></i></a></div>
                            <p style="color:rgba(0,0,0,.5)"></p>
                            <ul id="file-list">
                                <li>
                                    <div class="info" style="text-align:center">
                                        暂无关联文件
                                    </div>
                                </li>
                            </ul>
                            
                            
                            <div><b>文章包含链接</b><a class="link-list-question" href="#"><i class="fa fa-question-circle-o"></i></a></div>
                            <ul id="link-list">
                            </ul>
                        </div>
                    </div>
                  </div>
                </div>
            </form>
        </div>
        <input type="hidden" name="unfolded"/>
        <th:block th:replace="~{admin/include::head-script}"></th:block>
        <script type="text/html" id="editFile">
            <div class="layui-form" style="margin:10px 15px" id="editFileForm" lay-filter="editFileForm">
                <div class="layui-form-item">
                    <input type="hidden" name="assetId"/>
                    <label class="layui-form-label">标题</label>
                    <div class="layui-input-block">
                        <input type="text" lay-verify="required" name="title" placeholder="请输入" autocomplete="off" class="layui-input">
                    </div>
                </div>
                <div class="layui-form-item layui-form-text">
                    <label class="layui-form-label">描述</label>
                    <div class="layui-input-block">
                        <textarea placeholder="描述文件" name="description" class="layui-textarea"></textarea>
                    </div>
                </div>
                <div style="display:none" class="layui-form-item">
                    <div class="layui-input-block">
                        <button class="layui-btn" lay-submit lay-filter="editFile">提交</button>
                    </div>
                </div>
            </div>
        </script>
        <div th:replace="~{admin/include::feet}"></div>
        <script type="text/javascript" th:src="@{/blog/plugins/editormd/editormd.min.js}"></script>
        <script type="text/javascript" th:src="@{/admin/js/hackEditormd.js}"></script>
        <script type="text/javascript" th:src="@{/admin/js/linkSync.js}"></script>
        <script th:replace="~{admin/post/editJS::editJS}"></script>
    </body>

</html>