mirror of
https://github.com/siyuan-note/siyuan.git
synced 2026-02-15 19:48:06 +01:00
🎨 Community marketplace adds plugin section https://github.com/siyuan-note/siyuan/issues/8043
This commit is contained in:
parent
0384261c95
commit
4a5f3ea104
5 changed files with 320 additions and 0 deletions
|
|
@ -66,6 +66,28 @@ type Package struct {
|
|||
Downloads int `json:"downloads"`
|
||||
}
|
||||
|
||||
func PluginJSON(pluginDirName string) (ret map[string]interface{}, err error) {
|
||||
p := filepath.Join(util.DataDir, "plugins", pluginDirName, "plugin.json")
|
||||
if !gulu.File.IsExist(p) {
|
||||
err = os.ErrNotExist
|
||||
return
|
||||
}
|
||||
data, err := os.ReadFile(p)
|
||||
if nil != err {
|
||||
logging.LogErrorf("read plugin.json [%s] failed: %s", p, err)
|
||||
return
|
||||
}
|
||||
if err = gulu.JSON.UnmarshalJSON(data, &ret); nil != err {
|
||||
logging.LogErrorf("parse plugin.json [%s] failed: %s", p, err)
|
||||
return
|
||||
}
|
||||
if 4 > len(ret) {
|
||||
logging.LogWarnf("invalid plugin.json [%s]", p)
|
||||
return nil, errors.New("invalid plugin.json")
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
func WidgetJSON(widgetDirName string) (ret map[string]interface{}, err error) {
|
||||
p := filepath.Join(util.DataDir, "widgets", widgetDirName, "widget.json")
|
||||
if !gulu.File.IsExist(p) {
|
||||
|
|
@ -216,6 +238,26 @@ func isOutdatedIcon(icon *Icon, bazaarIcons []*Icon) bool {
|
|||
return false
|
||||
}
|
||||
|
||||
func isOutdatedPlugin(plugin *Plugin, bazaarPlugins []*Plugin) bool {
|
||||
if !strings.HasPrefix(plugin.URL, "https://github.com/") {
|
||||
return false
|
||||
}
|
||||
|
||||
repo := strings.TrimPrefix(plugin.URL, "https://github.com/")
|
||||
parts := strings.Split(repo, "/")
|
||||
if 2 != len(parts) || "" == strings.TrimSpace(parts[1]) {
|
||||
return false
|
||||
}
|
||||
|
||||
for _, pkg := range bazaarPlugins {
|
||||
if plugin.URL == pkg.URL && plugin.Name == pkg.Name && plugin.Author == pkg.Author && plugin.Version < pkg.Version {
|
||||
plugin.RepoHash = pkg.RepoHash
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
func isOutdatedWidget(widget *Widget, bazaarWidgets []*Widget) bool {
|
||||
if !strings.HasPrefix(widget.URL, "https://github.com/") {
|
||||
return false
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue