From c380ca2ad477eda90bedff6999647d3535a76ef9 Mon Sep 17 00:00:00 2001 From: shaoying Date: Sat, 3 Nov 2018 11:01:35 +0800 Subject: [PATCH] tce clear log --- etc/dotsfile/.vimrc | 2 +- src/contexts/aaa/aaa.go | 9 +---- src/contexts/ctx/ctx.go | 7 ---- src/contexts/log/log.go | 10 ++---- src/contexts/nfs/nfs.go | 6 ++++ src/contexts/web/web.go | 66 ++++++++++++++++++++--------------- usr/library/base.js | 7 ++-- usr/template/common/base.tmpl | 7 +++- 8 files changed, 58 insertions(+), 56 deletions(-) diff --git a/etc/dotsfile/.vimrc b/etc/dotsfile/.vimrc index 65ac0f96..fc980df2 100644 --- a/etc/dotsfile/.vimrc +++ b/etc/dotsfile/.vimrc @@ -128,7 +128,7 @@ nnoremap h nnoremap j nnoremap k nnoremap l -nnoremap :make +" nnoremap :make nnoremap : nnoremap j gj diff --git a/src/contexts/aaa/aaa.go b/src/contexts/aaa/aaa.go index 0fb109c8..168f7909 100644 --- a/src/contexts/aaa/aaa.go +++ b/src/contexts/aaa/aaa.go @@ -480,7 +480,6 @@ var Index = &ctx.Context{Name: "aaa", Help: "认证中心", IsCA: true, KeyUsage: x509.KeyUsageCertSign, } - m.Log("fuck", "what %#v", template) cert, e := x509.CreateCertificate(crand.Reader, &template, &template, &keys.PublicKey, keys) m.Assert(e) @@ -569,8 +568,7 @@ var Index = &ctx.Context{Name: "aaa", Help: "认证中心", } case "check": defer func() { - e := recover() - m.Log("fuck", "what %v", e) + recover() }() root, e := x509.ParseCertificate(aaa.Decode(arg[1])) @@ -582,15 +580,10 @@ var Index = &ctx.Context{Name: "aaa", Help: "认证中心", // ee := cert.CheckSignatureFrom(root) // m.Echo("%v", ee) // - m.Log("fuck", "----") pool := &x509.CertPool{} - m.Log("fuck", "----") m.Echo("%c", pool) - m.Log("fuck", "----") pool.AddCert(root) - m.Log("fuck", "----") c, e := cert.Verify(x509.VerifyOptions{Roots: pool}) - m.Log("fuck", "----") m.Echo("%c", c) } } diff --git a/src/contexts/ctx/ctx.go b/src/contexts/ctx/ctx.go index 9fd250e5..9212485a 100644 --- a/src/contexts/ctx/ctx.go +++ b/src/contexts/ctx/ctx.go @@ -1414,8 +1414,6 @@ func (m *Message) Cmd(args ...interface{}) *Message { } if len(args) > 0 { m.Set("detail", Trans(args...)...) - m.Log("what", "waht %v", m.Meta) - m.Log("what", "waht %v", len(m.Meta["detail"])) } key, arg := m.Meta["detail"][0], m.Meta["detail"][1:] @@ -1467,9 +1465,7 @@ func (m *Message) Confx(key string, arg ...interface{}) string { switch v := arg[0].(type) { case map[string]interface{}: conf = v[key].(string) - m.Log("fuck", "conf %v", conf) value = m.Option(key) - m.Log("fuck", "value %v", value) arg = arg[1:] case string: value, arg = v, arg[1:] @@ -3517,13 +3513,10 @@ var Index = &Context{Name: "ctx", Help: "模块中心", v := Chain(m, value, arg[1]) value = v } - m.Log("fuck", "info %T", value) - m.Log("fuck", "info %v", value) switch val := value.(type) { case map[string]interface{}: for k, v := range val { - m.Log("fuck", "info %v %v", k, v) m.Add("append", "key", k) m.Add("append", "value", v) } diff --git a/src/contexts/log/log.go b/src/contexts/log/log.go index 2ff66026..e855c9d7 100644 --- a/src/contexts/log/log.go +++ b/src/contexts/log/log.go @@ -9,7 +9,6 @@ import ( ) type LOG struct { - nfs *ctx.Message out *os.File *ctx.Context } @@ -17,6 +16,7 @@ type LOG struct { func (log *LOG) Spawn(m *ctx.Message, c *ctx.Context, arg ...string) ctx.Server { c.Caches = map[string]*ctx.Cache{} c.Configs = map[string]*ctx.Config{} + s := new(LOG) s.Context = c return s @@ -28,8 +28,7 @@ func (log *LOG) Begin(m *ctx.Message, arg ...string) ctx.Server { return log } func (log *LOG) Start(m *ctx.Message, arg ...string) bool { - log.nfs = m.Sess("nfs").Cmd("open", m.Confx("bench.log", arg, 0)) - log.out = log.nfs.Optionv("out").(*os.File) + log.out = m.Sess("nfs").Cmd("open", m.Confx("bench.log", arg, 0)).Optionv("out").(*os.File) log.out.Truncate(0) fmt.Fprintln(log.out, "\n\n") return false @@ -64,8 +63,6 @@ var Index = &ctx.Context{Name: "log", Help: "日志中心", "log_name": &ctx.Config{Name: "log_name", Value: "dump", Help: "日志屏蔽类型"}, }, Commands: map[string]*ctx.Command{ - "open": &ctx.Command{Name: "open file", Help: "打开日志文件", Hand: func(m *ctx.Message, c *ctx.Context, key string, arg ...string) { - }}, "log": &ctx.Command{Name: "log level string...", Help: "输出日志, level: 日志类型, string: 日志内容", Hand: func(m *ctx.Message, c *ctx.Context, key string, arg ...string) { if log, ok := m.Target().Server.(*LOG); m.Assert(ok) && log.out != nil { if m.Confs("silent", arg[0]) { @@ -92,9 +89,6 @@ var Index = &ctx.Context{Name: "log", Help: "日志中心", } } }}, - "pwd": &ctx.Command{Name: "pwd", Help: "打开日志文件", Hand: func(m *ctx.Message, c *ctx.Context, key string, arg ...string) { - m.Echo("nice") - }}, }, } diff --git a/src/contexts/nfs/nfs.go b/src/contexts/nfs/nfs.go index 37205b0d..f4808efd 100644 --- a/src/contexts/nfs/nfs.go +++ b/src/contexts/nfs/nfs.go @@ -1133,6 +1133,12 @@ var Index = &ctx.Context{Name: "nfs", Help: "存储中心", Hand: func(m *ctx.Message, c *ctx.Context, key string, arg ...string) { conf := m.Confv("dir_conf") + m.Log("info", "option %s", m.Option("dir")) + if len(arg) > 0 { + m.Log("info", "arg0 %s", arg[0]) + } + m.Log("info", "elect %s", ctx.Elect(m.Option("dir"), arg, 0)) + m.Option("dir", path.Clean(ctx.Elect(m.Option("dir"), arg, 0))) d := path.Join(m.Confx("dir_root", conf), m.Option("dir")) if s, e := os.Stat(d); m.Assert(e) && !s.IsDir() { diff --git a/src/contexts/web/web.go b/src/contexts/web/web.go index ffe3da4a..e34cd992 100644 --- a/src/contexts/web/web.go +++ b/src/contexts/web/web.go @@ -279,37 +279,18 @@ var Index = &ctx.Context{Name: "web", Help: "应用中心", "index": []interface{}{ map[string]interface{}{"name": "head", "template": "head"}, map[string]interface{}{"name": "clipbaord", "help": "clipbaord", "template": "clipboard"}, - map[string]interface{}{"name": "prompt", "help": "prompt", "template": "componet", - "context": "nfs.stdio", "command": "prompt", "arguments": []interface{}{"@string"}, - "inputs": []interface{}{ - map[string]interface{}{"type": "text", "name": "string", "label": "string"}, - map[string]interface{}{"type": "button", "label": "refresh"}, - }, - }, - map[string]interface{}{"name": "exec", "help": "exec", "template": "componet", - "context": "nfs.stdio", "command": "exec", "arguments": []interface{}{"@string"}, - "inputs": []interface{}{ - map[string]interface{}{"type": "text", "name": "string"}, - }, - }, - map[string]interface{}{"name": "show", "help": "show", "template": "componet", - "context": "nfs.stdio", "command": "show", "arguments": []interface{}{"\n", "@string", "\n"}, - "inputs": []interface{}{ - map[string]interface{}{"type": "text", "name": "string", "label": "string"}, - map[string]interface{}{"type": "button", "label": "refresh"}, - }, - }, map[string]interface{}{"name": "buffer", "help": "buffer", "template": "componet", "context": "cli", "command": "tmux", "arguments": []interface{}{"buffer"}, "inputs": []interface{}{ map[string]interface{}{"type": "text", "name": "limit", "label": "limit", "value": "3"}, map[string]interface{}{"type": "text", "name": "index", "label": "index"}, map[string]interface{}{"type": "button", "label": "refresh"}, }, + "pre_run": true, }, map[string]interface{}{"name": "command", "help": "command", "template": "componet", "context": "cli.shell1", "command": "source", "arguments": []interface{}{"@cmd"}, "inputs": []interface{}{ - map[string]interface{}{"type": "text", "name": "cmd", "value": "pwd", + map[string]interface{}{"type": "text", "name": "cmd", "value": "", "class": "cmd", "clipstack": "clistack", }, }, @@ -331,14 +312,21 @@ var Index = &ctx.Context{Name: "web", Help: "应用中心", map[string]interface{}{"type": "button", "label": "refresh"}, }, }, + map[string]interface{}{"name": "upload", "help": "upload", "template": "componet", + "form_type": "upload", + "inputs": []interface{}{ + map[string]interface{}{"type": "file", "name": "upload"}, + map[string]interface{}{"type": "submit", "value": "submit"}, + }, + "display_result": "", + }, map[string]interface{}{"name": "dir", "help": "dir", "template": "componet", "context": "nfs", "command": "dir", "arguments": []interface{}{"@dir", "dir_deep", "no", "dir_name", "name", "dir_info", "", "dir_link", "%s", }, - "form_type": "upload", + "pre_run": true, "inputs": []interface{}{ - map[string]interface{}{"type": "text", "name": "dir", "label": "dir"}, map[string]interface{}{"type": "choice", "name": "dir_type", "label": "dir_type", "value": "both", "choice": []interface{}{ map[string]interface{}{"name": "both", "value": "both"}, @@ -365,8 +353,7 @@ var Index = &ctx.Context{Name: "web", Help: "应用中心", map[string]interface{}{"name": "time_r", "value": "time_r"}, }, }, - map[string]interface{}{"type": "file", "name": "upload"}, - map[string]interface{}{"type": "submit", "value": "submit"}, + map[string]interface{}{"type": "text", "name": "dir", "label": "dir"}, }, }, map[string]interface{}{"name": "web_site", "help": "web_site", "template": "componet", @@ -375,6 +362,26 @@ var Index = &ctx.Context{Name: "web", Help: "应用中心", }, "display_result": "", }, + map[string]interface{}{"name": "prompt", "help": "prompt", "template": "componet", + "context": "nfs.stdio", "command": "prompt", "arguments": []interface{}{"@string"}, + "inputs": []interface{}{ + map[string]interface{}{"type": "text", "name": "string", "label": "string"}, + map[string]interface{}{"type": "button", "label": "refresh"}, + }, + }, + map[string]interface{}{"name": "exec", "help": "exec", "template": "componet", + "context": "nfs.stdio", "command": "exec", "arguments": []interface{}{"@string"}, + "inputs": []interface{}{ + map[string]interface{}{"type": "text", "name": "string"}, + }, + }, + map[string]interface{}{"name": "show", "help": "show", "template": "componet", + "context": "nfs.stdio", "command": "show", "arguments": []interface{}{"\n", "@string", "\n"}, + "inputs": []interface{}{ + map[string]interface{}{"type": "text", "name": "string", "label": "string"}, + map[string]interface{}{"type": "button", "label": "refresh"}, + }, + }, map[string]interface{}{"name": "tail", "template": "tail"}, }, }, Help: "组件列表"}, @@ -470,7 +477,7 @@ var Index = &ctx.Context{Name: "web", Help: "应用中心", m.Log("info", "%s %s", req.Method, req.URL) m.Echo("%s: %s\n", req.Method, req.URL) for k, v := range req.Header { - m.Log("fuck", "%s: %s", k, v) + m.Log("info", "%s: %s", k, v) } if web.Client == nil { @@ -757,7 +764,6 @@ var Index = &ctx.Context{Name: "web", Help: "应用中心", m.Log("upload", "file(%d): %s", h.Size, p) m.Append("redirect", m.Option("referer")) }}, - "/render": &ctx.Command{Name: "/render template", Help: "渲染模板, template: 模板名称", Hand: func(m *ctx.Message, c *ctx.Context, key string, arg ...string) { if _, ok := m.Target().Server.(*WEB); m.Assert(ok) { accept_json := strings.HasPrefix(m.Option("accept"), "application/json") @@ -870,8 +876,10 @@ var Index = &ctx.Context{Name: "web", Help: "应用中心", } } - if val["command"] != nil { - msg.Cmd(val["command"], args) + if order != "" || (val["pre_run"] != nil && val["pre_run"].(bool)) { + if val["command"] != nil { + msg.Cmd(val["command"], args) + } } if accept_json { diff --git a/usr/library/base.js b/usr/library/base.js index 328a6f4b..902fbaec 100644 --- a/usr/library/base.js +++ b/usr/library/base.js @@ -35,6 +35,10 @@ function send_command(form, cb) { data[form[i].name] = form[i].value } + if (data["dir"]) { + context.Cookie("dir", data["dir"]) + } + context.GET("", data, function(msg) { msg = msg[0] @@ -79,7 +83,6 @@ function check_argument(form, target) { function onaction(event, action) { switch (action) { case "submit": - return false break case "click": if (event.target.nodeName == "INPUT") { @@ -249,7 +252,7 @@ function init_download(event) { document.querySelector("form.option.dir input[name=dir]").value = context.Search("download_dir") - option["dir"].value && send_command(option) + option["dir"].value && option["dir"].value != context.Cookie("dir") && send_command(option) var append = document.querySelector("table.append.dir") append.onchange = diff --git a/usr/template/common/base.tmpl b/usr/template/common/base.tmpl index 299b204e..2a5a4751 100644 --- a/usr/template/common/base.tmpl +++ b/usr/template/common/base.tmpl @@ -111,6 +111,9 @@ {{define "componet"}}
{{option .Meta "help"}}({{option .Meta "context"}}.{{option .Meta "command"}}) {{$form_type := option . "form_type"|meta}} + + {{if eq $form_type "upload"}} + {{end}}
{{range $index, $input := option . "inputs"}} @@ -165,6 +168,8 @@ {{end}}
+ {{if eq $form_type "upload"}} + {{end}} {{if index .Meta "display_append"}} {{option .Meta "display_append"}}