mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-12-17 07:00:12 +01:00
🎨 Add more file formats supporting snapshots comparing https://github.com/siyuan-note/siyuan/issues/8438
This commit is contained in:
parent
922f9ee820
commit
7ebc8f0459
2 changed files with 7 additions and 7 deletions
|
|
@ -36,7 +36,7 @@ func openRepoSnapshotDoc(c *gin.Context) {
|
||||||
}
|
}
|
||||||
|
|
||||||
id := arg["id"].(string)
|
id := arg["id"].(string)
|
||||||
id, rootID, content, isLargeDoc, updated, err := model.OpenRepoSnapshotDoc(id)
|
content, isLargeDoc, updated, err := model.OpenRepoSnapshotDoc(id)
|
||||||
if nil != err {
|
if nil != err {
|
||||||
ret.Code = -1
|
ret.Code = -1
|
||||||
ret.Msg = err.Error()
|
ret.Msg = err.Error()
|
||||||
|
|
@ -44,8 +44,6 @@ func openRepoSnapshotDoc(c *gin.Context) {
|
||||||
}
|
}
|
||||||
|
|
||||||
ret.Data = map[string]interface{}{
|
ret.Data = map[string]interface{}{
|
||||||
"id": id,
|
|
||||||
"rootID": rootID,
|
|
||||||
"content": content,
|
"content": content,
|
||||||
"isLargeDoc": isLargeDoc,
|
"isLargeDoc": isLargeDoc,
|
||||||
"updated": updated,
|
"updated": updated,
|
||||||
|
|
|
||||||
|
|
@ -71,7 +71,7 @@ type TypeCount struct {
|
||||||
Count int `json:"count"`
|
Count int `json:"count"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func OpenRepoSnapshotDoc(fileID string) (id, rootID, content string, isLargeDoc bool, updated int64, err error) {
|
func OpenRepoSnapshotDoc(fileID string) (content string, isLargeDoc bool, updated int64, err error) {
|
||||||
if 1 > len(Conf.Repo.Key) {
|
if 1 > len(Conf.Repo.Key) {
|
||||||
err = errors.New(Conf.Language(26))
|
err = errors.New(Conf.Language(26))
|
||||||
return
|
return
|
||||||
|
|
@ -102,8 +102,6 @@ func OpenRepoSnapshotDoc(fileID string) (id, rootID, content string, isLargeDoc
|
||||||
logging.LogErrorf("parse tree from snapshot file [%s] failed", fileID)
|
logging.LogErrorf("parse tree from snapshot file [%s] failed", fileID)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
id = snapshotTree.Root.ID
|
|
||||||
rootID = snapshotTree.Root.ID
|
|
||||||
|
|
||||||
if !isLargeDoc {
|
if !isLargeDoc {
|
||||||
renderTree := &parse.Tree{Root: &ast.Node{Type: ast.NodeDocument}}
|
renderTree := &parse.Tree{Root: &ast.Node{Type: ast.NodeDocument}}
|
||||||
|
|
@ -147,7 +145,11 @@ func OpenRepoSnapshotDoc(fileID string) (id, rootID, content string, isLargeDoc
|
||||||
if strings.HasSuffix(file.Path, ".json") {
|
if strings.HasSuffix(file.Path, ".json") {
|
||||||
content = gulu.Str.FromBytes(data)
|
content = gulu.Str.FromBytes(data)
|
||||||
} else {
|
} else {
|
||||||
content = file.Path
|
if strings.Contains(file.Path, "assets/") {
|
||||||
|
content = file.Path[strings.Index(file.Path, "assets/"):]
|
||||||
|
} else {
|
||||||
|
content = file.Path
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return
|
return
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue