Browse Source

Merge remote-tracking branch 'origin/dev' into dev

Vanessa 1 year ago
parent
commit
fcd77b05ad

+ 1 - 1
kernel/model/blockial.go

@@ -66,7 +66,7 @@ func SetBlockReminder(id string, timed string) (err error) {
 	if ast.NodeDocument != node.Type && node.IsContainerBlock() {
 	if ast.NodeDocument != node.Type && node.IsContainerBlock() {
 		node = treenode.FirstLeafBlock(node)
 		node = treenode.FirstLeafBlock(node)
 	}
 	}
-	content := treenode.NodeStaticContent(node, nil, false, false)
+	content := treenode.NodeStaticContent(node, nil, false, false, false)
 	content = gulu.Str.SubStr(content, 128)
 	content = gulu.Str.SubStr(content, 128)
 	err = SetCloudBlockReminder(id, content, timedMills)
 	err = SetCloudBlockReminder(id, content, timedMills)
 	if nil != err {
 	if nil != err {

+ 2 - 2
kernel/model/render.go

@@ -93,7 +93,7 @@ func renderOutline(heading *ast.Node, luteEngine *lute.Lute) (ret string) {
 }
 }
 
 
 func renderBlockText(node *ast.Node, excludeTypes []string) (ret string) {
 func renderBlockText(node *ast.Node, excludeTypes []string) (ret string) {
-	ret = treenode.NodeStaticContent(node, excludeTypes, false, false)
+	ret = treenode.NodeStaticContent(node, excludeTypes, false, false, false)
 	ret = strings.TrimSpace(ret)
 	ret = strings.TrimSpace(ret)
 	ret = strings.ReplaceAll(ret, "\n", "")
 	ret = strings.ReplaceAll(ret, "\n", "")
 	ret = util.EscapeHTML(ret)
 	ret = util.EscapeHTML(ret)
@@ -156,7 +156,7 @@ func renderBlockContentByNodes(nodes []*ast.Node) string {
 
 
 	buf := bytes.Buffer{}
 	buf := bytes.Buffer{}
 	for _, n := range subNodes {
 	for _, n := range subNodes {
-		buf.WriteString(treenode.NodeStaticContent(n, nil, false, false))
+		buf.WriteString(treenode.NodeStaticContent(n, nil, false, false, false))
 	}
 	}
 	return buf.String()
 	return buf.String()
 }
 }

+ 1 - 1
kernel/model/virutalref.go

@@ -51,7 +51,7 @@ func getBlockVirtualRefKeywords(root *ast.Node) (ret []string) {
 				return ast.WalkContinue
 				return ast.WalkContinue
 			}
 			}
 
 
-			content := treenode.NodeStaticContent(n, nil, false, false)
+			content := treenode.NodeStaticContent(n, nil, false, false, false)
 			buf.WriteString(content)
 			buf.WriteString(content)
 			return ast.WalkContinue
 			return ast.WalkContinue
 		})
 		})

+ 1 - 1
kernel/sql/block.go

@@ -109,7 +109,7 @@ func indexNode(tx *sql.Tx, id string) (err error) {
 		return
 		return
 	}
 	}
 
 
