From 40d8677155f2807c6e2e7a21ecbce36489e5d612 Mon Sep 17 00:00:00 2001 From: Daniel <845765@qq.com> Date: Thu, 27 Mar 2025 17:40:20 +0800 Subject: [PATCH 1/3] :art: Supports local shorthands on Android https://github.com/siyuan-note/siyuan/issues/14414 --- kernel/model/shortcuts.go | 3 --- 1 file changed, 3 deletions(-) diff --git a/kernel/model/shortcuts.go b/kernel/model/shortcuts.go index 53dd42037..5778fd977 100644 --- a/kernel/model/shortcuts.go +++ b/kernel/model/shortcuts.go @@ -59,7 +59,6 @@ func MoveLocalShorthands(boxID, hPath, parentID, id string) (retID string, err e buff.Write(bytes.TrimSpace(data)) buff.WriteString("\n\n") - logging.LogInfof("read shorthand [%s] content [%s]", p, data) toRemoves = append(toRemoves, p) } @@ -77,8 +76,6 @@ func MoveLocalShorthands(boxID, hPath, parentID, id string) (retID string, err e return } - logging.LogInfof("shorthand content [%s]", content) - retID, err = CreateWithMarkdown("", boxID, hPath, content, parentID, id, false, "") if nil != err { logging.LogErrorf("create doc failed: %s", err) From 33ed82526c457eda9be039d9684bad32d03fd82b Mon Sep 17 00:00:00 2001 From: Daniel <845765@qq.com> Date: Fri, 28 Mar 2025 12:46:55 +0800 Subject: [PATCH 2/3] :art: Supports local shorthands on Android https://github.com/siyuan-note/siyuan/issues/14414 --- kernel/mobile/kernel.go | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/kernel/mobile/kernel.go b/kernel/mobile/kernel.go index 4906a3ab8..05b88cca6 100644 --- a/kernel/mobile/kernel.go +++ b/kernel/mobile/kernel.go @@ -279,3 +279,15 @@ func SetTimezone(container, appDir, timezoneID string) { func DisableFeature(feature string) { util.DisableFeature(feature) } + +func FilepathBase(path string) string { + return filepath.Base(path) +} + +func FilterUploadFileName(name string) string { + return util.FilterUploadFileName(name) +} + +func AssetName(name string) string { + return util.AssetName(name) +} From f2654be837df2c66d4fa8062b102d7d05b1d9aa9 Mon Sep 17 00:00:00 2001 From: Daniel <845765@qq.com> Date: Fri, 28 Mar 2025 13:10:06 +0800 Subject: [PATCH 3/3] :art: Supports local shorthands on Android https://github.com/siyuan-note/siyuan/issues/14414 --- kernel/model/shortcuts.go | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/kernel/model/shortcuts.go b/kernel/model/shortcuts.go index 5778fd977..9bcc81fbe 100644 --- a/kernel/model/shortcuts.go +++ b/kernel/model/shortcuts.go @@ -41,9 +41,28 @@ func MoveLocalShorthands(boxID, hPath, parentID, id string) (retID string, err e buff := bytes.Buffer{} var toRemoves []string + assetsDir := filepath.Join(util.DataDir, "assets") for _, entry := range entries { if entry.IsDir() { - continue + if "assets" == entry.Name() { + assetsEntries, readErr := os.ReadDir(filepath.Join(shorthandsDir, entry.Name())) + if nil != readErr { + logging.LogErrorf("read dir [%s] failed: %s", shorthandsDir, readErr) + continue + } + for _, assetEntry := range assetsEntries { + if assetEntry.IsDir() { + continue + } + + p := filepath.Join(shorthandsDir, entry.Name(), assetEntry.Name()) + assetWritePath := filepath.Join(assetsDir, assetEntry.Name()) + if renameErr := os.Rename(p, assetWritePath); nil != renameErr { + logging.LogErrorf("rename file [%s] to [%s] failed: %s", p, assetWritePath, renameErr) + continue + } + } + } } if filepath.Ext(entry.Name()) != ".md" {