Skip to content

An open-source, privacy-first, self-hosted knowledge workspace where humans and AI agents work together 开源、隐私优先、自托管的知识工作空间,让人与智能体在此协作

:recycle: Extract const

Daniel32c2c242e25d
diff --git a/kernel/model/attribute_view.go b/kernel/model/attribute_view.go
index 7eb74c87ec..1fc4a857af 100644
--- a/kernel/model/attribute_view.go
+++ b/kernel/model/attribute_view.go
@@ -3844,8 +3844,8 @@ func removeAttributeViewBlock(srcIDs []string, avID string, tx *Transaction) (er
func removeNodeAvID(node *ast.Node, avID string, tx *Transaction, tree *parse.Tree) (err error) {
attrs := parse.IAL2Map(node.KramdownIAL)
if ast.NodeDocument == node.Type {
- delete(attrs, "custom-hidden")
- node.RemoveIALAttr("custom-hidden")
+ delete(attrs, DocHiddenAttr)
+ node.RemoveIALAttr(DocHiddenAttr)
}
if avs := attrs[av.NodeAttrNameAvs]; "" != avs {
diff --git a/kernel/model/blockial.go b/kernel/model/blockial.go
index 17681206ac..1119cdcf51 100644
--- a/kernel/model/blockial.go
+++ b/kernel/model/blockial.go
@@ -182,8 +182,8 @@ func setNodeAttrs(node *ast.Node, tree *parse.Tree, nameValues map[string]string
pushBlockAttrs(oldAttrs, node)
- if ("true" == oldAttrs["custom-hidden"] && "true" != nameValues["custom-hidden"]) ||
- "true" != oldAttrs["custom-hidden"] && "true" == nameValues["custom-hidden"] {
+ if ("true" == oldAttrs[DocHiddenAttr] && "true" != nameValues[DocHiddenAttr]) ||
+ "true" != oldAttrs[DocHiddenAttr] && "true" == nameValues[DocHiddenAttr] {
ReloadFiletree()
}
diff --git a/kernel/model/file.go b/kernel/model/file.go
index f7ae55a606..0557771214 100644
--- a/kernel/model/file.go
+++ b/kernel/model/file.go
@@ -300,7 +300,7 @@ func ListDocTree(boxID, listPath string, sortMode int, flashcard, showHidden boo
continue
}
if ial := box.docIAL(parentDocPath); nil != ial {
- if !showHidden && "true" == ial["custom-hidden"] {
+ if !showHidden && "true" == ial[DocHiddenAttr] {
continue
}
@@ -309,7 +309,7 @@ func ListDocTree(boxID, listPath string, sortMode int, flashcard, showHidden boo
if err == nil {
for _, subFile := range subFiles {
subDocFilePath := path.Join(file.path, subFile.Name())
- if subIAL := box.docIAL(subDocFilePath); "true" == subIAL["custom-hidden"] {
+ if subIAL := box.docIAL(subDocFilePath); "true" == subIAL[DocHiddenAttr] {
continue
}
@@ -347,7 +347,7 @@ func ListDocTree(boxID, listPath string, sortMode int, flashcard, showHidden boo
}
if ial := box.docIAL(file.path); nil != ial {
- if !showHidden && "true" == ial["custom-hidden"] {
+ if !showHidden && "true" == ial[DocHiddenAttr] {
continue
}
@@ -1090,6 +1090,7 @@ func CreateWithMarkdown(tags, boxID, hPath, md, parentID, id string, withMath bo
const (
DailyNoteAttrPrefix = "custom-dailynote-"
NodeAttrTitleEmpty = "custom-sy-title-empty"
+ DocHiddenAttr = "custom-hidden"
)
func CreateDailyNote(boxID string) (p string, existed bool, err error) {
diff --git a/kernel/model/heading.go b/kernel/model/heading.go
index 66ada90277..83ad9d6079 100644
--- a/kernel/model/heading.go
+++ b/kernel/model/heading.go
@@ -399,7 +399,7 @@ func Heading2Doc(srcHeadingID, targetBoxID, targetPath, previousPath string) (sr
headingNode.SetIALAttr("type", "doc")
headingNode.SetIALAttr("id", srcHeadingID)
headingNode.SetIALAttr("title", headingText)
- headingNode.RemoveIALAttr("custom-hidden")
+ headingNode.RemoveIALAttr(DocHiddenAttr)
newTree.Root.KramdownIAL = headingNode.KramdownIAL
topLevel := treenode.TopHeadingLevel(newTree)
diff --git a/kernel/model/listitem.go b/kernel/model/listitem.go
index 34e45abef2..75c190a620 100644
--- a/kernel/model/listitem.go
+++ b/kernel/model/listitem.go
@@ -111,7 +111,7 @@ func ListItem2Doc(srcListItemID, targetBoxID, targetPath, previousPath string) (
listItemNode.SetIALAttr("id", srcListItemID)
listItemNode.SetIALAttr("title", listItemText)
listItemNode.RemoveIALAttr("fold")
- listItemNode.RemoveIALAttr("custom-hidden")
+ listItemNode.RemoveIALAttr(DocHiddenAttr)
newTree.Root.KramdownIAL = listItemNode.KramdownIAL
srcLiParent := listItemNode.Parent
listItemNode.Unlink()
diff --git a/kernel/model/push_reload.go b/kernel/model/push_reload.go
index 65ac5f81ac..30237f4199 100644
--- a/kernel/model/push_reload.go
+++ b/kernel/model/push_reload.go
@@ -139,12 +139,12 @@ func refreshDocInfo0(tree *parse.Tree, size uint64) {
subFiles, err := os.ReadDir(subDir)
if err == nil {
for _, subFile := range subFiles {
- if "true" == tree.Root.IALAttr("custom-hidden") {
+ if "true" == tree.Root.IALAttr(DocHiddenAttr) {
continue
}
subDocIAL := filesys.DocIAL(filepath.Join(subDir, subFile.Name()))
- if "true" == subDocIAL["custom-hidden"] {
+ if "true" == subDocIAL[DocHiddenAttr] {
continue
}