mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-05-03 06:11:24 +08:00
This commit is contained in:
parent
26e9c3a4c6
commit
28485f7ffb
@ -26,6 +26,28 @@ import (
|
|||||||
"github.com/siyuan-note/siyuan/kernel/util"
|
"github.com/siyuan-note/siyuan/kernel/util"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
func renderRiffCard(c *gin.Context) {
|
||||||
|
ret := gulu.Ret.NewResult()
|
||||||
|
defer c.JSON(http.StatusOK, ret)
|
||||||
|
|
||||||
|
arg, ok := util.JsonArg(c, ret)
|
||||||
|
if !ok {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
blockID := arg["blockID"].(string)
|
||||||
|
content, err := model.RenderFlashcard(blockID)
|
||||||
|
if nil != err {
|
||||||
|
ret.Code = -1
|
||||||
|
ret.Msg = err.Error()
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
ret.Data = map[string]interface{}{
|
||||||
|
"content": content,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func reviewRiffCard(c *gin.Context) {
|
func reviewRiffCard(c *gin.Context) {
|
||||||
ret := gulu.Ret.NewResult()
|
ret := gulu.Ret.NewResult()
|
||||||
defer c.JSON(http.StatusOK, ret)
|
defer c.JSON(http.StatusOK, ret)
|
||||||
|
@ -305,6 +305,7 @@ func ServeAPI(ginServer *gin.Engine) {
|
|||||||
ginServer.Handle("POST", "/api/riff/addRiffCards", model.CheckAuth, addRiffCards)
|
ginServer.Handle("POST", "/api/riff/addRiffCards", model.CheckAuth, addRiffCards)
|
||||||
ginServer.Handle("POST", "/api/riff/removeRiffCards", model.CheckAuth, removeRiffCards)
|
ginServer.Handle("POST", "/api/riff/removeRiffCards", model.CheckAuth, removeRiffCards)
|
||||||
ginServer.Handle("POST", "/api/riff/getRiffDueCards", model.CheckAuth, getRiffDueCards)
|
ginServer.Handle("POST", "/api/riff/getRiffDueCards", model.CheckAuth, getRiffDueCards)
|
||||||
|
ginServer.Handle("POST", "/api/riff/renderRiffCard", model.CheckAuth, renderRiffCard)
|
||||||
ginServer.Handle("POST", "/api/riff/reviewRiffCard", model.CheckAuth, reviewRiffCard)
|
ginServer.Handle("POST", "/api/riff/reviewRiffCard", model.CheckAuth, reviewRiffCard)
|
||||||
|
|
||||||
ginServer.Handle("POST", "/api/notification/pushMsg", model.CheckAuth, pushMsg)
|
ginServer.Handle("POST", "/api/notification/pushMsg", model.CheckAuth, pushMsg)
|
||||||
|
@ -17,6 +17,8 @@
|
|||||||
package model
|
package model
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"github.com/88250/lute"
|
||||||
|
"github.com/siyuan-note/siyuan/kernel/treenode"
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"strings"
|
"strings"
|
||||||
@ -31,6 +33,27 @@ import (
|
|||||||
var Decks = map[string]*riff.Deck{}
|
var Decks = map[string]*riff.Deck{}
|
||||||
var deckLock = sync.Mutex{}
|
var deckLock = sync.Mutex{}
|
||||||
|
|
||||||
|
func RenderFlashcard(blockID string) (content string, err error) {
|
||||||
|
tree, err := loadTreeByBlockID(blockID)
|
||||||
|
if nil != err {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
node := treenode.GetNodeInTree(tree, blockID)
|
||||||
|
if nil == node {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
luteEngine := NewLute()
|
||||||
|
luteEngine.RenderOptions.ProtyleContenteditable = false
|
||||||
|
if ast.NodeDocument == node.Type {
|
||||||
|
content = luteEngine.Tree2BlockDOM(tree, luteEngine.RenderOptions)
|
||||||
|
} else {
|
||||||
|
content = lute.RenderNodeBlockDOM(node, luteEngine.ParseOptions, luteEngine.RenderOptions)
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
func ReviewFlashcard(deckID string, blockID string, rating riff.Rating) (err error) {
|
func ReviewFlashcard(deckID string, blockID string, rating riff.Rating) (err error) {
|
||||||
deckLock.Lock()
|
deckLock.Lock()
|
||||||
deck := Decks[deckID]
|
deck := Decks[deckID]
|
||||||
|
Loading…
Reference in New Issue
Block a user