Merge remote-tracking branch 'origin/dev' into dev
This commit is contained in:
commit
fcd77b05ad
6 changed files with 36 additions and 10 deletions
|
@ -66,7 +66,7 @@ func SetBlockReminder(id string, timed string) (err error) {
|
|||
if ast.NodeDocument != node.Type && node.IsContainerBlock() {
|
||||
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)
|
||||
err = SetCloudBlockReminder(id, content, timedMills)
|
||||
if nil != err {
|
||||
|
|
|
@ -93,7 +93,7 @@ func renderOutline(heading *ast.Node, luteEngine *lute.Lute) (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.ReplaceAll(ret, "\n", "")
|
||||
ret = util.EscapeHTML(ret)
|
||||
|
@ -156,7 +156,7 @@ func renderBlockContentByNodes(nodes []*ast.Node) string {
|
|||
|
||||
buf := bytes.Buffer{}
|
||||
for _, n := range subNodes {
|
||||
buf.WriteString(treenode.NodeStaticContent(n, nil, false, false))
|
||||
buf.WriteString(treenode.NodeStaticContent(n, nil, false, false, false))
|
||||
}
|
||||
return buf.String()
|
||||
}
|
||||
|
|
|
@ -51,7 +51,7 @@ func getBlockVirtualRefKeywords(root *ast.Node) (ret []string) {
|
|||
return ast.WalkContinue
|
||||
}
|
||||
|
||||
content := treenode.NodeStaticContent(n, nil, false, false)
|
||||
content := treenode.NodeStaticContent(n, nil, false, false, false)
|
||||
buf.WriteString(content)
|
||||
return ast.WalkContinue
|
||||
})
|
||||
|
|
|
@ -109,7 +109,7 @@ func indexNode(tx *sql.Tx, id string) (err error) {
|
|||
return
|
||||
}
|
||||
|
||||
content := treenode.NodeStaticContent(node, nil, true, indexAssetPath)
|
||||
content := treenode.NodeStaticContent(node, nil, true, indexAssetPath, true)
|
||||
stmt := "UPDATE blocks SET content = ? WHERE id = ?"
|
||||
if err = execStmtTx(tx, stmt, content, id); nil != err {
|
||||
tx.Rollback()
|
||||
|
|
|
@ -801,13 +801,13 @@ func buildBlockFromNode(n *ast.Node, tree *parse.Tree) (block *Block, attributes
|
|||
if !treenode.IsNodeOCRed(n) {
|
||||
util.PushNodeOCRQueue(n)
|
||||
}
|
||||
content = treenode.NodeStaticContent(n, nil, true, indexAssetPath)
|
||||
content = treenode.NodeStaticContent(n, nil, true, indexAssetPath, true)
|
||||
|
||||
fc := treenode.FirstLeafBlock(n)
|
||||
if !treenode.IsNodeOCRed(fc) {
|
||||
util.PushNodeOCRQueue(fc)
|
||||
}
|
||||
fcontent = treenode.NodeStaticContent(fc, nil, true, false)
|
||||
fcontent = treenode.NodeStaticContent(fc, nil, true, false, true)
|
||||
|
||||
parentID = n.Parent.ID
|
||||
// 将标题块作为父节点
|
||||
|
@ -820,7 +820,7 @@ func buildBlockFromNode(n *ast.Node, tree *parse.Tree) (block *Block, attributes
|
|||
if !treenode.IsNodeOCRed(n) {
|
||||
util.PushNodeOCRQueue(n)
|
||||
}
|
||||
content = treenode.NodeStaticContent(n, nil, true, indexAssetPath)
|
||||
content = treenode.NodeStaticContent(n, nil, true, indexAssetPath, true)
|
||||
|
||||
parentID = n.Parent.ID
|
||||
// 将标题块作为父节点
|
||||
|
|
|
@ -168,7 +168,7 @@ func IsNodeOCRed(node *ast.Node) (ret bool) {
|
|||
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 {
|
||||
return ""
|
||||
}
|
||||
|
@ -178,7 +178,11 @@ func NodeStaticContent(node *ast.Node, excludeTypes []string, includeTextMarkATi
|
|||
}
|
||||
|
||||
if ast.NodeAttributeView == node.Type {
|
||||
return getAttributeViewContent(node.AttributeViewID)
|
||||
if fullAttrView {
|
||||
return getAttributeViewContent(node.AttributeViewID)
|
||||
}
|
||||
|
||||
return getAttributeViewName(node.AttributeViewID)
|
||||
}
|
||||
|
||||
buf := bytes.Buffer{}
|
||||
|
@ -528,6 +532,28 @@ func GetAttributeViewName(avID string) (name string) {
|
|||
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) {
|
||||
if "" == avID {
|
||||
return
|
||||
|
|
Loading…
Add table
Reference in a new issue