master
Evan Chen 2021-11-17 17:24:04 +08:00
parent b0d76dff3e
commit 3895e90876
4 changed files with 55 additions and 8 deletions

View File

@ -65,6 +65,33 @@ sudo sh -c "curl -fsSL RELEASE_URL | tar -C /usr/local/bin/ -xz"
`configui -f PATH/TO/CONFIG`
## Add custom links in nav
**config**
```json
{
"cust":"path/to/dir"
}
```
**No link**
> path/to/dir/none.tmpl
```go
{{ define "links" }}
<!-- none -->
{{end}}
```
**Custom links**
> path/to/dir/links.tmpl
```go
{{ define "links" }}
<a class="button is-white level-item"
href="https://kumoly.io/tools/configui/issues"
>Report Issue</a>
{{end}}
```
## Add integrations to ConfigUI
```go

View File

@ -7,6 +7,7 @@ import (
"fmt"
"html/template"
"os"
"path/filepath"
"runtime"
"strings"
"sync"
@ -76,6 +77,7 @@ type ConfigUI struct {
LogLevel klog.Llevel `json:"log_level"`
TmplFS embed.FS `json:"-"`
CustTmpl string `json:"cust,omitempty"`
tmpl *engine.Engine
PublicFS embed.FS `json:"-"`
log *klog.Logger
@ -175,6 +177,16 @@ func (cui *ConfigUI) LoadConfig(confstr string) error {
cui.NoReconfig = tmpConf.NoReconfig
cui.ResultBellow = tmpConf.ResultBellow
cui.CustTmpl = tmpConf.CustTmpl
if cui.CustTmpl != "" {
ntmpl, err := cui.tmpl.OverrideGlob(filepath.Join(cui.CustTmpl, "*.tmpl"))
if err != nil {
cui.log.Error(err)
} else {
cui.tmpl = ntmpl
}
}
cui.Actions = tmpConf.Actions
for i := range cui.Actions {
if cui.Actions[i].Name == "" {

View File

@ -17,7 +17,7 @@ type File struct {
Cmd string `json:"cmd"`
// RO is readonly
RO bool `json:"ro"`
Lang string `json:"lang"`
Lang string `json:"lang,omitempty"`
// Order order of the display on ui
Order int `json:"order"`

View File

@ -5,14 +5,22 @@
var Active = "{{.File.Name}}";
</script>
<nav class="level">
<div class="level-left">
<div class="level-item">
<a class="title is-size-4 ml-2 mt-1" href="{{.BaseUrl}}">
{{.AppName}}
</a>
</div>
<nav class="level py-1">
<div class="level-left">
<div class="level-item">
<a class="title is-size-4 ml-2" href="{{.BaseUrl}}">
{{.AppName}}
</a>
</div>
</div>
<div class="level-right">
{{ block "links" .}}
<a class="button is-white level-item"
href="https://kumoly.io/tools/configui/issues"
>Report Issue</a>
{{end}}
<p class="level-item mr-2"></p>
</div>
</nav>
<div class="columns">