-	content := treenode.NodeStaticContent(node, nil, true, indexAssetPath)
+	content := treenode.NodeStaticContent(node, nil, true, indexAssetPath, true)
 	stmt := "UPDATE blocks SET content = ? WHERE id = ?"
 	stmt := "UPDATE blocks SET content = ? WHERE id = ?"
 	if err = execStmtTx(tx, stmt, content, id); nil != err {
 	if err = execStmtTx(tx, stmt, content, id); nil != err {
 		tx.Rollback()
 		tx.Rollback()

+ 3 - 3
kernel/sql/database.go

@@ -801,13 +801,13 @@ func buildBlockFromNode(n *ast.Node, tree *parse.Tree) (block *Block, attributes
 		if !treenode.IsNodeOCRed(n) {
 		if !treenode.IsNodeOCRed(n) {
 			util.PushNodeOCRQueue(n)
 			util.PushNodeOCRQueue(n)
 		}
 		}
-		content = treenode.NodeStaticContent(n, nil, true, indexAssetPath)
+		content = treenode.NodeStaticContent(n, nil, true, indexAssetPath, true)
 
 
 		fc := treenode.FirstLeafBlock(n)
 		fc := treenode.FirstLeafBlock(n)
 		if !treenode.IsNodeOCRed(fc) {
 		if !treenode.IsNodeOCRed(fc) {
 			util.PushNodeOCRQueue(fc)
 			util.PushNodeOCRQueue(fc)
 		}
 		}
-		fcontent = treenode.NodeStaticContent(fc, nil, true, false)
+		fcontent = treenode.NodeStaticContent(fc, nil, true, false, true)
 
 
 		parentID = n.Parent.ID
 		parentID = n.Parent.ID
 		// 将标题块作为父节点
 		// 将标题块作为父节点
@@ -820,7 +820,7 @@ func buildBlockFromNode(n *ast.Node, tree *parse.Tree) (block *Block, attributes
 		if !treenode.IsNodeOCRed(n) {
 		if !treenode.IsNodeOCRed(n) {
 			util.PushNodeOCRQueue(n)
 			util.PushNodeOCRQueue(n)
 		}
 		}
-		content = treenode.NodeStaticContent(n, nil, true, indexAssetPath)
+		content = treenode.NodeStaticContent(n, nil, true, indexAssetPath, true)
 
 
 		parentID = n.Parent.ID
 		parentID = n.Parent.ID
 		// 将标题块作为父节点
 		// 将标题块作为父节点

+ 28 - 2
kernel/treenode/node.go

@@ -168,7 +168,7 @@ func IsNodeOCRed(node *ast.Node) (ret bool) {
 	return
 	return
 }
 }
 
 
-func NodeStaticContent(node *ast.Node, excludeTypes []string, includeTextMarkATitleURL, includeAssetPath bool) string {
+func NodeStaticContent(node *ast.Node, excludeTypes []string, includeTextMarkATitleURL, includeAssetPath, fullAttrView bool) string {
 	if nil == node {
 	if nil == node {
 		return ""
 		return ""
 	}
 	}
@@ -178,7 +178,11 @@ func NodeStaticContent(node *ast.Node, excludeTypes []string, includeTextMarkATi
 	}
 	}
 
 
 	if ast.NodeAttributeView == node.Type {
 	if ast.NodeAttributeView == node.Type {
-		return getAttributeViewContent(node.AttributeViewID)
+		if fullAttrView {
+			return getAttributeViewContent(node.AttributeViewID)
+		}
+
+		return getAttributeViewName(node.AttributeViewID)
 	}
 	}
 
 
 	buf := bytes.Buffer{}
 	buf := bytes.Buffer{}
@@ -528,6 +532,28 @@ func GetAttributeViewName(avID string) (name string) {
 	return
 	return
 }
 }
 
 
+func getAttributeViewName(avID string) (name string) {
+	if "" == avID {
+		return
+	}
+
+	attrView, err := av.ParseAttributeView(avID)
+	if nil != err {
+		logging.LogErrorf("parse attribute view [%s] failed: %s", avID, err)
+		return
+	}
+
+	buf := bytes.Buffer{}
+	buf.WriteString(attrView.Name)
+	buf.WriteByte(' ')
+	for _, v := range attrView.Views {
+		buf.WriteString(v.Name)
+		buf.WriteByte(' ')
+	}
+	name = strings.TrimSpace(buf.String())
+	return
+}
+
 func getAttributeViewContent(avID string) (content string) {
 func getAttributeViewContent(avID string) (content string) {
 	if "" == avID {
 	if "" == avID {
 		return
 		return