| 
					
				 | 
			
			
				@@ -1,4 +1,5 @@ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 from flask import flash, render_template, Blueprint, request, redirect, url_for 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+from flask.app import Flask 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 from flask.wrappers import Response 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import requests 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import os 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -11,7 +12,6 @@ from backstage.utils import get_now_time, translate 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 from backstage.utils.routes import create_content, remove_content, get_trans_title_url_name 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 from backstage.config import PORTAL_SERVER, UPLOAD_PATH_MAP 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				- 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 blogs_app = Blueprint('blogs', __name__) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 SwfType = { 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -20,22 +20,34 @@ SwfType = { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     "living_room": "客廳", 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     "study_room": "書房", 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     "dining_room": "餐廳", 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    "custom_made_system_cabinet": "客製模組系統櫃", 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    "system_cabinet": "模組系統櫃單品", 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+SfType = { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    "custom_made_system_cabinet": "客製模組系統櫃", 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    "system_cabinet": "模組系統櫃單品", 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 furniturePath = UPLOAD_PATH_MAP[0][0] + '../設計家具' 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+sfurniturePath = UPLOAD_PATH_MAP[0][0] + '../模組系統櫃' 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 furnitureTypes = [] 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 furnitureTypeFiles = [] 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 furnitureFiles = [] 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 furnitures = [] 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-def refreshFur(): 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+def refreshFur(itype): 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    scanpath = "" 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     furnitureTypes.clear() 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     furnitureTypeFiles.clear() 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     furnitureFiles.clear() 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     furnitures.clear() 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    if itype == '單品家具': 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        scanpath = furniturePath 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    else: 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        scanpath = sfurniturePath 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    for dirname, dirnames, filenames in os.walk(furniturePath): 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    for dirname, dirnames, filenames in os.walk(scanpath): 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         # print path to all subdirectories first. 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         for subdirname in dirnames: 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             if subdirname.find('.') == -1: 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -80,7 +92,16 @@ def refreshFur(): 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 def newFur(irequest): 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				- 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    print(irequest.url) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    myType = {} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    myPath = "" 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    print(str(irequest.url).find("system_furniture")) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    if str(irequest.url).find("system_furniture") >= 0: 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        myType = SfType 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        myPath = sfurniturePath 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    else: 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        myType = SwfType 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        myPath = furniturePath 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     ename = get_trans_title_url_name(irequest.args['newSwfName']) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     front_matter = '''--- 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 title: "{}" 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -91,8 +112,8 @@ url: "/{}/{}" 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 image: "" 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 ---'''.format(irequest.args['newSwfName'], get_now_time(), irequest.args['newSwfDropdown'], irequest.args['newSwfDropdown'], ename) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    newPath = furniturePath + '/' + \ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        SwfType[irequest.args['newSwfDropdown']] + '/' + ename 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    newPath = myPath + '/' + \ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        myType[irequest.args['newSwfDropdown']] + '/' + ename 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     if not os.path.exists(newPath): 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         os.mkdir(newPath) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     with open(os.path.join(newPath, 'index.md'), 'w', encoding="utf-8") as md: 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -108,7 +129,7 @@ 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) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        #print(sortedData) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        # print(sortedData) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         return render_template('blogs.html', 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                                title='設計專欄', 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                                legend='設計專欄列表', 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -123,6 +144,12 @@ def new_solid_wood_furniture(): 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     return newFur(request) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+@blogs_app.route('/backstage/new_system_furniture', methods=['GET']) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+def new_system_furniture(): 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    # edit_solid_wood_furniture() 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    return newFur(request) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 @blogs_app.route('/backstage/del_solid_wood_furniture', methods=['GET']) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 def del_solid_wood_furniture(): 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     url = request.args.get('url', type=str) 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -137,59 +164,7 @@ def del_solid_wood_furniture(): 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 @blogs_app.route('/backstage/edit_solid_wood_furniture', methods=['GET']) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 def edit_solid_wood_furniture(): 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    refreshFur() 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    """ furniturePath = UPLOAD_PATH_MAP[0][0] + '../設計家具' 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    furnitureTypes = [] 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    furnitureTypeFiles = [] 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    furnitureFiles = [] 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    furnitures = [] 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    for dirname, dirnames, filenames in os.walk(furniturePath): 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        # print path to all subdirectories first. 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        for subdirname in dirnames: 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            if subdirname.find('.') == -1: 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                furnitureTypes.append(subdirname) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				- 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        # print path to all filenames. 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        for filename in filenames: 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            if filename.find('_index.md') >= 0: 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                furnitureTypeFiles.append(os.path.join(dirname, filename)) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            if filename.find('index.md') >= 0: 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                furnitureFiles.append(os.path.join(dirname, filename)) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				- 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    headerStart = False 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    for files in furnitureFiles: 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        tmpfurniture = {} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        with open(files, 'r', encoding="utf-8") as md: 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            md_line_data = md.readlines() 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            # print(md_line_data) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        for line in md_line_data: 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            # print(line) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            if '---' in line: 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                headerStart = not headerStart 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                continue 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            if headerStart: 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                if 'title:' in line: 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                    tmpfurniture['title'] = re.split('"|\n', line)[1] 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                if 'date:' in line: 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                    tmpfurniture['date'] = re.split(':"|\n', line)[0].removeprefix('date: ') 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                if 'draft:' in line: 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                    tmpfurniture['draft'] = re.split(':"|\n', line)[0].removeprefix('draft: ') 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                if 'type:' in line: 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                    tmpfurniture['type'] = re.split('"|\n', line)[1] 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                if 'url:' in line: 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                    tmpfurniture['url'] = re.split('"|\n', line)[1] 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                if 'image:' in line: 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                    tmpfurniture['image'] = re.split('"|\n', line)[1] 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                if 'tags:' in line: 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                    tmpfurniture['tags'] = re.split('"|\n', line)[1] 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        #避免加入類別項目 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        if tmpfurniture['type'] != tmpfurniture['url'].removeprefix('/'): 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            furnitures.append(tmpfurniture) """ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				- 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    #sortedData = sorted(furnitures, key=lambda x: x['date'], reverse=True) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    # print(furnitures) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    """ response = requests.get('{}contents?url=/blog'.format(PORTAL_SERVER)) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    if response.status_code == 200: """ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    refreshFur('單品家具') 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     sortedData = sorted(furnitures, key=lambda x: x['date'], reverse=True) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     sortedData = sorted(sortedData, key=lambda x: x['type']) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     return render_template('solid_wood_furniture.html', 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -199,6 +174,18 @@ def edit_solid_wood_furniture(): 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                            ) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+@blogs_app.route('/backstage/edit_system_furniture', methods=['GET']) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+def edit_system_furniture(): 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    refreshFur('模組系統櫃') 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    sortedData = sorted(furnitures, key=lambda x: x['date'], reverse=True) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    sortedData = sorted(sortedData, key=lambda x: x['type']) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    return render_template('system_furniture.html', 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                           title='模組系統櫃', 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                           legend='模組系統櫃', 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                           furnitures=sortedData, length=len(furnitures), 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                           ) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 @blogs_app.route('/backstage/blog/create/', methods=['POST']) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 def create(): 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     transcat = "" 
			 |