diff --git a/app.go b/app.go index ac8fa72..807b118 100644 --- a/app.go +++ b/app.go @@ -27,6 +27,7 @@ type Page struct { BaseUrl string Actions []Action Integrations []*Integration + Onitachi map[string]*Oni Version string Build string Files []ActiveFile @@ -79,6 +80,7 @@ func (cui *ConfigUI) App(w http.ResponseWriter, r *http.Request) { }, Actions: cui.Actions, Integrations: cui.Integrations, + Onitachi: cui.Onitachi, Static: cui.NoReconfig, HideConfig: cui.HideConfig, ResultBellow: cui.ResultBellow, @@ -127,3 +129,44 @@ func (cui *ConfigUI) App(w http.ResponseWriter, r *http.Request) { panic(err) } } + +func (cui *ConfigUI) Program(w http.ResponseWriter, r *http.Request) { + Files := []ActiveFile{} + for _, i := range cui.fileIndex { + Files = append(Files, ActiveFile{ + Name: cui.Files[i].Name, + Path: cui.Files[i].Path, + Order: cui.Files[i].Order, + }) + } + sort.Slice(Files, func(i, j int) bool { + if Files[i].Order == Files[j].Order { + return Files[i].Name < Files[j].Name + } + return Files[i].Order < Files[j].Order + }) + plat := "unix" + if runtime.GOOS == "windows" { + plat = "windows" + } + data := Page{ + AppName: cui.AppName, + BaseUrl: cui.BaseUrl, + File: ActiveFile{}, + Files: Files, + Editor: Editor{ + Platform: plat, + }, + Actions: cui.Actions, + Integrations: cui.Integrations, + Onitachi: cui.Onitachi, + Static: cui.NoReconfig, + HideConfig: cui.HideConfig, + Version: version, + } + + err := cui.tmpl.ExecuteTemplate(w, "muzan", data) + if err != nil { + panic(err) + } +} diff --git a/server.go b/server.go index a8b878d..748deb1 100644 --- a/server.go +++ b/server.go @@ -152,6 +152,7 @@ func (cui *ConfigUI) mux() *http.ServeMux { } }) cuiR.Handle("/public/", http.StripPrefix("/public/", http.FileServer(http.FS(cui.PublicFS)))) + cuiR.HandleFunc("/program", cui.Program) cuiR.HandleFunc("/", cui.App) return cuiR } diff --git a/templates/action.tmpl b/templates/action.tmpl deleted file mode 100644 index 1324ed4..0000000 --- a/templates/action.tmpl +++ /dev/null @@ -1,7 +0,0 @@ -{{define "action"}} -{{template "base/header" .}} -{{template "components/error" .}} - - -{{template "base/footer" .}} -{{end}} \ No newline at end of file diff --git a/templates/base/footer.tmpl b/templates/base/footer.tmpl index fc2e9d5..4525dab 100644 --- a/templates/base/footer.tmpl +++ b/templates/base/footer.tmpl @@ -6,11 +6,6 @@

- - - - {{template "base/script" .}} - {{end}} \ No newline at end of file diff --git a/templates/base/script.tmpl b/templates/base/script.tmpl index 1f1d6ed..187a0ed 100644 --- a/templates/base/script.tmpl +++ b/templates/base/script.tmpl @@ -1,4 +1,8 @@ {{define "base/script"}} + + + + + +
+
+
+ {{template "components/menu" .}} +
+ {{if .Actions}} +
+ +
+ {{- range .Actions -}} + + {{- end -}} +
+
+ {{end}} + {{if .Integrations}} +
+ +
+ {{- range .Integrations -}} + + {{- end -}} +
+
+ {{end}} + +
+
+
+ Home + {{/* {{template "components/editor" .}} */}} +
+
+
+ + +{{template "base/footer" .}} +{{end}} \ No newline at end of file