mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-12-21 17:10:12 +01:00
🎨 Support for symlinked theme folder when exporting HTML https://github.com/siyuan-note/siyuan/issues/9173
This commit is contained in:
parent
07b28ddb48
commit
736256e26a
2 changed files with 31 additions and 2 deletions
|
|
@ -524,8 +524,19 @@ func ExportMarkdownHTML(id, savePath string, docx, merge bool) (name, dom string
|
||||||
theme = Conf.Appearance.ThemeDark
|
theme = Conf.Appearance.ThemeDark
|
||||||
}
|
}
|
||||||
srcs = []string{"icons", "themes/" + theme}
|
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 = os.Readlink(util.AppearancePath)
|
||||||
|
if nil != readErr {
|
||||||
|
logging.LogErrorf("readlink [%s] failed: %s", util.AppearancePath, readErr)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
for _, src := range srcs {
|
for _, src := range srcs {
|
||||||
from := filepath.Join(util.AppearancePath, src)
|
from := filepath.Join(appearancePath, src)
|
||||||
to := filepath.Join(savePath, "appearance", src)
|
to := filepath.Join(savePath, "appearance", src)
|
||||||
if err := filelock.Copy(from, to); nil != err {
|
if err := filelock.Copy(from, to); nil != err {
|
||||||
logging.LogErrorf("copy appearance from [%s] to [%s] failed: %s", from, savePath, 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
|
theme = Conf.Appearance.ThemeDark
|
||||||
}
|
}
|
||||||
srcs = []string{"icons", "themes/" + theme}
|
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 = os.Readlink(util.AppearancePath)
|
||||||
|
if nil != readErr {
|
||||||
|
logging.LogErrorf("readlink [%s] failed: %s", util.AppearancePath, readErr)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
for _, src := range srcs {
|
for _, src := range srcs {
|
||||||
from := filepath.Join(util.AppearancePath, src)
|
from := filepath.Join(appearancePath, src)
|
||||||
to := filepath.Join(savePath, "appearance", src)
|
to := filepath.Join(savePath, "appearance", src)
|
||||||
if err := filelock.Copy(from, to); nil != err {
|
if err := filelock.Copy(from, to); nil != err {
|
||||||
logging.LogErrorf("copy appearance from [%s] to [%s] failed: %s", from, savePath, err)
|
logging.LogErrorf("copy appearance from [%s] to [%s] failed: %s", from, savePath, err)
|
||||||
|
|
|
||||||
|
|
@ -31,6 +31,14 @@ import (
|
||||||
"github.com/siyuan-note/logging"
|
"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 {
|
func IsEmptyDir(p string) bool {
|
||||||
if !gulu.File.IsDir(p) {
|
if !gulu.File.IsDir(p) {
|
||||||
return false
|
return false
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue