Merge remote-tracking branch 'origin/dev' into dev
This commit is contained in:
commit
4187c39b2f
2 changed files with 5 additions and 2 deletions
|
@ -70,7 +70,7 @@ func openRepoSnapshotDoc(c *gin.Context) {
|
|||
}
|
||||
|
||||
id := arg["id"].(string)
|
||||
content, isProtyleDoc, updated, err := model.OpenRepoSnapshotDoc(id)
|
||||
title, content, isProtyleDoc, updated, err := model.OpenRepoSnapshotDoc(id)
|
||||
if err != nil {
|
||||
ret.Code = -1
|
||||
ret.Msg = err.Error()
|
||||
|
@ -78,6 +78,7 @@ func openRepoSnapshotDoc(c *gin.Context) {
|
|||
}
|
||||
|
||||
ret.Data = map[string]interface{}{
|
||||
"title": title,
|
||||
"content": content,
|
||||
"isProtyleDoc": isProtyleDoc,
|
||||
"updated": updated,
|
||||
|
|
|
@ -79,7 +79,7 @@ func GetRepoFile(fileID string) (ret []byte, p string, err error) {
|
|||
return
|
||||
}
|
||||
|
||||
func OpenRepoSnapshotDoc(fileID string) (content string, isProtyleDoc bool, updated int64, err error) {
|
||||
func OpenRepoSnapshotDoc(fileID string) (title, content string, isProtyleDoc bool, updated int64, err error) {
|
||||
if 1 > len(Conf.Repo.Key) {
|
||||
err = errors.New(Conf.Language(26))
|
||||
return
|
||||
|
@ -110,6 +110,7 @@ func OpenRepoSnapshotDoc(fileID string) (content string, isProtyleDoc bool, upda
|
|||
logging.LogErrorf("parse tree from snapshot file [%s] failed", fileID)
|
||||
return
|
||||
}
|
||||
title = snapshotTree.Root.IALAttr("title")
|
||||
|
||||
if !isProtyleDoc {
|
||||
renderTree := &parse.Tree{Root: &ast.Node{Type: ast.NodeDocument}}
|
||||
|
@ -150,6 +151,7 @@ func OpenRepoSnapshotDoc(fileID string) (content string, isProtyleDoc bool, upda
|
|||
}
|
||||
} else {
|
||||
isProtyleDoc = true
|
||||
title = path.Base(file.Path)
|
||||
if strings.HasSuffix(file.Path, ".json") {
|
||||
content = gulu.Str.FromBytes(data)
|
||||
} else {
|
||||
|
|
Loading…
Add table
Reference in a new issue