diff --git a/base/web/dream.go b/base/web/dream.go index 1bb98d01..4ada2cae 100644 --- a/base/web/dream.go +++ b/base/web/dream.go @@ -84,7 +84,7 @@ func _dream_show(m *ice.Message, name string) { // 启动任务 m.Cmd(cli.DAEMON, m.Configv(ice.CMD), ice.DEV, ice.DEV, mdb.NAME, name, m.OptionSimple(RIVER)) defer m.Event(DREAM_CREATE, kit.SimpleKV("", m.Option(mdb.TYPE), name)...) - m.Sleep300ms() + m.Sleep3s() } const ( diff --git a/base/web/render.go b/base/web/render.go index 70995b84..ef4bf7dd 100644 --- a/base/web/render.go +++ b/base/web/render.go @@ -123,3 +123,7 @@ func (b *Buffer) Close() error { return nil } func PushStream(m *ice.Message) { m.Option(cli.CMD_OUTPUT, &Buffer{m: m, n: m.Option(ice.MSG_DAEMON)}) } + +func Format(tag string, arg ...interface{}) string { + return kit.Format("<%s>%s%s>", tag, strings.Join(kit.Simple(arg), "")) +} diff --git a/base/web/share.go b/base/web/share.go index 0962b9ad..7271432c 100644 --- a/base/web/share.go +++ b/base/web/share.go @@ -76,7 +76,7 @@ func _share_local(m *ice.Message, arg ...string) { } // 上传文件 - m.Cmdy(SPACE, m.Option(ice.POD), SPIDE, ice.DEV, SPIDE_RAW, m.MergeURL2("/share/proxy"), + m.Cmdy(SPACE, m.Option(ice.POD), SPIDE, ice.DEV, SPIDE_RAW, m.MergeURL2(SHARE_PROXY), SPIDE_PART, m.OptionSimple(ice.POD), nfs.PATH, p, CACHE, cache.Format(ice.MOD_TIME), UPLOAD, "@"+p) if s, e := os.Stat(pp); e == nil && !s.IsDir() { @@ -97,6 +97,15 @@ const ( RIVER = "river" STORM = "storm" FIELD = "field" + + SHARE_TOAST = "/share/toast/" + SHARE_CACHE = "/share/cache/" + SHARE_REPOS = "/share/repos/" + SHARE_PROXY = "/share/proxy/" + SHARE_LOCAL = "/share/local/" + + SHARE_LOCAL_AVATAR = "/share/local/avatar" + SHARE_LOCAL_BACKGROUND = "/share/local/background" ) const SHARE = "share" @@ -157,26 +166,26 @@ func init() { m.RenderIndex(SERVE, ice.VOLCANOS) }}, - "/share/toast/": {Name: "/share/toast/", Help: "推送流", Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) { + SHARE_TOAST: {Name: "/share/toast/", Help: "推送流", Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) { m.Cmdy(SPACE, m.Option(ice.POD), m.Optionv("cmds")) }}, - "/share/repos/": {Name: "/share/repos/", Help: "代码库", Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) { - _share_repos(m, path.Join(arg[0], arg[1], arg[2]), arg[3:]...) - }}, - "/share/proxy": {Name: "/share/proxy", Help: "文件流", Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) { - _share_proxy(m) - }}, - "/share/cache/": {Name: "/share/cache/", Help: "缓存池", Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) { + SHARE_CACHE: {Name: "/share/cache/", Help: "缓存池", Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) { _share_cache(m, arg...) }}, - "/share/local/": {Name: "/share/local/", Help: "文件夹", Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) { + SHARE_REPOS: {Name: "/share/repos/", Help: "代码库", Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) { + _share_repos(m, path.Join(arg[0], arg[1], arg[2]), arg[3:]...) + }}, + SHARE_PROXY: {Name: "/share/proxy/", Help: "文件流", Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) { + _share_proxy(m) + }}, + SHARE_LOCAL: {Name: "/share/local/", Help: "文件夹", Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) { _share_local(m, arg...) }}, - "/share/local/avatar": {Name: "avatar", Help: "头像", Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) { - m.RenderDownload(strings.TrimPrefix(m.Cmd(aaa.USER, m.Option(ice.MSG_USERNAME)).Append(aaa.AVATAR), "/share/local/")) + SHARE_LOCAL_AVATAR: {Name: "avatar", Help: "头像", Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) { + m.RenderDownload(strings.TrimPrefix(m.Cmd(aaa.USER, m.Option(ice.MSG_USERNAME)).Append(aaa.AVATAR), SHARE_LOCAL)) }}, - "/share/local/background": {Name: "background", Help: "壁纸", Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) { - m.RenderDownload(strings.TrimPrefix(m.Cmd(aaa.USER, m.Option(ice.MSG_USERNAME)).Append(aaa.BACKGROUND), "/share/local/")) + SHARE_LOCAL_BACKGROUND: {Name: "background", Help: "壁纸", Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) { + m.RenderDownload(strings.TrimPrefix(m.Cmd(aaa.USER, m.Option(ice.MSG_USERNAME)).Append(aaa.BACKGROUND), SHARE_LOCAL)) }}, }}) } diff --git a/base/web/spide.go b/base/web/spide.go index 8a934f15..5a069392 100644 --- a/base/web/spide.go +++ b/base/web/spide.go @@ -319,6 +319,7 @@ const ( SPIDE_HEADER = "header" SPIDE_COOKIE = "cookie" + FORM = "form" ADDRESS = "address" REQUEST = "request" RESPONSE = "response" diff --git a/conf.go b/conf.go index c7e3307e..24d59aff 100644 --- a/conf.go +++ b/conf.go @@ -20,6 +20,7 @@ const ( INIT = "init" LOAD = "load" AUTO = "auto" + SHOW = "show" HELP = "help" HTTP = "http" SAVE = "save" diff --git a/core/code/autogen.go b/core/code/autogen.go index 80116c05..fa98e5d3 100644 --- a/core/code/autogen.go +++ b/core/code/autogen.go @@ -152,16 +152,20 @@ func init() { m.RenameAppend(nfs.PATH, arg[0]) } }}, - mdb.CREATE: {Name: "create main=src/main.go@key key zone type=Zone,Hash,Data name=hi list help", Help: "模块", Hand: func(m *ice.Message, arg ...string) { + mdb.CREATE: {Name: "create main=src/main.go@key zone name=hi help type=Hash,Zone,Lists,Data,Code list key", Help: "模块", Hand: func(m *ice.Message, arg ...string) { _defs(m, mdb.ZONE, m.Option(mdb.NAME), mdb.HELP, m.Option(mdb.NAME)) _defs(m, mdb.KEY, kit.Keys("web.code", m.Option(mdb.ZONE), m.Option(mdb.NAME))) switch m.Option(mdb.TYPE) { - case "Zone": - _defs(m, "list", m.Option(mdb.NAME)+" zone id auto insert") case "Hash": _defs(m, "list", m.Option(mdb.NAME)+" hash auto create") + case "Zone": + _defs(m, "list", m.Option(mdb.NAME)+" zone id auto insert") + case "Lists": + _defs(m, "list", m.Option(mdb.NAME)+" id auto insert") case "Data": - _defs(m, "list", m.Option(mdb.NAME)+" path auto upload") + _defs(m, "list", m.Option(mdb.NAME)+" path auto") + case "Code": + _defs(m, "list", m.Option(mdb.NAME)+" port path auto start order build download") } m.Option("tags", kit.Format("`name:\"%s\" help:\"%s\"`", m.Option("list"), m.Option("help"))) diff --git a/core/code/binpack.go b/core/code/binpack.go index b4f57b0c..ad5e0753 100644 --- a/core/code/binpack.go +++ b/core/code/binpack.go @@ -100,7 +100,7 @@ func init() { } if b, ok := ice.Info.Pack[name]; ok { - m.Logs("binpack", len(b), name) + m.Logs(BINPACK, len(b), name) return b // 打包文件 } return nil diff --git a/core/code/case.go b/core/code/case.go index 2bac4238..bd8aea53 100644 --- a/core/code/case.go +++ b/core/code/case.go @@ -62,7 +62,7 @@ func init() { m.Echo(kit.Formats(kit.UnMarshal(m.Cmdx(web.SPIDE, m.Option(ice.DEV), web.SPIDE_RAW, m.Option(ice.CMD), m.Option(cli.API), web.SPIDE_DATA, m.Option(ice.ARG))))) m.Info(`curl "` + m.Option(cli.API) + `" -H "Content-Type: application/json"` + ` -d '` + m.Option(ice.ARG) + `'`) - m.ProcessDisplay("/plugin/local/wiki/json.js") + m.ProcessDisplay("/plugin/story/json.js") }}, }, mdb.ZoneAction()), Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) { if len(arg) == 0 { diff --git a/core/code/code.go b/core/code/code.go index e2deb300..447e6078 100644 --- a/core/code/code.go +++ b/core/code/code.go @@ -11,8 +11,8 @@ var Index = &ice.Context{Name: CODE, Help: "编程中心"} func init() { web.Index.Register(Index, &web.Frame{}, - AUTOGEN, WEBPACK, BINPACK, COMPILE, PUBLISH, UPGRADE, INSTALL, - VIMER, INNER, FAVOR, BENCH, PPROF, + WEBPACK, BINPACK, AUTOGEN, COMPILE, PUBLISH, UPGRADE, INSTALL, + INNER, VIMER, FAVOR, BENCH, PPROF, C, SH, SHY, GO, JS, ) } diff --git a/core/code/code.shy b/core/code/code.shy index b154c21a..4eb52036 100644 --- a/core/code/code.shy +++ b/core/code/code.shy @@ -1,48 +1,28 @@ chapter "源码" -field "前端" web.code.webpack -field "后端" web.code.binpack -field "生成" web.code.autogen -field "编译" web.code.compile -field "升级" web.code.upgrade -field "发布" web.code.publish -field "安装" web.code.install - -field "编辑" web.code.vimer -field "查看" web.code.inner -field "收藏" web.code.favor -field "测试" web.code.bench -field "优化" web.code.pprof - -field "系统" web.code.c -field "命令" web.code.sh -field "脚本" web.code.shy -field "后端" web.code.go -field "前端" web.code.js - -code.go -code.shy - -autogen.go webpack.go binpack.go +autogen.go compile.go publish.go upgrade.go install.go -vimer.go inner.go +vimer.go favor.go bench.go pprof.go c.go +js.go +go.go sh.go shy.go -go.go -js.go python.go python.shy case.go +code.go +code.shy + diff --git a/core/code/compile.go b/core/code/compile.go index eed7b975..a2acc090 100644 --- a/core/code/compile.go +++ b/core/code/compile.go @@ -24,7 +24,7 @@ func init() { ), GO, kit.List(GO, cli.BUILD), )}, }, Commands: map[string]*ice.Command{ - COMPILE: {Name: "compile arch=amd64,386,arm os=linux,darwin,windows src=src/main.go@key run:button", Help: "编译", Action: map[string]*ice.Action{ + COMPILE: {Name: "compile arch=amd64,386,arm,arm64 os=linux,darwin,windows src=src/main.go@key run:button", Help: "编译", Action: map[string]*ice.Action{ mdb.INPUTS: {Name: "inputs", Help: "补全", Hand: func(m *ice.Message, arg ...string) { m.Cmdy(nfs.DIR, ice.SRC, "path,size,time", ice.Option{nfs.DIR_REG, `.*\.go$`}) m.Sort(nfs.PATH) diff --git a/core/code/favor.go b/core/code/favor.go index f0c6b608..9df06afb 100644 --- a/core/code/favor.go +++ b/core/code/favor.go @@ -10,9 +10,7 @@ const FAVOR = "favor" func init() { Index.Merge(&ice.Context{Configs: map[string]*ice.Config{ - FAVOR: {Name: FAVOR, Help: "收藏夹", Value: kit.Data( - mdb.SHORT, mdb.ZONE, mdb.FIELD, "time,id,type,name,text,path,file,line", - )}, + FAVOR: {Name: FAVOR, Help: "收藏夹", Value: kit.Data(mdb.SHORT, mdb.ZONE, mdb.FIELD, "time,id,type,name,text,path,file,line")}, }, Commands: map[string]*ice.Command{ FAVOR: {Name: "favor zone id auto insert", Help: "收藏夹", Action: ice.MergeAction(map[string]*ice.Action{ mdb.INSERT: {Name: "insert zone=数据结构 type=go name=hi text=hello path file line", Help: "添加"}, diff --git a/core/code/inner.go b/core/code/inner.go index b6a22811..a712cc50 100644 --- a/core/code/inner.go +++ b/core/code/inner.go @@ -73,7 +73,7 @@ const INNER = "inner" func init() { Index.Merge(&ice.Context{Commands: map[string]*ice.Command{ INNER: {Name: "inner path=src/ file=main.go line=1 auto", Help: "源代码", Meta: kit.Dict( - ice.Display("/plugin/local/code/inner.js"), + ice.DisplayLocal(""), ), Action: ice.MergeAction(map[string]*ice.Action{ mdb.PLUGIN: {Name: "plugin", Help: "插件", Hand: func(m *ice.Message, arg ...string) { if m.Cmdy(mdb.PLUGIN, arg); m.Result() == "" { diff --git a/core/code/install.go b/core/code/install.go index a16ddd09..05337d19 100644 --- a/core/code/install.go +++ b/core/code/install.go @@ -153,9 +153,7 @@ const INSTALL = "install" func init() { Index.Merge(&ice.Context{Configs: map[string]*ice.Config{ - INSTALL: {Name: INSTALL, Help: "安装", Value: kit.Data( - mdb.SHORT, mdb.NAME, nfs.PATH, ice.USR_INSTALL, - )}, + INSTALL: {Name: INSTALL, Help: "安装", Value: kit.Data(mdb.SHORT, mdb.NAME, nfs.PATH, ice.USR_INSTALL)}, }, Commands: map[string]*ice.Command{ INSTALL: {Name: "install name port path auto download", Help: "安装", Meta: kit.Dict(), Action: map[string]*ice.Action{ web.DOWNLOAD: {Name: "download link path", Help: "下载", Hand: func(m *ice.Message, arg ...string) { diff --git a/core/code/publish.go b/core/code/publish.go index a293a1c2..7dcb3a5e 100644 --- a/core/code/publish.go +++ b/core/code/publish.go @@ -62,7 +62,7 @@ func init() { Index.Merge(&ice.Context{Configs: map[string]*ice.Config{ PUBLISH: {Name: PUBLISH, Help: "发布", Value: kit.Data( nfs.PATH, ice.USR_PUBLISH, ice.CONTEXTS, _contexts, - SH, `#!/bin/bash + SH, `#! /bin/sh echo "hello world" `, JS, `Volcanos("onengine", {}) diff --git a/core/code/vimer.go b/core/code/vimer.go index 6e0e3ba1..2df88519 100644 --- a/core/code/vimer.go +++ b/core/code/vimer.go @@ -15,7 +15,7 @@ const VIMER = "vimer" func init() { Index.Merge(&ice.Context{Commands: map[string]*ice.Command{ VIMER: {Name: "vimer path=src/ file=main.go line=1 refresh:button=auto save", Help: "编辑器", Meta: kit.Dict( - ice.Display("/plugin/local/code/vimer.js", INNER), + ice.DisplayLocal("", INNER), ), Action: map[string]*ice.Action{ nfs.SAVE: {Name: "save type file path", Help: "保存", Hand: func(m *ice.Message, arg ...string) { m.Cmdy(nfs.SAVE, path.Join(m.Option(nfs.PATH), m.Option(nfs.FILE))) diff --git a/core/wiki/brief.go b/core/wiki/brief.go index 8e87b88c..9fb0f7fb 100644 --- a/core/wiki/brief.go +++ b/core/wiki/brief.go @@ -14,8 +14,6 @@ func init() { _wiki_template(m, cmd, "", arg[0], arg[1:]...) }}, }, Configs: map[string]*ice.Config{ - BRIEF: {Name: BRIEF, Help: "摘要", Value: kit.Data( - nfs.TEMPLATE, `
{{.Option "text"}}
`, - )}, + BRIEF: {Name: BRIEF, Help: "摘要", Value: kit.Data(nfs.TEMPLATE, `{{.Option "text"}}
`)}, }}) } diff --git a/core/wiki/data.go b/core/wiki/data.go index 3f51a37d..82909e73 100644 --- a/core/wiki/data.go +++ b/core/wiki/data.go @@ -2,6 +2,7 @@ package wiki import ( ice "shylinux.com/x/icebergs" + "shylinux.com/x/icebergs/base/lex" "shylinux.com/x/icebergs/base/nfs" kit "shylinux.com/x/toolkits" ) @@ -10,13 +11,9 @@ const DATA = "data" func init() { Index.Merge(&ice.Context{Configs: map[string]*ice.Config{ - DATA: {Name: DATA, Help: "数据表格", Value: kit.Data( - nfs.PATH, ice.USR_LOCAL_EXPORT, REGEXP, ".*\\.csv", - )}, + DATA: {Name: DATA, Help: "数据表格", Value: kit.Data(nfs.PATH, ice.USR_LOCAL_EXPORT, lex.REGEXP, ".*\\.csv")}, }, Commands: map[string]*ice.Command{ - DATA: {Name: "data path auto", Help: "数据表格", Meta: kit.Dict( - ice.Display("/plugin/local/wiki/data.js"), - ), Action: map[string]*ice.Action{ + DATA: {Name: "data path auto", Help: "数据表格", Meta: kit.Dict(ice.DisplayLocal("")), Action: map[string]*ice.Action{ nfs.SAVE: {Name: "save path text", Help: "保存", Hand: func(m *ice.Message, arg ...string) { _wiki_save(m, m.CommandKey(), arg[0], arg[1]) }}, diff --git a/core/wiki/draw.go b/core/wiki/draw.go index 91d69fd0..ad22046f 100644 --- a/core/wiki/draw.go +++ b/core/wiki/draw.go @@ -3,6 +3,7 @@ package wiki import ( ice "shylinux.com/x/icebergs" "shylinux.com/x/icebergs/base/ctx" + "shylinux.com/x/icebergs/base/lex" "shylinux.com/x/icebergs/base/nfs" kit "shylinux.com/x/toolkits" ) @@ -11,11 +12,9 @@ const DRAW = "draw" func init() { Index.Merge(&ice.Context{Configs: map[string]*ice.Config{ - DRAW: {Name: DRAW, Help: "思维导图", Value: kit.Data(REGEXP, ".*\\.svg")}, + DRAW: {Name: DRAW, Help: "思维导图", Value: kit.Data(lex.REGEXP, ".*\\.svg")}, }, Commands: map[string]*ice.Command{ - DRAW: {Name: "draw path=src/main.svg pid refresh:button=auto edit save actions", Help: "思维导图", Meta: kit.Dict( - ice.DisplayLocal(""), - ), Action: ice.MergeAction(map[string]*ice.Action{ + DRAW: {Name: "draw path=src/main.svg pid refresh:button=auto edit save actions", Help: "思维导图", Meta: kit.Dict(ice.DisplayLocal("")), Action: ice.MergeAction(map[string]*ice.Action{ nfs.SAVE: {Name: "save", Help: "保存", Hand: func(m *ice.Message, arg ...string) { _wiki_save(m, DRAW, arg[0], m.Option("content")) }}, diff --git a/core/wiki/feel.go b/core/wiki/feel.go index 71515193..5edc8819 100644 --- a/core/wiki/feel.go +++ b/core/wiki/feel.go @@ -5,6 +5,7 @@ import ( "strings" ice "shylinux.com/x/icebergs" + "shylinux.com/x/icebergs/base/lex" "shylinux.com/x/icebergs/base/mdb" "shylinux.com/x/icebergs/base/nfs" "shylinux.com/x/icebergs/base/web" @@ -15,18 +16,14 @@ const FEEL = "feel" func init() { Index.Merge(&ice.Context{Configs: map[string]*ice.Config{ - FEEL: {Name: FEEL, Help: "影音媒体", Value: kit.Data( - nfs.PATH, ice.USR_LOCAL_IMAGE, REGEXP, ".*.(png|PNG|jpg|JPG|jpeg|mp4|m4v|MOV)", - )}, + FEEL: {Name: FEEL, Help: "影音媒体", Value: kit.Data(nfs.PATH, ice.USR_LOCAL_IMAGE, lex.REGEXP, ".*.(png|PNG|jpg|JPG|jpeg|mp4|m4v|MOV)")}, }, Commands: map[string]*ice.Command{ - FEEL: {Name: "feel path auto upload 上一页 下一页 actions", Help: "影音媒体", Meta: kit.Dict( - ice.Display("/plugin/local/wiki/feel.js"), - ), Action: map[string]*ice.Action{ + FEEL: {Name: "feel path auto upload 上一页 下一页 actions", Help: "影音媒体", Meta: kit.Dict(ice.DisplayLocal("")), Action: map[string]*ice.Action{ web.UPLOAD: {Name: "upload", Help: "上传", Hand: func(m *ice.Message, arg ...string) { _wiki_upload(m, m.CommandKey(), m.Option(nfs.PATH)) }}, mdb.REMOVE: {Name: "remove", Help: "删除", Hand: func(m *ice.Message, arg ...string) { - os.Remove(strings.TrimPrefix(arg[0], "/share/local/")) + os.Remove(strings.TrimPrefix(arg[0], web.SHARE_LOCAL)) }}, }, Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) { _wiki_list(m, m.CommandKey(), kit.Select(ice.PWD, arg, 0)) diff --git a/core/wiki/field.go b/core/wiki/field.go index 1fff11dd..0266acd3 100644 --- a/core/wiki/field.go +++ b/core/wiki/field.go @@ -15,7 +15,7 @@ func Parse(m *ice.Message, meta string, key string, arg ...string) *ice.Message for _, line := range kit.Split(strings.Join(arg, ice.SP), ice.NL) { ls := kit.Split(line) for i := 0; i < len(ls); i++ { - if strings.HasPrefix(ls[i], "#") { + if strings.HasPrefix(ls[i], "# ") { ls = ls[:i] break } @@ -41,8 +41,7 @@ func _field_show(m *ice.Message, name, text string, arg ...string) { }) name = strings.ReplaceAll(name, ice.SP, "_") - meta[mdb.NAME] = name - meta[mdb.INDEX] = text + meta[mdb.NAME], meta[mdb.INDEX] = name, text // 扩展参数 for i := 0; i < len(arg)-1; i += 2 { @@ -77,9 +76,7 @@ func _field_show(m *ice.Message, name, text string, arg ...string) { if len(args) > count { list := meta[INPUTS].([]interface{}) for i := count; i < len(args); i++ { - list = append(list, kit.Dict( - mdb.TYPE, "text", mdb.NAME, "args", mdb.VALUE, args[i], - )) + list = append(list, kit.Dict(mdb.TYPE, "text", mdb.NAME, ARGS, mdb.VALUE, args[i])) } meta[INPUTS] = list } diff --git a/core/wiki/json.go b/core/wiki/json.go deleted file mode 100644 index 5ba271b7..00000000 --- a/core/wiki/json.go +++ /dev/null @@ -1,78 +0,0 @@ -package wiki - -import ( - "encoding/json" - - ice "shylinux.com/x/icebergs" - "shylinux.com/x/icebergs/base/nfs" - kit "shylinux.com/x/toolkits" -) - -func _json_show(m *ice.Message, data interface{}) { - switch data := data.(type) { - case map[string]interface{}: - i := 0 - if m.Echo(`{`); len(data) > 0 { - m.Echo(`...`) - } - m.Echo(`