diff --git a/base/web/cache.go b/base/web/cache.go index e014f459..ece86e6e 100644 --- a/base/web/cache.go +++ b/base/web/cache.go @@ -41,9 +41,11 @@ func _cache_save(m *ice.Message, kind, name, text string, arg ...string) { // fi // 添加数据 size := kit.Int(kit.Select(kit.Format(len(text)), arg, 1)) + file := kit.Select("", arg, 0) + text = kit.Select(file, text) h := m.Rich(CACHE, nil, kit.Dict( kit.MDB_TYPE, kind, kit.MDB_NAME, name, kit.MDB_TEXT, text, - kit.MDB_FILE, kit.Select("", arg, 0), kit.MDB_SIZE, size, + kit.MDB_FILE, file, kit.MDB_SIZE, size, )) m.Log_CREATE(CACHE, h, kit.MDB_TYPE, kind, kit.MDB_NAME, name) @@ -59,6 +61,7 @@ func _cache_save(m *ice.Message, kind, name, text string, arg ...string) { // fi m.Push(kit.MDB_NAME, name) m.Push(kit.MDB_TEXT, text) m.Push(kit.MDB_SIZE, size) + m.Push(kit.MDB_FILE, file) m.Push(DATA, h) } func _cache_watch(m *ice.Message, key, file string) { @@ -152,10 +155,8 @@ func init() { _cache_save(m, arg[0], arg[1], "", file, size) }}, UPLOAD: {Name: "upload", Help: "上传", Hand: func(m *ice.Message, arg ...string) { - if r, ok := m.Optionv("request").(*http.Request); ok { - kind, name, file, size := _cache_upload(m, r) - _cache_save(m, kind, name, "", file, size) - } + kind, name, file, size := _cache_upload(m, m.R) + _cache_save(m, kind, name, "", file, size) }}, DOWNLOAD: {Name: "download type name", Help: "下载", Hand: func(m *ice.Message, arg ...string) { if r, ok := m.Optionv("response").(*http.Response); ok { diff --git a/base/web/spide.go b/base/web/spide.go index 99589baa..84fd0d22 100644 --- a/base/web/spide.go +++ b/base/web/spide.go @@ -238,8 +238,8 @@ func init() { switch cache { case "cache": m.Optionv("response", res) - m.Cmdy(CACHE, "catch", res.Header.Get("Content-Type"), uri) - m.Echo(m.Append("data")) + m.Cmdy(CACHE, DOWNLOAD, res.Header.Get("Content-Type"), uri) + m.Echo(m.Append(DATA)) case "raw": if b, e := ioutil.ReadAll(res.Body); m.Assert(e) { m.Echo(string(b)) diff --git a/core/code/inner.go b/core/code/inner.go index 91219f90..f3b7f485 100644 --- a/core/code/inner.go +++ b/core/code/inner.go @@ -6,7 +6,6 @@ import ( "github.com/shylinux/icebergs/base/web" kit "github.com/shylinux/toolkits" - "os" "path" "strings" ) @@ -28,8 +27,8 @@ func _inner_protect(m *ice.Message, name string) bool { ls := strings.Split(name, "/") return !m.Right(ls) && m.Conf(INNER, kit.Keys("meta.protect", ls[0])) == "true" } -func _inner_binary(m *ice.Message, name string) bool { - return m.Conf(INNER, kit.Keys("meta.binary", _inner_ext(name))) == "true" +func _inner_source(m *ice.Message, name string) bool { + return m.Conf(INNER, kit.Keys("meta.source", _inner_ext(name))) == "true" } func _inner_ext(name string) string { return strings.ToLower(kit.Select(path.Base(name), strings.TrimPrefix(path.Ext(name), "."))) @@ -52,7 +51,7 @@ func _inner_list(m *ice.Message, name string) { return } - if m.Set(ice.MSG_RESULT); strings.HasSuffix(name, "/") || !_inner_binary(m, name) { + if m.Set(ice.MSG_RESULT); strings.HasSuffix(name, "/") || _inner_source(m, name) { m.Cmdy("nfs.dir", name, "file size time") return } @@ -63,12 +62,13 @@ func _inner_save(m *ice.Message, name, text string) { return } - if f, e := os.Create(name); m.Assert(e) { + if f, p, e := kit.Create(name); m.Assert(e) { defer f.Close() m.Cmd(web.FAVOR, "inner.save", "shell", name, text) if n, e := f.WriteString(text); m.Assert(e) { m.Log_EXPORT("file", name, "size", n) } + m.Echo(p) } } func _inner_plug(m *ice.Message, name string) { @@ -126,7 +126,13 @@ func init() { Configs: map[string]*ice.Config{ INNER: {Name: "inner", Help: "编辑器", Value: kit.Data( "protect", kit.Dict("etc", "true", "var", "true", "usr", "true"), - "binary", kit.Dict("bin", "true", "gz", "true"), + "source", kit.Dict( + "sh", "true", + "py", "true", + "shy", "true", + "go", "true", + "js", "true", + ), "plug", kit.Dict( "py", kit.Dict( "prefix", kit.Dict("#", "comment"), @@ -136,14 +142,14 @@ func init() { "csv", kit.Dict("display", true), ), "show", kit.Dict( - "sh", []string{"bash"}, + "sh", []string{"sh"}, "py", []string{"python"}, "js", []string{"node"}, ), )}, }, Commands: map[string]*ice.Command{ - INNER: {Name: "inner path=tmp file=hi.qrc key auto", Help: "编辑器", Meta: map[string]interface{}{ + INNER: {Name: "inner path=usr/demo file=hi.qrc key auto", Help: "编辑器", Meta: map[string]interface{}{ "display": "/plugin/local/code/inner.js", "style": "editor", }, Action: map[string]*ice.Action{ "cmd": {Name: "cmd arg", Help: "命令", Hand: func(m *ice.Message, arg ...string) { @@ -162,9 +168,6 @@ func init() { "find": {Name: "find word", Help: "搜索", Hand: func(m *ice.Message, arg ...string) { web.FavorList(m, arg[0], arg[1], arg[2:]...) }}, - "upload": {Name: "upload path name", Help: "上传", Hand: func(m *ice.Message, arg ...string) { - m.Cmd(web.STORY, web.WATCH, m.Option("data"), path.Join(m.Option("path"), m.Option("name"))) - }}, "project": {Name: "project path", Help: "项目", Hand: func(m *ice.Message, arg ...string) { _inner_list(m, path.Join("./", kit.Select("", arg, 0))+"/") }}, @@ -206,6 +209,11 @@ func init() { SAVE: {Name: "save path name content", Help: "保存", Hand: func(m *ice.Message, arg ...string) { _inner_save(m, path.Join("./", arg[0], arg[1]), kit.Select(m.Option("content"), arg, 2)) }}, + + web.UPLOAD: {Name: "upload path name", Help: "上传", Hand: func(m *ice.Message, arg ...string) { + m.Cmdy(web.CACHE, web.UPLOAD) + m.Cmdy(web.CACHE, web.WATCH, m.Option(web.DATA), path.Join(m.Option("path"), m.Option("name"))) + }}, }, Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) { _inner_main(m, arg...) }}, }, }, nil) diff --git a/core/code/pprof.go b/core/code/pprof.go index a44bee5b..28f771bc 100644 --- a/core/code/pprof.go +++ b/core/code/pprof.go @@ -43,9 +43,9 @@ func _pprof_show(m *ice.Message, zone string, id string) { val = val[kit.MDB_META].(map[string]interface{}) list := []string{} - m.Grows(PPROF, kit.Keys(kit.MDB_HASH, key), "", "", func(index int, value map[string]interface{}) { - task.Put(val, func(task *task.Task) error { - m.Sleep("1s") + task.Put(val, func(task *task.Task) error { + m.Sleep("1s") + m.Grows(PPROF, kit.Keys(kit.MDB_HASH, key), "", "", func(index int, value map[string]interface{}) { // 压测命令 m.Log_EXPORT(kit.MDB_META, PPROF, kit.MDB_ZONE, zone, kit.MDB_VALUE, kit.Format(value)) cmd := kit.Format(value[kit.MDB_TYPE]) @@ -54,16 +54,17 @@ func _pprof_show(m *ice.Message, zone string, id string) { arg, kit.Simple(value[kit.MDB_EXTRA])...).Result() m.Cmd(web.FAVOR, favor, cmd, arg, res) list = append(list, cmd+": "+arg, res) - return nil }) + return nil }) // 收藏程序 - bin := m.Cmd(web.CACHE, "catch", kit.MIME_FILE, kit.Format(val[BINNARY])).Append(kit.MDB_TEXT) + msg := m.Cmd(web.CACHE, web.CATCH, kit.MIME_FILE, kit.Format(val[BINNARY])) + bin := msg.Append(kit.MDB_TEXT) m.Cmd(web.FAVOR, favor, kit.MIME_FILE, bin, val[BINNARY]) // 性能分析 - msg := m.Cmd(web.SPIDE, "self", "cache", "GET", kit.Select("/code/pprof/profile", val[SERVICE]), "seconds", kit.Select("5", kit.Format(val[SECONDS]))) + msg = m.Cmd(web.SPIDE, "self", web.CACHE, http.MethodGet, kit.Select("/code/pprof/profile", val[SERVICE]), "seconds", kit.Select("5", kit.Format(val[SECONDS]))) m.Cmd(web.FAVOR, favor, PPROF, msg.Append(kit.MDB_TEXT), kit.Keys(zone, "pd.gz")) // 结果摘要 diff --git a/core/code/qrcode.go b/core/code/qrcode.go index bfde43c8..487b2a26 100644 --- a/core/code/qrcode.go +++ b/core/code/qrcode.go @@ -4,9 +4,10 @@ import ( ice "github.com/shylinux/icebergs" kit "github.com/shylinux/toolkits" + "os" + qrs "github.com/skip2/go-qrcode" "github.com/tuotoo/qrcode" - "os" ) func init() { @@ -40,7 +41,7 @@ func init() { m.Echo(m.Conf(QRCODE, "meta.plug")) }}, "show": {Name: "show name", Help: "渲染", Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) { - m.Echo(``, arg[0]) + m.Echo(``, arg[0], m.Option(ice.MSG_USERPOD)) }}, }, }, nil) diff --git a/core/wiki/draw.go b/core/wiki/draw.go index 2bb4a079..51d5721b 100644 --- a/core/wiki/draw.go +++ b/core/wiki/draw.go @@ -1,10 +1,11 @@ package wiki import ( - "github.com/shylinux/icebergs" + ice "github.com/shylinux/icebergs" "github.com/shylinux/icebergs/base/mdb" "github.com/shylinux/icebergs/base/nfs" - "github.com/shylinux/toolkits" + "github.com/shylinux/icebergs/base/web" + kit "github.com/shylinux/toolkits" ) func _draw_show(m *ice.Message, zone, kind, name, text string, arg ...string) { @@ -25,18 +26,18 @@ const ( ) func init() { - Index.Register(&ice.Context{Name: "draw", Help: "思维导图", + sub := Index.Register(&ice.Context{Name: "draw", Help: "思维导图", Configs: map[string]*ice.Config{ - DRAW: {Name: "draw", Help: "思维导图", Value: kit.Data(kit.MDB_SHORT, "name", "path", "", "regs", ".*\\.svg", + DRAW: {Name: "draw", Help: "思维导图", Value: kit.Data(kit.MDB_SHORT, "name", "path", "usr/demo", "regs", ".*\\.svg", "prefix", ``, "suffix", ``, )}, }, Commands: map[string]*ice.Command{ - DRAW: {Name: "draw path=自然/编程/hi.svg auto", Help: "思维导图", Meta: kit.Dict(mdb.PLUGIN, DrawPlugin), Action: map[string]*ice.Action{ + DRAW: {Name: "draw path=hi.svg auto", Help: "思维导图", Meta: kit.Dict(mdb.PLUGIN, DrawPlugin), Action: map[string]*ice.Action{ nfs.SAVE: {Name: "save path text", Help: "保存", Hand: func(m *ice.Message, arg ...string) { _wiki_save(m, DATA, arg[0], arg[1]) }}, - "run": {Name: "show path text", Help: "运行", Hand: func(m *ice.Message, arg ...string) { + "run": {Name: "show zone type name text", Help: "运行", Hand: func(m *ice.Message, arg ...string) { _draw_show(m, arg[0], arg[1], arg[2], arg[3], arg[4:]...) }}, mdb.PLUGIN: {Name: "plugin", Help: "插件", Hand: func(m *ice.Message, arg ...string) { @@ -49,4 +50,20 @@ func init() { }}, }, }, nil) + + sub.Register(&ice.Context{Name: "工作", Help: "工作", + Commands: map[string]*ice.Command{ + "项目开发": {Name: "项目开发", Help: "项目开发", Action: map[string]*ice.Action{ + "run": {Hand: func(m *ice.Message, arg ...string) { + m.Echo("hello world") + }}, + }, Hand: func(m *ice.Message, c *ice.Context, key string, arg ...string) { + m.Echo("hello world") + }}, + "项目测试": {Name: "项目测试", Help: "项目测试", Hand: func(m *ice.Message, c *ice.Context, key string, arg ...string) { + + }}, + }, + }, &web.Frame{}) + } diff --git a/core/wiki/feel.go b/core/wiki/feel.go index c9c9075f..b0f37e5b 100644 --- a/core/wiki/feel.go +++ b/core/wiki/feel.go @@ -1,10 +1,10 @@ package wiki import ( - "github.com/shylinux/icebergs" + ice "github.com/shylinux/icebergs" "github.com/shylinux/icebergs/base/mdb" "github.com/shylinux/icebergs/base/web" - "github.com/shylinux/toolkits" + kit "github.com/shylinux/toolkits" "os" "path" diff --git a/core/wiki/wiki.go b/core/wiki/wiki.go index fc4324b7..e3625d77 100644 --- a/core/wiki/wiki.go +++ b/core/wiki/wiki.go @@ -32,10 +32,8 @@ func _wiki_save(m *ice.Message, cmd, name, text string, arg ...string) { m.Cmd(nfs.SAVE, path.Join(m.Conf(cmd, "meta.path"), name), text) } func _wiki_upload(m *ice.Message, cmd string) { - m.Option("request", m.R) - msg := m.Cmd(web.CACHE, "catch", "", "") - m.Cmd(web.CACHE, "watch", msg.Append("data"), path.Join(msg.Conf(cmd, "meta.path"), - path.Dir(m.Option("path")), msg.Append("name"))) + m.Cmdy(web.CACHE, web.UPLOAD) + m.Cmdy(web.CACHE, web.WATCH, m.Option(web.DATA), path.Join(m.Option("path"), m.Option("name"))) } func reply(m *ice.Message, cmd string, arg ...string) bool { diff --git a/core/wiki/word.go b/core/wiki/word.go index b6200960..8201c79f 100644 --- a/core/wiki/word.go +++ b/core/wiki/word.go @@ -286,7 +286,7 @@ func init() { STACK: {Name: "stack", Help: "结构", Value: kit.Data("template", stack)}, WORD: {Name: "word", Help: "语言文字", Value: kit.Data(kit.MDB_SHORT, "name", - "path", "", "regs", ".*\\.shy", "alias", map[string]interface{}{ + "path", "usr/demo", "regs", ".*\\.shy", "alias", map[string]interface{}{ LABEL: []interface{}{CHART, LABEL}, CHAIN: []interface{}{CHART, CHAIN}, @@ -359,7 +359,7 @@ func init() { _stack_show(m, arg[0], arg[1], arg[2:]...) }}, - WORD: {Name: "word path=自然/编程/hi.shy auto", Help: "语言文字", Meta: kit.Dict( + WORD: {Name: "word path=hi.shy auto", Help: "语言文字", Meta: kit.Dict( "display", "/plugin/local/wiki/word.js", ), Action: map[string]*ice.Action{ "story": {Name: "story", Help: "运行", Hand: func(m *ice.Message, arg ...string) { diff --git a/init.go b/init.go index 9437265d..0a8962fc 100644 --- a/init.go +++ b/init.go @@ -176,7 +176,6 @@ func Run(arg ...string) string { Pulse.Table(nil) } fmt.Printf(Pulse.Result()) - os.Exit(frame.code) return "" } diff --git a/misc/alpha/alpha.go b/misc/alpha/alpha.go index 3202d749..76cd7140 100644 --- a/misc/alpha/alpha.go +++ b/misc/alpha/alpha.go @@ -39,7 +39,7 @@ func _alpha_find(m *ice.Message, method, word string) { }) } func _alpha_find2(m *ice.Message, method, word string) { - p := path.Join(m.Conf(ALPHA, "meta.store"), ALPHA) + p := path.Join(m.Conf(ALPHA, "meta.store"), ALPHA+".ecdict") if ls, e := ioutil.ReadDir(p); m.Assert(e) { args := []interface{}{} for _, v := range ls { @@ -80,7 +80,7 @@ func _alpha_load(m *ice.Message, file, name string) { )) m.Cmd(mdb.IMPORT, ALPHA, name, kit.MDB_LIST, - m.Cmd(web.CACHE, "catch", "csv", file+".csv").Append(web.DATA)) + m.Cmd(web.CACHE, "catch", "csv", file+".csv").Append(kit.MDB_FILE)) // 保存词库 m.Conf(ALPHA, kit.Keys(name, "meta.limit"), 0) diff --git a/misc/docker/docker.go b/misc/docker/docker.go index a94a7892..be78fcdf 100644 --- a/misc/docker/docker.go +++ b/misc/docker/docker.go @@ -26,7 +26,10 @@ var _container = []string{cli.SYSTEM, DOCKER, CONTAINER} var Index = &ice.Context{Name: "docker", Help: "虚拟机", Configs: map[string]*ice.Config{ DOCKER: {Name: "docker", Help: "虚拟机", Value: kit.Data( - "repos", "centos", "build", []interface{}{"home", "mount"}, + "repos", "centos", "build", []interface{}{ + "home", + // "mount", + }, "alpine", []interface{}{ `sed -i 's/dl-cdn.alpinelinux.org/mirrors.aliyun.com/g' /etc/apk/repositories`, `apk add curl`,