feat(plugins): made it possible to have relative plugin template urls

This commit is contained in:
Torkel Ödegaard
2016-02-09 18:17:32 +01:00
parent 9653f43466
commit 8784be9a14
24 changed files with 61 additions and 32 deletions
+2
View File
@@ -11,6 +11,7 @@ type AppSettings struct {
Enabled bool `json:"enabled"`
Pinned bool `json:"pinned"`
Module string `json:"module"`
BaseUrl string `json:"baseUrl"`
Info *plugins.PluginInfo `json:"info"`
Pages []*plugins.AppPluginPage `json:"pages"`
Includes []*plugins.AppIncludeInfo `json:"includes"`
@@ -23,6 +24,7 @@ func NewAppSettingsDto(def *plugins.AppPlugin, data *models.AppSettings) *AppSet
Name: def.Name,
Info: &def.Info,
Module: def.Module,
BaseUrl: def.BaseUrl,
Pages: def.Pages,
Includes: def.Includes,
}
+5 -4
View File
@@ -121,10 +121,11 @@ func getFrontendSettingsMap(c *middleware.Context) (map[string]interface{}, erro
panels := map[string]interface{}{}
for _, panel := range enabledPlugins.Panels {
panels[panel.Id] = map[string]interface{}{
"module": panel.Module,
"name": panel.Name,
"id": panel.Id,
"info": panel.Info,
"module": panel.Module,
"baseUrl": panel.BaseUrl,
"name": panel.Name,
"id": panel.Id,
"info": panel.Info,
}
}
+3
View File
@@ -9,6 +9,7 @@ import (
type FrontendPluginBase struct {
PluginBase
Module string `json:"module"`
BaseUrl string `json:"baseUrl"`
StaticRoot string `json:"staticRoot"`
StaticRootAbs string `json:"-"`
}
@@ -34,10 +35,12 @@ func (fp *FrontendPluginBase) handleModuleDefaults() {
if fp.StaticRoot != "" {
fp.Module = path.Join("plugins", fp.Id, "module")
fp.BaseUrl = path.Join("public/plugins", fp.Id)
return
}
fp.Module = path.Join("app/plugins", fp.Type, fp.Id, "module")
fp.BaseUrl = path.Join("public/app/plugins", fp.Type, fp.Id)
}
func evalRelativePluginUrlPath(pathStr string, pluginId string) string {
+4
View File
@@ -102,6 +102,10 @@ func (scanner *PluginScanner) walker(currentPath string, f os.FileInfo, err erro
return err
}
if f.Name() == "node_modules" {
return util.WalkSkipDir
}
if f.IsDir() {
return nil
}