mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-12-16 14:40:12 +01:00
🎨 Trim space in dialynote/block ref/new doc save path https://github.com/siyuan-note/siyuan/issues/14482
This commit is contained in:
parent
54c25af19f
commit
4c080e2b34
3 changed files with 15 additions and 6 deletions
|
|
@ -361,14 +361,14 @@ func setNotebookConf(c *gin.Context) {
|
|||
return
|
||||
}
|
||||
|
||||
boxConf.RefCreateSavePath = strings.TrimSpace(boxConf.RefCreateSavePath)
|
||||
boxConf.RefCreateSavePath = util.TrimSpaceInPath(boxConf.RefCreateSavePath)
|
||||
if "" != boxConf.RefCreateSavePath {
|
||||
if !strings.HasSuffix(boxConf.RefCreateSavePath, "/") {
|
||||
boxConf.RefCreateSavePath += "/"
|
||||
}
|
||||
}
|
||||
|
||||
boxConf.DailyNoteSavePath = strings.TrimSpace(boxConf.DailyNoteSavePath)
|
||||
boxConf.DailyNoteSavePath = util.TrimSpaceInPath(boxConf.DailyNoteSavePath)
|
||||
if "" != boxConf.DailyNoteSavePath {
|
||||
if !strings.HasPrefix(boxConf.DailyNoteSavePath, "/") {
|
||||
boxConf.DailyNoteSavePath = "/" + boxConf.DailyNoteSavePath
|
||||
|
|
@ -380,7 +380,7 @@ func setNotebookConf(c *gin.Context) {
|
|||
return
|
||||
}
|
||||
|
||||
boxConf.DailyNoteTemplatePath = strings.TrimSpace(boxConf.DailyNoteTemplatePath)
|
||||
boxConf.DailyNoteTemplatePath = util.TrimSpaceInPath(boxConf.DailyNoteTemplatePath)
|
||||
if "" != boxConf.DailyNoteTemplatePath {
|
||||
if !strings.HasSuffix(boxConf.DailyNoteTemplatePath, ".md") {
|
||||
boxConf.DailyNoteTemplatePath += ".md"
|
||||
|
|
@ -390,7 +390,7 @@ func setNotebookConf(c *gin.Context) {
|
|||
}
|
||||
}
|
||||
|
||||
boxConf.DocCreateSavePath = strings.TrimSpace(boxConf.DocCreateSavePath)
|
||||
boxConf.DocCreateSavePath = util.TrimSpaceInPath(boxConf.DocCreateSavePath)
|
||||
|
||||
box.SaveConf(boxConf)
|
||||
ret.Data = boxConf
|
||||
|
|
|
|||
|
|
@ -399,14 +399,14 @@ func setFiletree(c *gin.Context) {
|
|||
return
|
||||
}
|
||||
|
||||
fileTree.RefCreateSavePath = strings.TrimSpace(fileTree.RefCreateSavePath)
|
||||
fileTree.RefCreateSavePath = util.TrimSpaceInPath(fileTree.RefCreateSavePath)
|
||||
if "" != fileTree.RefCreateSavePath {
|
||||
if !strings.HasSuffix(fileTree.RefCreateSavePath, "/") {
|
||||
fileTree.RefCreateSavePath += "/"
|
||||
}
|
||||
}
|
||||
|
||||
fileTree.DocCreateSavePath = strings.TrimSpace(fileTree.DocCreateSavePath)
|
||||
fileTree.DocCreateSavePath = util.TrimSpaceInPath(fileTree.DocCreateSavePath)
|
||||
|
||||
if 1 > fileTree.MaxOpenTabCount {
|
||||
fileTree.MaxOpenTabCount = 8
|
||||
|
|
|
|||
|
|
@ -38,6 +38,15 @@ var (
|
|||
UserAgent = "SiYuan/" + Ver
|
||||
)
|
||||
|
||||
func TrimSpaceInPath(p string) string {
|
||||
p = strings.ReplaceAll(p, "\\", "/")
|
||||
parts := strings.Split(p, "/")
|
||||
for i, part := range parts {
|
||||
parts[i] = strings.TrimSpace(part)
|
||||
}
|
||||
return strings.Join(parts, "/")
|
||||
}
|
||||
|
||||
func GetTreeID(treePath string) string {
|
||||
if strings.Contains(treePath, "\\") {
|
||||
return strings.TrimSuffix(filepath.Base(treePath), ".sy")
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue