Procházet zdrojové kódy

:art: Init plugin system https://github.com/siyuan-note/siyuan/issues/8041

Liang Ding před 2 roky
rodič
revize
37e2528713

+ 1 - 0
kernel/bazaar/icon.go

@@ -133,6 +133,7 @@ func InstalledIcons() (ret []*Icon) {
 		icon.PreviewURL = "/appearance/icons/" + dirName + "/preview.png"
 		icon.PreviewURLThumb = "/appearance/icons/" + dirName + "/preview.png"
 		icon.IconURL = "/appearance/icons/" + dirName + "/icon.png"
+		icon.Funding = parseFunding(iconConf)
 		info, statErr := os.Stat(filepath.Join(installPath, "README.md"))
 		if nil != statErr {
 			logging.LogWarnf("stat install theme README.md failed: %s", statErr)

+ 10 - 0
kernel/bazaar/package.go

@@ -75,6 +75,16 @@ type Package struct {
 	Downloads    int    `json:"downloads"`
 }
 
+func parseFunding(conf map[string]interface{}) (ret *Funding) {
+	ret = &Funding{}
+	funding := conf["funding"].(map[string]interface{})
+	ret.OpenCollective = funding["openCollective"].(string)
+	ret.Patreon = funding["patreon"].(string)
+	ret.GitHub = funding["github"].(string)
+	ret.Custom = funding["custom"].([]string)
+	return
+}
+
 func PluginJSON(pluginDirName string) (ret map[string]interface{}, err error) {
 	p := filepath.Join(util.DataDir, "plugins", pluginDirName, "plugin.json")
 	if !gulu.File.IsExist(p) {

+ 1 - 0
kernel/bazaar/plugin.go

@@ -138,6 +138,7 @@ func InstalledPlugins() (ret []*Plugin) {
 		plugin.PreviewURL = "/plugins/" + dirName + "/preview.png"
 		plugin.PreviewURLThumb = "/plugins/" + dirName + "/preview.png"
 		plugin.IconURL = "/plugins/" + dirName + "/icon.png"
+		plugin.Funding = parseFunding(pluginConf)
 		info, statErr := os.Stat(filepath.Join(installPath, "README.md"))
 		if nil != statErr {
 			logging.LogWarnf("stat install theme README.md failed: %s", statErr)

+ 1 - 0
kernel/bazaar/template.go

@@ -140,6 +140,7 @@ func InstalledTemplates() (ret []*Template) {
 		template.PreviewURL = "/templates/" + dirName + "/preview.png"
 		template.PreviewURLThumb = "/templates/" + dirName + "/preview.png"
 		template.IconURL = "/templates/" + dirName + "/icon.png"
+		template.Funding = parseFunding(templateConf)
 		info, statErr := os.Stat(filepath.Join(installPath, "README.md"))
 		if nil != statErr {
 			logging.LogWarnf("stat install theme README.md failed: %s", statErr)

+ 1 - 0
kernel/bazaar/theme.go

@@ -144,6 +144,7 @@ func InstalledThemes() (ret []*Theme) {
 		theme.PreviewURL = "/appearance/themes/" + dirName + "/preview.png"
 		theme.PreviewURLThumb = "/appearance/themes/" + dirName + "/preview.png"
 		theme.IconURL = "/appearance/themes/" + dirName + "/icon.png"
+		theme.Funding = parseFunding(themeConf)
 		info, statErr := os.Stat(filepath.Join(installPath, "README.md"))
 		if nil != statErr {
 			logging.LogWarnf("stat install theme README.md failed: %s", statErr)

+ 1 - 0
kernel/bazaar/widget.go

@@ -138,6 +138,7 @@ func InstalledWidgets() (ret []*Widget) {
 		widget.PreviewURL = "/widgets/" + dirName + "/preview.png"
 		widget.PreviewURLThumb = "/widgets/" + dirName + "/preview.png"
 		widget.IconURL = "/widgets/" + dirName + "/icon.png"
+		widget.Funding = parseFunding(widgetConf)
 		info, statErr := os.Stat(filepath.Join(installPath, "README.md"))
 		if nil != statErr {
 			logging.LogWarnf("stat install theme README.md failed: %s", statErr)