diff --git a/base/aaa/user.go b/base/aaa/user.go index 8f008ff5..580a43b5 100644 --- a/base/aaa/user.go +++ b/base/aaa/user.go @@ -49,6 +49,14 @@ const USER = "user" func init() { Index.MergeCommands(ice.Commands{ USER: {Name: "user username auto create", Help: "用户", Actions: ice.MergeActions(ice.Actions{ + mdb.INPUTS: {Hand: func(m *ice.Message, arg ...string) { + switch mdb.HashInputs(m, arg); arg[0] { + case USERNAME: + m.Push(arg[0], m.Option(ice.MSG_USERNAME)) + case USERNICK: + m.Push(arg[0], m.Option(ice.MSG_USERNICK)) + } + }}, mdb.CREATE: {Name: "create username* password usernick userzone userrole=void,tech", Hand: func(m *ice.Message, arg ...string) { _user_create(m, m.Option(USERNAME), m.Option(PASSWORD), m.OptionSimple(USERNICK, USERZONE, USERROLE)...) }}, diff --git a/base/cli/runtime.go b/base/cli/runtime.go index 113b335a..4d5825b6 100644 --- a/base/cli/runtime.go +++ b/base/cli/runtime.go @@ -166,7 +166,7 @@ func init() { m.Split(m.Cmdx(SYSTEM, "ps", "u")).PushAction(PROCKILL).SortIntR("RSS") m.StatusTimeCount("nCPU", msg.Append("nCPU"), "MemTotal", msg.Append("MemTotal"), "MemFree", msg.Append("MemFree")) }}, - PROCKILL: {Hand: func(m *ice.Message, arg ...string) { m.Cmdy(gdb.SIGNAL, gdb.STOP, m.Option("PID")).ProcessRefresh() }}, + PROCKILL: {Help: "结束进程", Hand: func(m *ice.Message, arg ...string) { m.Cmdy(gdb.SIGNAL, gdb.STOP, m.Option("PID")).ProcessRefresh() }}, MAXPROCS: {Hand: func(m *ice.Message, arg ...string) { if len(arg) > 0 { runtime.GOMAXPROCS(kit.Int(m.Conf(RUNTIME, kit.Keys(HOST, MAXPROCS), arg[0]))) @@ -175,27 +175,23 @@ func init() { }}, DISKINFO: {Hand: func(m *ice.Message, arg ...string) { _runtime_diskinfo(m) }}, API: {Hand: func(m *ice.Message, arg ...string) { - for k, v := range ice.Info.Route { - m.Push(nfs.PATH, k).Push(nfs.FILE, v) - } - m.Sort(nfs.PATH).StatusTimeCount() + kit.For(ice.Info.Route, func(k, v string) { m.Push(nfs.PATH, k).Push(nfs.FILE, v) }) + m.StatusTimeCount().Sort(nfs.PATH) }}, CLI: {Hand: func(m *ice.Message, arg ...string) { - for k, v := range ice.Info.File { - m.Push(nfs.FILE, k).Push(mdb.NAME, v) - } - m.Sort(nfs.FILE).StatusTimeCount() + kit.For(ice.Info.File, func(k, v string) { m.Push(nfs.FILE, k).Push(mdb.NAME, v) }) + m.StatusTimeCount().Sort(nfs.FILE) }}, CMD: {Hand: func(m *ice.Message, arg ...string) { m.OptionFields(ctx.INDEX, mdb.NAME, mdb.HELP, nfs.FILE) m.Cmdy(ctx.COMMAND, mdb.SEARCH, ctx.COMMAND).StatusTimeCount() }}, ENV: {Hand: func(m *ice.Message, arg ...string) { - for _, v := range os.Environ() { + kit.For(os.Environ(), func(v string) { ls := strings.SplitN(v, ice.EQ, 2) m.Push(mdb.NAME, ls[0]).Push(mdb.VALUE, ls[1]) - } - m.StatusTimeCount() + }) + m.StatusTimeCount().Sort(mdb.NAME) }}, MAKE_DOMAIN: {Hand: func(m *ice.Message, arg ...string) { if os.Getenv(CTX_DEV) == "" || os.Getenv(CTX_POD) == "" { @@ -204,9 +200,7 @@ func init() { m.Echo(kit.MergePOD(os.Getenv(CTX_DEV), os.Getenv(CTX_POD))) } }}, - "chain": {Hand: func(m *ice.Message, arg ...string) { - m.Echo(m.FormatChain()) - }}, + "chain": {Hand: func(m *ice.Message, arg ...string) { m.Echo(m.FormatChain()) }}, }, ctx.ConfAction("")), Hand: func(m *ice.Message, arg ...string) { if len(arg) > 0 && arg[0] == BOOTINFO { arg = arg[1:] diff --git a/base/web/render.go b/base/web/render.go index 445d167d..289cec81 100644 --- a/base/web/render.go +++ b/base/web/render.go @@ -24,6 +24,7 @@ const ( const ( WEBSITE = "website" + CODE_VIMER = "web.code.vimer" CODE_INNER = "web.code.inner" WIKI_WORD = "web.wiki.word" ) diff --git a/base/web/serve.go b/base/web/serve.go index d81eb765..f4df2d64 100644 --- a/base/web/serve.go +++ b/base/web/serve.go @@ -101,7 +101,7 @@ func _serve_handle(key string, cmd *ice.Command, m *ice.Message, w http.Response m.Option(ice.MSG_USERPOD, m.Option(ice.POD)) } u := OptionUserWeb(m) - m.Option(ice.MSG_USERHOST, u.Scheme+"//"+u.Host) + m.Option(ice.MSG_USERHOST, tcp.PublishLocalhost(m, u.Scheme+"://"+u.Host)) m.Option(ice.MSG_SESSID, kit.Select(m.Option(ice.MSG_SESSID), m.Option(CookieName(m.Option(ice.MSG_USERWEB))))) if m.Optionv(ice.MSG_CMDS) == nil { if p := strings.TrimPrefix(r.URL.Path, key); p != "" { @@ -230,7 +230,7 @@ func init() { PP(ice.REQUIRE, ice.SRC): {Name: "/require/src/", Help: "源代码", Hand: func(m *ice.Message, arg ...string) { _share_local(m, ice.SRC, path.Join(arg...)) }}, - PP(ice.HELP): {Name: "/help/", Help: "帮助", Actions: aaa.WhiteAction(), Hand: func(m *ice.Message, arg ...string) { + PP(ice.HELP): {Name: "/help/", Help: "帮助", Actions: ice.MergeActions(ctx.CmdAction(), aaa.WhiteAction()), Hand: func(m *ice.Message, arg ...string) { if len(arg) == 0 { arg = append(arg, "tutor.shy") } diff --git a/core/code/webpack.go b/core/code/webpack.go index 47c10bc1..bd47be75 100644 --- a/core/code/webpack.go +++ b/core/code/webpack.go @@ -99,10 +99,14 @@ func _webpack_build(m *ice.Message, file string) { if f, p, e := nfs.CreateFile(m, kit.Keys(file, HTML)); m.Assert(e) { defer f.Close() defer m.Echo(p) + main_js := _volcanos(m, PAGE_INDEX_JS) + if nfs.ExistsFile(m, ice.SRC_MAIN_JS) { + main_js = ice.SRC_MAIN_JS + } fmt.Fprintf(f, _webpack_template, m.Cmdx(nfs.CAT, _volcanos(m, PAGE_INDEX_CSS)), m.Cmdx(nfs.CAT, _volcanos(m, PAGE_CACHE_CSS)), m.Cmdx(nfs.CAT, _volcanos(m, ice.PROTO_JS)), m.Cmdx(nfs.CAT, kit.Keys(file, JS)), - m.Cmdx(nfs.CAT, _volcanos(m, PAGE_CACHE_JS)), m.Cmdx(nfs.CAT, _volcanos(m, PAGE_INDEX_JS)), + m.Cmdx(nfs.CAT, _volcanos(m, PAGE_CACHE_JS)), m.Cmdx(nfs.CAT, main_js), ) } }