Merge remote-tracking branch 'origin/dev' into dev

This commit is contained in:
Vanessa 2023-09-13 09:37:01 +08:00
commit c1ee0d0638
4 changed files with 36 additions and 11 deletions

View file

@ -524,8 +524,19 @@ func ExportMarkdownHTML(id, savePath string, docx, merge bool) (name, dom string
theme = Conf.Appearance.ThemeDark
}
srcs = []string{"icons", "themes/" + theme}
appearancePath := util.AppearancePath
if util.IsSymlinkPath(util.AppearancePath) {
// Support for symlinked theme folder when exporting HTML https://github.com/siyuan-note/siyuan/issues/9173
var readErr error
appearancePath, readErr = filepath.EvalSymlinks(util.AppearancePath)
if nil != readErr {
logging.LogErrorf("readlink [%s] failed: %s", util.AppearancePath, readErr)
return
}
}
for _, src := range srcs {
from := filepath.Join(util.AppearancePath, src)
from := filepath.Join(appearancePath, src)
to := filepath.Join(savePath, "appearance", src)
if err := filelock.Copy(from, to); nil != err {
logging.LogErrorf("copy appearance from [%s] to [%s] failed: %s", from, savePath, err)
@ -663,8 +674,18 @@ func ExportHTML(id, savePath string, pdf, image, keepFold, merge bool) (name, do
theme = Conf.Appearance.ThemeDark
}
srcs = []string{"icons", "themes/" + theme}
appearancePath := util.AppearancePath
if util.IsSymlinkPath(util.AppearancePath) {
// Support for symlinked theme folder when exporting HTML https://github.com/siyuan-note/siyuan/issues/9173
var readErr error
appearancePath, readErr = filepath.EvalSymlinks(util.AppearancePath)
if nil != readErr {
logging.LogErrorf("readlink [%s] failed: %s", util.AppearancePath, readErr)
return
}
}
for _, src := range srcs {
from := filepath.Join(util.AppearancePath, src)
from := filepath.Join(appearancePath, src)
to := filepath.Join(savePath, "appearance", src)
if err := filelock.Copy(from, to); nil != err {
logging.LogErrorf("copy appearance from [%s] to [%s] failed: %s", from, savePath, err)

View file

@ -1058,7 +1058,8 @@ func GetHPathsByPaths(paths []string) (hPaths []string, err error) {
continue
}
hPaths = append(hPaths, box.Name+bt.HPath)
hpath := html.UnescapeString(bt.HPath)
hPaths = append(hPaths, util.EscapeHTML(box.Name)+hpath)
}
return
}

View file

@ -31,6 +31,14 @@ import (
"github.com/siyuan-note/logging"
)
func IsSymlinkPath(absPath string) bool {
fi, err := os.Lstat(absPath)
if nil != err {
return false
}
return 0 != fi.Mode()&os.ModeSymlink
}
func IsEmptyDir(p string) bool {
if !gulu.File.IsDir(p) {
return false

View file

@ -392,15 +392,10 @@ func initMime() {
func GetDataAssetsAbsPath() (ret string) {
ret = filepath.Join(DataDir, "assets")
var err error
stat, err := os.Lstat(ret)
if nil != err {
logging.LogErrorf("stat assets failed: %s", err)
return
}
if 0 != stat.Mode()&os.ModeSymlink {
if IsSymlinkPath(ret) {
// 跟随符号链接 https://github.com/siyuan-note/siyuan/issues/5480
ret, err = os.Readlink(ret)
var err error
ret, err = filepath.EvalSymlinks(ret)
if nil != err {
logging.LogErrorf("read assets link failed: %s", err)
}