From 2a7c0dfe6558f6507871b6099a0807c2c75daa2d Mon Sep 17 00:00:00 2001 From: shaoying Date: Fri, 17 Aug 2018 19:01:03 +0800 Subject: [PATCH] tce mod nfs.json --- src/contexts/nfs/nfs.go | 25 +++++++++++++++++++++++++ src/contexts/web/web.go | 15 ++++++++++++--- usr/template/common/base.html | 25 ++++++++++++++++++------- usr/template/upload.html | 4 ++-- 4 files changed, 57 insertions(+), 12 deletions(-) diff --git a/src/contexts/nfs/nfs.go b/src/contexts/nfs/nfs.go index bc2dfe93..2661dbc7 100644 --- a/src/contexts/nfs/nfs.go +++ b/src/contexts/nfs/nfs.go @@ -1099,6 +1099,31 @@ var Index = &ctx.Context{Name: "nfs", Help: "存储中心", } // }}} }}, "json": &ctx.Command{Name: "json [key value]...", Help: "生成格式化内容, key: 参数名, value: 参数值", Hand: func(m *ctx.Message, c *ctx.Context, key string, arg ...string) { + if len(arg) == 1 { + data := map[string]interface{}{} + e := json.Unmarshal([]byte(arg[0]), &data) + m.Assert(e) + + buf, e := json.MarshalIndent(data, "", " ") + m.Assert(e) + m.Echo("'") + m.Echo(string(buf)) + m.Echo("'") + return + } + + if len(arg) > 1 && arg[0] == "file" { + data := map[string]interface{}{} + f, e := os.Open(arg[1]) + m.Assert(e) + d := json.NewDecoder(f) + d.Decode(&data) + + buf, e := json.MarshalIndent(data, "", " ") + m.Assert(e) + m.Echo(string(buf)) + return + } data := map[string]interface{}{} // {{{ for _, k := range m.Meta["option"] { if v, ok := m.Data[k]; ok { diff --git a/src/contexts/web/web.go b/src/contexts/web/web.go index 86858cd3..3a048ccd 100644 --- a/src/contexts/web/web.go +++ b/src/contexts/web/web.go @@ -345,7 +345,15 @@ var Index = &ctx.Context{Name: "web", Help: "应用中心", }, map[string]interface{}{ "module": "nfs", "detail": []interface{}{"pwd"}, - "template": "detail", "title": "detail", + "template": "detail", "title": "pwd", + }, + map[string]interface{}{ + "module": "cli", "detail": []interface{}{"time"}, + "template": "detail", "title": "time", + }, + map[string]interface{}{ + "module": "nfs", "detail": []interface{}{"json"}, + "template": "detail", "title": "json", }, }, "xujianing": []interface{}{ @@ -664,7 +672,7 @@ var Index = &ctx.Context{Name: "web", Help: "应用中心", } } - msg := m.Find(m.Option("module")).Cmd(m.Option("details")) + msg := m.Find(m.Option("module")).Cmd(m.Optionv("details")) m.Copy(msg, "result").Copy(msg, "append") return } @@ -954,7 +962,7 @@ var Index = &ctx.Context{Name: "web", Help: "应用中心", // }}} }}, "/share": &ctx.Command{Name: "/share arg...", Help: "资源共享", Hand: func(m *ctx.Message, c *ctx.Context, key string, arg ...string) { - if check := m.Spawn().Cmd("/check", "target", m.Option("module"), m.Optionv("share")); !check.Results(0) { + if check := m.Spawn().Cmd("/check", "target", m.Option("module"), m.Optionv("share")); !check.Results(0) { // {{{ m.Copy(check, "append") return } @@ -969,6 +977,7 @@ var Index = &ctx.Context{Name: "web", Help: "应用中心", msg := m.Spawn().Cmd("right", "target", m.Option("module"), m.Append("username"), "show", "context") m.Copy(msg, "append") + // }}} }}, "/check": &ctx.Command{Name: "/check arg...", Help: "权限检查, cache|config|command: 接口类型, name: 接口名称, args: 其它参数", Hand: func(m *ctx.Message, c *ctx.Context, key string, arg ...string) { if login := m.Spawn().Cmd("/login"); login.Has("template") { // {{{ diff --git a/usr/template/common/base.html b/usr/template/common/base.html index 54d052f4..6b33ae9e 100644 --- a/usr/template/common/base.html +++ b/usr/template/common/base.html @@ -38,17 +38,28 @@ {{end}} {{define "detail"}} -
{{append . "title"}} - {{template "code" detail .Meta}} -
+{{$key := append . "title"|meta}} +
{{append . "title"|meta}} + + {{template "code" detail .Meta}} +
{{end}} diff --git a/usr/template/upload.html b/usr/template/upload.html index 0fdb68fe..cc19746e 100644 --- a/usr/template/upload.html +++ b/usr/template/upload.html @@ -114,7 +114,7 @@ {{define "upload"}}
upload -
+
@@ -122,7 +122,7 @@ {{define "create"}}
create -
+
filename:
content: