瀏覽代碼

211201 remove contents sorting(moved to api)/tags

yukyo0821 3 年之前
父節點
當前提交
4ecc21764c
共有 4 個文件被更改,包括 77 次插入11 次删除
  1. 4 7
      backstage/blogs/routes.py
  2. 3 3
      backstage/collections/routes.py
  3. 23 1
      backstage/static/js/yo.js
  4. 47 0
      backstage/templates/collections.html

+ 4 - 7
backstage/blogs/routes.py

@@ -128,12 +128,12 @@ image: ""
 def blog_list():
     response = requests.get('{}contents?url=/blog'.format(PORTAL_SERVER))
     if response.status_code == 200:
-        sortedData = sorted(response.json(), key=lambda x: x['date'], reverse=True)
+        #sortedData = sorted(response.json(), key=lambda x: x['date'], reverse=True)
         # print(sortedData)
         return render_template('blogs.html',
                                title='設計專欄',
                                legend='設計專欄列表',
-                               blogs=sortedData,
+                               blogs=response.json(),
                                length=len(response.json()),
                                form=BlogCreateForm())
 
@@ -190,12 +190,11 @@ def edit_system_furniture():
 def edit_news():
     response = requests.get('{}contents?url=/news'.format(PORTAL_SERVER))
     if response.status_code == 200:
-        sortedData = sorted(response.json(), key=lambda x: x['date'], reverse=True)
-        #sortedData = sorted(sortedData, key=lambda x: x['type'])
+        #sortedData = sorted(response.json(), key=lambda x: x['date'], reverse=True)
         return render_template('news.html',
                                title='消息與報導',
                                legend='消息與報導',
-                               news=sortedData, length=len(response.json()), form=BlogCreateForm()
+                               news=response.json(), length=len(response.json()), form=BlogCreateForm()
                                )
 
 
@@ -203,8 +202,6 @@ def edit_news():
 def edit_contact_us():
     response = requests.get('{}contents?url=/contact'.format(PORTAL_SERVER))
     if response.status_code == 200:
-        sortedData = sorted(response.json(), key=lambda x: x['date'], reverse=True)
-        #sortedData = sorted(sortedData, key=lambda x: x['type'])
         return render_template('contact_us.html',
                                title='聯絡我們',
                                )

+ 3 - 3
backstage/collections/routes.py

@@ -15,9 +15,9 @@ def collection_list():
     response = requests.get('{}contents?url=/collection'.format(PORTAL_SERVER))
     if response.status_code == 200:
         #sortedData = sorted(response.json(), key='date', reverse=True)        
-        #print(len(response))
+        #print(response.json())
         #aa = json.loads(response.text)
-        sortedData = sorted(response.json(), key=lambda x:x['date'], reverse=True)
+        #sortedData = sorted(response.json(), key=lambda x:x['date'], reverse=True)
         """ i=1
         for d in sortedData:
             if i == 1:
@@ -30,7 +30,7 @@ def collection_list():
         return render_template('collections.html',
                                title='家具規劃作品',
                                legend='家具規劃作品列表',
-                               collections=sortedData,
+                               collections=response.json(),
                                length=len(response.json()),
                                form=CollectionCreateForm())
 

+ 23 - 1
backstage/static/js/yo.js

@@ -1,6 +1,7 @@
 contentApiUrl = `${PORTAL_SERVER}contents?url=`;
 frontMatters = [];
 contentMatters = [];
+tagOptionIds = ['thousetype', 'tpinsize', 'tbudget', 'troomscount'];
 
 var SwfType = {};
 if (location.pathname.indexOf('system_furniture') >= 0) {
@@ -205,6 +206,20 @@ function parseMd(content) {
                 //alert(line);
                 $('#ctag').val(line.replace('tag: ', '').replaceAll('\"', ''));
             }
+            if (line.includes('tags: ')) {
+                //alert(line);
+                $('#ctags').val(line.replace('tags: ', '').replaceAll('\"', ''));
+                tags = $('#ctags').val().split(',');
+                for (var tag of tags) {
+                    //console.log(tag);
+                    for (var toi of tagOptionIds) {
+                        $('#'+toi+' option').each(function(){
+                            if(this.value == tag)
+                                this.selected = true;
+                        });
+                    }
+                }
+            }
             if (line.includes('categories: ')) {
                 //alert(line);
                 $('#ccategories').val(line.replace('categories: ', '').replace('categories: ', '').replace(/\[|]/g, '').replace(/\"/g, ''));
@@ -299,7 +314,14 @@ function GetMdHeader() {
     if ($('#ctype').val() == "collection") {
         rContent += 'description: "' + $('#cdescription').val().replace(/\r?\n/g, '<br>') + '"\n';
         rContent += 'weight: ' + ($('#cweight').val() == 'undefined' ? "" : $('#cweight').val()) + '\n';
-        rContent += 'tag: "' + ($('#ctag').val() == 'undefined' ? "" : $('#ctag').val()) + '"\n';
+
+        tags = [];
+        for (var toi of tagOptionIds) {
+            if($('#'+toi).val() != "")
+                tags.push($('#'+toi).val());
+        }
+        rContent += 'tags: "' + tags.join(',') + '"\n';
+        //rContent += 'tags: "' + ($('#ctags').val() == 'undefined' ? "" : $('#ctags').val()) + '"\n';
     }
     else if ($('#ctype').val() == "blog") {
         rContent += 'categories: ["' + $('#ccategories').val() + '"]\n';

+ 47 - 0
backstage/templates/collections.html

@@ -96,6 +96,52 @@
               </td>
               <td><input class="form-control" id="cdate" type="text" /></td>
             </tr>
+            <tr>
+              <td>
+                <h4>房型</h4>
+              </td>
+              <td><select id="thousetype">
+                  <option value="">房型</option>
+                  <option>透天</option>
+                  <option>大樓</option>
+                </select></td>
+            </tr>
+            <tr>
+              <td>
+                <h4>坪數</h4>
+              </td>
+              <td><select id="tpinsize">
+                  <option value="">坪數</option>
+                  <option>19坪以下</option>
+                  <option>20-29坪</option>
+                  <option>30-39坪</option>
+                  <option>40坪以上</option>
+                </select></td>
+            </tr>
+            <tr>
+              <td>
+                <h4>預算</h4>
+              </td>
+              <td><select id="tbudget">
+                  <option value="">預算</option>
+                  <option>45-59萬</option>
+                  <option>60-79萬</option>
+                  <option>80-99萬</option>
+                  <option>100萬以上</option>
+                </select></td>
+            </tr>
+            <tr>
+              <td>
+                <h4>格局</h4>
+              </td>
+              <td><select id="troomscount">
+                  <option value="">格局</option>
+                  <option>兩房</option>
+                  <option>三房</option>
+                  <option>四房</option>
+                  <option>四房以上</option>
+                </select></td>
+            </tr>
             <tr>
               <td>
                 <h4>是否顯示</h4>
@@ -110,6 +156,7 @@
           <input id="cimage" type="text" /><br />
           <input id="cweight" type="text" /><br />
           <input id="ctag" type="text" /><br />
+          <input id="ctags" type="text" /><br />
           <input id="ccategories" type="text" /><br />
           <input id="ccol1" type="text" /><br />
           <input id="ccol2" type="text" /><br />