diff --git a/base/ctx/command.go b/base/ctx/command.go index 4391fa6f..04701898 100644 --- a/base/ctx/command.go +++ b/base/ctx/command.go @@ -47,7 +47,7 @@ func _command_search(m *ice.Message, kind, name, text string) { } m.PushSearch(ice.CTX, kit.PathName(1), ice.CMD, kit.FileName(1), kit.SimpleKV("", s.Prefix(), kit.Select(key, cmd.Name), cmd.Help), - INDEX, kit.Keys(s.Prefix(), key)) + INDEX, kit.Keys(s.Prefix(), key), mdb.HELP, cmd.Help) }).Sort(m.OptionFields()) } @@ -124,7 +124,7 @@ func init() { }}, }), Hand: func(m *ice.Message, arg ...string) { if len(arg) == 0 { - m.OptionFields(INDEX) + m.OptionFields(INDEX, mdb.HELP) m.Cmdy("", mdb.SEARCH, COMMAND) } else { kit.For(arg, func(k string) { _command_list(m, k) }) diff --git a/base/web/html/html.go b/base/web/html/html.go index dae72278..ab680842 100644 --- a/base/web/html/html.go +++ b/base/web/html/html.go @@ -90,6 +90,7 @@ const ( VIEW = "view" VALUE = "value" INPUT = "input" + TITLE = "title" ICON = "icon" ICONS = "icons" OUTPUT = "output" diff --git a/base/web/render.go b/base/web/render.go index ece71876..4e22327a 100644 --- a/base/web/render.go +++ b/base/web/render.go @@ -85,7 +85,7 @@ func Render(m *ice.Message, cmd string, args ...ice.Any) bool { "$status", fieldset+">div.status", "$fieldset", fieldset, "$field", fieldset, - "$input", "body>div.input.float."+m.Option(ctx.INDEX), + "$input", "div.input.float."+m.Option(ctx.INDEX), "$body", "body.cmd."+m.Option(ctx.INDEX), "$index", m.Option(ctx.INDEX), ))) diff --git a/base/web/space.go b/base/web/space.go index 98b05e2e..4695432c 100644 --- a/base/web/space.go +++ b/base/web/space.go @@ -155,7 +155,7 @@ func _space_handle(m *ice.Message, safe bool, name string, c *websocket.Conn) { }() msg := m.Spawn(b) if safe && msg.Option(ice.MSG_UNSAFE) != ice.TRUE { // 下行权限 - if !aaa.IsTechOrRoot(msg) && msg.Option(ice.MSG_HANDLE) != ice.TRUE { + if !aaa.IsTechOrRoot(msg) && msg.Option(ice.MSG_HANDLE) != ice.TRUE && msg.Option(ice.MSG_USERUID) == "" { msg.Option(ice.MSG_USERROLE, kit.Select(msg.Option(ice.MSG_USERROLE), aaa.UserRole(msg, msg.Option(ice.MSG_USERNAME)))) } // kit.If(kit.IsIn(msg.Option(ice.MSG_USERROLE), "", aaa.VOID), func() { msg.Option(ice.MSG_USERROLE, aaa.UserRole(msg, msg.Option(ice.MSG_USERNAME))) }) @@ -530,7 +530,10 @@ func init() { }) case SPACE: AdminCmd(m, SPACE).Table(func(value ice.Maps) { - kit.If(kit.IsIn(value[mdb.TYPE], WORKER, SERVER), func() { m.Push(arg[0], value[mdb.NAME]) }) + kit.If(kit.IsIn(value[mdb.TYPE], WORKER, SERVER), func() { + m.Push(arg[0], value[mdb.NAME]) + m.Push(mdb.HELP, value[mdb.HELP]) + }) }) case SERVER: AdminCmd(m, SPACE).Table(func(value ice.Maps) { @@ -559,7 +562,8 @@ func init() { } else { m.Cmdy(ctx.COMMAND) } - m.CutTo(ctx.INDEX, arg[0]) + m.Cut(ctx.INDEX, mdb.HELP) + m.RenameAppend(ctx.INDEX, arg[0]) case ctx.ARGS: m.OptionDefault(ctx.INDEX, m.Option("extra.index")) if space := m.Option(SPACE); space != "" { diff --git a/conf.go b/conf.go index 27f988ea..856cb598 100644 --- a/conf.go +++ b/conf.go @@ -171,6 +171,7 @@ const ( // DIR SRC_MAIN_CSS = "src/main.css" SRC_MAIN_JS = "src/main.js" SRC_MAIN_GO = "src/main.go" + SRC_OPTION_GO = "src/option.go" SRC_WEBVIEW_GO = "src/webview.go" SRC_VERSION_GO = "src/version.go" SRC_BINPACK_GO = "src/binpack.go" diff --git a/core/code/compile.go b/core/code/compile.go index 2e32ed5a..1f291c32 100644 --- a/core/code/compile.go +++ b/core/code/compile.go @@ -111,15 +111,16 @@ func init() { kit.If(cli.SystemFindGo(m), func() { m.PushButton(kit.Dict(m.CommandKey(), m.Commands("").Help)) }) }) }}, - }, web.DreamTablesAction(), ctx.ConfAction(cli.ENV, kit.Dict(GOPRIVATE, "shylinux.com,github.com", GOPROXY, "https://goproxy.cn,direct", CGO_ENABLED, "0"))), Hand: func(m *ice.Message, arg ...string) { + }, web.DreamTablesAction(), ctx.ConfAction(cli.ENV, kit.Dict(GOPRIVATE, "shylinux.com", GOPROXY, "https://goproxy.cn,direct", CGO_ENABLED, "0"))), Hand: func(m *ice.Message, arg ...string) { main, file, goos, arch := _compile_target(m, arg...) env := kit.Simple(cli.PATH, cli.BinPath(), cli.HOME, kit.Select(kit.Path(""), kit.Env(cli.HOME)), mdb.Configv(m, cli.ENV), m.Optionv(cli.ENV), cli.GOOS, goos, cli.GOARCH, arch) kit.If(runtime.GOOS == cli.WINDOWS, func() { env = append(env, GOPATH, kit.HomePath(GO), GOCACHE, kit.HomePath("go/go-build")) }) m.Options(cli.CMD_ENV, env).Cmd(AUTOGEN, VERSION) _compile_get(m, main) defer m.StatusTime(VERSION, strings.TrimPrefix(GoVersion(m), "go version")) - args := []string{main, ice.SRC_VERSION_GO} - nfs.Exists(m, "src/option.go", func(p string) { args = append(args, p) }) + args := []string{main} + nfs.Exists(m, ice.SRC_OPTION_GO, func(p string) { args = append(args, p) }) + nfs.Exists(m, ice.SRC_VERSION_GO, func(p string) { args = append(args, p) }) kit.If(file != ice.BIN_ICE_BIN, func() { args = append(args, ice.SRC_BINPACK_GO, ice.SRC_BINPACK_USR_GO) }) if msg := GoBuild(m.Spawn(), file, args...); !cli.IsSuccess(msg) { m.Copy(msg) diff --git a/core/code/css.go b/core/code/css.go index 27518e81..a28359a2 100644 --- a/core/code/css.go +++ b/core/code/css.go @@ -18,20 +18,13 @@ func _css_stat(m *ice.Message, zone string, stats map[string]int) { m.Copy(msg.SortIntR(mdb.VALUE)) } func _css_show(m *ice.Message, arg ...string) { + if _go_portal(m, arg...) { + return + } if arg[1] == "main.css" { m.EchoIFrame(m.MergePodCmd("", web.ADMIN)) return } - if cmd := ctx.GetFileCmd(path.Join(arg[2], arg[1])); cmd != "" { - if p := path.Join(arg[2], strings.Split(arg[1], "/")[0], "portal.go"); nfs.Exists(m, p) { - if _cmd := ctx.GetFileCmd(p); _cmd != "" { - if msg := m.Cmd(_cmd, "commandSelect", cmd); msg.Length() > 0 { - ctx.ProcessField(m, _cmd, kit.Simple()) - return - } - } - } - } cmd := kit.Select(ice.CAN_PLUGIN, ctx.GetFileCmd(kit.ExtChange(path.Join(arg[2], arg[1]), GO))) ctx.DisplayBaseCSS(m, require(arg[2], arg[1]), "render", "replace", ctx.INDEX, cmd, ice.POD, m.Option(ice.MSG_USERPOD)) ctx.DisplayBase(m, require(arg[2], arg[1])) @@ -72,6 +65,9 @@ func _css_show(m *ice.Message, arg ...string) { _css_stat(m, "stats.value", stats_value) } func _css_exec(m *ice.Message, arg ...string) { + if _go_portal(m, arg...) { + return + } if arg[2] == ice.USR_VOLCANOS { if strings.HasPrefix(arg[1], ice.PLUGIN_LOCAL) { ctx.ProcessField(m, kit.Select(ice.CAN_PLUGIN, "web."+strings.Replace(kit.TrimExt(strings.TrimPrefix(arg[1], ice.PLUGIN_LOCAL), JS), nfs.PS, nfs.PT, -1)), kit.Simple()) diff --git a/core/code/go.go b/core/code/go.go index cc547c51..2ac8253a 100644 --- a/core/code/go.go +++ b/core/code/go.go @@ -5,6 +5,7 @@ import ( "strings" ice "shylinux.com/x/icebergs" + "shylinux.com/x/icebergs/base/aaa" "shylinux.com/x/icebergs/base/cli" "shylinux.com/x/icebergs/base/ctx" "shylinux.com/x/icebergs/base/gdb" @@ -61,6 +62,33 @@ func _go_navigate(m *ice.Message, arg ...string) { } _c_tags(m, GOTAGS, "-f", nfs.TAGS, "-R", nfs.PWD) } +func _go_portal(m *ice.Message, arg ...string) bool { + if p := path.Join(arg[2], strings.Split(arg[1], "/")[0], "portal.go"); nfs.Exists(m, p) { + cmd := ctx.GetFileCmd(path.Join(arg[2], kit.ExtChange(arg[1], "go"))) + if _cmd := ctx.GetFileCmd(p); _cmd != "" { + if m.ActionKey() == mdb.RENDER { + if path.Base(arg[1]) == "common.go" { + ctx.ProcessField(m, strings.ReplaceAll(_cmd, ".portal", ".clean"), kit.Simple()) + } else if msg := m.Cmd(_cmd, "commandSelect", cmd); msg.Length() > 0 || cmd == "" { + ctx.ProcessField(m, _cmd, kit.Simple()) + } else { + ctx.ProcessField(m, cmd, kit.Simple()) + } + } else if aaa.IsTechOrRoot(m) { + ls := kit.Split(arg[1], "/") + if msg := m.Cmd(_cmd, "commandSelect", cmd); msg.Length() > 0 && !kit.IsIn(path.Base(arg[1]), "model.go", "common.go") { + ctx.ProcessField(m, "web.code.mysql.query", kit.Simple("mysql", ls[0], TableName(kit.TrimExt(kit.Select("", ls, -1), arg[0])))) + } else { + ctx.ProcessField(m, "web.code.mysql.query", kit.Simple("mysql", ls[0])) + } + } else { + m.Option(ice.MSG_DISPLAY, "") + } + } + return true + } + return false +} func _go_show(m *ice.Message, arg ...string) { if arg[1] == MAIN_GO { ProcessXterm(m, kit.JoinWord("ish", arg[1]), "", "") @@ -68,31 +96,8 @@ func _go_show(m *ice.Message, arg ...string) { ctx.ProcessField(m, cli.RUNTIME, kit.Simple()) } else if arg[1] == "binpack.go" { ctx.ProcessField(m, nfs.PACK, kit.Simple()) - } else if path.Base(arg[1]) == "model.go" { - ctx.ProcessField(m, "web.code.mysql.query", kit.Simple("mysql", kit.Split(arg[1], "/", "/")[0])) + } else if _go_portal(m, arg...) { } else if cmd := ctx.GetFileCmd(path.Join(arg[2], arg[1])); cmd != "" { - if p := path.Join(arg[2], strings.Split(arg[1], "/")[0], "portal.go"); path.Base(arg[1]) != "portal.go" && nfs.Exists(m, p) { - if _cmd := ctx.GetFileCmd(p); _cmd != "" { - if m.ActionKey() == mdb.RENDER { - if path.Base(arg[1]) == "common.go" { - ctx.ProcessField(m, strings.ReplaceAll(_cmd, ".portal", ".clean"), kit.Simple()) - return - } - if msg := m.Cmd(_cmd, "commandSelect", cmd); msg.Length() > 0 { - ctx.ProcessField(m, _cmd, kit.Simple()) - return - } - } else { - ls := kit.Split(strings.TrimSuffix(arg[1], ".go"), "/") - if path.Base(arg[1]) == "common.go" { - ctx.ProcessField(m, "web.code.mysql.query", kit.Simple("mysql", ls[0])) - } else { - ctx.ProcessField(m, "web.code.mysql.query", kit.Simple("mysql", ls[0], TableName(kit.Select("", ls, -1)))) - } - return - } - } - } ctx.ProcessField(m, cmd, kit.Simple()) } else if msg := m.Cmd(yac.STACK, path.Join(arg[2], arg[1])); msg.Option("__index") != "" { ctx.ProcessField(m, msg.Option("__index"), kit.Simple()) diff --git a/core/code/js.go b/core/code/js.go index 3164b0df..a018dbfd 100644 --- a/core/code/js.go +++ b/core/code/js.go @@ -1,7 +1,6 @@ package code import ( - "path" "strings" ice "shylinux.com/x/icebergs" @@ -21,17 +20,7 @@ func _js_show(m *ice.Message, arg ...string) { } else if strings.HasPrefix(arg[1], "plugin/local/") { ctx.ProcessField(m, kit.Select(ice.CAN_PLUGIN, "web."+strings.Replace(strings.TrimSuffix(strings.TrimPrefix(arg[1], "plugin/local/"), nfs.PT+JS), nfs.PS, nfs.PT, -1)), nil) } - } else if cmd := ctx.GetFileCmd(path.Join(arg[2], arg[1])); cmd != "" { - if p := path.Join(arg[2], strings.Split(arg[1], "/")[0], "portal.go"); nfs.Exists(m, p) { - if _cmd := ctx.GetFileCmd(p); _cmd != "" { - if msg := m.Cmd(_cmd, "commandSelect", cmd); msg.Length() > 0 { - ctx.ProcessField(m, _cmd, kit.Simple()) - return - } - } - } - ctx.DisplayBase(m, require(arg[2], arg[1])) - ctx.ProcessField(m, kit.Select(ice.CAN_PLUGIN, ctx.GetFileCmd(kit.ExtChange(path.Join(arg[2], arg[1]), GO))), kit.Simple()) + } else if _go_portal(m, arg...) { } } diff --git a/core/code/json.go b/core/code/json.go index 3fe078e4..91f67225 100644 --- a/core/code/json.go +++ b/core/code/json.go @@ -32,6 +32,12 @@ func init() { }) }}, mdb.ENGINE: {Hand: func(m *ice.Message, arg ...string) { + if path.Base(arg[1]) == "portal.json" { + if cmd := ctx.GetFileCmd(path.Join(arg[2], arg[1])); cmd != "" { + ctx.ProcessField(m, cmd, kit.Simple("table")) + return + } + } m.Cmdy(nfs.CAT, path.Join(arg[2], arg[1])) ctx.DisplayStoryJSON(m) }}, diff --git a/core/code/vimer.go b/core/code/vimer.go index a824b04d..09c52db0 100644 --- a/core/code/vimer.go +++ b/core/code/vimer.go @@ -145,6 +145,7 @@ func init() { gdb.Event(m, VIMER_SAVE) }}, mdb.RENDER: {Role: aaa.VOID, Hand: func(m *ice.Message, arg ...string) { _inner_show(m, arg[0], arg[1], arg[2]) }}, + mdb.ENGINE: {Role: aaa.VOID, Hand: func(m *ice.Message, arg ...string) { _inner_exec(m, arg[0], arg[1], arg[2]) }}, TEMPLATE: {Hand: func(m *ice.Message, arg ...string) { m.Cmdy(TEMPLATE, kit.Ext(m.Option(mdb.FILE)), m.Option(nfs.FILE), m.Option(nfs.PATH)) }}, diff --git a/misc/wx/agent.go b/misc/wx/agent.go index 02594431..3da56d1a 100644 --- a/misc/wx/agent.go +++ b/misc/wx/agent.go @@ -52,6 +52,7 @@ func init() { "oauth", "", web.SPACE, "", nfs.SCRIPT, "https://res.wx.qq.com/open/js/jweixin-1.6.0.js", )), Hand: func(m *ice.Message, arg ...string) { m.Cmdy(ACCESS, AGENT).Options(SIGNATURE, _wx_sign(m, m.Option(NONCESTR, ice.Info.Pathname), m.Option(TIMESTAMP, kit.Format(time.Now().Unix())))).Display("") + m.Info("what %v", m.FormatsMeta(nil)) ctx.OptionFromConfig(m, "oauth", nfs.SCRIPT) if m.Option(ice.MSG_USERNAME) == "" { msg := m.Spawn() diff --git a/misc/wx/agent.js b/misc/wx/agent.js index bf8c290b..fa61f6d7 100644 --- a/misc/wx/agent.js +++ b/misc/wx/agent.js @@ -8,6 +8,7 @@ Volcanos(chat.ONIMPORT, { debug = false, can.onmotion.hidden(can, can._fields) wx.config({debug: debug, signature: msg.Option("signature"), timestamp: msg.Option("timestamp"), nonceStr: msg.Option("noncestr"), appId: msg.Option("appid"), jsApiList: can.core.Item({ + /* getLocation: function(can, cb) { wx.getLocation({type: "gcj02", success: function (res) { can.base.isFunc(cb) && cb({type: "gcj02", name: "当前位置", text: "当前位置", latitude: parseInt(res.latitude*100000), longitude: parseInt(res.longitude*100000) }) } }) }, @@ -27,6 +28,7 @@ Volcanos(chat.ONIMPORT, { scanQRCode: function(can, cb) { wx.scanQRCode({needResult: cb? 1: 0, scanType: ["qrCode", "barCode"], success: function (res) { can.base.isFunc(cb) && cb(can.base.ParseJSON(res.resultStr)) } }) }, + */ }, function(key, value) { return can.user.agent[key] = value, key }).concat([ "updateAppMessageShareData", ], can.user.isMobile? ["updateTimelineShareData"]: []), openTagList: ["wx-open-subscribe"],