An open-source, privacy-first, self-hosted knowledge workspace where humans and AI agents work together 开源、隐私优先、自托管的知识工作空间,让人与智能体在此协作
TypeScript agentic-aiai-agentknowledge-baselocal-firstmarkdownmcpmindmapnote-takingself-hostedsiyuanworkspace
:art: Spaced repetition interface supports review by document selection https://github.com/siyuan-note/siyuan/issues/7954
Liang Ding0ebdd49f8afb
diff --git a/kernel/api/riff.go b/kernel/api/riff.goindex cdd2d0b99f..84f8b6b2cf 100644--- a/kernel/api/riff.go+++ b/kernel/api/riff.go@@ -27,6 +27,16 @@ import ("github.com/siyuan-note/siyuan/kernel/util")+func getRiffCardNotebooks(c *gin.Context) {+ ret := gulu.Ret.NewResult()+ defer c.JSON(http.StatusOK, ret)++ notebooks := model.GetFlashcardNotebooks()+ ret.Data = map[string]interface{}{+ "notebooks": notebooks,+ }+}+func getNotebookRiffCards(c *gin.Context) {ret := gulu.Ret.NewResult()defer c.JSON(http.StatusOK, ret)diff --git a/kernel/model/flashcard.go b/kernel/model/flashcard.goindex c230b47d16..6051e60676 100644--- a/kernel/model/flashcard.go+++ b/kernel/model/flashcard.go@@ -38,8 +38,53 @@ import ("github.com/siyuan-note/siyuan/kernel/util")-var Decks = map[string]*riff.Deck{}-var deckLock = sync.Mutex{}+func GetFlashcardNotebooks() (ret []*Box) {+ deck := Decks[builtinDeckID]+ if nil == deck {+ return+ }+ deckBlockIDs := deck.GetBlockIDs()++ boxes := Conf.GetOpenedBoxes()+ for _, box := range boxes {+ if isNotebookContainFlashcard(box.ID, deckBlockIDs) {+ ret = append(ret, box)+ }+ }+ return+}++func isNotebookContainFlashcard(boxID string, deckBlockIDs []string) (ret bool) {+ entries, err := os.ReadDir(filepath.Join(util.DataDir, boxID))+ if nil != err {+ logging.LogErrorf("read dir failed: %s", err)+ return+ }++ for _, entry := range entries {+ if entry.IsDir() {+ continue+ }++ if !strings.HasSuffix(entry.Name(), ".sy") {+ continue+ }++ rootID := strings.TrimSuffix(entry.Name(), ".sy")+ blockIDs := getTreeSubTreeChildBlocks(rootID)+ for _, blockID := range deckBlockIDs {+ if gulu.Str.Contains(blockID, blockIDs) {+ return true+ }+ }+ }+ return+}++var (+ Decks = map[string]*riff.Deck{}+ deckLock = sync.Mutex{}+)func GetNotebookFlashcards(boxID string, page int) (blocks []*Block, total, pageCount int) {blocks = []*Block{}@@ -66,9 +111,7 @@ func GetNotebookFlashcards(boxID string, page int) (blocks []*Block, total, pagevar treeBlockIDs []stringfor _, rootID := range rootIDs {blockIDs := getTreeSubTreeChildBlocks(rootID)- for _, blockID := range blockIDs {- treeBlockIDs = append(treeBlockIDs, blockID)- }+ treeBlockIDs = append(treeBlockIDs, blockIDs...)}treeBlockIDs = gulu.Str.RemoveDuplicatedElem(treeBlockIDs)@@ -307,9 +350,7 @@ func GetNotebookDueFlashcards(boxID string, reviewedCardIDs []string) (ret []*Flvar treeBlockIDs []stringfor _, rootID := range rootIDs {blockIDs := getTreeSubTreeChildBlocks(rootID)- for _, blockID := range blockIDs {- treeBlockIDs = append(treeBlockIDs, blockID)- }+ treeBlockIDs = append(treeBlockIDs, blockIDs...)}treeBlockIDs = gulu.Str.RemoveDuplicatedElem(treeBlockIDs)