mirror of https://github.com/statping/statping
upgrades - plugins
parent
8a6f6a2cf8
commit
ade9c69f25
|
@ -17,7 +17,7 @@ services:
|
||||||
- mongodb
|
- mongodb
|
||||||
|
|
||||||
env:
|
env:
|
||||||
- VERSION=0.16
|
- VERSION=0.161
|
||||||
|
|
||||||
matrix:
|
matrix:
|
||||||
allow_failures:
|
allow_failures:
|
||||||
|
|
14
README.md
14
README.md
|
@ -1,7 +1,8 @@
|
||||||
# Statup [![Build Status](https://travis-ci.org/hunterlong/statup.svg?branch=master)](https://travis-ci.org/hunterlong/statup)
|
# Statup - Status Page [![Build Status](https://travis-ci.org/hunterlong/statup.svg?branch=master)](https://travis-ci.org/hunterlong/statup)
|
||||||
An easy to use Status Page for your websites and applications. Statup will automatically fetch the application and render a beutiful status page.
|
An easy to use Status Page for your websites and applications. Statup will automatically fetch the application and render a beautiful status page with tons of features
|
||||||
|
for you to build an even better status page.
|
||||||
|
|
||||||
## Docker
|
## Run on Docker
|
||||||
Use the [Statup Docker Image](https://hub.docker.com/r/hunterlong/statup) to create a status page in seconds.
|
Use the [Statup Docker Image](https://hub.docker.com/r/hunterlong/statup) to create a status page in seconds.
|
||||||
```
|
```
|
||||||
docker run -it -p 8080:8080 hunterlong/statup
|
docker run -it -p 8080:8080 hunterlong/statup
|
||||||
|
@ -10,4 +11,9 @@ docker run -it -p 8080:8080 hunterlong/statup
|
||||||
### Install on Linux
|
### Install on Linux
|
||||||
```
|
```
|
||||||
bash <(curl -s https://statup.io/install.sh)
|
bash <(curl -s https://statup.io/install.sh)
|
||||||
```
|
```
|
||||||
|
|
||||||
|
## User Created Plugins
|
||||||
|
Statup isn't just another Status Page for your applications, it's a framework that allows you to create your own plugins to interact with every element of your status page.
|
||||||
|
Plugin are created in Golang using the [statup/plugin](https://github.com/hunterlong/statup/tree/master/plugin) golang package. The plugin package has a list of
|
||||||
|
interfaces/events to accept into your own plugin application.
|
|
@ -56,6 +56,6 @@
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<script src="/js/jquery-3.3.1.slim.min.js"></script>
|
<script src="/js/jquery-3.3.1.slim.min.js"></script>
|
||||||
|
<script src="/js/bootstrap.min.js"></script>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
|
@ -26,7 +26,7 @@
|
||||||
<a class="nav-link" id="v-pills-home-tab" data-toggle="pill" href="#v-pills-style" role="tab" aria-controls="v-pills-style" aria-selected="false">Styling</a>
|
<a class="nav-link" id="v-pills-home-tab" data-toggle="pill" href="#v-pills-style" role="tab" aria-controls="v-pills-style" aria-selected="false">Styling</a>
|
||||||
<a class="nav-link" id="v-pills-browse-tab" data-toggle="pill" href="#v-pills-browse" role="tab" aria-controls="v-pills-home" aria-selected="false">Browse Plugins</a>
|
<a class="nav-link" id="v-pills-browse-tab" data-toggle="pill" href="#v-pills-browse" role="tab" aria-controls="v-pills-home" aria-selected="false">Browse Plugins</a>
|
||||||
{{ range .Plugins }}
|
{{ range .Plugins }}
|
||||||
<a class="nav-link text-capitalize" id="v-pills-{{.Name}}-tab" data-toggle="pill" href="#v-pills-{{.Name}}" role="tab" aria-controls="v-pills-profile" aria-selected="false">{{.Name}}</a>
|
<a class="nav-link text-capitalize" id="v-pills-{{underscore .Name}}-tab" data-toggle="pill" href="#v-pills-{{underscore .Name}}" role="tab" aria-controls="v-pills-profile" aria-selected="false">{{.Name}}</a>
|
||||||
{{end}}
|
{{end}}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@ -86,25 +86,13 @@
|
||||||
|
|
||||||
{{ range .Plugins }}
|
{{ range .Plugins }}
|
||||||
|
|
||||||
<div class="tab-pane fade" id="v-pills-{{.Name}}" role="tabpanel" aria-labelledby="v-pills-{{.Name}}-tab">
|
<div class="tab-pane fade" id="v-pills-{{underscore .Name}}" role="tabpanel" aria-labelledby="v-pills-{{underscore .Name}}-tab">
|
||||||
|
|
||||||
<h4 class="text-capitalize">{{ .Name }}</h4>
|
<h4 class="text-capitalize">{{ .Name }}</h4>
|
||||||
<span class="text-muted">{{ .Description }}</span>
|
<span class="text-muted">{{ .Description }}</span>
|
||||||
|
|
||||||
<form class="mt-3" method="POST" action="/plugins/{{.Name}}/save">
|
{{ safe .Form }}
|
||||||
{{ range .Form }}
|
|
||||||
<div class="form-group">
|
|
||||||
<label for="input_{{ .InputName }}" class="text-capitalize">{{ .Name }}</label>
|
|
||||||
<input type="text" class="form-control" name="{{ .InputName }}" value="{{ .Value }}" id="input_{{ .InputName }}" placeholder="Example input" aria-describedby="help_{{ .InputName }}">
|
|
||||||
{{ if .Description }}
|
|
||||||
<small id="help_{{ .InputName }}" class="form-text text-muted">
|
|
||||||
{{ .Description }}
|
|
||||||
</small>
|
|
||||||
{{ end }}
|
|
||||||
</div>
|
|
||||||
{{ end }}
|
|
||||||
<button type="submit" class="btn btn-primary">Save</button>
|
|
||||||
</form>
|
|
||||||
</div>
|
</div>
|
||||||
{{end}}
|
{{end}}
|
||||||
|
|
||||||
|
|
|
@ -35,8 +35,13 @@ type PluginInfo struct {
|
||||||
PluginActions
|
PluginActions
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (p *PluginInfo) Form() string {
|
||||||
|
return "okkokokkok"
|
||||||
|
}
|
||||||
|
|
||||||
type PluginActions interface {
|
type PluginActions interface {
|
||||||
GetInfo() Info
|
GetInfo() Info
|
||||||
|
GetForm() string
|
||||||
SetInfo(map[string]interface{}) Info
|
SetInfo(map[string]interface{}) Info
|
||||||
Routes() []Routing
|
Routes() []Routing
|
||||||
OnSave(map[string]interface{})
|
OnSave(map[string]interface{})
|
||||||
|
@ -64,4 +69,5 @@ type Routing struct {
|
||||||
type Info struct {
|
type Info struct {
|
||||||
Name string
|
Name string
|
||||||
Description string
|
Description string
|
||||||
|
Form string
|
||||||
}
|
}
|
||||||
|
|
Binary file not shown.
32
web.go
32
web.go
|
@ -10,6 +10,7 @@ import (
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
"regexp"
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
|
@ -284,7 +285,7 @@ func PluginsHandler(w http.ResponseWriter, r *http.Request) {
|
||||||
for _, p := range allPlugins {
|
for _, p := range allPlugins {
|
||||||
fields := structs.Map(p.GetInfo())
|
fields := structs.Map(p.GetInfo())
|
||||||
|
|
||||||
pluginFields = append(pluginFields, PluginSelect{p.GetInfo().Name, fields})
|
pluginFields = append(pluginFields, PluginSelect{p.GetInfo().Name, p.GetForm(),fields})
|
||||||
}
|
}
|
||||||
|
|
||||||
core.PluginFields = pluginFields
|
core.PluginFields = pluginFields
|
||||||
|
@ -293,6 +294,7 @@ func PluginsHandler(w http.ResponseWriter, r *http.Request) {
|
||||||
|
|
||||||
type PluginSelect struct {
|
type PluginSelect struct {
|
||||||
Plugin string
|
Plugin string
|
||||||
|
Form string
|
||||||
Params map[string]interface{}
|
Params map[string]interface{}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -391,6 +393,9 @@ func ExecuteResponse(w http.ResponseWriter, r *http.Request, file string, data i
|
||||||
"VERSION": func() string {
|
"VERSION": func() string {
|
||||||
return VERSION
|
return VERSION
|
||||||
},
|
},
|
||||||
|
"underscore": func(html string) string {
|
||||||
|
return UnderScoreString(html)
|
||||||
|
},
|
||||||
})
|
})
|
||||||
t, _ = t.Parse(nav)
|
t, _ = t.Parse(nav)
|
||||||
t.Parse(render)
|
t.Parse(render)
|
||||||
|
@ -425,3 +430,28 @@ func UsersDeleteHandler(w http.ResponseWriter, r *http.Request) {
|
||||||
user.Delete()
|
user.Delete()
|
||||||
http.Redirect(w, r, "/users", http.StatusSeeOther)
|
http.Redirect(w, r, "/users", http.StatusSeeOther)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
func UnderScoreString(str string) string {
|
||||||
|
|
||||||
|
// convert every letter to lower case
|
||||||
|
newStr := strings.ToLower(str)
|
||||||
|
|
||||||
|
// convert all spaces/tab to underscore
|
||||||
|
regExp := regexp.MustCompile("[[:space:][:blank:]]")
|
||||||
|
newStrByte := regExp.ReplaceAll([]byte(newStr), []byte("_"))
|
||||||
|
|
||||||
|
regExp = regexp.MustCompile("`[^a-z0-9]`i")
|
||||||
|
newStrByte = regExp.ReplaceAll(newStrByte, []byte("_"))
|
||||||
|
|
||||||
|
regExp = regexp.MustCompile("[!/']")
|
||||||
|
newStrByte = regExp.ReplaceAll(newStrByte, []byte("_"))
|
||||||
|
|
||||||
|
// and remove underscore from beginning and ending
|
||||||
|
|
||||||
|
newStr = strings.TrimPrefix(string(newStrByte), "_")
|
||||||
|
newStr = strings.TrimSuffix(newStr, "_")
|
||||||
|
|
||||||
|
return newStr
|
||||||
|
}
|
Loading…
Reference in New Issue