diff --git a/base/aaa/email.go b/base/aaa/email.go index dabce2dc..ceda9e92 100644 --- a/base/aaa/email.go +++ b/base/aaa/email.go @@ -29,7 +29,7 @@ func init() { DF = ": " ) Index.MergeCommands(ice.Commands{ - EMAIL: {Name: "email name auto create mailbox", Help: "邮件", Actions: ice.MergeActions(ice.Actions{ + EMAIL: {Name: "email name auto", Help: "邮件", Actions: ice.MergeActions(ice.Actions{ MAILBOX: {Help: "邮箱", Hand: func(m *ice.Message, arg ...string) { m.EchoIFrame(mdb.Config(m, MAILBOX)).ProcessInner() }}, SEND: {Name: "send to*='shy@shylinux.com' cc subject*=hi content*:textarea=hello", Help: "发送", Hand: func(m *ice.Message, arg ...string) { msg := m.Cmd("", m.OptionDefault(mdb.NAME, ADMIN)) diff --git a/base/aaa/offer.go b/base/aaa/offer.go index d37895f8..52c5f007 100644 --- a/base/aaa/offer.go +++ b/base/aaa/offer.go @@ -34,7 +34,7 @@ func init() { }}, }, RoleAction(ACCEPT), mdb.ImportantHashAction(mdb.SHORT, mdb.UNIQ, mdb.FIELD, "time,hash,status,invite,email,title,content")), Hand: func(m *ice.Message, arg ...string) { if !m.Warn(len(arg) == 0 && m.Option(ice.MSG_USERROLE) == VOID, ice.ErrNotRight) { - kit.If(mdb.HashSelect(m, arg...).FieldsIsDetail(), func() { m.PushAction(ACCEPT) }, func() { m.Action(mdb.CREATE) }) + kit.If(mdb.HashSelect(m, arg...).FieldsIsDetail(), func() { m.PushAction(ACCEPT) }) } }}, }) diff --git a/base/aaa/role.go b/base/aaa/role.go index 43710934..679443fb 100644 --- a/base/aaa/role.go +++ b/base/aaa/role.go @@ -16,7 +16,7 @@ func _role_keys(key ...string) string { key[0] = _key } } - return strings.TrimPrefix(strings.TrimPrefix(strings.TrimSuffix(strings.Replace(path.Join(strings.Replace(kit.Keys(key), ice.PT, ice.PS, -1)), ice.PS, ice.PT, -1), ice.PT), ice.PT), "web.") + return strings.TrimPrefix(strings.TrimPrefix(strings.TrimSuffix(strings.ReplaceAll(path.Join(strings.ReplaceAll(kit.Keys(key), ice.PT, ice.PS)), ice.PS, ice.PT), ice.PT), ice.PT), "web.") } func _role_set(m *ice.Message, role, zone, key string, status bool) { m.Logs(mdb.INSERT, mdb.KEY, ROLE, ROLE, role, zone, key) @@ -68,6 +68,12 @@ const ROLE = "role" func init() { Index.MergeCommands(ice.Commands{ ROLE: {Name: "role role auto insert filter:text", Help: "角色", Actions: ice.MergeActions(ice.Actions{ + mdb.INPUTS: {Hand: func(m *ice.Message, arg ...string) { + switch arg[0] { + case mdb.KEY: + mdb.HashInputs(m, ice.INDEX).CutTo(ice.INDEX, arg[0]) + } + }}, mdb.CREATE: {Hand: func(m *ice.Message, arg ...string) { kit.For(arg, func(role string) { mdb.Rich(m, ROLE, nil, kit.Dict(mdb.NAME, role, BLACK, kit.Dict(), WHITE, kit.Dict())) @@ -110,6 +116,12 @@ func WhiteAction(key ...string) ice.Actions { kit.For(key, func(key string) { m.Cmd(ROLE, WHITE, VOID, m.CommandKey(), ice.ACTION, key) }) }}} } +func White(m *ice.Message, key ...string) { + kit.For(key, func(key string) { m.Cmd(ROLE, WHITE, VOID, key) }) +} +func Black(m *ice.Message, key ...string) { + kit.For(key, func(key string) { m.Cmd(ROLE, BLACK, VOID, key) }) +} func Right(m *ice.Message, key ...ice.Any) bool { if key := kit.Simple(key); len(key) > 2 && key[1] == ice.ACTION && kit.IsIn(kit.Format(key[2]), ice.RUN, ice.COMMAND) { return true @@ -119,9 +131,3 @@ func Right(m *ice.Message, key ...ice.Any) bool { return m.Option(ice.MSG_USERROLE) == ROOT || !m.Warn(m.Cmdx(ROLE, RIGHT, m.Option(ice.MSG_USERROLE), key, logs.FileLineMeta(-1)) != ice.OK, ice.ErrNotRight, kit.Keys(key...), USERROLE, m.Option(ice.MSG_USERROLE), logs.FileLineMeta(-1)) } -func White(m *ice.Message, key ...string) { - kit.For(key, func(key string) { m.Cmd(ROLE, WHITE, VOID, key) }) -} -func Black(m *ice.Message, key ...string) { - kit.For(key, func(key string) { m.Cmd(ROLE, BLACK, VOID, key) }) -} diff --git a/base/aaa/sess.go b/base/aaa/sess.go index 02e08696..7eb58776 100644 --- a/base/aaa/sess.go +++ b/base/aaa/sess.go @@ -33,7 +33,7 @@ const SESS = "sess" func init() { Index.MergeCommands(ice.Commands{ - SESS: {Name: "sess hash auto prunes", Help: "会话", Actions: ice.MergeActions(ice.Actions{ + SESS: {Name: "sess hash auto", Help: "会话", Actions: ice.MergeActions(ice.Actions{ mdb.CREATE: {Name: "create username*", Hand: func(m *ice.Message, arg ...string) { _sess_create(m, m.Option(USERNAME), UA, m.Option(ice.MSG_USERUA), IP, m.Option(ice.MSG_USERIP)) }}, diff --git a/base/aaa/totp.go b/base/aaa/totp.go index d18643b9..77317a63 100644 --- a/base/aaa/totp.go +++ b/base/aaa/totp.go @@ -46,7 +46,7 @@ func init() { SECRET = "secret" ) Index.MergeCommands(ice.Commands{ - TOTP: {Name: "totp name auto create", Help: "令牌", Actions: ice.MergeActions(ice.Actions{ + TOTP: {Name: "totp name auto", Help: "令牌", Actions: ice.MergeActions(ice.Actions{ mdb.CREATE: {Name: "create name*=hi number*=6 period*=30 secret", Hand: func(m *ice.Message, arg ...string) { kit.If(m.Option(SECRET) == "", func() { m.Option(SECRET, _totp_gen(kit.Int64(m.Option(PERIOD)))) }) mdb.HashCreate(m, m.OptionSimple(mdb.NAME, NUMBER, PERIOD, SECRET)) @@ -61,10 +61,11 @@ func init() { if len(arg) > 0 { m.PushQRCode(mdb.SCAN, kit.Format(mdb.Config(m, mdb.LINK), value[mdb.NAME], value[SECRET])) m.Echo(m.Append(mdb.VALUE)) - } else { - m.PushAction(mdb.REMOVE).StatusTimeCount() } }) + if len(arg) == 0 { + m.PushAction(mdb.REMOVE).Action(mdb.CREATE, mdb.PRUNES).StatusTimeCount() + } }}, }) } diff --git a/base/aaa/user.go b/base/aaa/user.go index 96c32ca3..3dd562ed 100644 --- a/base/aaa/user.go +++ b/base/aaa/user.go @@ -38,7 +38,7 @@ const USER = "user" func init() { Index.MergeCommands(ice.Commands{ - USER: {Name: "user username auto create", Help: "用户", Actions: ice.MergeActions(ice.Actions{ + USER: {Name: "user username auto", Help: "用户", Actions: ice.MergeActions(ice.Actions{ mdb.INPUTS: {Hand: func(m *ice.Message, arg ...string) { switch mdb.HashInputs(m, arg); arg[0] { case USERNICK: @@ -48,7 +48,7 @@ func init() { } }}, mdb.CREATE: {Name: "create usernick username* userrole=void,tech userzone", Hand: func(m *ice.Message, arg ...string) { - _user_create(m, m.Option(USERNAME), m.OptionSimple(USERNICK, USERROLE, USERZONE, BACKGROUND, AVATAR, AVATAR_URL, EMAIL, LANGUAGE)...) + _user_create(m, m.Option(USERNAME), m.OptionSimple(USERNICK, USERROLE, USERZONE, BACKGROUND, AVATAR, AVATAR_URL, LANGUAGE, EMAIL)...) }}, }, mdb.ImportantHashAction(mdb.SHORT, USERNAME, mdb.FIELD, "time,usernick,username,userrole,userzone"))}, }) diff --git a/base/cli/color.go b/base/cli/color.go index d2168249..e7b6ed7c 100644 --- a/base/cli/color.go +++ b/base/cli/color.go @@ -65,7 +65,7 @@ const ( PURPLE = "purple" YELLOW = "yellow" RANDOM = "random" - GLASS = "#0000" + TRANS = "#0000" LIGHT = "light" DARK = "dark" ) diff --git a/base/cli/daemon.go b/base/cli/daemon.go index 261b2770..cfd3002e 100644 --- a/base/cli/daemon.go +++ b/base/cli/daemon.go @@ -81,22 +81,22 @@ const ( STATUS = "status" ERROR = "error" CLEAR = "clear" + DELAY = "delay" RELOAD = "reload" RESTART = "restart" - DELAY = "delay" BEGIN = "begin" + END = "end" START = "start" + STOP = "stop" OPEN = "open" CLOSE = "close" - STOP = "stop" - END = "end" MAIN = "main" CODE = "code" COST = "cost" - BACK = "back" FROM = "from" + BACK = "back" ) const DAEMON = "daemon" @@ -147,20 +147,6 @@ func init() { }) } -func OpenCmds(m *ice.Message, arg ...string) { - if !tcp.IsLocalHost(m, m.Option(ice.MSG_USERIP)) { - return - } - if len(arg) == 0 || arg[0] == "" { - return - } - m.Cmd(SYSTEM, "osascript", "-e", kit.Format(` -tell application "Terminal" - do script "%s" - activate -end tell -`, strings.Join(arg, "; "))) -} func Opens(m *ice.Message, arg ...string) { if !tcp.IsLocalHost(m, m.Option(ice.MSG_USERIP)) { return @@ -183,3 +169,17 @@ func Opens(m *ice.Message, arg ...string) { } } } +func OpenCmds(m *ice.Message, arg ...string) { + if !tcp.IsLocalHost(m, m.Option(ice.MSG_USERIP)) { + return + } + if len(arg) == 0 || arg[0] == "" { + return + } + m.Cmd(SYSTEM, "osascript", "-e", kit.Format(` +tell application "Terminal" + do script "%s" + activate +end tell +`, strings.Join(arg, "; "))) +} diff --git a/base/cli/forever.go b/base/cli/forever.go index 2622de69..6454d7cf 100644 --- a/base/cli/forever.go +++ b/base/cli/forever.go @@ -14,26 +14,12 @@ import ( ) func _path_sep() string { return kit.Select(nfs.DF, ";", strings.Contains(os.Getenv(PATH), ";")) } -func BinPath(arg ...string) string { - list := []string{} - push := func(p string) { - kit.If(kit.IndexOf(list, p) == -1, func() { list = append(list, kit.ReplaceAll(p, "\\", nfs.PS)) }) - } - kit.For(arg, func(p string) { - list = append(list, kit.Path(p, ice.BIN), kit.Path(p, ice.USR_PUBLISH), kit.Path(p, ice.USR_LOCAL_BIN), kit.Path(p, ice.USR_LOCAL_GO_BIN)) - kit.For(kit.Reverse(strings.Split(ice.Pulse.Cmdx(nfs.CAT, kit.Path(p, ice.ETC_PATH)), lex.NL)), func(l string) { - kit.If(strings.TrimSpace(l) != "" && !strings.HasPrefix(strings.TrimSpace(l), "#"), func() { push(kit.Path(p, l)) }) - }) - }) - kit.For(strings.Split(kit.Env(PATH), _path_sep()), func(p string) { push(p) }) - return kit.Join(list, _path_sep()) -} const FOREVER = "forever" func init() { Index.MergeCommands(ice.Commands{ - FOREVER: {Name: "forever auto", Help: "启动", Actions: ice.Actions{ + FOREVER: {Help: "启动", Actions: ice.Actions{ START: {Hand: func(m *ice.Message, arg ...string) { env := []string{PATH, BinPath(""), HOME, kit.Select(kit.Path(""), os.Getenv(HOME))} kit.For(ENV_LIST, func(k string) { kit.If(kit.Env(k) != "", func() { env = append(env, k, kit.Env(k)) }) }) @@ -70,3 +56,18 @@ func init() { }}, }) } + +func BinPath(arg ...string) string { + list := []string{} + push := func(p string) { + kit.If(kit.IndexOf(list, p) == -1, func() { list = append(list, kit.ReplaceAll(p, "\\", nfs.PS)) }) + } + kit.For(arg, func(p string) { + list = append(list, kit.Path(p, ice.BIN), kit.Path(p, ice.USR_PUBLISH), kit.Path(p, ice.USR_LOCAL_BIN), kit.Path(p, ice.USR_LOCAL_GO_BIN)) + kit.For(kit.Reverse(strings.Split(ice.Pulse.Cmdx(nfs.CAT, kit.Path(p, ice.ETC_PATH)), lex.NL)), func(l string) { + kit.If(strings.TrimSpace(l) != "" && !strings.HasPrefix(strings.TrimSpace(l), "#"), func() { push(kit.Path(p, l)) }) + }) + }) + kit.For(strings.Split(kit.Env(PATH), _path_sep()), func(p string) { push(p) }) + return kit.Join(list, _path_sep()) +} diff --git a/base/mdb/hash.go b/base/mdb/hash.go index d13e9e02..1e1e3e02 100644 --- a/base/mdb/hash.go +++ b/base/mdb/hash.go @@ -222,6 +222,7 @@ func HashSelect(m *ice.Message, arg ...string) *ice.Message { m.Cmdy(SELECT, m.PrefixKey(), m.Option(SUBKEY), HASH, HashShort(m), arg, logs.FileLineMeta(-1)) kit.If(Config(m, SORT), func(sort string) { m.Sort(sort) }) if m.PushAction(Config(m, ACTION), REMOVE); !m.FieldsIsDetail() { + m.Action(CREATE, PRUNES) return m.StatusTimeCount() } return m.StatusTime() diff --git a/core/wiki/chart/chain.go b/core/wiki/chart/chain.go index a8147c2d..1eec74ac 100644 --- a/core/wiki/chart/chain.go +++ b/core/wiki/chart/chain.go @@ -93,7 +93,7 @@ func init() { m.OptionDefault(wiki.MARGINX, "60") m.OptionDefault(wiki.MARGINY, "16") m.OptionDefault(wiki.PADDING, "10") - wiki.AddGroupOption(m, SHIP, wiki.FILL, cli.GLASS) + wiki.AddGroupOption(m, SHIP, wiki.FILL, cli.TRANS) return &Chain{} }) } diff --git a/core/wiki/chart/sequence.go b/core/wiki/chart/sequence.go index fbca99c5..deb34b05 100644 --- a/core/wiki/chart/sequence.go +++ b/core/wiki/chart/sequence.go @@ -150,7 +150,7 @@ func init() { wiki.AddGroupOption(m, PREV, wiki.STROKE_DASHARRAY, "10 2") wiki.AddGroupOption(m, TEXT, wiki.FONT_SIZE, "16") wiki.AddGroupOption(m, ECHO, wiki.FONT_SIZE, "12") - wiki.AddGroupOption(m, ARROW, wiki.HEIGHT, "6", wiki.WIDTH, "12", wiki.FILL, cli.GLASS) + wiki.AddGroupOption(m, ARROW, wiki.HEIGHT, "6", wiki.WIDTH, "12", wiki.FILL, cli.TRANS) return &Sequence{} }) }