瀏覽代碼

210831 editing blog header

yukyo0821 3 年之前
父節點
當前提交
0a05788b8a
共有 3 個文件被更改,包括 23 次插入3 次删除
  1. 2 2
      backstage/static/js/yo.js
  2. 1 0
      backstage/templates/blogs.html
  3. 20 1
      backstage/templates/tables/editor_table.html

+ 2 - 2
backstage/static/js/yo.js

@@ -66,7 +66,7 @@ function parseMd(content) {
             }
             if (line.includes('categories: ')) {
                 //alert(line);
-                $('#ccategories').val(line.replace('categories: ', ''));
+                $('#ccategories').val(line.replace('categories: ', '').replace('categories: ', '').replace(/\[|]/g, '').replace(/\"/g, ''));
             }
             if (line.includes('col1: ')) {
                 //alert(line);
@@ -157,7 +157,7 @@ function GetMdHeader() {
         rContent += 'tag: "' + ($('#ctag').val() == 'undefined' ? "" : $('#ctag').val()) + '"\n';
     }
     else if ($('#ctype').val() == "blog") {
-        rContent += 'categories: ' + $('#ccategories').val() + '\n';
+        rContent += 'categories: ["' + $('#ccategories').val() + '"]\n';
         rContent += 'col1: "' + ($('#ccol1').val() == 'undefined' ? "" : $('#ccol1').val()) + '"\n';
         rContent += 'col2: "' + ($('#ccol2').val() == 'undefined' ? "" : $('#ccol2').val()) + '"\n';
     }

+ 1 - 0
backstage/templates/blogs.html

@@ -9,6 +9,7 @@
       <td class="table__data"><input type="checkbox" {{ 'checked' if (blogs[idx].draft.lower()=='false') }} onclick="toggleDraft(this,'{{ blogs[idx].url }}');" /></td>
       <td>
         <div class="d-flex justify-content-center">
+          <button class="btn btn_light mr-1" onclick="getHeader('{{ blogs[idx].url }}');" ><b>主資訊</b> <i class="fas fa-pencil-alt"></i></button>
           <a class="m-1 btn__edit" href="{{ url_for('editor.editor', url=blogs[idx].url) }}"><i class="fas fa-edit"></i></a>
           <form action="{{ url_for('blogs.remove', url=blogs[idx].url) }}" method="POST" class="m-1 inline_block">
             <button class="btn__delete" type="submit" value="delete"><i class="fas fa-trash-alt"></i></button>

+ 20 - 1
backstage/templates/tables/editor_table.html

@@ -53,7 +53,7 @@
                 <div class="mt-1 text-danger">(建議尺寸/比例: 寬2048px * 高1365px)</div>
               </td>
             </tr>
-            <tr>
+            <tr id='sdesc'>
               <td>
                 <h4>描述</h4>
               </td>
@@ -62,6 +62,15 @@
               </td>
             </tr>
             <tr>
+              <tr id='scat'>
+                <td>
+                  <h4>文章分類</h4>
+                </td>
+                <td><textarea class="form-control" rows="1" id="ccategories"></textarea>
+                  <div class="mt-1 text-danger">(建議字數: 15字內)</div>
+                </td>
+              </tr>
+              <tr>
               <td>
                 <h4>日期</h4>
               </td>
@@ -122,6 +131,15 @@
       blocks = parseMd(aa);
       oTitle = $("#ctitle").val();
       // $("#dialog-form").dialog();
+      if($("#ctype").val() == "collection")
+      {
+        $("#scat").hide();
+        
+      }
+      else
+      {
+        $("#sdesc").hide();
+      }
       $("#myModal").modal();
       editTarget = url;
       //console.log(frontMatters);
@@ -217,6 +235,7 @@
   $(function () {
 
     $("#dialog-form").hide();
+    
 
   });
   //allObjs = JSON.parse(htmlDecode('{{ collections }}'));