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: Add an internal kernel API `/api/block/prependDailyNoteBlock` https://github.com/siyuan-note/siyuan/issues/11442
Daniel15375cfd98a7
diff --git a/kernel/api/block_op.go b/kernel/api/block_op.goindex 65d9a96a2a..24bb48fdb4 100644--- a/kernel/api/block_op.go+++ b/kernel/api/block_op.go@@ -133,6 +133,59 @@ func appendDailyNoteBlock(c *gin.Context) {broadcastTransactions(transactions)}+func prependDailyNoteBlock(c *gin.Context) {+ ret := gulu.Ret.NewResult()+ defer c.JSON(http.StatusOK, ret)++ arg, ok := util.JsonArg(c, ret)+ if !ok {+ return+ }++ data := arg["data"].(string)+ dataType := arg["dataType"].(string)+ boxID := arg["notebook"].(string)+ if util.InvalidIDPattern(boxID, ret) {+ return+ }+ if "markdown" == dataType {+ luteEngine := util.NewLute()+ var err error+ data, err = dataBlockDOM(data, luteEngine)+ if nil != err {+ ret.Code = -1+ ret.Msg = "data block DOM failed: " + err.Error()+ return+ }+ }++ p, _, err := model.CreateDailyNote(boxID)+ if nil != err {+ ret.Code = -1+ ret.Msg = "create daily note failed: " + err.Error()+ return+ }++ parentID := strings.TrimSuffix(path.Base(p), ".sy")+ transactions := []*model.Transaction{+ {+ DoOperations: []*model.Operation{+ {+ Action: "prependInsert",+ Data: data,+ ParentID: parentID,+ },+ },+ },+ }++ model.PerformTransactions(&transactions)+ model.WaitForWritingFiles()++ ret.Data = transactions+ broadcastTransactions(transactions)+}+func unfoldBlock(c *gin.Context) {ret := gulu.Ret.NewResult()defer c.JSON(http.StatusOK, ret)diff --git a/kernel/api/router.go b/kernel/api/router.goindex 45f2148e16..d4e622fa59 100644--- a/kernel/api/router.go+++ b/kernel/api/router.go@@ -185,6 +185,7 @@ func ServeAPI(ginServer *gin.Engine) {ginServer.Handle("POST", "/api/block/prependBlock", model.CheckAuth, model.CheckReadonly, prependBlock)ginServer.Handle("POST", "/api/block/appendBlock", model.CheckAuth, model.CheckReadonly, appendBlock)ginServer.Handle("POST", "/api/block/appendDailyNoteBlock", model.CheckAuth, model.CheckReadonly, appendDailyNoteBlock)+ ginServer.Handle("POST", "/api/block/prependDailyNoteBlock", model.CheckAuth, model.CheckReadonly, prependDailyNoteBlock)ginServer.Handle("POST", "/api/block/updateBlock", model.CheckAuth, model.CheckReadonly, updateBlock)ginServer.Handle("POST", "/api/block/deleteBlock", model.CheckAuth, model.CheckReadonly, deleteBlock)ginServer.Handle("POST", "/api/block/moveBlock", model.CheckAuth, model.CheckReadonly, moveBlock)