From 100d49f1b262a7b51283cf888cc8a0ac17454f24 Mon Sep 17 00:00:00 2001 From: shaoying Date: Sun, 19 Aug 2018 10:47:40 +0800 Subject: [PATCH] tce add usr/shy --- src/contexts/cli/cli.go | 4 +++- src/contexts/ctx.go | 9 +++++++++ src/contexts/log/log.go | 8 +++++--- src/contexts/web/web.go | 24 ++++++++++++++++++++++-- 4 files changed, 39 insertions(+), 6 deletions(-) diff --git a/src/contexts/cli/cli.go b/src/contexts/cli/cli.go index ddaed0d7..63903f60 100644 --- a/src/contexts/cli/cli.go +++ b/src/contexts/cli/cli.go @@ -230,7 +230,9 @@ var Index = &ctx.Context{Name: "cli", Help: "管理中心", m.Wait() m.Target().Close(m) if arg[0] == "stdio" { - m.Spawn().Cmd("source", m.Conf("exit.shy")) + if f, e := os.Stat(m.Conf("exit.shy")); e == nil && !f.IsDir() { + m.Spawn().Cmd("source", m.Conf("exit.shy")) + } } } }}, diff --git a/src/contexts/ctx.go b/src/contexts/ctx.go index d56b7e2e..9d57edcd 100644 --- a/src/contexts/ctx.go +++ b/src/contexts/ctx.go @@ -2950,14 +2950,23 @@ var Index = &Context{Name: "ctx", Help: "模块中心", m.Capi("list_count", 1) return case "list": + if m.Cap("list_begin") == "" { + return + } begin, end := m.Capi("list_begin"), m.Capi("list_count") if len(arg) > 1 { n, e := strconv.Atoi(arg[1]) + if e != nil { + return + } m.Assert(e) begin = n } if len(arg) > 2 { n, e := strconv.Atoi(arg[2]) + if e != nil { + return + } m.Assert(e) end = n } diff --git a/src/contexts/log/log.go b/src/contexts/log/log.go index 6ea332e5..44bbdb7c 100644 --- a/src/contexts/log/log.go +++ b/src/contexts/log/log.go @@ -36,9 +36,11 @@ func (log *LOG) Begin(m *ctx.Message, arg ...string) ctx.Server { // {{{ // }}} func (log *LOG) Start(m *ctx.Message, arg ...string) bool { // {{{ - log.nfs = m.Sess("nfs").Cmd("append", m.Confx("bench.log", arg, 0), "", "日志文件") - log.out = log.nfs.Optionv("out").(*os.File) - fmt.Fprintln(log.out, "\n\n") + if f, e := os.Stat(m.Confx("bench.log", arg, 0)); e == nil && !f.IsDir() { + log.nfs = m.Sess("nfs").Cmd("append", m.Confx("bench.log", arg, 0), "", "日志文件") + log.out = log.nfs.Optionv("out").(*os.File) + fmt.Fprintln(log.out, "\n\n") + } return false } diff --git a/src/contexts/web/web.go b/src/contexts/web/web.go index a752adf6..9fb172ad 100644 --- a/src/contexts/web/web.go +++ b/src/contexts/web/web.go @@ -323,6 +323,21 @@ var Index = &ctx.Context{Name: "web", Help: "应用中心", "argument": []interface{}{"duyu"}, "template": "append", "title": "lark", }, + map[string]interface{}{ + "module": "nfs", "command": "dir", + "argument": []interface{}{"dir_type", "all", "dir_deep", "false", "dir_field", "time size line filename", "sort_field", "time", "sort_order", "time_r"}, + "template": "append", "title": "", + }, + map[string]interface{}{ + "template": "upload", "title": "upload", + }, + map[string]interface{}{ + "template": "create", "title": "create", + }, + map[string]interface{}{ + "module": "nfs", "detail": []interface{}{"pwd"}, + "template": "detail", "title": "pwd", + }, }, "shy": []interface{}{ map[string]interface{}{ @@ -694,13 +709,18 @@ var Index = &ctx.Context{Name: "web", Help: "应用中心", r := m.Optionv("request").(*http.Request) // {{{ w := m.Optionv("response").(http.ResponseWriter) + if login := m.Spawn().Cmd("/login"); login.Has("template") { + m.Echo("no").Copy(login, "append") + return + } + m.Option("username", m.Append("username")) + //权限检查 - dir := m.Option("dir", path.Join(m.Cap("directory"), m.Option("dir", strings.TrimPrefix(m.Option("path"), "/index")))) + dir := m.Option("dir", path.Join(m.Cap("directory"), m.Option("username"), m.Option("dir", strings.TrimPrefix(m.Option("path"), "/index")))) if check := m.Spawn(c).Cmd("/check", "command", "/index/", "dir", dir); !check.Results(0) { m.Copy(check, "append") return } - m.Option("username", m.Append("username")) //执行命令 if m.Has("details") {