瀏覽代碼

add thumbnail

SyuanYu 2 年之前
父節點
當前提交
0d389c4839
共有 2 個文件被更改,包括 30 次插入15 次删除
  1. 22 10
      backstage/static/js/yo.js
  2. 8 5
      backstage/templates/collections.html

+ 22 - 10
backstage/static/js/yo.js

@@ -542,6 +542,18 @@ function parseMd(content) {
         );
       }
 
+      if (line.includes("image: ")) {
+        $("#cfile-file").attr("src",`${line.replace("image: ", "https://bhouse.com.tw").replaceAll('"', "")}`);
+      }
+
+      if (line.includes("cover_img: ")) {
+        $("#cnewcoverimg-file").attr("src",`${line.replace("cover_img: ", "https://bhouse.com.tw").replaceAll('"', "")}`);
+      }
+
+      if (line.includes("owner_img: ")) {
+        $("#cnewownerimg-file").attr("src",`${line.replace("owner_img: ", "https://bhouse.com.tw").replaceAll('"', "")}`);
+      }
+
       if (line.includes("collection_slider: ")) {
         let slider = $("#ccollslider").val(
           line.replace("collection_slider: ", "").replaceAll('"', "")
@@ -653,23 +665,23 @@ function parseMd(content) {
       continue;
     }
 
-    if (line.includes("<img") || foundImg) {
+    if (line.includes("<iframe") || foundYT) {
       crossLine += line;
-      foundImg = true;
-      if (line.includes("</img>")) {
-        rblocks.push({ type: "img", text: crossLine });
-        foundImg = false;
+      foundYT = true;
+      if (line.includes("</iframe>")) {
+        rblocks.push({ type: "youtube", text: crossLine });
+        foundYT = false;
         crossLine = "";
       }
       continue;
     }
 
-    if (line.includes("<iframe") || foundYT) {
+    if (line.includes("<img") || foundImg) {
       crossLine += line;
-      foundYT = true;
-      if (line.includes("</iframe>")) {
-        rblocks.push({ type: "youtube", text: crossLine });
-        foundYT = false;
+      foundImg = true;
+      if (line.includes("</img>")) {
+        rblocks.push({ type: "img", text: crossLine });
+        foundImg = false;
         crossLine = "";
       }
       continue;

+ 8 - 5
backstage/templates/collections.html

@@ -20,7 +20,7 @@
         onclick="toggleDraft(this,'{{ collections[idx].url }}');" /></td>
     <td>
       <div class="d-flex justify-content-center">
-        <button class="btn btn_light mr-1" onclick="getHeader('{{ collections[idx].url }}');"><b>主資訊</b> <i
+        <button class="btn btn_light mr-1 blog-btn" onclick="getHeader('{{ collections[idx].url }}');"><b>主資訊</b> <i
             class="fas fa-pencil-alt"></i></button>
         <a class="m-1 btn__edit" href="{{ url_for('editor.editor', url=collections[idx].url) }}"><i
             class="fas fa-edit"></i></a>
@@ -190,7 +190,8 @@
               </td>
               <td>
                 <input class="form-control" id="cfile" type="file" />
-                <div class="mt-1 text-danger">(建議尺寸/比例:寬 2048px * 高 1365px)</div>
+                <div class="mt-1 text-danger mb-2">(建議尺寸/比例:寬 2048px * 高 1365px)</div>
+                <img src="" alt="" width="300" id="cfile-file">
               </td>
             </tr>
             <tr>
@@ -206,7 +207,8 @@
               </td>
               <td>
                 <input class="form-control" id="cnewcoverimg" type="file" />
-                <div class="mt-1 text-danger">(建議尺寸/比例:寬 ____px * 高 ____px)</div>
+                <div class="mt-1 text-danger mb-2">(建議尺寸/比例:寬 ____px * 高 ____px)</div>
+                <img src="" alt="" width="300" id="cnewcoverimg-file">
               </td>
             </tr>
             <tr>
@@ -228,7 +230,8 @@
                 <h4>屋主照片</h4>
               </td>
               <td class="d-flex flex-column">
-                <input class="form-control" id="cnewownerimg" type="file" />
+                <input class="form-control mb-2" id="cnewownerimg" type="file" />
+                <img src="" alt="" width="300" id="cnewownerimg-file">
                 <button id="removeOwnerImg" type="button" class="btn btn_light mt-2">移除前台屋主照片</button>
               </td>
             </tr>
@@ -391,6 +394,6 @@
   </div>
 </div>
 <script>
-  
+
 </script>
 {% endblock %}