diff --git a/base/base.shy b/base/base.shy deleted file mode 100644 index ed35653e..00000000 --- a/base/base.shy +++ /dev/null @@ -1,5 +0,0 @@ -label ` -ctx mdb web aaa -lex yac ssh gdb -tcp nfs cli log -` \ No newline at end of file diff --git a/base/ctx/command.go b/base/ctx/command.go index 436dc585..d20e40e1 100644 --- a/base/ctx/command.go +++ b/base/ctx/command.go @@ -115,7 +115,7 @@ func Command(m *ice.Message, arg ...string) { kit.If(!PodCmd(m, COMMAND, arg), func() { m.Cmdy(COMMAND, arg) }) } func CmdAction(args ...ice.Any) ice.Actions { - return ice.Actions{ice.CTX_INIT: mdb.AutoConfig(args...), ice.RUN: {Hand: Run}, COMMAND: {Hand: Command}} + return ice.Actions{ice.CTX_INIT: mdb.AutoConfig(args...), RUN: {Hand: Run}, COMMAND: {Hand: Command}} } func CmdHandler(args ...ice.Any) ice.Handler { return func(m *ice.Message, arg ...string) { m.Cmdy(args...) } @@ -123,7 +123,7 @@ func CmdHandler(args ...ice.Any) ice.Handler { func CmdList(m *ice.Message) *ice.Message { return m.Cmdy(COMMAND, mdb.SEARCH, COMMAND, ice.OptionFields(INDEX)) } -func CmdInputs(m *ice.Message, arg ...string) { +func CmdInputs(m *ice.Message, arg ...string) *ice.Message { switch arg[0] { case INDEX: m.Cmdy(COMMAND, mdb.SEARCH, COMMAND, ice.OptionFields(INDEX)) @@ -132,6 +132,7 @@ func CmdInputs(m *ice.Message, arg ...string) { m.Cmdy(m.Option(INDEX)) } } + return m } func IsOrderCmd(key string) bool { return key[0] == '/' || key[0] == '_' } diff --git a/base/ctx/process.go b/base/ctx/process.go index d34589a4..8a86c698 100644 --- a/base/ctx/process.go +++ b/base/ctx/process.go @@ -47,13 +47,13 @@ func Process(m *ice.Message, key string, args ice.Any, arg ...string) { } } func ProcessField(m *ice.Message, cmd string, args ice.Any, arg ...string) *ice.Message { - if cmd = kit.Select(m.ActionKey(), cmd); !kit.HasPrefixList(arg, ice.RUN) { + if cmd = kit.Select(m.ActionKey(), cmd); !kit.HasPrefixList(arg, RUN) { if PodCmd(m, COMMAND, cmd) { m.Push(ice.SPACE, m.Option(ice.MSG_USERPOD)) } else { m.Cmdy(COMMAND, cmd) } - m.Push(ARGS, kit.Format(_process_args(m, args))).Options(ice.MSG_INDEX, m.PrefixKey()).ProcessField(ACTION, m.ActionKey(), ice.RUN) + m.Push(ARGS, kit.Format(_process_args(m, args))).Options(ice.MSG_INDEX, m.PrefixKey()).ProcessField(ACTION, m.ActionKey(), RUN) } else { if !PodCmd(m, cmd, arg[1:]) { kit.If(aaa.Right(m, cmd, arg[1:]), func() { m.Cmdy(cmd, arg[1:]) }) @@ -62,8 +62,8 @@ func ProcessField(m *ice.Message, cmd string, args ice.Any, arg ...string) *ice. return m } func ProcessCommand(m *ice.Message, cmd string, args []string, arg ...string) { - if !kit.HasPrefixList(arg, ice.RUN) { - m.Cmdy(COMMAND, cmd).Push(ice.ARG, kit.Format(args)).ProcessField(cmd, ice.RUN) + if !kit.HasPrefixList(arg, RUN) { + m.Cmdy(COMMAND, cmd).Push(ice.ARG, kit.Format(args)).ProcessField(cmd, RUN) } else { m.Cmdy(cmd, arg[1:]) } diff --git a/base/web/dream.go b/base/web/dream.go index 0d30fac1..203f9b31 100644 --- a/base/web/dream.go +++ b/base/web/dream.go @@ -306,13 +306,13 @@ func DreamAction() ice.Actions { }, gdb.EventsAction(DREAM_OPEN, DREAM_CLOSE, DREAM_INPUTS, DREAM_CREATE, DREAM_TABLES, DREAM_ACTION)) } func DreamProcess(m *ice.Message, args ice.Any, arg ...string) { - if kit.HasPrefixList(arg, ice.RUN) { + if kit.HasPrefixList(arg, ctx.RUN) { ctx.ProcessField(m, m.PrefixKey(), args, kit.Slice(arg, 1)...) } else if kit.HasPrefixList(arg, ctx.ACTION, m.PrefixKey()) || kit.HasPrefixList(arg, ctx.ACTION, m.CommandKey()) { if arg = kit.Slice(arg, 2); kit.HasPrefixList(arg, DREAM) { - m.Cmdy(SPACE, m.Option(ice.MSG_USERPOD, arg[1]), m.PrefixKey(), ctx.ACTION, DREAM_ACTION, ice.RUN, arg[2:]) + m.Cmdy(SPACE, m.Option(ice.MSG_USERPOD, arg[1]), m.PrefixKey(), ctx.ACTION, DREAM_ACTION, ctx.RUN, arg[2:]) } else if dream := m.Option(mdb.NAME); dream != "" { - m.Cmdy(SPACE, dream, m.PrefixKey(), ctx.ACTION, DREAM_ACTION, ice.RUN, arg).Optionv(ice.FIELD_PREFIX, kit.Simple(ctx.ACTION, m.PrefixKey(), DREAM, dream, ice.RUN)) + m.Cmdy(SPACE, dream, m.PrefixKey(), ctx.ACTION, DREAM_ACTION, ctx.RUN, arg).Optionv(ice.FIELD_PREFIX, kit.Simple(ctx.ACTION, m.PrefixKey(), DREAM, dream, ctx.RUN)) m.Push("_space", dream) } } diff --git a/base/web/render.go b/base/web/render.go index 37ba2b8d..1f13a7be 100644 --- a/base/web/render.go +++ b/base/web/render.go @@ -163,9 +163,11 @@ const ( CODE_VIMER = "web.code.vimer" CODE_INNER = "web.code.inner" CODE_XTERM = "web.code.xterm" - WIKI_WORD = "web.wiki.word" - WIKI_DRAW = "web.wiki.draw" WIKI_FEEL = "web.wiki.feel" + WIKI_DRAW = "web.wiki.draw" + WIKI_WORD = "web.wiki.word" + WIKI_PORTAL = "web.wiki.portal" + CHAT_PORTAL = "web.chat.portal" CHAT_HEADER = "web.chat.header" CHAT_IFRAME = "web.chat.iframe" CHAT_FAVOR = "web.chat.favor" diff --git a/base/web/serve.go b/base/web/serve.go index 6446ea09..aace6a6b 100644 --- a/base/web/serve.go +++ b/base/web/serve.go @@ -105,7 +105,7 @@ func _serve_handle(key string, cmd *ice.Command, m *ice.Message, w http.Response kit.For(r.PostForm, func(k string, v []string) { _log(FORM, k, kit.Join(v, lex.SP)).Optionv(k, v) }) } kit.For(r.Cookies(), func(k, v string) { m.Optionv(k, v) }) - m.Options(ice.MSG_COUNT, "0") + m.Options(ice.MSG_METHOD, r.Method, ice.MSG_COUNT, "0") m.Options(ice.MSG_USERWEB, _serve_domain(m), ice.MSG_USERPOD, m.Option(ice.POD)) m.Options(ice.MSG_USERUA, r.Header.Get(UserAgent), ice.MSG_USERIP, r.Header.Get(ice.MSG_USERIP)) m.Options(ice.MSG_SESSID, kit.Select(m.Option(ice.MSG_SESSID), m.Option(CookieName(m.Option(ice.MSG_USERWEB))))) diff --git a/conf.go b/conf.go index e73f5d60..e6b8ccdf 100644 --- a/conf.go +++ b/conf.go @@ -24,6 +24,7 @@ const ( HTTPS = "https" HTTP = "http" + HELP = "help" MAIN = "main" AUTO = "auto" LIST = "list" @@ -177,6 +178,7 @@ const ( // MSG MSG_CMDS = "cmds" MSG_FIELDS = "fields" MSG_SESSID = "sessid" + MSG_METHOD = "method" MSG_DETAIL = "detail" MSG_OPTION = "option" diff --git a/core/chat/action.go b/core/chat/action.go index 76c0efe8..102860df 100644 --- a/core/chat/action.go +++ b/core/chat/action.go @@ -47,8 +47,7 @@ func _action_share(m *ice.Message, arg ...string) { switch msg := _action_auth(m, arg[0]); msg.Append(mdb.TYPE) { case web.STORM: if len(arg) == 1 { - m.Push(TITLE, msg.Append(TITLE)) - m.Push(THEME, msg.Append(THEME)) + m.Push(TITLE, msg.Append(TITLE)).Push(THEME, msg.Append(THEME)) _action_list(m, msg.Append(web.RIVER), msg.Append(web.STORM)) break } @@ -56,42 +55,36 @@ func _action_share(m *ice.Message, arg ...string) { case web.FIELD: m.Option(ice.MSG_USERPOD, kit.Keys(m.Option(ice.MSG_USERPOD), msg.Append(ice.POD))) if len(arg) == 1 { - m.Push(TITLE, msg.Append(TITLE)) - m.Push(THEME, msg.Append(THEME)) - m.Push(ctx.ARGS, msg.Append(mdb.TEXT)) + m.Push(TITLE, msg.Append(TITLE)).Push(THEME, msg.Append(THEME)) m.Cmdy(web.Space(m, msg.Append(ice.POD)), ctx.COMMAND, msg.Append(mdb.NAME)) + m.Push(ctx.ARGS, msg.Append(mdb.TEXT)) break } m.Cmdy(web.Space(m, msg.Append(ice.POD)), msg.Append(mdb.NAME), arg[2:]) } } -const ( - THEME = "theme" -) const ACTION = "action" func init() { Index.MergeCommands(ice.Commands{ - ACTION: {Name: "action", Help: "工作台", Actions: ice.MergeActions(ice.Actions{ + ACTION: {Actions: ice.MergeActions(ice.Actions{ mdb.MODIFY: {Hand: func(m *ice.Message, arg ...string) { m.Cmdy(mdb.MODIFY, RIVER, _storm_key(m), mdb.LIST, m.OptionSimple(mdb.ID), arg) }}, web.SHARE: {Hand: func(m *ice.Message, arg ...string) { _action_share(m, arg...) }}, - "/": {Hand: func(m *ice.Message, arg ...string) { - if m.Warn(m.Option(ice.MSG_USERNAME) == "", ice.ErrNotLogin, arg) { - return - } - if m.Option(ice.MSG_USERPOD) == "" && m.Warn(!_river_right(m, arg[0]), ice.ErrNotRight, arg) { - return - } - if len(arg) == 2 { - ctx.OptionFromConfig(m, MENUS) - _action_list(m, arg[0], arg[1]) - } else { - _action_exec(m, arg[0], arg[1], arg[2], arg[3:]...) - } - }}, - }, ctx.CmdAction(), aaa.WhiteAction(web.SHARE, ctx.COMMAND, ice.RUN))}, + }, web.ApiAction(), aaa.WhiteAction(web.SHARE, ctx.RUN, ctx.COMMAND), ctx.CmdAction()), Hand: func(m *ice.Message, arg ...string) { + if m.Warn(m.Option(ice.MSG_USERNAME) == "", ice.ErrNotLogin, arg) { + return + } else if m.Warn(!_river_right(m, arg[0]), ice.ErrNotRight, arg) { + return + } + if len(arg) == 2 { + ctx.OptionFromConfig(m, MENUS) + _action_list(m, arg[0], arg[1]) + } else { + _action_exec(m, arg[0], arg[1], arg[2], arg[3:]...) + } + }}, }) } diff --git a/core/chat/chat.shy b/core/chat/chat.shy index 59f45822..dd77739f 100644 --- a/core/chat/chat.shy +++ b/core/chat/chat.shy @@ -1,21 +1,27 @@ -header.go -action.go -footer.go -search.go -river.go -storm.go -favor.go -grant.go -sso.go -pod.go -cmd.go chat.go chat.shy - -trans.go +header.go +footer.go +river.go +storm.go +action.go +search.go +portal.go iframe.go +icons.go + +pod.go +cmd.go +sso.go +grant.go +oauth + +macos +trans.go +favor.go +flows.go +flows.js +flows.css keyboard.go location.go location.shy -template.go -oauth diff --git a/core/chat/cmd.go b/core/chat/cmd.go index a9a5fc63..b78d13f1 100644 --- a/core/chat/cmd.go +++ b/core/chat/cmd.go @@ -1,55 +1,24 @@ package chat import ( - "path" - "strings" - ice "shylinux.com/x/icebergs" "shylinux.com/x/icebergs/base/aaa" "shylinux.com/x/icebergs/base/ctx" - "shylinux.com/x/icebergs/base/mdb" - "shylinux.com/x/icebergs/base/nfs" "shylinux.com/x/icebergs/base/web" - kit "shylinux.com/x/toolkits" ) -func _cmd_file(m *ice.Message, arg ...string) bool { - switch p := path.Join(arg...); kit.Ext(p) { - // case nfs.SHY: - // web.RenderCmd(m, "web.wiki.word", p) - case nfs.GO: - web.RenderCmd(m, ctx.GetFileCmd(p)) - case nfs.JS: - ctx.DisplayBase(m, ctx.FileURI(p)) - web.RenderCmd(m, kit.Select(ice.CAN_PLUGIN, ctx.GetFileCmd(p))) - default: - if p = strings.TrimPrefix(p, ice.SRC+nfs.PS); nfs.Exists(m, path.Join(ice.SRC, p)) { - if msg := m.Cmd(mdb.ENGINE, kit.Ext(p)); msg.Length() > 0 { - m.Cmdy(mdb.ENGINE, kit.Ext(p), p, ice.SRC+nfs.PS).RenderResult() - break - } - } - return false - } - return true -} - const CMD = "cmd" func init() { Index.MergeCommands(ice.Commands{ - CMD: {Name: "cmd path auto upload up home", Help: "命令", Actions: ice.MergeActions( - mdb.HashAction(mdb.SHORT, mdb.TYPE, nfs.PATH, nfs.PWD), ctx.CmdAction(), web.ApiAction(), aaa.WhiteAction(ice.RUN), - ), Hand: func(m *ice.Message, arg ...string) { - if _cmd_file(m, arg...) { - return - } else if len(arg[0]) == 0 || arg[0] == "" { - return + CMD: {Actions: ice.MergeActions(web.ApiAction(), aaa.WhiteAction(ctx.RUN), ctx.CmdAction()), Hand: func(m *ice.Message, arg ...string) { + if len(arg[0]) == 0 || arg[0] == "" { + web.RenderMain(m) } else if m.IsCliUA() { - m.Cmdy(arg, m.Optionv(ice.ARG)).RenderResult() - return - } - if arg[0] == "web.chat.portal" { + if aaa.Right(m, arg) { + m.Cmdy(arg, m.Optionv(ice.ARG)).RenderResult() + } + } else if arg[0] == web.CHAT_PORTAL { web.RenderMain(m) } else if m.Cmdy(ctx.COMMAND, arg[0]); m.Length() > 0 { web.RenderCmd(m, m.Append(ctx.INDEX), arg[1:]) diff --git a/core/chat/favor.go b/core/chat/favor.go index e8070173..49167f1e 100644 --- a/core/chat/favor.go +++ b/core/chat/favor.go @@ -35,11 +35,9 @@ const FAVOR = "favor" func init() { Index.MergeCommands(ice.Commands{ FAVOR: {Name: "favor hash auto create upload getClipboardData", Help: "收藏夹", Actions: ice.MergeActions(ice.Actions{ - ice.CTX_INIT: {Hand: func(m *ice.Message, arg ...string) { mdb.HashImport(m) }}, - ice.CTX_EXIT: {Hand: func(m *ice.Message, arg ...string) { mdb.HashExport(m) }}, mdb.SEARCH: {Hand: func(m *ice.Message, arg ...string) { - if arg[0] == mdb.FOREACH { - m.Cmd("", ice.OptionFields("")).Table(func(value ice.Maps) { + if mdb.IsSearchPreview(m, arg) { + m.Cmds("", func(value ice.Maps) { if arg[1] == "" || arg[1] == value[mdb.TYPE] || strings.Contains(value[mdb.TEXT], arg[1]) { m.PushSearch(value) } @@ -53,7 +51,7 @@ func init() { case mdb.NAME: switch m.Option(mdb.TYPE) { case ctx.INDEX: - m.Copy(m.Cmd(ctx.COMMAND, mdb.SEARCH, ctx.COMMAND, arg[1:], ice.OptionFields(ctx.INDEX)).RenameAppend(ctx.INDEX, arg[0])) + ctx.CmdInputs(m, m.Option(mdb.TYPE)).RenameAppend(ctx.INDEX, arg[0]) return } } @@ -74,7 +72,7 @@ func init() { m.Cmd("", mdb.CREATE, m.OptionSimple(mdb.TYPE, mdb.NAME, mdb.TEXT)) }}, web.DOWNLOAD: {Hand: func(m *ice.Message, arg ...string) { - m.ProcessOpen(web.MergeURL2(m, web.SHARE_LOCAL+m.Option(mdb.TEXT), "filename", m.Option(mdb.NAME))) + m.ProcessOpen(web.MergeURL2(m, web.SHARE_LOCAL+m.Option(mdb.TEXT), nfs.FILENAME, m.Option(mdb.NAME))) }}, ctx.DISPLAY: {Help: "预览", Hand: func(m *ice.Message, arg ...string) { if link := web.SHARE_LOCAL + m.Option(mdb.TEXT); _favor_is_image(m, m.Option(mdb.NAME), m.Option(mdb.TYPE)) { @@ -86,23 +84,23 @@ func init() { } m.ProcessInner() }}, - ctx.INDEX: {Help: "命令", Hand: func(m *ice.Message, arg ...string) { - msg := mdb.HashSelects(m.Spawn(), m.Option(mdb.HASH)) - ls := kit.Split(msg.Option(mdb.TEXT)) - ctx.ProcessField(m, ls[0], ls[1:], arg...) - }}, "vimer": {Help: "源码", Hand: func(m *ice.Message, arg ...string) { ctx.Process(m, "", nfs.SplitPath(m, m.Option(mdb.TEXT)), arg...) }}, "xterm": {Help: "命令", Hand: func(m *ice.Message, arg ...string) { ctx.Process(m, "", []string{mdb.TYPE, m.Option(mdb.TEXT), mdb.NAME, m.Option(mdb.NAME), mdb.TEXT, ""}, arg...) }}, - cli.OPENS: {Hand: func(m *ice.Message, arg ...string) { cli.Opens(m, m.Option(mdb.TEXT)) }}, - ice.RUN: {Hand: func(m *ice.Message, arg ...string) { + ctx.INDEX: {Help: "命令", Hand: func(m *ice.Message, arg ...string) { + msg := mdb.HashSelects(m.Spawn(), m.Option(mdb.HASH)) + ls := kit.Split(msg.Option(mdb.TEXT)) + ctx.ProcessField(m, ls[0], ls[1:], arg...) + }}, + ctx.RUN: {Hand: func(m *ice.Message, arg ...string) { m.Option(mdb.TYPE, mdb.HashSelects(m.Spawn(), m.Option(mdb.HASH)).Append(mdb.TYPE)) ctx.Run(m, arg...) }}, - }, ctx.CmdAction(), mdb.ImportantHashAction()), Hand: func(m *ice.Message, arg ...string) { + cli.OPENS: {Hand: func(m *ice.Message, arg ...string) { cli.Opens(m, m.Option(mdb.TEXT)) }}, + }, ctx.CmdAction(), mdb.ImportantHashAction(), mdb.ExportHashAction()), Hand: func(m *ice.Message, arg ...string) { if len(arg) > 0 && arg[0] == ctx.ACTION { m.Option(mdb.TYPE, mdb.HashSelects(m.Spawn(), m.Option(mdb.HASH)).Append(mdb.TYPE)) gdb.Event(m, FAVOR_ACTION, arg) diff --git a/core/chat/footer.go b/core/chat/footer.go index ceb691f5..28aef294 100644 --- a/core/chat/footer.go +++ b/core/chat/footer.go @@ -15,13 +15,9 @@ const FOOTER = "footer" func init() { Index.MergeCommands(ice.Commands{ - FOOTER: {Name: "footer", Help: "状态栏", Actions: ice.MergeActions(ice.Actions{ - ice.RUN: {Hand: func(m *ice.Message, arg ...string) { - if aaa.Right(m, arg) { - if m.Cmdy(arg); m.IsErrNotFound() { - m.RenderResult(m.Cmdx(cli.SYSTEM, arg)) - } - } + FOOTER: {Actions: ice.MergeActions(ice.Actions{ + ice.HELP: {Hand: func(m *ice.Message, arg ...string) { + ctx.ProcessField(m, web.WIKI_WORD, []string{ice.SRC_DOCUMENT + arg[0] + "/list.shy"}, arg...) }}, nfs.SCRIPT: {Hand: func(m *ice.Message, arg ...string) { ctx.ProcessField(m, web.CODE_VIMER, func() []string { @@ -34,12 +30,15 @@ func init() { ctx.CONFIG: {Hand: func(m *ice.Message, arg ...string) { ctx.ProcessField(m, ctx.CONFIG, arg, arg...) }}, - "help": {Hand: func(m *ice.Message, arg ...string) { - ctx.ProcessField(m, web.WIKI_WORD, []string{"src/document/" + arg[0] + "/list.shy"}, arg...) + ctx.RUN: {Hand: func(m *ice.Message, arg ...string) { + if aaa.Right(m, arg) { + if m.Cmdy(arg); m.IsErrNotFound() { + m.RenderResult(m.Cmdx(cli.SYSTEM, arg)) + } + } }}, - "/": {Hand: func(m *ice.Message, arg ...string) { - m.Result(kit.Select(mdb.Config(m, TITLE), ice.Info.Make.Email)) - }}, - }, ctx.CmdAction(), aaa.WhiteAction(ctx.COMMAND, ice.RUN))}, + }, web.ApiAction(), aaa.WhiteAction(ctx.RUN, ctx.COMMAND), ctx.CmdAction()), Hand: func(m *ice.Message, arg ...string) { + m.Result(kit.Select(ice.Info.Make.Email, mdb.Config(m, TITLE))) + }}, }) } diff --git a/core/chat/header.go b/core/chat/header.go index 66fd518b..01e845c5 100644 --- a/core/chat/header.go +++ b/core/chat/header.go @@ -1,8 +1,6 @@ package chat import ( - "path" - ice "shylinux.com/x/icebergs" "shylinux.com/x/icebergs/base/aaa" "shylinux.com/x/icebergs/base/cli" @@ -21,8 +19,9 @@ func _header_users(m *ice.Message, arg ...string) { return } else if m.Warn(m.Option(web.SHARE) != "", ice.ErrNotRight, "没有权限") { return + } else { + m.Cmdy(aaa.USER, mdb.MODIFY, aaa.USERNAME, m.Option(ice.MSG_USERNAME), m.ActionKey(), m.Option(m.ActionKey(), arg[0])) } - m.Cmdy(aaa.USER, mdb.MODIFY, aaa.USERNAME, m.Option(ice.MSG_USERNAME), m.ActionKey(), m.Option(m.ActionKey(), arg[0])) } func _header_share(m *ice.Message, arg ...string) { if m.Warn(m.Option(ice.MSG_USERNAME) == "", ice.ErrNotLogin, "没有登录") { @@ -35,7 +34,7 @@ func _header_share(m *ice.Message, arg ...string) { m.Push(mdb.NAME, m.Option(mdb.LINK)).PushQRCode(mdb.TEXT, m.Option(mdb.LINK)) } func _header_check(m *ice.Message, arg ...string) bool { - m.Option(ice.MAIN, mdb.Conf(m, "web.serve", kit.Keym(ice.MAIN))) + m.Option(ice.MAIN, mdb.Conf(m, web.SERVE, kit.Keym(ice.MAIN))) if m.Option(ice.CMD) == aaa.OFFER && m.Option(mdb.HASH) != "" { m.Cmd(aaa.OFFER, m.Option(mdb.HASH), func(value ice.Maps) { aaa.SessAuth(m, kit.Dict(aaa.USERNAME, value[aaa.EMAIL], aaa.USERROLE, aaa.VOID)) @@ -46,21 +45,22 @@ func _header_check(m *ice.Message, arg ...string) bool { return } switch value[mdb.TYPE] { - case web.STORM, web.FIELD: + case web.FIELD, web.STORM: aaa.SessAuth(m, kit.Dict(value)) } }) } if m.Option(ice.MSG_USERNAME) != "" { return true - } else if ctx.OptionFromConfig(m, SSO) == "" && ctx.OptionFromConfig(m, web.LOGIN) == "" { - m.Option(SSO, kit.Format(kit.Dict("serve.icon", "usr/icons/icebergs.jpg", "serve.url", GetSSO(m)))) + } else if ctx.OptionFromConfig(m, SSO) == "" { + m.Option(SSO, kit.Format(kit.Dict("serve.icon", nfs.USR_ICONS_ICEBERGS, "serve.url", GetSSO(m)))) } return false } const ( TITLE = "title" + THEME = "theme" MENUS = "menus" HEADER_AGENT = "header.agent" @@ -69,7 +69,7 @@ const HEADER = "header" func init() { Index.MergeCommands(ice.Commands{ - HEADER: {Name: "header", Help: "标题栏", Actions: ice.Actions{ + HEADER: {Actions: ice.MergeActions(ice.Actions{ ice.CTX_INIT: {Hand: func(m *ice.Message, arg ...string) { aaa.White(m, HEADER) }}, aaa.LOGIN: {Hand: func(m *ice.Message, arg ...string) {}}, aaa.LOGOUT: {Hand: aaa.SessLogout}, @@ -85,7 +85,7 @@ func init() { } }}, aaa.EMAIL: {Name: "email to subject content", Hand: func(m *ice.Message, arg ...string) { - if m.Option("to") != aaa.UserEmail(m, "") && !aaa.Right(m, aaa.EMAIL, m.Option("to")) { + if m.Option(nfs.TO) != aaa.UserEmail(m, "") && !aaa.Right(m, aaa.EMAIL, m.Option(nfs.TO)) { return } m.Options("volcano", web.UserHost(m), nfs.VERSION, web.RenderVersion(m)) @@ -93,22 +93,20 @@ func init() { m.Cmdy(aaa.EMAIL, aaa.SEND, arg, aaa.CONTENT, nfs.Template(m, "email.html")) }}, web.SHARE: {Hand: _header_share}, - "webpack": {Hand: ctx.CmdHandler("webpack", "build")}, - "/": {Hand: func(m *ice.Message, arg ...string) { - m.Option("language.list", m.Cmd(nfs.DIR, path.Join(ice.SRC_TEMPLATE, m.PrefixKey(), aaa.LANGUAGE), nfs.FILE).Appendv(nfs.FILE)) - m.Option("theme.list", m.Cmd(nfs.DIR, path.Join(ice.SRC_TEMPLATE, m.PrefixKey(), aaa.THEME), nfs.FILE).Appendv(nfs.FILE)) - m.Option(ICONS, mdb.Conf(m, "web.chat.icons", kit.Keym(nfs.PATH))) - m.Option(nfs.REPOS, m.Cmdv(web.SPIDE, ice.HUB, web.CLIENT_URL)) - if gdb.Event(m, HEADER_AGENT); !_header_check(m, arg...) { - return - } - msg := m.Cmd(aaa.USER, m.Option(ice.MSG_USERNAME)) - kit.For([]string{aaa.USERNICK, aaa.LANGUAGE, aaa.EMAIL}, func(k string) { m.Option(k, msg.Append(k)) }) - kit.For([]string{aaa.AVATAR, aaa.BACKGROUND}, func(k string) { m.Option(k, web.RequireFile(m, msg.Append(k))) }) - kit.If(m.Option(aaa.LANGUAGE) == "", func() { m.Option(aaa.LANGUAGE, kit.Split(m.R.Header.Get(web.AcceptLanguage), ",;")[0]) }) - m.Option(MENUS, mdb.Config(m, MENUS)) - m.Echo(mdb.Config(m, TITLE)) - }}, + }, web.ApiAction()), Hand: func(m *ice.Message, arg ...string) { + m.Option("language.list", m.Cmd(nfs.DIR, nfs.TemplatePath(m, aaa.LANGUAGE)+nfs.PS, nfs.FILE).Appendv(nfs.FILE)) + m.Option("theme.list", m.Cmd(nfs.DIR, nfs.TemplatePath(m, aaa.THEME)+nfs.PS, nfs.FILE).Appendv(nfs.FILE)) + m.Option(nfs.REPOS, m.Cmdv(web.SPIDE, nfs.REPOS, web.CLIENT_URL)) + m.Option(ICONS, mdb.Conf(m, ICONS, kit.Keym(nfs.PATH))) + m.Option(MENUS, mdb.Config(m, MENUS)) + m.Echo(mdb.Config(m, TITLE)) + if gdb.Event(m, HEADER_AGENT); !_header_check(m, arg...) { + return + } + msg := m.Cmd(aaa.USER, m.Option(ice.MSG_USERNAME)) + kit.For([]string{aaa.USERNICK, aaa.LANGUAGE, aaa.EMAIL}, func(k string) { m.Option(k, msg.Append(k)) }) + kit.For([]string{aaa.AVATAR, aaa.BACKGROUND}, func(k string) { m.Option(k, web.RequireFile(m, msg.Append(k))) }) + kit.If(m.Option(aaa.LANGUAGE) == "", func() { m.Option(aaa.LANGUAGE, kit.Split(m.R.Header.Get(web.AcceptLanguage), ",;")[0]) }) }}, }) } diff --git a/core/chat/icons.go b/core/chat/icons.go index 51187abc..a5daff8c 100644 --- a/core/chat/icons.go +++ b/core/chat/icons.go @@ -18,7 +18,7 @@ func init() { ICONS: {Actions: ctx.ConfAction(nfs.PATH, "bootstrap-icons/font/bootstrap-icons.css"), Hand: func(m *ice.Message, arg ...string) { m.Cmd(lex.SPLIT, ice.USR_MODULES+mdb.Config(m, nfs.PATH), kit.Dict(lex.SPLIT_SPACE, " {:;}"), func(text string, ls []string) { if len(ls) > 2 && ls[2] == nfs.CONTENT { - name := "bi " + strings.TrimPrefix(ls[0], ".") + name := "bi " + strings.TrimPrefix(ls[0], nfs.PT) m.Push(mdb.NAME, name).Push(mdb.ICON, kit.Format(``, name)) } }) diff --git a/core/chat/iframe.go b/core/chat/iframe.go index 1930e510..20658a94 100644 --- a/core/chat/iframe.go +++ b/core/chat/iframe.go @@ -14,19 +14,7 @@ const IFRAME = "iframe" func init() { Index.MergeCommands(ice.Commands{ - IFRAME: {Name: "iframe hash@key auto safari", Icon: "usr/icons/Safari.png", Help: "浏览器", Actions: ice.MergeActions(ice.Actions{ - ice.CTX_INIT: {Hand: func(m *ice.Message, arg ...string) { - if m.Cmd("").Length() == 0 { - m.Cmd(web.SPIDE, ice.OptionFields(web.CLIENT_NAME, web.CLIENT_ORIGIN), func(value ice.Maps) { - if kit.IsIn(value[web.CLIENT_NAME], "ops", "dev", "com", "shy") { - m.Cmd("", mdb.CREATE, kit.Dict(mdb.NAME, value[web.CLIENT_NAME], web.LINK, value[web.CLIENT_ORIGIN])) - } - }) - } - }}, - mdb.CREATE: {Name: "create type name link", Hand: func(m *ice.Message, arg ...string) { - m.ProcessRewrite(mdb.HASH, mdb.HashCreate(m, mdb.TYPE, web.LINK, mdb.NAME, kit.ParseURL(m.Option(web.LINK)).Host, m.OptionSimple())) - }}, + IFRAME: {Name: "iframe hash@key auto safari", Help: "浏览器", Icon: "usr/icons/Safari.png", Actions: ice.MergeActions(ice.Actions{ mdb.INPUTS: {Hand: func(m *ice.Message, arg ...string) { switch mdb.HashInputs(m, arg); arg[0] { case mdb.NAME: @@ -37,12 +25,14 @@ func init() { case mdb.HASH: m.Cmd(mdb.SEARCH, mdb.FOREACH, "", "type,name,text", func(value ice.Maps) { kit.If(value[mdb.TYPE] == web.LINK, func() { - m.Push(arg[0], value[mdb.TEXT]) - m.Push(mdb.NAME, value[mdb.NAME]) + m.Push(arg[0], value[mdb.TEXT]).Push(mdb.NAME, value[mdb.NAME]) }) }) } }}, + mdb.CREATE: {Name: "create type name link", Hand: func(m *ice.Message, arg ...string) { + m.ProcessRewrite(mdb.HASH, mdb.HashCreate(m, mdb.TYPE, web.LINK, mdb.NAME, kit.ParseURL(m.Option(web.LINK)).Host, m.OptionSimple())) + }}, FAVOR_INPUTS: {Hand: func(m *ice.Message, arg ...string) { switch arg[0] { case mdb.TYPE: @@ -75,9 +65,6 @@ func init() { } }}, web.OPEN: {Hand: func(m *ice.Message, arg ...string) { m.ProcessOpen(m.Option(web.LINK)) }}, - web.DREAM_CREATE: {Hand: func(m *ice.Message, arg ...string) { - m.Cmd("", mdb.CREATE, kit.Dict(web.LINK, m.MergePod(m.Option(mdb.NAME)))) - }}, "safari": {Help: "本机", Hand: func(m *ice.Message, arg ...string) { if h := kit.Select(m.Option(mdb.HASH), arg, 0); h == "" { cli.Opens(m, "Safari.app") @@ -85,8 +72,8 @@ func init() { cli.Opens(m, m.Cmd("", h).Append(mdb.LINK)) } }}, - }, mdb.HashAction(mdb.SHORT, web.LINK, mdb.FIELD, "time,hash,type,name,link"), FavorAction()), Hand: func(m *ice.Message, arg ...string) { - list := []string{m.MergePodCmd("", "web.wiki.portal", log.DEBUG, m.Option(log.DEBUG))} + }, FavorAction(), mdb.HashAction(mdb.SHORT, web.LINK, mdb.FIELD, "time,hash,type,name,link")), Hand: func(m *ice.Message, arg ...string) { + list := []string{m.MergePodCmd("", web.WIKI_PORTAL, log.DEBUG, m.Option(log.DEBUG))} list = append(list, web.MergeLink(m, "/chat/portal/", ice.POD, m.Option(ice.MSG_USERPOD), log.DEBUG, m.Option(log.DEBUG))) if mdb.HashSelect(m, arg...); len(arg) == 0 { for _, link := range list { diff --git a/core/chat/pod.go b/core/chat/pod.go index ea1cd0d1..6471e482 100644 --- a/core/chat/pod.go +++ b/core/chat/pod.go @@ -18,11 +18,11 @@ const POD = "pod" func init() { Index.MergeCommands(ice.Commands{ - POD: {Actions: ice.MergeActions(ctx.CmdAction(), web.ApiAction(), aaa.WhiteAction()), Hand: func(m *ice.Message, arg ...string) { - if len(arg) == 0 || kit.Select("", arg, 0) == "" { - web.RenderCmd(m, web.SPACE) + POD: {Actions: ice.MergeActions(web.ApiAction(), aaa.WhiteAction(), ctx.CmdAction()), Hand: func(m *ice.Message, arg ...string) { + if len(arg) == 0 || arg[0] == "" { + web.RenderMain(m) } else if strings.HasPrefix(m.Option(ice.MSG_USERUA), "git/") { - m.RenderRedirect(m.Cmdv(web.SPACE, arg[0], "web.code.git.repos", nfs.REMOTE, nfs.REMOTE) + "/info/refs?service=" + m.Option("service")) + m.RenderRedirect(kit.MergeURL2(m.Cmdv(web.SPACE, arg[0], web.CODE_GIT_REPOS, nfs.REMOTE, nfs.REMOTE), "/info/refs", m.OptionSimple("service"))) } else if m.Option(cli.GOOS) != "" && m.Option(cli.GOARCH) != "" { m.RenderDownload(path.Join(ice.USR_LOCAL_WORK, arg[0], ice.USR_PUBLISH, kit.Keys(ice.ICE, m.Option(cli.GOOS), m.Option(cli.GOARCH)))) } else if m.IsCliUA() { diff --git a/core/chat/portal.go b/core/chat/portal.go index 97ba7786..b5b459eb 100644 --- a/core/chat/portal.go +++ b/core/chat/portal.go @@ -2,7 +2,6 @@ package chat import ( ice "shylinux.com/x/icebergs" - "shylinux.com/x/icebergs/base/nfs" "shylinux.com/x/icebergs/base/web" ) @@ -10,8 +9,8 @@ const PORTAL = "portal" func init() { Index.MergeCommands(ice.Commands{ - PORTAL: {Name: "portal path auto", Help: "门户", Actions: ice.MergeActions(ice.Actions{ - nfs.PS: {Hand: func(m *ice.Message, arg ...string) { web.RenderMain(m) }}, - }), Hand: func(m *ice.Message, arg ...string) { web.RenderMain(m) }}, + PORTAL: {Actions: web.ApiAction(), Hand: func(m *ice.Message, arg ...string) { + web.RenderMain(m) + }}, }) } diff --git a/core/chat/river.go b/core/chat/river.go index 186d09f8..5982082f 100644 --- a/core/chat/river.go +++ b/core/chat/river.go @@ -5,7 +5,6 @@ import ( "shylinux.com/x/icebergs/base/aaa" "shylinux.com/x/icebergs/base/gdb" "shylinux.com/x/icebergs/base/mdb" - "shylinux.com/x/icebergs/base/nfs" "shylinux.com/x/icebergs/base/web" kit "shylinux.com/x/toolkits" ) @@ -22,7 +21,7 @@ func _river_key(m *ice.Message, key ...ice.Any) string { func _river_list(m *ice.Message) { if m.Option(web.SHARE) != "" { switch msg := m.Cmd(web.SHARE, m.Option(web.SHARE)); msg.Append(mdb.TYPE) { - case web.STORM, web.FIELD: + case web.FIELD, web.STORM: m.Option(ice.MSG_RIVER, web.SHARE) return } @@ -40,36 +39,23 @@ const RIVER = "river" func init() { Index.MergeCommands(ice.Commands{ - RIVER: {Name: "river", Help: "群组", Actions: ice.MergeActions(ice.Actions{ - ice.CTX_INIT: {Hand: func(m *ice.Message, arg ...string) { mdb.HashImport(m) }}, - ice.CTX_EXIT: {Hand: func(m *ice.Message, arg ...string) { mdb.HashExport(m) }}, - mdb.INPUTS: {Hand: func(m *ice.Message, arg ...string) { - switch arg[0] { - case nfs.TEMPLATE: - m.Cmdy(TEMPLATE).CutTo(RIVER, arg[0]) - default: - mdb.HashInputs(m, arg) - } - }}, + RIVER: {Actions: ice.MergeActions(ice.Actions{ mdb.CREATE: {Name: "create type=void,tech,root name=hi text=hello template=base", Hand: func(m *ice.Message, arg ...string) { h := mdb.HashCreate(m, arg) defer m.Result(h) - if m.Option(mdb.TYPE) == aaa.VOID { - m.Cmd(aaa.ROLE, aaa.WHITE, aaa.VOID, kit.Keys(RIVER, h)) - } + kit.If(m.Option(mdb.TYPE) == aaa.VOID, func() { m.Cmd(aaa.ROLE, aaa.WHITE, aaa.VOID, kit.Keys(RIVER, h)) }) gdb.Event(m, RIVER_CREATE, RIVER, m.Option(ice.MSG_RIVER, h), arg) }}, - "/": {Hand: func(m *ice.Message, arg ...string) { - if m.Warn(m.Option(ice.MSG_USERNAME) == "", ice.ErrNotLogin) || !aaa.Right(m, RIVER, arg) { - return - } else if len(arg) == 0 { - _river_list(m) - } else if len(arg) > 1 && arg[1] == STORM { - m.Cmdy(arg[1], arg[2:], kit.Dict(ice.MSG_RIVER, arg[0])) - } else if len(arg) > 2 && arg[2] == STORM { - m.Cmdy(arg[2], arg[3:], kit.Dict(ice.MSG_RIVER, arg[0], ice.MSG_STORM, arg[1])) - } - }}, - }, aaa.WhiteAction(), mdb.ImportantHashAction(mdb.FIELD, "time,hash,type,icon,name,text,template"))}, + }, web.ApiAction(), aaa.WhiteAction(), mdb.ImportantHashAction(mdb.FIELD, "time,hash,type,icon,name,text,template"), mdb.ExportHashAction()), Hand: func(m *ice.Message, arg ...string) { + if m.Warn(m.Option(ice.MSG_USERNAME) == "", ice.ErrNotLogin) || !aaa.Right(m, RIVER, arg) { + return + } else if len(arg) == 0 { + _river_list(m) + } else if len(arg) > 1 && arg[1] == STORM { + m.Cmdy(arg[1], arg[2:], kit.Dict(ice.MSG_RIVER, arg[0])) + } else if len(arg) > 2 && arg[2] == STORM { + m.Cmdy(arg[2], arg[3:], kit.Dict(ice.MSG_RIVER, arg[0], ice.MSG_STORM, arg[1])) + } + }}, }) } diff --git a/core/chat/search.go b/core/chat/search.go index 62980a63..ea9c1f8c 100644 --- a/core/chat/search.go +++ b/core/chat/search.go @@ -11,13 +11,10 @@ const SEARCH = "search" func init() { Index.MergeCommands(ice.Commands{ - SEARCH: {Name: "search", Help: "搜索框", Actions: ice.MergeActions(ice.Actions{ + SEARCH: {Actions: ice.MergeActions(ice.Actions{ cli.OPENS: {Hand: func(m *ice.Message, arg ...string) { cli.Opens(m, arg...) }}, - "/": {Hand: func(m *ice.Message, arg ...string) { - m.Cmdy(web.Space(m, m.Option(ice.POD)), "mdb.search", arg).StatusTimeCount() - }}, - }, ctx.CmdAction()), Hand: func(m *ice.Message, arg ...string) { - m.Cmdy("mdb.search", arg) + }, web.ApiAction(), ctx.CmdAction()), Hand: func(m *ice.Message, arg ...string) { + m.Cmdy(web.Space(m, m.Option(ice.POD)), "mdb.search", arg).StatusTimeCount() }}, }) } diff --git a/core/chat/sso.go b/core/chat/sso.go index 12034a92..50d1533f 100644 --- a/core/chat/sso.go +++ b/core/chat/sso.go @@ -16,8 +16,8 @@ const SSO = "sso" func init() { Index.MergeCommands(ice.Commands{ - web.P(SSO): {Name: "/sso", Help: "授权", Actions: aaa.WhiteAction(), Hand: func(m *ice.Message, arg ...string) { - if m.Warn(m.Option(ice.MSG_USERNAME) == "", ice.ErrNotLogin) || m.Warn(m.Option(cli.BACK) == "", ice.ErrNotValid) { + SSO: {Actions: ice.MergeActions(web.ApiAction(), aaa.WhiteAction()), Hand: func(m *ice.Message, arg ...string) { + if m.Warn(m.Option(ice.MSG_USERNAME) == "", ice.ErrNotLogin) || m.Warn(m.Option(web.SPACE) == "", ice.ErrNotValid) || m.Warn(m.Option(cli.BACK) == "", ice.ErrNotValid) { web.RenderMain(m) return } @@ -34,5 +34,5 @@ func GetSSO(m *ice.Message) string { return "" } ls := strings.Split(kit.ParseURL(link).Path, nfs.PS) - return kit.MergeURL2(link, web.P(CHAT, SSO), web.SPACE, kit.Select("", ls, 3), cli.BACK, m.R.Header.Get(web.Referer)) + return kit.MergeURL2(link, web.PP(CHAT, SSO), web.SPACE, kit.Select("", ls, 3), cli.BACK, m.R.Header.Get(web.Referer)) } diff --git a/core/chat/storm.go b/core/chat/storm.go index 899e245d..7c90f83b 100644 --- a/core/chat/storm.go +++ b/core/chat/storm.go @@ -17,7 +17,6 @@ const STORM = "storm" func init() { Index.MergeCommands(ice.Commands{ STORM: {Name: "storm hash id auto insert create", Help: "应用", Actions: ice.Actions{ - mdb.INPUTS: {Hand: func(m *ice.Message, arg ...string) {}}, mdb.CREATE: {Name: "create name=hi text=hello", Hand: func(m *ice.Message, arg ...string) { m.Cmdy(mdb.INSERT, RIVER, _river_key(m), mdb.HASH, arg) }}, @@ -28,7 +27,7 @@ func init() { m.Cmdy(mdb.INSERT, RIVER, _storm_key(m), mdb.LIST, arg) }}, mdb.DELETE: {Hand: func(m *ice.Message, arg ...string) { - m.Cmdy(mdb.MODIFY, RIVER, _storm_key(m), mdb.LIST, arg, "deleted", "true") + m.Cmdy(mdb.MODIFY, RIVER, _storm_key(m), mdb.LIST, arg, "deleted", ice.TRUE) }}, mdb.MODIFY: {Hand: func(m *ice.Message, arg ...string) { if len(arg) > 0 && arg[0] == mdb.ID { diff --git a/core/chat/template.go b/core/chat/template.go deleted file mode 100644 index c83e402b..00000000 --- a/core/chat/template.go +++ /dev/null @@ -1,98 +0,0 @@ -package chat - -import ( - ice "shylinux.com/x/icebergs" - "shylinux.com/x/icebergs/base/ctx" - "shylinux.com/x/icebergs/base/gdb" - "shylinux.com/x/icebergs/base/mdb" - kit "shylinux.com/x/toolkits" -) - -const TEMPLATE = "template" - -func init() { - Index.MergeCommands(ice.Commands{ - TEMPLATE: {Name: "template river storm index auto 删除配置 查看配置", Help: "模板", Actions: ice.MergeActions(ice.Actions{ - ice.CTX_INIT: {Hand: func(m *ice.Message, arg ...string) { - return - if gdb.Watch(m, RIVER_CREATE); m.Cmd("").Length() == 0 { - kit.For(_river_template, func(river string, value ice.Any) { - m.Cmd("", mdb.CREATE, RIVER, river) - kit.For(value, func(storm string, value ice.Any) { - m.Cmd("", mdb.INSERT, RIVER, river, STORM, storm) - kit.For(value, func(index int, value ice.Any) { - m.Cmd("", "add", RIVER, river, STORM, storm, ctx.INDEX, value) - }) - }) - }) - } - }}, - RIVER_CREATE: {Name: "river.create river template", Hand: func(m *ice.Message, arg ...string) { - m.Cmd("", m.Option(TEMPLATE), ice.OptionFields(STORM), func(value ice.Maps) { - m.Option(ice.MSG_STORM, m.Cmdx(STORM, mdb.CREATE, mdb.NAME, value[STORM])) - m.Cmd("", m.Option(TEMPLATE), value[STORM], ice.OptionFields(ctx.INDEX), func(value ice.Maps) { - m.Cmd(STORM, mdb.INSERT, ctx.INDEX, value[ctx.INDEX]) - }) - }) - }}, - mdb.CREATE: {Name: "create river", Hand: func(m *ice.Message, arg ...string) { - m.Cmd(mdb.INSERT, m.PrefixKey(), "", mdb.HASH, m.OptionSimple(RIVER), kit.Dict(mdb.SHORT, RIVER)) - }}, - mdb.INSERT: {Name: "insert river storm", Hand: func(m *ice.Message, arg ...string) { - m.Cmd(mdb.INSERT, m.PrefixKey(), kit.KeyHash(m.Option(RIVER)), mdb.HASH, arg[2:], kit.Dict(mdb.SHORT, STORM)) - }}, - "add": {Name: "add river storm index", Hand: func(m *ice.Message, arg ...string) { - m.Cmd(mdb.INSERT, m.PrefixKey(), kit.KeyHash(m.Option(RIVER), kit.KeyHash(m.Option(STORM))), mdb.LIST, arg[4:]) - }}, - mdb.REMOVE: {Name: "remove", Hand: func(m *ice.Message, arg ...string) { - if m.Option(STORM) == "" { - m.Cmd(mdb.DELETE, m.PrefixKey(), "", mdb.HASH, m.OptionSimple(RIVER)) - } else { - m.Cmd(mdb.DELETE, m.PrefixKey(), kit.KeyHash(m.Option(RIVER)), mdb.HASH, m.OptionSimple(STORM)) - } - }}, - }, mdb.ClearOnExitHashAction()), Hand: func(m *ice.Message, arg ...string) { - switch len(arg) { - case 0: - m.Cmdy(mdb.SELECT, m.PrefixKey(), "", mdb.HASH, ice.OptionFields("time,river")) - m.PushAction(mdb.REMOVE).Action(mdb.CREATE) - case 1: - m.Cmdy(mdb.SELECT, m.PrefixKey(), kit.KeyHash(arg[0]), mdb.HASH, ice.OptionFields("time,storm")) - m.PushAction(mdb.REMOVE).Action(mdb.INSERT) - case 2: - m.Cmdy(mdb.SELECT, m.PrefixKey(), kit.KeyHash(arg[0], kit.KeyHash(arg[1])), mdb.LIST, ice.OptionFields("time,index")) - m.Action("add") - } - }}, - }) -} - -var _river_template = kit.Dict( - "base", kit.Dict( - "draw", kit.List( - "web.wiki.draw", - "web.wiki.data", - "web.wiki.word", - ), - "term", kit.List( - "web.code.xterm", - "web.code.vimer", - "web.chat.iframe", - ), - "task", kit.List( - "web.team.task", - "web.team.plan", - "web.mall.asset", - "web.mall.salary", - "web.wiki.word", - ), - "scan", kit.List( - "web.chat.scan", - "web.chat.paste", - "web.chat.files", - "web.chat.location", - "web.chat.meet.miss", - "web.wiki.feel", - ), - ), -) diff --git a/core/chat/trans.go b/core/chat/trans.go index 7e61824b..94fa508a 100644 --- a/core/chat/trans.go +++ b/core/chat/trans.go @@ -30,7 +30,7 @@ func init() { ).ProcessHold() web.ToastSuccess(m, SEND) }}, - ice.RUN: {Name: "run", Help: "执行", Hand: func(m *ice.Message, arg ...string) { + ctx.RUN: {Name: "run", Help: "执行", Hand: func(m *ice.Message, arg ...string) { m.Option(ice.POD, m.Option("_pod")) m.Option(ice.MSG_USERPOD, m.Option("_pod")) if aaa.Right(m, arg) && !ctx.PodCmd(m, arg) { diff --git a/core/code/bench.go b/core/code/bench.go index 8bd4b8d4..2af230f5 100644 --- a/core/code/bench.go +++ b/core/code/bench.go @@ -8,6 +8,7 @@ import ( "sync/atomic" ice "shylinux.com/x/icebergs" + "shylinux.com/x/icebergs/base/ctx" "shylinux.com/x/icebergs/base/lex" "shylinux.com/x/icebergs/base/mdb" "shylinux.com/x/icebergs/base/nfs" @@ -59,7 +60,7 @@ func init() { Index.MergeCommands(ice.Commands{ BENCH: {Name: "bench zone id auto insert", Help: "压测", Actions: ice.MergeActions(ice.Actions{ mdb.INSERT: {Name: "insert zone*=demo type*=http,redis name=demo text*='http://localhost:9020/chat/cmd/run/web.chat.favor' nconn=10 nreqs=100"}, - ice.RUN: {Hand: func(m *ice.Message, arg ...string) { + ctx.RUN: {Hand: func(m *ice.Message, arg ...string) { switch m.Option(mdb.TYPE) { case HTTP: _bench_http(m, m.Option(mdb.TEXT)) @@ -68,7 +69,7 @@ func init() { } }}, }, mdb.ZoneAction(mdb.FIELD, "time,id,type,name,text,nconn,nreqs")), Hand: func(m *ice.Message, arg ...string) { - mdb.ZoneSelect(m, arg...).PushAction(kit.Select(ice.RUN, mdb.REMOVE, len(arg) == 0)) + mdb.ZoneSelect(m, arg...).PushAction(kit.Select(ctx.RUN, mdb.REMOVE, len(arg) == 0)) }}, }) } diff --git a/core/code/case.go b/core/code/case.go index d6e26687..6c7d36c7 100644 --- a/core/code/case.go +++ b/core/code/case.go @@ -3,6 +3,7 @@ package code import ( ice "shylinux.com/x/icebergs" "shylinux.com/x/icebergs/base/cli" + "shylinux.com/x/icebergs/base/ctx" "shylinux.com/x/icebergs/base/mdb" "shylinux.com/x/icebergs/base/nfs" "shylinux.com/x/icebergs/base/web" @@ -33,7 +34,7 @@ func init() { m.StatusTimeCount(ice.SUCCESS, success) return } - if res := kit.UnMarshal(m.Cmdx("", ice.RUN)); m.Option(ice.RES) != "" { + if res := kit.UnMarshal(m.Cmdx("", ctx.RUN)); m.Option(ice.RES) != "" { for k, v := range kit.KeyValue(nil, "", kit.UnMarshal(m.Option(ice.RES))) { if v != kit.Value(res, k) { m.Echo(kit.Formats(res)) @@ -43,7 +44,7 @@ func init() { } m.Echo(ice.OK) }}, - ice.RUN: {Hand: func(m *ice.Message, arg ...string) { + ctx.RUN: {Hand: func(m *ice.Message, arg ...string) { m.Option(web.SPIDE_HEADER, web.ContentType, web.ApplicationJSON, web.UserAgent, "Mozilla/5.0") m.Cmdy(web.SPIDE, m.Option(ice.DEV), web.SPIDE_RAW, m.Option(ice.CMD), m.Option(cli.API), web.SPIDE_DATA, m.Option(ice.ARG)).ProcessInner() m.StatusTime(nfs.SCRIPT, `curl "`+kit.MergeURL2(m.Cmd(web.SPIDE, m.Option(ice.DEV)).Append(web.CLIENT_ORIGIN), m.Option(cli.API))+`" -H "Content-Type: application/json"`+` -d '`+m.Option(ice.ARG)+`'`) @@ -52,7 +53,7 @@ func init() { if len(arg) == 0 { m.Cmdy(web.SPIDE).RenameAppend(web.CLIENT_NAME, ice.DEV, web.CLIENT_URL, "address") } else if mdb.ZoneSelect(m, arg[1:]...); len(arg) > 1 { - m.PushAction(ice.RUN, cli.CHECK).Action(cli.CHECK) + m.PushAction(ctx.RUN, cli.CHECK).Action(cli.CHECK) } }}, }) diff --git a/core/team/plan.go b/core/team/plan.go index 73ecf9b2..74b03265 100644 --- a/core/team/plan.go +++ b/core/team/plan.go @@ -58,8 +58,8 @@ func init() { PLAN: {Name: "plan scale=month,day,week,month,year,long begin_time@date list prev next", Icon: "usr/icons/Calendar.png", Help: "计划表", Actions: ice.MergeActions(ice.Actions{ mdb.INPUTS: {Hand: func(m *ice.Message, arg ...string) { m.Cmdy(TODO, mdb.INPUTS, arg) }}, mdb.PLUGIN: {Name: "plugin extra.index extra.args", Hand: func(m *ice.Message, arg ...string) { m.Cmdy(TASK, mdb.MODIFY, arg) }}, - ice.RUN: {Hand: func(m *ice.Message, arg ...string) { - if m.RenameOption(TASK_POD, ice.POD); ctx.PodCmd(m, m.PrefixKey(), ice.RUN, arg) { + ctx.RUN: {Hand: func(m *ice.Message, arg ...string) { + if m.RenameOption(TASK_POD, ice.POD); ctx.PodCmd(m, m.PrefixKey(), ctx.RUN, arg) { return } if cmd := m.CmdAppend(TASK, kit.Slice(arg, 0, 2), ctx.INDEX); cmd != "" { diff --git a/core/wiki/table.go b/core/wiki/table.go index 3cc0dd18..a3139688 100644 --- a/core/wiki/table.go +++ b/core/wiki/table.go @@ -4,6 +4,7 @@ import ( "strings" ice "shylinux.com/x/icebergs" + "shylinux.com/x/icebergs/base/ctx" kit "shylinux.com/x/toolkits" ) @@ -50,7 +51,7 @@ const TABLE = "table" func init() { Index.MergeCommands(ice.Commands{ TABLE: {Name: "table text", Help: "表格", Actions: ice.MergeActions(ice.Actions{ - ice.RUN: {Hand: func(m *ice.Message, arg ...string) { _table_run(m, arg...) }}, + ctx.RUN: {Hand: func(m *ice.Message, arg ...string) { _table_run(m, arg...) }}, }), Hand: func(m *ice.Message, arg ...string) { _table_show(m, arg[0], arg[1:]...) }}, }) } diff --git a/misc/bash/favor.go b/misc/bash/favor.go index 3cce64c1..2c1b2e3b 100644 --- a/misc/bash/favor.go +++ b/misc/bash/favor.go @@ -17,7 +17,7 @@ func init() { FAVOR: {Name: "favor zone id auto insert", Help: "收藏夹", Actions: ice.MergeActions(ice.Actions{ mdb.INSERT: {Name: "insert zone*=demo type=shell name=1 text=pwd pwd=/home"}, cli.SYSTEM: {Hand: func(m *ice.Message, arg ...string) { - if len(arg) > 0 && arg[0] == ice.RUN { + if len(arg) > 0 && arg[0] == ctx.RUN { if msg := mdb.ZoneSelect(m.Spawn(), m.Option(mdb.ZONE), m.Option(mdb.ID)); nfs.Exists(m, msg.Append(cli.PWD)) { m.Option(cli.CMD_DIR, msg.Append(cli.PWD)) } diff --git a/misc/bash/run.go b/misc/bash/run.go index c4fdaffb..b9222b8c 100644 --- a/misc/bash/run.go +++ b/misc/bash/run.go @@ -79,7 +79,7 @@ func init() { _run_action(m, cmd, m.Results(), arg...) }) }}, - ice.RUN: {Hand: func(m *ice.Message, arg ...string) { + ctx.RUN: {Hand: func(m *ice.Message, arg ...string) { if !ctx.PodCmd(m, arg) && aaa.Right(m, arg) { m.Cmdy(arg) } diff --git a/misc/bash/sync.go b/misc/bash/sync.go index 1ccf4525..5c516016 100644 --- a/misc/bash/sync.go +++ b/misc/bash/sync.go @@ -26,7 +26,7 @@ func init() { SYNC: {Name: "sync id auto page export import", Help: "同步流", Actions: ice.MergeActions(ice.Actions{ mdb.INPUTS: {Hand: func(m *ice.Message, arg ...string) { m.Cmdy(FAVOR, mdb.INPUTS, arg) }}, cli.SYSTEM: {Hand: func(m *ice.Message, arg ...string) { - if len(arg) > 0 && arg[0] == ice.RUN { + if len(arg) > 0 && arg[0] == ctx.RUN { if msg := mdb.ListSelect(m.Spawn(), m.Option(mdb.ID)); nfs.Exists(m, msg.Append(cli.PWD)) { m.Option(cli.CMD_DIR, msg.Append(cli.PWD)) } diff --git a/misc/git/repos.go b/misc/git/repos.go index 10a21866..0a14a776 100644 --- a/misc/git/repos.go +++ b/misc/git/repos.go @@ -304,7 +304,7 @@ func _repos_total(m *ice.Message, p string, repos *git.Repository, stats map[str return nil } func _repos_inner(m *ice.Message, _repos_path func(m *ice.Message, p string, arg ...string) string, arg ...string) { - if len(arg) == 0 || arg[0] != ice.RUN { + if len(arg) == 0 || arg[0] != ctx.RUN { arg = []string{path.Join(arg[:3]...) + nfs.PS, kit.Select("README.md", arg, 3)} } else if kit.Select("", arg, 1) != ctx.ACTION { if ls := kit.Split(path.Join(m.Option(nfs.DIR_ROOT), arg[1]), nfs.PS); len(ls) < 2 || ls[2] == INDEX { diff --git a/type.go b/type.go index 72fe4b24..6a45084c 100644 --- a/type.go +++ b/type.go @@ -174,7 +174,7 @@ func (c *Context) Merge(s *Context) *Context { kit.If(action.List == nil, func() { action.List = SplitCmd(action.Name, nil) }) kit.If(len(action.List) > 0, func() { cmd.Meta[sub] = action.List }) } - kit.If(cmd.Name == "", func() { cmd.Name = "list list" }) + kit.If(cmd.Name == "", func() { cmd.Name = "list auto" }) kit.If(strings.HasPrefix(cmd.Name, "list"), func() { cmd.Name = strings.Replace(cmd.Name, "list", key, 1) }) kit.If(cmd.List == nil, func() { cmd.List = SplitCmd(cmd.Name, cmd.Actions) }) }