mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-12-16 22:50:13 +01:00
Signed-off-by: Daniel <845765@qq.com>
This commit is contained in:
parent
9f0eaa6a0b
commit
a65f46c922
2 changed files with 38 additions and 6 deletions
|
|
@ -1074,6 +1074,8 @@ func CreateWithMarkdown(tags, boxID, hPath, md, parentID, id string, withMath bo
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const DailyNoteAttrPrefix = "custom-dailynote-"
|
||||||
|
|
||||||
func CreateDailyNote(boxID string) (p string, existed bool, err error) {
|
func CreateDailyNote(boxID string) (p string, existed bool, err error) {
|
||||||
createDocLock.Lock()
|
createDocLock.Lock()
|
||||||
defer createDocLock.Unlock()
|
defer createDocLock.Unlock()
|
||||||
|
|
@ -1110,8 +1112,8 @@ func CreateDailyNote(boxID string) (p string, existed bool, err error) {
|
||||||
}
|
}
|
||||||
p = tree.Path
|
p = tree.Path
|
||||||
date := time.Now().Format("20060102")
|
date := time.Now().Format("20060102")
|
||||||
if tree.Root.IALAttr("custom-dailynote-"+date) == "" {
|
if tree.Root.IALAttr(DailyNoteAttrPrefix+date) == "" {
|
||||||
tree.Root.SetIALAttr("custom-dailynote-"+date, date)
|
tree.Root.SetIALAttr(DailyNoteAttrPrefix+date, date)
|
||||||
if err = indexWriteTreeUpsertQueue(tree); err != nil {
|
if err = indexWriteTreeUpsertQueue(tree); err != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
@ -1179,7 +1181,7 @@ func CreateDailyNote(boxID string) (p string, existed bool, err error) {
|
||||||
}
|
}
|
||||||
p = tree.Path
|
p = tree.Path
|
||||||
date := time.Now().Format("20060102")
|
date := time.Now().Format("20060102")
|
||||||
tree.Root.SetIALAttr("custom-dailynote-"+date, date)
|
tree.Root.SetIALAttr(DailyNoteAttrPrefix+date, date)
|
||||||
if err = indexWriteTreeUpsertQueue(tree); err != nil {
|
if err = indexWriteTreeUpsertQueue(tree); err != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -126,17 +126,17 @@ func BuildTreeGraph(id, query string) (boxID string, nodes []*GraphNode, links [
|
||||||
refBlocks := fromSQLBlocks(&sqlRefBs, "", 0)
|
refBlocks := fromSQLBlocks(&sqlRefBs, "", 0)
|
||||||
|
|
||||||
if 0 < len(dailyNotesPaths) {
|
if 0 < len(dailyNotesPaths) {
|
||||||
filterDailyNote := false
|
isDailyNote := false
|
||||||
var tmp []*Block
|
var tmp []*Block
|
||||||
for _, refBlock := range refBlocks {
|
for _, refBlock := range refBlocks {
|
||||||
for _, dailyNotePath := range dailyNotesPaths {
|
for _, dailyNotePath := range dailyNotesPaths {
|
||||||
if strings.HasPrefix(refBlock.HPath, dailyNotePath) {
|
if strings.HasPrefix(refBlock.HPath, dailyNotePath) {
|
||||||
filterDailyNote = true
|
isDailyNote = true
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if !filterDailyNote {
|
if !isDailyNote {
|
||||||
tmp = append(tmp, refBlock)
|
tmp = append(tmp, refBlock)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -149,6 +149,7 @@ func BuildTreeGraph(id, query string) (boxID string, nodes []*GraphNode, links [
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
blocks = filterDailyNote(blocks, true)
|
||||||
genTreeNodes(blocks, &nodes, &links, true)
|
genTreeNodes(blocks, &nodes, &links, true)
|
||||||
growTreeGraph(&forwardlinks, &backlinks, &nodes)
|
growTreeGraph(&forwardlinks, &backlinks, &nodes)
|
||||||
blocks = append(blocks, forwardlinks...)
|
blocks = append(blocks, forwardlinks...)
|
||||||
|
|
@ -187,6 +188,7 @@ func BuildGraph(query string) (boxID string, nodes []*GraphNode, links []*GraphL
|
||||||
|
|
||||||
sqlBlocks := sql.GetAllChildBlocks(rootIDs, stmt, Conf.Graph.MaxBlocks)
|
sqlBlocks := sql.GetAllChildBlocks(rootIDs, stmt, Conf.Graph.MaxBlocks)
|
||||||
treeBlocks := fromSQLBlocks(&sqlBlocks, "", 0)
|
treeBlocks := fromSQLBlocks(&sqlBlocks, "", 0)
|
||||||
|
treeBlocks = filterDailyNote(treeBlocks, false)
|
||||||
genTreeNodes(treeBlocks, &nodes, &links, false)
|
genTreeNodes(treeBlocks, &nodes, &links, false)
|
||||||
blocks = append(blocks, treeBlocks...)
|
blocks = append(blocks, treeBlocks...)
|
||||||
|
|
||||||
|
|
@ -598,6 +600,34 @@ func graphTypeFilter(local bool) string {
|
||||||
return " AND ref.type IN (" + strings.Join(inList, ",") + ")"
|
return " AND ref.type IN (" + strings.Join(inList, ",") + ")"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func filterDailyNote(blocks []*Block, local bool) (ret []*Block) {
|
||||||
|
// Graph dailynote filtering not working https://github.com/siyuan-note/siyuan/issues/16463
|
||||||
|
|
||||||
|
dailyNote := Conf.Graph.Local.DailyNote
|
||||||
|
if !local {
|
||||||
|
dailyNote = Conf.Graph.Global.DailyNote
|
||||||
|
}
|
||||||
|
|
||||||
|
if dailyNote {
|
||||||
|
ret = blocks
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, block := range blocks {
|
||||||
|
isDailyNote := false
|
||||||
|
for k, _ := range block.IAL {
|
||||||
|
isDailyNote = strings.HasPrefix(k, DailyNoteAttrPrefix)
|
||||||
|
if isDailyNote {
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if !isDailyNote {
|
||||||
|
ret = append(ret, block)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
func graphDailyNoteFilter(local bool) string {
|
func graphDailyNoteFilter(local bool) string {
|
||||||
dailyNotesPaths := dailyNotePaths(local)
|
dailyNotesPaths := dailyNotePaths(local)
|
||||||
if 1 > len(dailyNotesPaths) {
|
if 1 > len(dailyNotesPaths) {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue