mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-12-24 02:20:13 +01:00
🎨 Community marketplace adds plugin section https://github.com/siyuan-note/siyuan/issues/8043
This commit is contained in:
parent
4a5f3ea104
commit
88d70b0c00
2 changed files with 13 additions and 80 deletions
|
|
@ -17,7 +17,6 @@
|
|||
package model
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"os"
|
||||
"path/filepath"
|
||||
|
|
@ -142,72 +141,6 @@ func loadThemes() {
|
|||
}
|
||||
}
|
||||
|
||||
func iconJSON(iconName string) (ret map[string]interface{}, err error) {
|
||||
p := filepath.Join(util.IconsPath, iconName, "icon.json")
|
||||
if !gulu.File.IsExist(p) {
|
||||
err = os.ErrNotExist
|
||||
return
|
||||
}
|
||||
data, err := os.ReadFile(p)
|
||||
if nil != err {
|
||||
logging.LogErrorf("read icon.json [%s] failed: %s", p, err)
|
||||
return
|
||||
}
|
||||
if err = gulu.JSON.UnmarshalJSON(data, &ret); nil != err {
|
||||
logging.LogErrorf("parse icon.json [%s] failed: %s", p, err)
|
||||
return
|
||||
}
|
||||
if 4 > len(ret) {
|
||||
logging.LogWarnf("invalid icon.json [%s]", p)
|
||||
return nil, errors.New("invalid icon.json")
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
func templateJSON(templateName string) (ret map[string]interface{}, err error) {
|
||||
p := filepath.Join(util.DataDir, "templates", templateName, "template.json")
|
||||
if !gulu.File.IsExist(p) {
|
||||
err = os.ErrNotExist
|
||||
return
|
||||
}
|
||||
data, err := os.ReadFile(p)
|
||||
if nil != err {
|
||||
logging.LogErrorf("read template.json [%s] failed: %s", p, err)
|
||||
return
|
||||
}
|
||||
if err = gulu.JSON.UnmarshalJSON(data, &ret); nil != err {
|
||||
logging.LogErrorf("parse template.json [%s] failed: %s", p, err)
|
||||
return
|
||||
}
|
||||
if 4 > len(ret) {
|
||||
logging.LogWarnf("invalid template.json [%s]", p)
|
||||
return nil, errors.New("invalid template.json")
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
func widgetJSON(widgetName string) (ret map[string]interface{}, err error) {
|
||||
p := filepath.Join(util.DataDir, "widgets", widgetName, "widget.json")
|
||||
if !gulu.File.IsExist(p) {
|
||||
err = os.ErrNotExist
|
||||
return
|
||||
}
|
||||
data, err := os.ReadFile(p)
|
||||
if nil != err {
|
||||
logging.LogErrorf("read widget.json [%s] failed: %s", p, err)
|
||||
return
|
||||
}
|
||||
if err = gulu.JSON.UnmarshalJSON(data, &ret); nil != err {
|
||||
logging.LogErrorf("parse widget.json [%s] failed: %s", p, err)
|
||||
return
|
||||
}
|
||||
if 4 > len(ret) {
|
||||
logging.LogWarnf("invalid widget.json [%s]", p)
|
||||
return nil, errors.New("invalid widget.json")
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
func loadIcons() {
|
||||
iconDirs, err := os.ReadDir(util.IconsPath)
|
||||
if nil != err {
|
||||
|
|
@ -222,7 +155,7 @@ func loadIcons() {
|
|||
continue
|
||||
}
|
||||
name := iconDir.Name()
|
||||
iconConf, err := iconJSON(name)
|
||||
iconConf, err := bazaar.IconJSON(name)
|
||||
if nil != err || nil == iconConf {
|
||||
continue
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue