mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-09-22 00:20:47 +02:00
🎨 Kernel API supports load plugins https://github.com/siyuan-note/siyuan/issues/8044
This commit is contained in:
parent
c62b1a102a
commit
6e864a2718
5 changed files with 36 additions and 3 deletions
|
@ -24,6 +24,7 @@ import (
|
|||
"strings"
|
||||
"sync"
|
||||
|
||||
"github.com/88250/gulu"
|
||||
"github.com/dustin/go-humanize"
|
||||
ants "github.com/panjf2000/ants/v2"
|
||||
"github.com/siyuan-note/httpclient"
|
||||
|
@ -98,7 +99,13 @@ func Plugins() (plugins []*Plugin) {
|
|||
|
||||
func InstalledPlugins() (ret []*Plugin) {
|
||||
ret = []*Plugin{}
|
||||
pluginDirs, err := os.ReadDir(filepath.Join(util.DataDir, "plugins"))
|
||||
|
||||
pluginsPath := filepath.Join(util.DataDir, "plugins")
|
||||
if !gulu.File.IsDir(pluginsPath) {
|
||||
return
|
||||
}
|
||||
|
||||
pluginDirs, err := os.ReadDir(pluginsPath)
|
||||
if nil != err {
|
||||
logging.LogWarnf("read plugins folder failed: %s", err)
|
||||
return
|
||||
|
|
|
@ -25,6 +25,7 @@ import (
|
|||
"sync"
|
||||
"time"
|
||||
|
||||
"github.com/88250/gulu"
|
||||
"github.com/dustin/go-humanize"
|
||||
"github.com/panjf2000/ants/v2"
|
||||
"github.com/siyuan-note/httpclient"
|
||||
|
@ -100,7 +101,13 @@ func Templates() (templates []*Template) {
|
|||
|
||||
func InstalledTemplates() (ret []*Template) {
|
||||
ret = []*Template{}
|
||||
templateDirs, err := os.ReadDir(filepath.Join(util.DataDir, "templates"))
|
||||
|
||||
templatesPath := filepath.Join(util.DataDir, "templates")
|
||||
if !gulu.File.IsDir(templatesPath) {
|
||||
return
|
||||
}
|
||||
|
||||
templateDirs, err := os.ReadDir(templatesPath)
|
||||
if nil != err {
|
||||
logging.LogWarnf("read templates folder failed: %s", err)
|
||||
return
|
||||
|
|
|
@ -24,6 +24,7 @@ import (
|
|||
"strings"
|
||||
"sync"
|
||||
|
||||
"github.com/88250/gulu"
|
||||
"github.com/dustin/go-humanize"
|
||||
ants "github.com/panjf2000/ants/v2"
|
||||
"github.com/siyuan-note/httpclient"
|
||||
|
@ -99,6 +100,11 @@ func Themes() (ret []*Theme) {
|
|||
|
||||
func InstalledThemes() (ret []*Theme) {
|
||||
ret = []*Theme{}
|
||||
|
||||
if !gulu.File.IsDir(util.ThemesPath) {
|
||||
return
|
||||
}
|
||||
|
||||
themeDirs, err := os.ReadDir(util.ThemesPath)
|
||||
if nil != err {
|
||||
logging.LogWarnf("read appearance themes folder failed: %s", err)
|
||||
|
|
|
@ -24,6 +24,7 @@ import (
|
|||
"strings"
|
||||
"sync"
|
||||
|
||||
"github.com/88250/gulu"
|
||||
"github.com/dustin/go-humanize"
|
||||
ants "github.com/panjf2000/ants/v2"
|
||||
"github.com/siyuan-note/httpclient"
|
||||
|
@ -98,7 +99,13 @@ func Widgets() (widgets []*Widget) {
|
|||
|
||||
func InstalledWidgets() (ret []*Widget) {
|
||||
ret = []*Widget{}
|
||||
widgetDirs, err := os.ReadDir(filepath.Join(util.DataDir, "widgets"))
|
||||
|
||||
widgetsPath := filepath.Join(util.DataDir, "widgets")
|
||||
if !gulu.File.IsDir(widgetsPath) {
|
||||
return
|
||||
}
|
||||
|
||||
widgetDirs, err := os.ReadDir(widgetsPath)
|
||||
if nil != err {
|
||||
logging.LogWarnf("read widgets folder failed: %s", err)
|
||||
return
|
||||
|
|
|
@ -19,6 +19,7 @@ package model
|
|||
import (
|
||||
"crypto/sha1"
|
||||
"fmt"
|
||||
"os"
|
||||
"path/filepath"
|
||||
|
||||
"github.com/88250/gulu"
|
||||
|
@ -41,6 +42,11 @@ type Petal struct {
|
|||
|
||||
func LoadPetals() (ret []*Petal) {
|
||||
petalDir := filepath.Join(util.DataDir, "storage", "petal")
|
||||
if err := os.MkdirAll(petalDir, 0755); nil != err {
|
||||
logging.LogErrorf("create petal dir [%s] failed: %s", petalDir, err)
|
||||
return
|
||||
}
|
||||
|
||||
confPath := filepath.Join(petalDir, "petals.json")
|
||||
|
||||
ret = []*Petal{}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue