From 09532849d4d7df514bba774b06bb8f891ca5b120 Mon Sep 17 00:00:00 2001 From: bel Date: Wed, 16 Feb 2022 07:57:47 -0700 Subject: [PATCH] wip --- spike/review/reinvent/ezmded/server/server.go | 7 +- .../ezmded/ui/templates/_filetree.ctmpl | 6 +- .../ezmded/ui/templates/_import.ctmpl | 116 ++++++++++-------- 3 files changed, 72 insertions(+), 57 deletions(-) diff --git a/spike/review/reinvent/ezmded/server/server.go b/spike/review/reinvent/ezmded/server/server.go index 3fb186d..283e077 100644 --- a/spike/review/reinvent/ezmded/server/server.go +++ b/spike/review/reinvent/ezmded/server/server.go @@ -200,7 +200,6 @@ func (server *Server) putContentHandler(filePath string, w http.ResponseWriter, } func (server *Server) uiSearchHandler(w http.ResponseWriter, r *http.Request) error { - r.URL.Path = strings.TrimPrefix(r.URL.Path, "/ui/files") t, err := server.uiSubTemplates() if err != nil { return err @@ -261,11 +260,11 @@ func (server *Server) uiFilesHandler(w http.ResponseWriter, r *http.Request) err leaf.Title = "My New File" } data := map[string]interface{}{ - "This": map[string]string{ + "This": map[string]interface{}{ "Title": leaf.Title, "Content": leaf.Content, - "ID": r.URL.Path, - "PID": strings.TrimPrefix(path.Dir(r.URL.Path), "/"), + "ID": id, + "PID": id.Pop(), "PTitle": parent.Title, }, "Tree": string(branchesJSON), diff --git a/spike/review/reinvent/ezmded/ui/templates/_filetree.ctmpl b/spike/review/reinvent/ezmded/ui/templates/_filetree.ctmpl index 54aa3ef..581d5a0 100644 --- a/spike/review/reinvent/ezmded/ui/templates/_filetree.ctmpl +++ b/spike/review/reinvent/ezmded/ui/templates/_filetree.ctmpl @@ -45,7 +45,7 @@ return `
- + ` } function branchesHTML(id, branches) { @@ -54,7 +54,7 @@ var out = `` for(var i in branches) { out += `
` - out += branchHTML((id ? id + "/" : "") + i, branches[i]) + out += branchHTML(i, branches[i]) out += `
` } return out @@ -65,6 +65,6 @@ n += 1 return n > 0 } - drawTree(JSON.parse(`{{ .Tree }}`)) + drawTree(JSON.parse({{ .Tree }})) {{ end }} diff --git a/spike/review/reinvent/ezmded/ui/templates/_import.ctmpl b/spike/review/reinvent/ezmded/ui/templates/_import.ctmpl index 30cdfaa..26d185d 100644 --- a/spike/review/reinvent/ezmded/ui/templates/_import.ctmpl +++ b/spike/review/reinvent/ezmded/ui/templates/_import.ctmpl @@ -15,48 +15,48 @@ --> {{ end }}