diff --git a/README.md b/README.md index 258ff5f..9ea20e0 100644 --- a/README.md +++ b/README.md @@ -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" }} + +{{end}} +``` + +**Custom links** +> path/to/dir/links.tmpl +```go +{{ define "links" }} +Report Issue +{{end}} +``` + ## Add integrations to ConfigUI ```go diff --git a/configui.go b/configui.go index 25ee656..6eeb99a 100644 --- a/configui.go +++ b/configui.go @@ -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 == "" { diff --git a/file.go b/file.go index a7b25ad..b04f4d1 100644 --- a/file.go +++ b/file.go @@ -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"` diff --git a/templates/home.tmpl b/templates/home.tmpl index 88e8dfc..fdf4dfc 100644 --- a/templates/home.tmpl +++ b/templates/home.tmpl @@ -5,14 +5,22 @@ var Active = "{{.File.Name}}"; -