diff --git a/core/wiki/word.go b/core/wiki/word.go index 035b3531..d50dcec5 100644 --- a/core/wiki/word.go +++ b/core/wiki/word.go @@ -171,13 +171,18 @@ func _field_show(m *ice.Message, name, text string, arg ...string) { } else { m.Parse("option", arg[i], arg[i+1]) } + data[arg[i]] = m.Optionv(arg[i]) - if arg[i] == "args" { + switch arg[i] { + case "content": + data[arg[i]] = arg[i+1] + + case "args": args := kit.Simple(m.Optionv(arg[i])) count := 0 kit.Fetch(data["inputs"], func(index int, value map[string]interface{}) { - if value["_input"] == "text" || value["type"] == "text" { + if value["_input"] != "button" && value["type"] != "button" { count++ } }) @@ -368,6 +373,20 @@ func init() { if len(arg) == 1 { arg = []string{"", arg[0]} } + if arg[0] == "shell" { + arg[1] = strings.TrimSpace(arg[1]) + m.Echo(`
`, arg[1]) + for _, l := range strings.Split(arg[1], "\n") { + m.Echo("
") + m.Echo("$ ") + m.Echo("") + m.Echo(l) + m.Echo("") + m.Echo("
") + } + m.Echo("
") + return + } _spark_show(m, arg[0], kit.Select(arg[0], arg[1]), arg[2:]...) }}, diff --git a/misc/es/es.go b/misc/es/es.go index 918a8069..764f9262 100644 --- a/misc/es/es.go +++ b/misc/es/es.go @@ -54,27 +54,35 @@ var Index = &ice.Context{Name: ES, Help: "搜索", return } - if len(arg) == 1 { - m.Richs(cli.DAEMON, "", arg[0], func(key string, value map[string]interface{}) { - m.Cmdy("web.spide", "dev", "raw", "GET", "http://localhost:9200") - }) - } - - if len(arg) == 2 { - m.Richs(cli.DAEMON, "", arg[0], func(key string, value map[string]interface{}) { - m.Cmdy("web.spide", "dev", "raw", "GET", "http://localhost:9200") - }) - } + m.Richs(cli.DAEMON, "", arg[0], func(key string, value map[string]interface{}) { + m.Cmdy("web.spide", "dev", "raw", "GET", "http://localhost:9200") + }) }}, - "command": {Name: "command 执行:button method:select=GET|PUT|POST|DELETE cmd=/ data:textarea", Help: "命令", Action: map[string]*ice.Action{}, Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) { + "GET": {Name: "GET 查看:button cmd=/", Help: "命令", Action: map[string]*ice.Action{}, Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) { if pod := m.Option("_pod"); pod != "" { m.Option("_pod", "") m.Cmdy(web.SPACE, pod, "web.code.es.command", arg) return } + m.Option("header", "Content-Type", "application/json") - m.Echo(kit.Formats(kit.UnMarshal(m.Cmdx("web.spide", "dev", "raw", arg[0], "http://localhost:9200/"+arg[1], "data", arg[2])))) + m.Echo(kit.Formats(kit.UnMarshal(m.Cmdx("web.spide", "dev", "raw", "GET", kit.MergeURL2("http://localhost:9200", kit.Select("/", arg, 0)))))) + }}, + "CMD": {Name: "CMD 执行:button method:select=GET|PUT|POST|DELETE cmd=/ data:textarea", Help: "命令", Action: map[string]*ice.Action{}, Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) { + if pod := m.Option("_pod"); pod != "" { + m.Option("_pod", "") + m.Cmdy(web.SPACE, pod, "web.code.es.CMD", arg) + return + } + + if arg[0] == "GET" { + m.Option("header", "Content-Type", "application/json") + m.Echo(kit.Formats(kit.UnMarshal(m.Cmdx("web.spide", "dev", "raw", arg[0], kit.MergeURL2("http://localhost:9200", arg[1]))))) + return + } + m.Option("header", "Content-Type", "application/json") + m.Echo(kit.Formats(kit.UnMarshal(m.Cmdx("web.spide", "dev", "raw", arg[0], kit.MergeURL2("http://localhost:9200", arg[1]), "data", arg[2])))) }}, "index": {Name: "table index 创建:button", Help: "索引", Action: map[string]*ice.Action{}, Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) { diff --git a/misc/es/es.shy b/misc/es/es.shy index 806a43ed..56a27dd8 100644 --- a/misc/es/es.shy +++ b/misc/es/es.shy @@ -16,20 +16,27 @@ linux https://elasticsearch.thans.cn/downloads/elasticsearch/elasticsearch-7.3.2 section 启动 spark shell ` -$ tar xvf elasticsearch-7.3.2-linux-x86_64.tar.gz -$ cd elasticsearch-7.3.2 -$ ./bin/elasticsearch +tar xvf elasticsearch-7.3.2-linux-x86_64.tar.gz +cd elasticsearch-7.3.2 +./bin/elasticsearch ` section 体验 spark shell ` -$ curl http://localhost:9200 +curl http://localhost:9200 ` -field command web.code.es.command option `{ _pod centos.remote }` +# field command web.code.es.command option `{ _pod centos.remote }` +field GET web.code.es.GET style command args `[ /index_test/test_type/1 ]` + +field CMD web.code.es.CMD style command args `[ POST /index_test/test_type/1 ] ` content `{ + "name": "lisi", + "age" : "12" +}` + field es web.code.es.es +field install web.code.install return field document web.code.es.document -field install web.code.install