From 1ccf015b8b0a3ed248fd8c68082e828bd3dc0498 Mon Sep 17 00:00:00 2001 From: shaoying Date: Mon, 21 May 2018 16:51:59 +0800 Subject: [PATCH] add up.html --- etc/init.shy | 11 ++--------- src/contexts/web/web.go | 25 ++++++++++++++++++++----- usr/up.html | 5 +++++ 3 files changed, 27 insertions(+), 14 deletions(-) create mode 100644 usr/up.html diff --git a/etc/init.shy b/etc/init.shy index 16b28a44..cdafa442 100644 --- a/etc/init.shy +++ b/etc/init.shy @@ -1,10 +1,3 @@ -~aaa - login root root - -~ssh - config domain tce - dial "shylinux.com:9090" -~nfs - command add git status - command add git branch +source etc/local.shy +~aaa login root root diff --git a/src/contexts/web/web.go b/src/contexts/web/web.go index 2acfcdb4..1a412c1c 100644 --- a/src/contexts/web/web.go +++ b/src/contexts/web/web.go @@ -116,11 +116,12 @@ func (web *WEB) generate(m *ctx.Message, uri string, arg ...string) string { // func (web *WEB) AppendJson(msg *ctx.Message) string { // {{{ meta := map[string][]string{} - for _, v := range msg.Meta["append"] { - meta[v] = msg.Meta[v] + if meta["result"] = msg.Meta["result"]; msg.Has("append") { + meta["append"] = msg.Meta["append"] + for _, v := range msg.Meta["append"] { + meta[v] = msg.Meta[v] + } } - meta["result"] = msg.Meta["result"] - meta["append"] = msg.Meta["append"] b, e := json.Marshal(meta) msg.Assert(e) @@ -153,6 +154,9 @@ func (web *WEB) Trans(m *ctx.Message, key string, hand func(*ctx.Message, *ctx.C for k, v := range r.Form { msg.Add("option", k, v...) } + for k, v := range r.PostForm { + msg.Add("option", k, v...) + } for _, v := range r.Cookies() { msg.Add("option", v.Name, v.Value) } @@ -555,7 +559,18 @@ var Index = &ctx.Context{Name: "web", Help: "应用中心", file, header, e := r.FormFile("file") m.Assert(e) - f, e := os.Create(path.Join(m.Conf("upload_dir"), header.Filename)) + dir := r.FormValue("path") + if dir == "" { + dir = m.Conf("upload_dir") + } + name := path.Join(dir, header.Filename) + m.Append("path", name) + if _, e := os.Stat(name); e == nil { + m.Echo("failure, file already exist!") + return + } + + f, e := os.Create(name) m.Assert(e) n, e := io.Copy(f, file) diff --git a/usr/up.html b/usr/up.html new file mode 100644 index 00000000..df40dd23 --- /dev/null +++ b/usr/up.html @@ -0,0 +1,5 @@ +
+ + + +