From 733dada3fef39b5297e9e877f96f9f28579d0286 Mon Sep 17 00:00:00 2001
From: Evan Chen
Date: Mon, 15 Nov 2021 12:33:28 +0800
Subject: [PATCH] chore
---
app.go | 43 ++++++++++++++++++++
server.go | 1 +
templates/action.tmpl | 7 ----
templates/base/footer.tmpl | 5 ---
templates/base/script.tmpl | 4 ++
templates/components/menu.tmpl | 22 +++++-----
templates/home.tmpl | 1 +
templates/muzan.tmpl | 73 ++++++++++++++++++++++++++++++++++
8 files changed, 134 insertions(+), 22 deletions(-)
delete mode 100644 templates/action.tmpl
create mode 100644 templates/muzan.tmpl
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" .}}
-