5 Commits ebd40b9d77 ... 1d67399d84

Author SHA1 Message Date
  weichen 1d67399d84 ignore .pyc 3 years ago
  weichen 608c808541 add parsing 敘述title 3 years ago
  weichen 819d7d9f09 fix generating description md content if feedline is exist in textarea 3 years ago
  weichen 09b387450d modify home2, room_planner2 to home3, room_planner3 3 years ago
  weichen 47feffc932 modify selected_choices to production category 3 years ago

+ 2 - 1
.gitignore

@@ -1,3 +1,4 @@
 __pycache__
 config*
-.DS_Store
+.DS_Store
+*.pyc

+ 3 - 3
backstage/blogs/forms.py

@@ -4,9 +4,9 @@ from wtforms import StringField, SelectField
 from wtforms.validators import DataRequired
 
 
-selected_choices = [('expertise_in_interior_decorating', '裝修專業'),
-                    ('house_style_design', '風格規劃'),
-                    ('home_inspection', '驗屋交屋')]
+selected_choices = [('home_aesthetics', '居家美學'),
+                    ('room_planner_expertise', '規劃師QA'),
+                    ('home_inspection_knowledge', '驗屋知識')]
 
 
 class BlogCreateForm(FlaskForm):

+ 1 - 1
backstage/home/routes.py

@@ -24,5 +24,5 @@ def update():
                         request.form.getlist('element'),
                         request.args,
                         request.files.getlist('image'),
-                        'home2')
+                        'home3')
     return redirect(url_for('home.home'))

+ 1 - 1
backstage/room_planner/routes.py

@@ -23,5 +23,5 @@ def update():
                         request.form.getlist('element'),
                         request.args,
                         request.files.getlist('image'),
-                        'room_planner2')
+                        'room_planner3')
     return redirect(url_for('room_planner.main'))

+ 12 - 2
backstage/static/js/editor.js

@@ -20,10 +20,20 @@ axios.get(contentApiUrl).then(({ data }) => {
       mdContent += frontMatter + '\n';
     }
     for (var idx=0; idx<blockArray.length; idx++) {
-      mdContent += `\n### **${_.get(blockArray[idx], 'title', '')}**\n`
+      if (_.get(blockArray[idx], 'title', '').includes('敘述')) {
+        mdContent += `\n<!-- ### **${_.get(blockArray[idx], 'title', '')}**-->\n`
+      } else {
+        mdContent += `\n### **${_.get(blockArray[idx], 'title', '')}**\n`
+      }
       for (var data of _.get(blockArray[idx], 'data', [])) {
         if (_.get(_.keys(data), 0) === 'description') {
-          mdContent += `\n${_.get(data, 'description.text', '')}`;
+          if (_.get(data, 'description.text', '').includes('\n')) {
+            for (const line of _.get(data, 'description.text', '').split('\n')) {
+              mdContent += `\n${line}    `;
+            }
+          } else {
+            mdContent += `\n${_.get(data, 'description.text', '')}`;
+          }
         } else if (_.get(_.keys(data), 0) === 'image') {
           ampImgForm = `\n<amp-img\
 \n  alt="${_.get(data, 'image.alt', '小寶優居')}"\

+ 4 - 0
backstage/static/js/parsers.js

@@ -63,6 +63,10 @@ const parseTitle = line => {
   var title = '';
   title = line.replace('### **', '');
   title = title.replace('**', '');
+  if (title.includes('敘述')) {
+    title = title.replace('<!-- ', '');
+    title = title.replace('-->', '');
+  }
   return title;
 };