mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-12-18 15:40:12 +01:00
🎨 Init plugin system https://github.com/siyuan-note/siyuan/issues/8041
This commit is contained in:
parent
109462a22f
commit
37e2528713
6 changed files with 15 additions and 0 deletions
|
|
@ -133,6 +133,7 @@ func InstalledIcons() (ret []*Icon) {
|
||||||
icon.PreviewURL = "/appearance/icons/" + dirName + "/preview.png"
|
icon.PreviewURL = "/appearance/icons/" + dirName + "/preview.png"
|
||||||
icon.PreviewURLThumb = "/appearance/icons/" + dirName + "/preview.png"
|
icon.PreviewURLThumb = "/appearance/icons/" + dirName + "/preview.png"
|
||||||
icon.IconURL = "/appearance/icons/" + dirName + "/icon.png"
|
icon.IconURL = "/appearance/icons/" + dirName + "/icon.png"
|
||||||
|
icon.Funding = parseFunding(iconConf)
|
||||||
info, statErr := os.Stat(filepath.Join(installPath, "README.md"))
|
info, statErr := os.Stat(filepath.Join(installPath, "README.md"))
|
||||||
if nil != statErr {
|
if nil != statErr {
|
||||||
logging.LogWarnf("stat install theme README.md failed: %s", statErr)
|
logging.LogWarnf("stat install theme README.md failed: %s", statErr)
|
||||||
|
|
|
||||||
|
|
@ -75,6 +75,16 @@ type Package struct {
|
||||||
Downloads int `json:"downloads"`
|
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) {
|
func PluginJSON(pluginDirName string) (ret map[string]interface{}, err error) {
|
||||||
p := filepath.Join(util.DataDir, "plugins", pluginDirName, "plugin.json")
|
p := filepath.Join(util.DataDir, "plugins", pluginDirName, "plugin.json")
|
||||||
if !gulu.File.IsExist(p) {
|
if !gulu.File.IsExist(p) {
|
||||||
|
|
|
||||||
|
|
@ -138,6 +138,7 @@ func InstalledPlugins() (ret []*Plugin) {
|
||||||
plugin.PreviewURL = "/plugins/" + dirName + "/preview.png"
|
plugin.PreviewURL = "/plugins/" + dirName + "/preview.png"
|
||||||
plugin.PreviewURLThumb = "/plugins/" + dirName + "/preview.png"
|
plugin.PreviewURLThumb = "/plugins/" + dirName + "/preview.png"
|
||||||
plugin.IconURL = "/plugins/" + dirName + "/icon.png"
|
plugin.IconURL = "/plugins/" + dirName + "/icon.png"
|
||||||
|
plugin.Funding = parseFunding(pluginConf)
|
||||||
info, statErr := os.Stat(filepath.Join(installPath, "README.md"))
|
info, statErr := os.Stat(filepath.Join(installPath, "README.md"))
|
||||||
if nil != statErr {
|
if nil != statErr {
|
||||||
logging.LogWarnf("stat install theme README.md failed: %s", statErr)
|
logging.LogWarnf("stat install theme README.md failed: %s", statErr)
|
||||||
|
|
|
||||||
|
|
@ -140,6 +140,7 @@ func InstalledTemplates() (ret []*Template) {
|
||||||
template.PreviewURL = "/templates/" + dirName + "/preview.png"
|
template.PreviewURL = "/templates/" + dirName + "/preview.png"
|
||||||
template.PreviewURLThumb = "/templates/" + dirName + "/preview.png"
|
template.PreviewURLThumb = "/templates/" + dirName + "/preview.png"
|
||||||
template.IconURL = "/templates/" + dirName + "/icon.png"
|
template.IconURL = "/templates/" + dirName + "/icon.png"
|
||||||
|
template.Funding = parseFunding(templateConf)
|
||||||
info, statErr := os.Stat(filepath.Join(installPath, "README.md"))
|
info, statErr := os.Stat(filepath.Join(installPath, "README.md"))
|
||||||
if nil != statErr {
|
if nil != statErr {
|
||||||
logging.LogWarnf("stat install theme README.md failed: %s", statErr)
|
logging.LogWarnf("stat install theme README.md failed: %s", statErr)
|
||||||
|
|
|
||||||
|
|
@ -144,6 +144,7 @@ func InstalledThemes() (ret []*Theme) {
|
||||||
theme.PreviewURL = "/appearance/themes/" + dirName + "/preview.png"
|
theme.PreviewURL = "/appearance/themes/" + dirName + "/preview.png"
|
||||||
theme.PreviewURLThumb = "/appearance/themes/" + dirName + "/preview.png"
|
theme.PreviewURLThumb = "/appearance/themes/" + dirName + "/preview.png"
|
||||||
theme.IconURL = "/appearance/themes/" + dirName + "/icon.png"
|
theme.IconURL = "/appearance/themes/" + dirName + "/icon.png"
|
||||||
|
theme.Funding = parseFunding(themeConf)
|
||||||
info, statErr := os.Stat(filepath.Join(installPath, "README.md"))
|
info, statErr := os.Stat(filepath.Join(installPath, "README.md"))
|
||||||
if nil != statErr {
|
if nil != statErr {
|
||||||
logging.LogWarnf("stat install theme README.md failed: %s", statErr)
|
logging.LogWarnf("stat install theme README.md failed: %s", statErr)
|
||||||
|
|
|
||||||
|
|
@ -138,6 +138,7 @@ func InstalledWidgets() (ret []*Widget) {
|
||||||
widget.PreviewURL = "/widgets/" + dirName + "/preview.png"
|
widget.PreviewURL = "/widgets/" + dirName + "/preview.png"
|
||||||
widget.PreviewURLThumb = "/widgets/" + dirName + "/preview.png"
|
widget.PreviewURLThumb = "/widgets/" + dirName + "/preview.png"
|
||||||
widget.IconURL = "/widgets/" + dirName + "/icon.png"
|
widget.IconURL = "/widgets/" + dirName + "/icon.png"
|
||||||
|
widget.Funding = parseFunding(widgetConf)
|
||||||
info, statErr := os.Stat(filepath.Join(installPath, "README.md"))
|
info, statErr := os.Stat(filepath.Join(installPath, "README.md"))
|
||||||
if nil != statErr {
|
if nil != statErr {
|
||||||
logging.LogWarnf("stat install theme README.md failed: %s", statErr)
|
logging.LogWarnf("stat install theme README.md failed: %s", statErr)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue