Skip to content

Commit

Permalink
Merge branch 'master' of github.com:grafana/grafana
Browse files Browse the repository at this point in the history
  • Loading branch information
torkelo committed Mar 15, 2016
2 parents c411714 + cba7c17 commit dddd155
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 17 deletions.
15 changes: 9 additions & 6 deletions pkg/plugins/frontend_plugin.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ package plugins
import (
"net/url"
"path"
"path/filepath"
"strings"

"github.com/grafana/grafana/pkg/setting"
"github.com/grafana/grafana/pkg/util"
)

Expand All @@ -14,10 +14,9 @@ type FrontendPluginBase struct {
}

func (fp *FrontendPluginBase) initFrontendPlugin() {
if fp.StaticRoot != "" {
fp.StaticRootAbs = filepath.Join(fp.PluginDir, fp.StaticRoot)
if isInternalPlugin(fp.PluginDir) {
StaticRoutes = append(StaticRoutes, &PluginStaticRoute{
Directory: fp.StaticRootAbs,
Directory: fp.PluginDir,
PluginId: fp.Id,
})
}
Expand All @@ -41,15 +40,15 @@ func getPluginLogoUrl(path, baseUrl string) string {
}

func (fp *FrontendPluginBase) setPathsBasedOnApp(app *AppPlugin) {
appSubPath := strings.Replace(fp.PluginDir, app.StaticRootAbs, "", 1)
appSubPath := strings.Replace(fp.PluginDir, app.PluginDir, "", 1)
fp.IncludedInAppId = app.Id
fp.BaseUrl = app.BaseUrl
fp.Module = util.JoinUrlFragments("plugins/"+app.Id, appSubPath) + "/module"
}

func (fp *FrontendPluginBase) handleModuleDefaults() {

if fp.StaticRoot != "" {
if isInternalPlugin(fp.PluginDir) {
fp.Module = path.Join("plugins", fp.Id, "module")
fp.BaseUrl = path.Join("public/plugins", fp.Id)
return
Expand All @@ -59,6 +58,10 @@ func (fp *FrontendPluginBase) handleModuleDefaults() {
fp.BaseUrl = path.Join("public/app/plugins", fp.Type, fp.Id)
}

func isInternalPlugin(pluginDir string) bool {
return !strings.Contains(pluginDir, setting.StaticRootPath)
}

func evalRelativePluginUrlPath(pathStr string, baseUrl string) string {
if pathStr == "" {
return ""
Expand Down
18 changes: 8 additions & 10 deletions pkg/plugins/models.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,16 +30,14 @@ type PluginLoader interface {
}

type PluginBase struct {
Type string `json:"type"`
Name string `json:"name"`
Id string `json:"id"`
Info PluginInfo `json:"info"`
Dependencies PluginDependencies `json:"dependencies"`
Includes []*PluginInclude `json:"includes"`
Module string `json:"module"`
BaseUrl string `json:"baseUrl"`
StaticRoot string `json:"staticRoot"`
StaticRootAbs string `json:"-"`
Type string `json:"type"`
Name string `json:"name"`
Id string `json:"id"`
Info PluginInfo `json:"info"`
Dependencies PluginDependencies `json:"dependencies"`
Includes []*PluginInclude `json:"includes"`
Module string `json:"module"`
BaseUrl string `json:"baseUrl"`

IncludedInAppId string `json:"-"`
PluginDir string `json:"-"`
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 5 additions & 1 deletion public/app/plugins/datasource/graphite/plugin.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@
"author": {
"name": "Grafana Project",
"url": "http://grafana.org"
},
"logos": {
"small": "img/graphite_logo.png",
"large": "img/graphite_logo.png"
}
}
}
}

0 comments on commit dddd155

Please sign in to comment.