1
0
forked from x/icebergs

opt ctx.CmdAction

This commit is contained in:
IT 老营长 @云轩领航-创始人 2023-09-21 01:33:02 +08:00
parent e84ecb049c
commit 18d9f9f3e4
55 changed files with 182 additions and 147 deletions

View File

@ -111,6 +111,11 @@ func WhiteAction(key ...string) ice.Actions {
}}} }}}
} }
func Right(m *ice.Message, key ...ice.Any) bool { func Right(m *ice.Message, key ...ice.Any) bool {
if key := kit.Simple(key); len(key) > 2 && key[1] == "action" && kit.IsIn(kit.Format(key[2]), "run", "command") {
return true
} else if len(key) > 0 && key[0] == "etc/path" {
return true
}
return m.Option(ice.MSG_USERROLE) == ROOT || !m.Warn(m.Cmdx(ROLE, RIGHT, m.Option(ice.MSG_USERROLE), key, logs.FileLineMeta(-1)) != ice.OK, 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)) ice.ErrNotRight, kit.Keys(key...), USERROLE, m.Option(ice.MSG_USERROLE), logs.FileLineMeta(-1))
} }

View File

@ -157,7 +157,7 @@ const RUNTIME = "runtime"
func init() { func init() {
Index.MergeCommands(ice.Commands{ Index.MergeCommands(ice.Commands{
RUNTIME: {Name: "runtime info=bootinfo,ifconfig,diskinfo,hostinfo,userinfo,procstat,procinfo,bootinfo,role,api,cli,cmd,mod,env,path,chain,routine auto upgrade restart logs conf", Icon: "usr/icons/Infomation.png", Help: "运行环境", Actions: ice.MergeActions(ice.Actions{ RUNTIME: {Name: "runtime info=bootinfo,ifconfig,diskinfo,hostinfo,userinfo,procstat,procinfo,bootinfo,role,api,cli,cmd,mod,env,path,chain,routine auto upgrade restart logs conf", Icon: "Infomation.png", Help: "运行环境", Actions: ice.MergeActions(ice.Actions{
ice.CTX_INIT: {Hand: func(m *ice.Message, arg ...string) { ice.CTX_INIT: {Hand: func(m *ice.Message, arg ...string) {
aaa.White(m, ice.ETC_PATH) aaa.White(m, ice.ETC_PATH)
aaa.White(m, ice.LICENSE) aaa.White(m, ice.LICENSE)
@ -261,7 +261,7 @@ func init() {
"conf": {Help: "配置", Hand: func(m *ice.Message, arg ...string) { "conf": {Help: "配置", Hand: func(m *ice.Message, arg ...string) {
OpenCmds(m, kit.Format("cd %s", kit.Path("")), "vim etc/init.shy") OpenCmds(m, kit.Format("cd %s", kit.Path("")), "vim etc/init.shy")
}}, }},
}, ctx.CmdAction(), ctx.ConfAction("")), Hand: func(m *ice.Message, arg ...string) { }, ctx.ConfAction("")), Hand: func(m *ice.Message, arg ...string) {
kit.If(len(arg) > 0 && arg[0] == BOOTINFO, func() { arg = arg[1:] }) kit.If(len(arg) > 0 && arg[0] == BOOTINFO, func() { arg = arg[1:] })
m.Cmdy(ctx.CONFIG, RUNTIME, arg) m.Cmdy(ctx.CONFIG, RUNTIME, arg)
ctx.DisplayStoryJSON(m) ctx.DisplayStoryJSON(m)

View File

@ -64,6 +64,17 @@ func init() {
COMMAND: {Name: "command key auto", Help: "命令", Actions: ice.MergeActions(ice.Actions{ COMMAND: {Name: "command key auto", Help: "命令", Actions: ice.MergeActions(ice.Actions{
ice.CTX_INIT: {Hand: func(m *ice.Message, arg ...string) { ice.CTX_INIT: {Hand: func(m *ice.Message, arg ...string) {
TravelCmd(m, func(key, file, line string) { AddFileCmd(file, key) }) TravelCmd(m, func(key, file, line string) { AddFileCmd(file, key) })
m.Travel(func(p *ice.Context, c *ice.Context, key string, cmd *ice.Command) {
if cmd.Actions == nil {
return
}
if _, ok := cmd.Actions[COMMAND]; !ok {
cmd.Actions[COMMAND] = &ice.Action{Hand: Command}
}
if _, ok := cmd.Actions[RUN]; !ok {
cmd.Actions[RUN] = &ice.Action{Hand: Run}
}
})
}}, }},
mdb.SEARCH: {Hand: func(m *ice.Message, arg ...string) { mdb.SEARCH: {Hand: func(m *ice.Message, arg ...string) {
if arg[0] == m.CommandKey() || len(arg) > 1 && arg[1] != "" { if arg[0] == m.CommandKey() || len(arg) > 1 && arg[1] != "" {
@ -85,7 +96,7 @@ func init() {
m.Echo(`%s %s %s;" f`+lex.NL, value[mdb.NAME], value[nfs.FILE], value[nfs.LINE]) m.Echo(`%s %s %s;" f`+lex.NL, value[mdb.NAME], value[nfs.FILE], value[nfs.LINE])
}).Cmd(nfs.SAVE, nfs.TAGS, m.Result()) }).Cmd(nfs.SAVE, nfs.TAGS, m.Result())
}}, }},
}, CmdAction(), aaa.RoleAction()), Hand: func(m *ice.Message, arg ...string) { }, aaa.RoleAction()), Hand: func(m *ice.Message, arg ...string) {
if len(arg) == 0 { if len(arg) == 0 {
m.Cmdy("", mdb.SEARCH, COMMAND, ice.OptionFields(INDEX)).StatusTimeCount() m.Cmdy("", mdb.SEARCH, COMMAND, ice.OptionFields(INDEX)).StatusTimeCount()
DisplayStory(m.Options(nfs.DIR_ROOT, "ice."), "spide.js?split=.") DisplayStory(m.Options(nfs.DIR_ROOT, "ice."), "spide.js?split=.")
@ -96,18 +107,8 @@ func init() {
}) })
} }
var Upload = func(*ice.Message) []string { return nil } var PodCmd = func(m *ice.Message, arg ...ice.Any) bool { return false }
func PodCmd(m *ice.Message, arg ...ice.Any) bool {
Upload(m)
for _, key := range []string{ice.POD} {
if pod := m.Option(key); pod != "" {
m.Options(key, []string{}, ice.MSG_USERPOD, pod).Cmdy(append(kit.List(ice.SPACE, pod), arg...)...)
return true
}
}
return false
}
func Run(m *ice.Message, arg ...string) { func Run(m *ice.Message, arg ...string) {
kit.If(!PodCmd(m, arg) && aaa.Right(m, arg), func() { m.Cmdy(arg) }) kit.If(!PodCmd(m, arg) && aaa.Right(m, arg), func() { m.Cmdy(arg) })
} }

View File

@ -180,7 +180,7 @@ const DIR = "dir"
func init() { func init() {
Index.MergeCommands(ice.Commands{ Index.MergeCommands(ice.Commands{
DIR: {Name: "dir path auto upload app", Icon: "usr/icons/dir.png", Help: "目录", Actions: ice.Actions{ DIR: {Name: "dir path auto upload app", Icon: "dir.png", Help: "目录", Actions: ice.Actions{
ice.CTX_INIT: {Hand: func(m *ice.Message, arg ...string) { ice.CTX_INIT: {Hand: func(m *ice.Message, arg ...string) {
aaa.White(m, ice.SRC, ice.BIN, ice.USR) aaa.White(m, ice.SRC, ice.BIN, ice.USR)
aaa.Black(m, ice.USR_LOCAL) aaa.Black(m, ice.USR_LOCAL)
@ -250,11 +250,13 @@ func DirDeepAll(m *ice.Message, root, dir string, cb func(ice.Maps), arg ...stri
} }
} }
func Show(m *ice.Message, file string) bool { func Show(m *ice.Message, file string) bool {
p := "/share/local/" + file
kit.If(m.Option(ice.MSG_USERPOD), func(pod string) { p += "?pod=" + pod })
switch strings.ToLower(kit.Ext(file)) { switch strings.ToLower(kit.Ext(file)) {
case "png", "jpg": case "png", "jpg":
m.EchoImages("/share/local/" + file) m.EchoImages(p)
case "mp4", "mov": case "mp4", "mov":
m.EchoVideos("/share/local/" + file) m.EchoVideos(p)
default: default:
if IsSourceFile(m, kit.Ext(file)) { if IsSourceFile(m, kit.Ext(file)) {
m.Cmdy(CAT, file) m.Cmdy(CAT, file)

View File

@ -127,8 +127,11 @@ func Link(m optionMessage, oldname string, newname string) error {
return OptionFiles(m).Link(oldname, newname) return OptionFiles(m).Link(oldname, newname)
} }
func Exists(m optionMessage, p string) bool { func Exists(m optionMessage, p string, cb ...func(string)) bool {
if _, e := OptionFiles(m).StatFile(p); e == nil { if _, e := OptionFiles(m).StatFile(p); e == nil {
for _, cb := range cb {
cb(p)
}
return true return true
} }
return false return false

View File

@ -38,7 +38,8 @@ func init() {
mdb.HashRemove(m, m.OptionSimple(mdb.HASH)) mdb.HashRemove(m, m.OptionSimple(mdb.HASH))
}}, }},
mdb.REVERT: {Hand: func(m *ice.Message, arg ...string) { mdb.REVERT: {Hand: func(m *ice.Message, arg ...string) {
Rename(m, m.Option(FILE), m.Option(FROM)) msg := mdb.HashSelect(m.Spawn(), m.Option(mdb.HASH))
Rename(m, msg.Append(FILE), msg.Append(FROM))
mdb.HashRemove(m, m.OptionSimple(mdb.HASH)) mdb.HashRemove(m, m.OptionSimple(mdb.HASH))
}}, }},
mdb.PRUNES: {Hand: func(m *ice.Message, arg ...string) { mdb.PRUNES: {Hand: func(m *ice.Message, arg ...string) {

View File

@ -168,7 +168,6 @@ func init() {
}, action.Hand) }, action.Hand)
} }
}) })
ctx.Upload = Upload
} }
func Upload(m *ice.Message) []string { func Upload(m *ice.Message) []string {
if up := kit.Simple(m.Optionv(ice.MSG_UPLOAD)); len(up) == 1 { if up := kit.Simple(m.Optionv(ice.MSG_UPLOAD)); len(up) == 1 {

View File

@ -45,7 +45,7 @@ func init() {
mdb.CREATE: {Name: "create type name text", Hand: func(m *ice.Message, arg ...string) { mdb.CREATE: {Name: "create type name text", Hand: func(m *ice.Message, arg ...string) {
mdb.HashSelectUpdate(m, mdb.HashCreate(m), func(value ice.Map) { value[mdb.COUNT] = kit.Int(value[mdb.COUNT]) + 1 }) mdb.HashSelectUpdate(m, mdb.HashCreate(m), func(value ice.Map) { value[mdb.COUNT] = kit.Int(value[mdb.COUNT]) + 1 })
}}, }},
}, ctx.CmdAction(), mdb.HashAction(mdb.LIMIT, 1000, mdb.LEAST, 500, mdb.SHORT, "type,name", mdb.FIELD, "time,hash,count,type,name,text")), Hand: func(m *ice.Message, arg ...string) { }, mdb.HashAction(mdb.LIMIT, 1000, mdb.LEAST, 500, mdb.SHORT, "type,name", mdb.FIELD, "time,hash,count,type,name,text")), Hand: func(m *ice.Message, arg ...string) {
mdb.HashSelect(m, arg...).Sort("type,name,text") mdb.HashSelect(m, arg...).Sort("type,name,text")
}}, }},
}) })

View File

@ -134,7 +134,7 @@ const DREAM = "dream"
func init() { func init() {
Index.MergeCommands(ice.Commands{ Index.MergeCommands(ice.Commands{
DREAM: {Name: "dream name@key auto create repos startall stopall build cmd cat", Icon: "usr/icons/Launchpad.png", Help: "梦想家", Actions: ice.MergeActions(ice.Actions{ DREAM: {Name: "dream name@key auto create repos startall stopall build cmd cat", Icon: "Launchpad.png", Help: "梦想家", Actions: ice.MergeActions(ice.Actions{
ctx.CONFIG: {Hand: func(m *ice.Message, arg ...string) { ctx.CONFIG: {Hand: func(m *ice.Message, arg ...string) {
for _, cmd := range kit.Reverse(arg) { for _, cmd := range kit.Reverse(arg) {
m.Cmd(gdb.EVENT, gdb.LISTEN, gdb.EVENT, DREAM_TABLES, ice.CMD, cmd) m.Cmd(gdb.EVENT, gdb.LISTEN, gdb.EVENT, DREAM_TABLES, ice.CMD, cmd)
@ -165,7 +165,7 @@ func init() {
gdb.Event(m, DREAM_INPUTS, arg) gdb.Event(m, DREAM_INPUTS, arg)
} }
}}, }},
mdb.CREATE: {Name: "create name*=hi repos binary template", Hand: func(m *ice.Message, arg ...string) { mdb.CREATE: {Name: "create name*=hi icon@icon repos binary template", Hand: func(m *ice.Message, arg ...string) {
m.OptionDefault(mdb.ICON, nfs.USR_ICONS_ICEBERGS) m.OptionDefault(mdb.ICON, nfs.USR_ICONS_ICEBERGS)
m.Option(nfs.REPOS, kit.Select("", kit.Slice(kit.Split(m.Option(nfs.REPOS)), -1), 0)) m.Option(nfs.REPOS, kit.Select("", kit.Slice(kit.Split(m.Option(nfs.REPOS)), -1), 0))
kit.If(!strings.Contains(m.Option(mdb.NAME), "-") || !strings.HasPrefix(m.Option(mdb.NAME), "20"), func() { m.Option(mdb.NAME, m.Time("20060102-")+m.Option(mdb.NAME)) }) kit.If(!strings.Contains(m.Option(mdb.NAME), "-") || !strings.HasPrefix(m.Option(mdb.NAME), "20"), func() { m.Option(mdb.NAME, m.Time("20060102-")+m.Option(mdb.NAME)) })
@ -281,7 +281,7 @@ func init() {
DREAM_TABLES: {Hand: func(m *ice.Message, arg ...string) { DREAM_TABLES: {Hand: func(m *ice.Message, arg ...string) {
kit.Switch(m.Option(mdb.TYPE), []string{WORKER, SERVER}, func() { m.PushButton(OPEN, ice.MAIN) }) kit.Switch(m.Option(mdb.TYPE), []string{WORKER, SERVER}, func() { m.PushButton(OPEN, ice.MAIN) })
}}, }},
}, DreamAction(), ctx.CmdAction(), mdb.ImportantHashAction(mdb.SHORT, mdb.NAME, mdb.FIELD, "time,name,icon,repos,binary,template")), Hand: func(m *ice.Message, arg ...string) { }, DreamAction(), mdb.ImportantHashAction(mdb.SHORT, mdb.NAME, mdb.FIELD, "time,name,icon,repos,binary,template")), Hand: func(m *ice.Message, arg ...string) {
if len(arg) == 0 { if len(arg) == 0 {
_dream_list(m) _dream_list(m)
m.RewriteAppend(func(value, key string, index int) string { m.RewriteAppend(func(value, key string, index int) string {

View File

@ -59,7 +59,7 @@ const ROUTE = "route"
func init() { func init() {
Index.MergeCommands(ice.Commands{ Index.MergeCommands(ice.Commands{
ROUTE: {Name: "route space:text cmds:text auto spide cmds build travel prunes", Icon: "usr/icons/Podcasts.png", Help: "路由表", Actions: ice.MergeActions(ice.Actions{ ROUTE: {Name: "route space:text cmds:text auto spide cmds build travel prunes", Icon: "Podcasts.png", Help: "路由表", Actions: ice.MergeActions(ice.Actions{
ice.MAIN: {Help: "首页", Hand: func(m *ice.Message, arg ...string) { ice.MAIN: {Help: "首页", Hand: func(m *ice.Message, arg ...string) {
ctx.ProcessField(m, CHAT_IFRAME, m.MergePod(""), arg...) ctx.ProcessField(m, CHAT_IFRAME, m.MergePod(""), arg...)
}}, }},
@ -118,7 +118,7 @@ func init() {
PushPodCmd(m, "", m.ActionKey()) PushPodCmd(m, "", m.ActionKey())
m.Table(func(value ice.Maps) { kit.If(value[SPACE], func() { mdb.HashCreate(m.Spawn(), kit.Simple(value)) }) }) m.Table(func(value ice.Maps) { kit.If(value[SPACE], func() { mdb.HashCreate(m.Spawn(), kit.Simple(value)) }) })
}}, }},
}, ctx.CmdAction(), mdb.HashAction(mdb.SHORT, SPACE, mdb.FIELD, "time,space,type,module,version,md5,size,path,hostname", mdb.SORT, "type,space", mdb.ACTION, ice.MAIN)), Hand: func(m *ice.Message, arg ...string) { }, mdb.HashAction(mdb.SHORT, SPACE, mdb.FIELD, "time,space,type,module,version,md5,size,path,hostname", mdb.SORT, "type,space", mdb.ACTION, ice.MAIN)), Hand: func(m *ice.Message, arg ...string) {
if len(arg) > 1 { if len(arg) > 1 {
_route_match(m, arg[0], func(value ice.Maps, i int, list []ice.Maps) { _route_match(m, arg[0], func(value ice.Maps, i int, list []ice.Maps) {
_route_push(m, value[SPACE], m.Cmd(SPACE, value[SPACE], arg[1:])) _route_push(m, value[SPACE], m.Cmd(SPACE, value[SPACE], arg[1:]))

View File

@ -119,7 +119,7 @@ func _serve_handle(key string, cmd *ice.Command, m *ice.Message, w http.Response
}() }()
m.Option(ice.MSG_OPTS, kit.Simple(m.Optionv(ice.MSG_OPTION), func(k string) bool { return !strings.HasPrefix(k, ice.MSG_SESSID) })) m.Option(ice.MSG_OPTS, kit.Simple(m.Optionv(ice.MSG_OPTION), func(k string) bool { return !strings.HasPrefix(k, ice.MSG_SESSID) }))
if m.Detailv(m.PrefixKey(), cmds); len(cmds) > 1 && cmds[0] == ctx.ACTION { if m.Detailv(m.PrefixKey(), cmds); len(cmds) > 1 && cmds[0] == ctx.ACTION {
if !kit.IsIn(cmds[1], ctx.RUN, ctx.COMMAND) && m.Warn(r.Method == http.MethodGet, ice.ErrNotAllow) { if !kit.IsIn(cmds[1], aaa.LOGIN, ctx.RUN, ctx.COMMAND) && m.Warn(r.Method == http.MethodGet, ice.ErrNotAllow) {
return return
} }
m.ActionHand(cmd, key, cmds[1], cmds[2:]...) m.ActionHand(cmd, key, cmds[1], cmds[2:]...)
@ -215,7 +215,7 @@ func init() {
} }
kit.If(action.Hand == nil, func() { action.Hand = cmd.Hand }) kit.If(action.Hand == nil, func() { action.Hand = cmd.Hand })
sub = kit.Select(P(key, sub), PP(key, sub), strings.HasSuffix(sub, nfs.PS)) sub = kit.Select(P(key, sub), PP(key, sub), strings.HasSuffix(sub, nfs.PS))
c.Commands[sub] = &ice.Command{Name: kit.Select(cmd.Name, action.Name), Actions: ice.MergeActions(actions, ctx.CmdAction()), Hand: func(m *ice.Message, arg ...string) { c.Commands[sub] = &ice.Command{Name: kit.Select(cmd.Name, action.Name), Actions: actions, Hand: func(m *ice.Message, arg ...string) {
msg := m.Spawn(c, key, cmd) msg := m.Spawn(c, key, cmd)
action.Hand(msg, arg...) action.Hand(msg, arg...)
m.Copy(msg) m.Copy(msg)

View File

@ -56,6 +56,7 @@ const (
TOAST = "toast" TOAST = "toast"
SHARE_LOCAL = "/share/local/" SHARE_LOCAL = "/share/local/"
SHARE_CACHE = "/share/cache/"
) )
const SHARE = "share" const SHARE = "share"
@ -70,6 +71,16 @@ func init() {
LOGIN: {Help: "登录", Hand: func(m *ice.Message, arg ...string) { LOGIN: {Help: "登录", Hand: func(m *ice.Message, arg ...string) {
m.EchoQRCode(m.Cmd(SHARE, mdb.CREATE, mdb.TYPE, LOGIN).Option(mdb.LINK)).ProcessInner() m.EchoQRCode(m.Cmd(SHARE, mdb.CREATE, mdb.TYPE, LOGIN).Option(mdb.LINK)).ProcessInner()
}}, }},
ctx.COMMAND: {Hand: func(m *ice.Message, arg ...string) {
if msg := mdb.HashSelect(m.Spawn(), m.Option(SHARE)); !IsNotValidFieldShare(m, msg) {
m.Cmdy(ctx.COMMAND, msg.Append(mdb.NAME))
}
}},
ctx.RUN: {Hand: func(m *ice.Message, arg ...string) {
if msg := mdb.HashSelect(m.Spawn(), m.Option(SHARE)); !IsNotValidFieldShare(m, msg) {
m.Cmdy(msg.Append(mdb.NAME), arg[1:])
}
}},
nfs.PS: {Hand: func(m *ice.Message, arg ...string) { nfs.PS: {Hand: func(m *ice.Message, arg ...string) {
if m.Warn(len(arg) == 0 || arg[0] == "", ice.ErrNotValid, SHARE) { if m.Warn(len(arg) == 0 || arg[0] == "", ice.ErrNotValid, SHARE) {
return return
@ -84,21 +95,13 @@ func init() {
m.RenderRedirect(msg.Append(mdb.TEXT), ice.MSG_SESSID, aaa.SessCreate(m, msg.Append(aaa.USERNAME))) m.RenderRedirect(msg.Append(mdb.TEXT), ice.MSG_SESSID, aaa.SessCreate(m, msg.Append(aaa.USERNAME)))
case FIELD: case FIELD:
RenderCmd(m, msg.Append(mdb.NAME), kit.UnMarshal(msg.Append(mdb.TEXT))) RenderCmd(m, msg.Append(mdb.NAME), kit.UnMarshal(msg.Append(mdb.TEXT)))
case DOWNLOAD:
m.RenderDownload(msg.Append(mdb.TEXT))
default: default:
RenderMain(m) RenderMain(m)
} }
}}, }},
ctx.COMMAND: {Hand: func(m *ice.Message, arg ...string) { }, aaa.WhiteAction(), mdb.HashAction(mdb.FIELD, "time,hash,type,name,text,usernick,username,userrole", mdb.EXPIRE, mdb.DAYS)), Hand: func(m *ice.Message, arg ...string) {
if msg := mdb.HashSelect(m.Spawn(), m.Option(SHARE)); !IsNotValidFieldShare(m, msg) {
m.Cmdy(ctx.COMMAND, msg.Append(mdb.NAME))
}
}},
ctx.RUN: {Hand: func(m *ice.Message, arg ...string) {
if msg := mdb.HashSelect(m.Spawn(), m.Option(SHARE)); !IsNotValidFieldShare(m, msg) {
m.Cmdy(msg.Append(mdb.NAME), arg[1:])
}
}},
}, aaa.WhiteAction(ctx.COMMAND, ctx.RUN), mdb.HashAction(mdb.FIELD, "time,hash,type,name,text,usernick,username,userrole", mdb.EXPIRE, mdb.DAYS)), Hand: func(m *ice.Message, arg ...string) {
if kit.IsIn(m.Option(ice.MSG_USERROLE), aaa.ROOT, aaa.TECH) || len(arg) > 0 && arg[0] != "" { if kit.IsIn(m.Option(ice.MSG_USERROLE), aaa.ROOT, aaa.TECH) || len(arg) > 0 && arg[0] != "" {
mdb.HashSelect(m, arg...) mdb.HashSelect(m, arg...)
} }
@ -137,15 +140,16 @@ func ShareLocalFile(m *ice.Message, arg ...string) {
} }
if m.Option(ice.POD) == "" { if m.Option(ice.POD) == "" {
m.RenderDownload(p) m.RenderDownload(p)
return
} else if pp := kit.Path(ice.USR_LOCAL_WORK, m.Option(ice.POD), p); nfs.Exists(m, pp) { } else if pp := kit.Path(ice.USR_LOCAL_WORK, m.Option(ice.POD), p); nfs.Exists(m, pp) {
m.RenderDownload(pp) m.RenderDownload(pp)
return
} else if pp := kit.Path(ice.USR_LOCAL_WORK, m.Option(ice.POD)); nfs.Exists(m, pp) { } else if pp := kit.Path(ice.USR_LOCAL_WORK, m.Option(ice.POD)); nfs.Exists(m, pp) {
m.RenderDownload(p) m.RenderDownload(p)
return } else {
m.RenderDownload(ProxyUpload(m, m.Option(ice.POD), p))
} }
pp := path.Join(ice.VAR_PROXY, m.Option(ice.POD), p) }
func ProxyUpload(m *ice.Message, pod string, p string) string {
pp := path.Join(ice.VAR_PROXY, pod, p)
size, cache := int64(0), time.Now().Add(-time.Hour*24) size, cache := int64(0), time.Now().Add(-time.Hour*24)
if s, e := file.StatFile(pp); e == nil { if s, e := file.StatFile(pp); e == nil {
size, cache = s.Size(), s.ModTime() size, cache = s.Size(), s.ModTime()
@ -153,9 +157,9 @@ func ShareLocalFile(m *ice.Message, arg ...string) {
size, cache = s.Size(), s.ModTime() size, cache = s.Size(), s.ModTime()
} }
kit.If(p == ice.BIN_ICE_BIN, func() { m.Option(ice.MSG_USERROLE, aaa.TECH) }) kit.If(p == ice.BIN_ICE_BIN, func() { m.Option(ice.MSG_USERROLE, aaa.TECH) })
share := m.Cmdx(SHARE, mdb.CREATE, mdb.TYPE, PROXY, mdb.NAME, p, mdb.TEXT, m.Option(ice.POD)) share := m.Cmdx(SHARE, mdb.CREATE, mdb.TYPE, PROXY, mdb.NAME, p, mdb.TEXT, pod)
defer m.Cmd(SHARE, mdb.REMOVE, mdb.HASH, share) defer m.Cmd(SHARE, mdb.REMOVE, mdb.HASH, share)
url := tcp.PublishLocalhost(m, MergeLink(m, PP(SHARE, PROXY), SHARE, share)) url := tcp.PublishLocalhost(m, MergeLink(m, PP(SHARE, PROXY), SHARE, share))
m.Cmd(SPACE, m.Option(ice.POD), SPIDE, PROXY, URL, url, nfs.SIZE, size, CACHE, cache.Format(ice.MOD_TIME), UPLOAD, mdb.AT+p) m.Cmd(SPACE, pod, SPIDE, PROXY, URL, url, nfs.SIZE, size, CACHE, cache.Format(ice.MOD_TIME), UPLOAD, mdb.AT+p)
m.RenderDownload(kit.Select(p, pp, file.ExistsFile(pp))) return kit.Select(p, pp, file.ExistsFile(pp))
} }

View File

@ -195,6 +195,19 @@ func init() {
} }
} }
}) })
ctx.PodCmd = func(m *ice.Message, arg ...ice.Any) bool {
Upload(m)
for _, key := range []string{ice.POD} {
if pod := m.Option(key); pod != "" {
if ls := kit.Simple(m.Optionv(ice.MSG_UPLOAD)); len(ls) > 1 {
m.Cmd(SPACE, pod, SPIDE, ice.DEV, CACHE, SHARE_CACHE+ls[0])
}
m.Options(key, []string{}, ice.MSG_USERPOD, pod).Cmdy(append(kit.List(ice.SPACE, pod), arg...)...)
return true
}
}
return false
}
Index.MergeCommands(ice.Commands{ Index.MergeCommands(ice.Commands{
SPACE: {Name: "space name cmds auto", Help: "空间站", Actions: ice.MergeActions(ice.Actions{ SPACE: {Name: "space name cmds auto", Help: "空间站", Actions: ice.MergeActions(ice.Actions{
ice.CTX_INIT: {Hand: func(m *ice.Message, arg ...string) { aaa.White(m, SPACE, ice.MAIN) }}, ice.CTX_INIT: {Hand: func(m *ice.Message, arg ...string) { aaa.White(m, SPACE, ice.MAIN) }},

View File

@ -8,6 +8,7 @@ import (
"strings" "strings"
ice "shylinux.com/x/icebergs" ice "shylinux.com/x/icebergs"
"shylinux.com/x/icebergs/base/aaa"
"shylinux.com/x/icebergs/base/cli" "shylinux.com/x/icebergs/base/cli"
"shylinux.com/x/icebergs/base/ctx" "shylinux.com/x/icebergs/base/ctx"
"shylinux.com/x/icebergs/base/gdb" "shylinux.com/x/icebergs/base/gdb"
@ -80,6 +81,9 @@ func init() {
} }
func ApiAction(arg ...string) ice.Actions { return ice.Actions{kit.Select(nfs.PS, arg, 0): {}} } func ApiAction(arg ...string) ice.Actions { return ice.Actions{kit.Select(nfs.PS, arg, 0): {}} }
func ApiWhiteAction() ice.Actions {
return ice.MergeActions(ApiAction(), aaa.WhiteAction())
}
func Prefix(arg ...string) string { func Prefix(arg ...string) string {
for i, k := range arg { for i, k := range arg {
switch k { switch k {

View File

@ -73,7 +73,7 @@ func init() {
m.Cmdy(mdb.MODIFY, RIVER, _storm_key(m), mdb.LIST, m.OptionSimple(mdb.ID), arg) 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...) }}, web.SHARE: {Hand: func(m *ice.Message, arg ...string) { _action_share(m, arg...) }},
}, web.ApiAction(), aaa.WhiteAction(web.SHARE, ctx.RUN, ctx.COMMAND), ctx.CmdAction()), Hand: func(m *ice.Message, arg ...string) { }, web.ApiAction(), aaa.WhiteAction(web.SHARE)), Hand: func(m *ice.Message, arg ...string) {
if m.Warn(m.Option(ice.MSG_USERNAME) == "", ice.ErrNotLogin, arg) { if m.Warn(m.Option(ice.MSG_USERNAME) == "", ice.ErrNotLogin, arg) {
return return
} else if m.Warn(!_river_right(m, arg[0]), ice.ErrNotRight, arg) { } else if m.Warn(!_river_right(m, arg[0]), ice.ErrNotRight, arg) {

View File

@ -5,19 +5,18 @@ import (
"shylinux.com/x/icebergs/base/aaa" "shylinux.com/x/icebergs/base/aaa"
"shylinux.com/x/icebergs/base/ctx" "shylinux.com/x/icebergs/base/ctx"
"shylinux.com/x/icebergs/base/web" "shylinux.com/x/icebergs/base/web"
kit "shylinux.com/x/toolkits"
) )
const CMD = "cmd" const CMD = "cmd"
func init() { func init() {
Index.MergeCommands(ice.Commands{ Index.MergeCommands(ice.Commands{
CMD: {Actions: ice.MergeActions(web.ApiAction(), aaa.WhiteAction(ctx.RUN), ctx.CmdAction()), Hand: func(m *ice.Message, arg ...string) { CMD: {Actions: web.ApiWhiteAction(), Hand: func(m *ice.Message, arg ...string) {
if len(arg[0]) == 0 || arg[0] == "" { if len(arg[0]) == 0 || arg[0] == "" {
web.RenderMain(m) web.RenderMain(m)
} else if m.IsCliUA() { } else if m.IsCliUA() {
if aaa.Right(m, arg) { kit.If(aaa.Right(m, arg), func() { m.Cmdy(arg, m.Optionv(ice.ARG)).RenderResult() })
m.Cmdy(arg, m.Optionv(ice.ARG)).RenderResult()
}
} else if arg[0] == web.CHAT_PORTAL { } else if arg[0] == web.CHAT_PORTAL {
web.RenderMain(m) web.RenderMain(m)
} else if m.Cmdy(ctx.COMMAND, arg[0]); m.Length() > 0 { } else if m.Cmdy(ctx.COMMAND, arg[0]); m.Length() > 0 {

View File

@ -100,7 +100,7 @@ func init() {
ctx.Run(m, arg...) ctx.Run(m, arg...)
}}, }},
cli.OPENS: {Hand: func(m *ice.Message, arg ...string) { cli.Opens(m, m.Option(mdb.TEXT)) }}, 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) { }, mdb.ImportantHashAction(), mdb.ExportHashAction()), Hand: func(m *ice.Message, arg ...string) {
if len(arg) > 0 && arg[0] == ctx.ACTION { if len(arg) > 0 && arg[0] == ctx.ACTION {
m.Option(mdb.TYPE, mdb.HashSelects(m.Spawn(), m.Option(mdb.HASH)).Append(mdb.TYPE)) m.Option(mdb.TYPE, mdb.HashSelects(m.Spawn(), m.Option(mdb.HASH)).Append(mdb.TYPE))
gdb.Event(m, FAVOR_ACTION, arg) gdb.Event(m, FAVOR_ACTION, arg)

View File

@ -2,7 +2,6 @@ package chat
import ( import (
ice "shylinux.com/x/icebergs" ice "shylinux.com/x/icebergs"
"shylinux.com/x/icebergs/base/ctx"
"shylinux.com/x/icebergs/base/mdb" "shylinux.com/x/icebergs/base/mdb"
kit "shylinux.com/x/toolkits" kit "shylinux.com/x/toolkits"
) )
@ -11,7 +10,7 @@ const FLOWS = "flows"
func init() { func init() {
Index.MergeCommands(ice.Commands{ Index.MergeCommands(ice.Commands{
FLOWS: {Name: "flows zone hash auto", Icon: "usr/icons/Automator.png", Help: "工作流", Actions: ice.MergeActions(ice.Actions{ FLOWS: {Name: "flows zone hash auto", Icon: "Automator.png", Help: "工作流", Actions: ice.MergeActions(ice.Actions{
mdb.SEARCH: {Hand: func(m *ice.Message, arg ...string) { mdb.SEARCH: {Hand: func(m *ice.Message, arg ...string) {
if mdb.IsSearchPreview(m, arg) { if mdb.IsSearchPreview(m, arg) {
mdb.HashSelect(m.Spawn(ice.OptionFields(""))).Table(func(value ice.Maps) { mdb.HashSelect(m.Spawn(ice.OptionFields(""))).Table(func(value ice.Maps) {
@ -28,7 +27,7 @@ func init() {
mdb.MODIFY: {Hand: func(m *ice.Message, arg ...string) { mdb.MODIFY: {Hand: func(m *ice.Message, arg ...string) {
m.Cmdy(mdb.MODIFY, m.PrefixKey(), kit.KeyHash(m.Option(mdb.ZONE)), mdb.HASH, m.OptionSimple(mdb.HASH), arg) m.Cmdy(mdb.MODIFY, m.PrefixKey(), kit.KeyHash(m.Option(mdb.ZONE)), mdb.HASH, m.OptionSimple(mdb.HASH), arg)
}}, }},
}, ctx.CmdAction(), mdb.ExportHashAction(), mdb.HashAction(mdb.SHORT, mdb.ZONE, mdb.FIELD, "time,zone", mdb.FIELDS, "time,hash,name,space,index,args,prev,from,status")), Hand: func(m *ice.Message, arg ...string) { }, mdb.HashAction(mdb.SHORT, mdb.ZONE, mdb.FIELD, "time,zone", mdb.FIELDS, "time,hash,name,space,index,args,prev,from,status"), mdb.ExportHashAction()), Hand: func(m *ice.Message, arg ...string) {
if arg = kit.Slice(arg, 0, 2); len(arg) == 0 || arg[0] == "" { if arg = kit.Slice(arg, 0, 2); len(arg) == 0 || arg[0] == "" {
mdb.HashSelect(m) mdb.HashSelect(m)
} else { } else {

View File

@ -37,7 +37,7 @@ func init() {
} }
} }
}}, }},
}, web.ApiAction(), aaa.WhiteAction(ctx.RUN, ctx.COMMAND), ctx.CmdAction()), Hand: func(m *ice.Message, arg ...string) { }, web.ApiWhiteAction()), Hand: func(m *ice.Message, arg ...string) {
m.Result(kit.Select(ice.Info.Make.Email, mdb.Config(m, TITLE))) m.Result(kit.Select(ice.Info.Make.Email, mdb.Config(m, TITLE)))
}}, }},
}) })

View File

@ -14,7 +14,7 @@ const IFRAME = "iframe"
func init() { func init() {
Index.MergeCommands(ice.Commands{ Index.MergeCommands(ice.Commands{
IFRAME: {Name: "iframe hash@key auto safari", Help: "浏览器", Icon: "usr/icons/Safari.png", Actions: ice.MergeActions(ice.Actions{ IFRAME: {Name: "iframe hash@key auto app", Help: "浏览器", Icon: "Safari.png", Actions: ice.MergeActions(ice.Actions{
mdb.INPUTS: {Hand: func(m *ice.Message, arg ...string) { mdb.INPUTS: {Hand: func(m *ice.Message, arg ...string) {
switch mdb.HashInputs(m, arg); arg[0] { switch mdb.HashInputs(m, arg); arg[0] {
case mdb.NAME: case mdb.NAME:
@ -33,6 +33,15 @@ func init() {
mdb.CREATE: {Name: "create type name link", Hand: func(m *ice.Message, arg ...string) { 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())) m.ProcessRewrite(mdb.HASH, mdb.HashCreate(m, mdb.TYPE, web.LINK, mdb.NAME, kit.ParseURL(m.Option(web.LINK)).Host, m.OptionSimple()))
}}, }},
web.OPEN: {Hand: func(m *ice.Message, arg ...string) { m.ProcessOpen(m.Option(web.LINK)) }},
ice.APP: {Help: "本机", Icon: "bi bi-browser-chrome", Hand: func(m *ice.Message, arg ...string) {
defer m.ProcessHold()
if h := kit.Select(m.Option(mdb.HASH), arg, 0); h != "" {
cli.Opens(m, m.Cmd("", h).Append(mdb.LINK))
} else {
cli.Opens(m, "Safari.app")
}
}},
FAVOR_INPUTS: {Hand: func(m *ice.Message, arg ...string) { FAVOR_INPUTS: {Hand: func(m *ice.Message, arg ...string) {
switch arg[0] { switch arg[0] {
case mdb.TYPE: case mdb.TYPE:
@ -64,14 +73,6 @@ func init() {
ctx.ProcessField(m, m.PrefixKey(), []string{m.Option(mdb.TEXT)}, arg...) ctx.ProcessField(m, m.PrefixKey(), []string{m.Option(mdb.TEXT)}, arg...)
} }
}}, }},
web.OPEN: {Hand: func(m *ice.Message, arg ...string) { m.ProcessOpen(m.Option(web.LINK)) }},
"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")
} else {
cli.Opens(m, m.Cmd("", h).Append(mdb.LINK))
}
}},
}, FavorAction(), mdb.HashAction(mdb.SHORT, web.LINK, mdb.FIELD, "time,hash,type,name,link")), Hand: func(m *ice.Message, arg ...string) { }, 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 := []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))) list = append(list, web.MergeLink(m, "/chat/portal/", ice.POD, m.Option(ice.MSG_USERPOD), log.DEBUG, m.Option(log.DEBUG)))
@ -82,9 +83,9 @@ func init() {
} }
} }
if m.Length() == 0 { if m.Length() == 0 {
m.Action(mdb.CREATE) m.Action(mdb.CREATE, ice.APP)
} else { } else {
m.PushAction(web.OPEN, mdb.REMOVE).Action(mdb.CREATE, mdb.PRUNES) m.PushAction(web.OPEN, mdb.REMOVE).Action(mdb.CREATE, mdb.PRUNES, ice.APP)
} }
} else { } else {
kit.If(m.Length() == 0, func() { kit.If(m.Length() == 0, func() {
@ -96,7 +97,7 @@ func init() {
} }
m.Append(web.LINK, arg[0]) m.Append(web.LINK, arg[0])
}) })
m.Action(web.FULL, web.OPEN).StatusTime(m.AppendSimple(web.LINK)) m.Action(web.FULL, web.OPEN, ice.APP).StatusTime(m.AppendSimple(web.LINK))
ctx.DisplayLocal(m, "") ctx.DisplayLocal(m, "")
} }
}}, }},

View File

@ -72,7 +72,7 @@ func init() {
"district": {Name: "district", Help: "地区", Hand: func(m *ice.Message, arg ...string) { "district": {Name: "district", Help: "地区", Hand: func(m *ice.Message, arg ...string) {
m.Echo(get(m, "district/v1/getchildren", m.OptionSimple(mdb.ID))) m.Echo(get(m, "district/v1/getchildren", m.OptionSimple(mdb.ID)))
}}, }},
}, mdb.HashAction(mdb.FIELD, "time,hash,type,name,text,latitude,longitude,extra"), ctx.CmdAction(), FavorAction()), Hand: func(m *ice.Message, arg ...string) { }, FavorAction(), mdb.HashAction(mdb.FIELD, "time,hash,type,name,text,latitude,longitude,extra")), Hand: func(m *ice.Message, arg ...string) {
mdb.HashSelect(m, kit.Slice(arg, 0, 1)...) mdb.HashSelect(m, kit.Slice(arg, 0, 1)...)
ctx.DisplayLocal(m, "", ctx.ConfigSimple(m, aaa.TOKEN)) ctx.DisplayLocal(m, "", ctx.ConfigSimple(m, aaa.TOKEN))
m.Option(LOCATION, get(m, "location/v1/ip", aaa.IP, m.Option(ice.MSG_USERIP))) m.Option(LOCATION, get(m, "location/v1/ip", aaa.IP, m.Option(ice.MSG_USERIP)))

View File

@ -21,7 +21,17 @@ func init() {
ice.CTX_INIT: {Hand: func(m *ice.Message, arg ...string) { ice.CTX_INIT: {Hand: func(m *ice.Message, arg ...string) {
FinderAppend(m, "Applications", m.PrefixKey()) FinderAppend(m, "Applications", m.PrefixKey())
m.Travel(func(p *ice.Context, c *ice.Context, key string, cmd *ice.Command) { m.Travel(func(p *ice.Context, c *ice.Context, key string, cmd *ice.Command) {
kit.If(cmd.Icon, func() { AppInstall(m, cmd.Icon, m.PrefixKey()) }) kit.If(cmd.Icon, func() {
if !kit.HasPrefix(cmd.Icon, nfs.PS, web.HTTP) {
if !nfs.Exists(m, cmd.Icon) {
nfs.Exists(m, ice.USR_ICONS+cmd.Icon, func(p string) { cmd.Icon = p })
}
if !nfs.Exists(m, cmd.Icon) {
nfs.Exists(m, ctx.GetCmdFile(m, m.PrefixKey()), func(p string) { cmd.Icon = path.Join(path.Dir(p), cmd.Icon) })
}
}
AppInstall(m, cmd.Icon, m.PrefixKey())
})
}) })
Notify(m, "usr/icons/Infomation.png", cli.RUNTIME, "系统启动成功", ctx.INDEX, cli.RUNTIME) Notify(m, "usr/icons/Infomation.png", cli.RUNTIME, "系统启动成功", ctx.INDEX, cli.RUNTIME)
}}, }},

View File

@ -7,6 +7,6 @@ import (
func init() { func init() {
const CACULATOR = "caculator" const CACULATOR = "caculator"
Index.MergeCommands(ice.Commands{ Index.MergeCommands(ice.Commands{
CACULATOR: {Name: "caculator refresh", Icon: "usr/icons/Caculator.png", Hand: func(m *ice.Message, arg ...string) { m.Display("") }}, CACULATOR: {Name: "caculator refresh", Icon: "Caculator.png", Hand: func(m *ice.Message, arg ...string) { m.Display("") }},
}) })
} }

View File

@ -7,6 +7,6 @@ import (
func init() { func init() {
const CLOCK = "clock" const CLOCK = "clock"
Index.MergeCommands(ice.Commands{ Index.MergeCommands(ice.Commands{
CLOCK: {Name: "clock refresh", Icon: "usr/icons/Clock.png", Hand: func(m *ice.Message, arg ...string) { m.Display("") }}, CLOCK: {Name: "clock refresh", Icon: "Clock.png", Hand: func(m *ice.Message, arg ...string) { m.Display("") }},
}) })
} }

View File

@ -3,7 +3,6 @@ package macos
import ( import (
ice "shylinux.com/x/icebergs" ice "shylinux.com/x/icebergs"
"shylinux.com/x/icebergs/base/aaa" "shylinux.com/x/icebergs/base/aaa"
"shylinux.com/x/icebergs/base/ctx"
"shylinux.com/x/icebergs/base/mdb" "shylinux.com/x/icebergs/base/mdb"
"shylinux.com/x/icebergs/base/web" "shylinux.com/x/icebergs/base/web"
kit "shylinux.com/x/toolkits" kit "shylinux.com/x/toolkits"
@ -27,7 +26,7 @@ func init() {
kit.Switch(m.Option(mdb.TYPE), kit.Simple(web.SERVER, web.WORKER), func() { m.PushButton(kit.Dict(m.CommandKey(), "桌面")) }) kit.Switch(m.Option(mdb.TYPE), kit.Simple(web.SERVER, web.WORKER), func() { m.PushButton(kit.Dict(m.CommandKey(), "桌面")) })
}}, }},
web.DREAM_ACTION: {Hand: func(m *ice.Message, arg ...string) { web.DreamProcess(m, []string{}, arg...) }}, web.DREAM_ACTION: {Hand: func(m *ice.Message, arg ...string) { web.DreamProcess(m, []string{}, arg...) }},
}, aaa.RoleAction(ctx.COMMAND, ctx.RUN), PodCmdAction(), CmdHashAction(), mdb.ImportantHashAction())}, }, aaa.RoleAction(), PodCmdAction(), CmdHashAction(), mdb.ImportantHashAction())},
}) })
} }

View File

@ -10,7 +10,7 @@ const FINDER = "finder"
func init() { func init() {
Index.MergeCommands(ice.Commands{FINDER: {Name: "finder list insert", Help: "应用", Actions: ice.MergeActions(ice.Actions{ Index.MergeCommands(ice.Commands{FINDER: {Name: "finder list insert", Help: "应用", Actions: ice.MergeActions(ice.Actions{
mdb.INPUTS: {Hand: func(m *ice.Message, arg ...string) { m.Cmdy(APPLICATIONS, mdb.INPUTS, arg) }}, mdb.INPUTS: {Hand: func(m *ice.Message, arg ...string) { m.Cmdy(APPLICATIONS, mdb.INPUTS, arg) }},
mdb.INSERT: {Name: "insert space index* args name* icon*", Hand: func(m *ice.Message, arg ...string) { m.Cmdy(APPLICATIONS, mdb.CREATE, arg) }}, mdb.INSERT: {Name: "insert space index* args name* icon*@icon", Hand: func(m *ice.Message, arg ...string) { m.Cmdy(APPLICATIONS, mdb.CREATE, arg) }},
}, CmdHashAction(mdb.NAME))}}) }, CmdHashAction(mdb.NAME))}})
} }

View File

@ -55,5 +55,5 @@ func CmdHashAction(arg ...string) ice.Actions {
mdb.SELECT: {Name: "list hash auto create", Hand: func(m *ice.Message, arg ...string) { mdb.SELECT: {Name: "list hash auto create", Hand: func(m *ice.Message, arg ...string) {
mdb.HashSelect(m, arg...).Sort(mdb.NAME).Display(ctx.FileURI(file)) mdb.HashSelect(m, arg...).Sort(mdb.NAME).Display(ctx.FileURI(file))
}}, }},
}, ctx.CmdAction(), mdb.HashAction(mdb.SHORT, kit.Select("", arg, 0), mdb.FIELD, kit.Select("time,hash,icon,name,text,space,index,args", arg, 1), kit.Slice(arg, 2))) }, mdb.HashAction(mdb.SHORT, kit.Select("", arg, 0), mdb.FIELD, kit.Select("time,hash,icon,name,text,space,index,args", arg, 1), kit.Slice(arg, 2)))
} }

View File

@ -8,7 +8,6 @@ import (
ice "shylinux.com/x/icebergs" ice "shylinux.com/x/icebergs"
"shylinux.com/x/icebergs/base/aaa" "shylinux.com/x/icebergs/base/aaa"
"shylinux.com/x/icebergs/base/ctx"
"shylinux.com/x/icebergs/base/lex" "shylinux.com/x/icebergs/base/lex"
"shylinux.com/x/icebergs/base/mdb" "shylinux.com/x/icebergs/base/mdb"
"shylinux.com/x/icebergs/base/nfs" "shylinux.com/x/icebergs/base/nfs"
@ -84,7 +83,7 @@ var Index = &ice.Context{Name: OAUTH, Help: "认证授权", Commands: ice.Comman
REPLY: {Name: "reply hash auto create prunes", Help: "授权", Actions: mdb.HashAction(mdb.EXPIRE, mdb.MONTH, mdb.SHORT, mdb.UNIQ, mdb.FIELD, "time,hash,username,scope,offer")}, REPLY: {Name: "reply hash auto create prunes", Help: "授权", Actions: mdb.HashAction(mdb.EXPIRE, mdb.MONTH, mdb.SHORT, mdb.UNIQ, mdb.FIELD, "time,hash,username,scope,offer")},
OFFER: {Name: "offer hash auto create prunes", Help: "访问", Actions: mdb.HashAction(mdb.EXPIRE, mdb.MONTH, mdb.SHORT, mdb.UNIQ, mdb.FIELD, "time,hash,username,scope,redirect_uri")}, OFFER: {Name: "offer hash auto create prunes", Help: "访问", Actions: mdb.HashAction(mdb.EXPIRE, mdb.MONTH, mdb.SHORT, mdb.UNIQ, mdb.FIELD, "time,hash,username,scope,redirect_uri")},
web.P(APPLY): {Name: "/apply scope redirect_uri", Help: "申请", Actions: ctx.CmdAction(), Hand: func(m *ice.Message, arg ...string) { web.P(APPLY): {Name: "/apply scope redirect_uri", Help: "申请", Hand: func(m *ice.Message, arg ...string) {
if m.Option(REDIRECT_URI) == "" { if m.Option(REDIRECT_URI) == "" {
m.RenderStatusBadRequest() // 参数错误 m.RenderStatusBadRequest() // 参数错误
@ -92,7 +91,7 @@ var Index = &ice.Context{Name: OAUTH, Help: "认证授权", Commands: ice.Comman
web.RenderCmd(m, m.Prefix(OAUTH), APPLY) web.RenderCmd(m, m.Prefix(OAUTH), APPLY)
} }
}}, }},
web.P(REPLY): {Name: "/reply scope offer", Help: "授权", Actions: ctx.CmdAction(), Hand: func(m *ice.Message, arg ...string) { web.P(REPLY): {Name: "/reply scope offer", Help: "授权", Hand: func(m *ice.Message, arg ...string) {
if m.Option(OFFER) == "" { if m.Option(OFFER) == "" {
m.RenderStatusBadRequest() // 参数错误 m.RenderStatusBadRequest() // 参数错误

View File

@ -39,7 +39,7 @@ type Client struct {
ice.Hash ice.Hash
short string `data:"domain,client_id"` short string `data:"domain,client_id"`
field string `data:"time,hash,domain,client_id,client_secret,oauth_url,grant_url,token_url,users_url,api_prefix,token_prefix"` field string `data:"time,hash,domain,client_id,client_secret,oauth_url,grant_url,token_url,users_url,api_prefix,token_prefix"`
sso string `name:"sso name* icon*" help:"登录"` sso string `name:"sso name* icon*@icons" help:"登录"`
auth string `name:"auth" help:"授权"` auth string `name:"auth" help:"授权"`
user string `name:"user" help:"用户"` user string `name:"user" help:"用户"`
orgs string `name:"orgs" help:"组织"` orgs string `name:"orgs" help:"组织"`
@ -62,6 +62,13 @@ func init() {
} }
func (s Client) Inputs(m *ice.Message, arg ...string) { func (s Client) Inputs(m *ice.Message, arg ...string) {
switch m.Option(ctx.ACTION) {
case web.SSO:
switch arg[0] {
case mdb.NAME:
case mdb.ICON:
}
}
switch s.Hash.Inputs(m, arg...); arg[0] { switch s.Hash.Inputs(m, arg...); arg[0] {
case web.DOMAIN: case web.DOMAIN:
m.Cmdy(web.SPIDE, mdb.INPUTS, arg) m.Cmdy(web.SPIDE, mdb.INPUTS, arg)

View File

@ -5,9 +5,7 @@ import (
"strings" "strings"
ice "shylinux.com/x/icebergs" ice "shylinux.com/x/icebergs"
"shylinux.com/x/icebergs/base/aaa"
"shylinux.com/x/icebergs/base/cli" "shylinux.com/x/icebergs/base/cli"
"shylinux.com/x/icebergs/base/ctx"
"shylinux.com/x/icebergs/base/mdb" "shylinux.com/x/icebergs/base/mdb"
"shylinux.com/x/icebergs/base/nfs" "shylinux.com/x/icebergs/base/nfs"
"shylinux.com/x/icebergs/base/web" "shylinux.com/x/icebergs/base/web"
@ -18,7 +16,7 @@ const POD = "pod"
func init() { func init() {
Index.MergeCommands(ice.Commands{ Index.MergeCommands(ice.Commands{
POD: {Actions: ice.MergeActions(web.ApiAction(), aaa.WhiteAction(), ctx.CmdAction()), Hand: func(m *ice.Message, arg ...string) { POD: {Actions: web.ApiWhiteAction(), Hand: func(m *ice.Message, arg ...string) {
if len(arg) == 0 || arg[0] == "" { if len(arg) == 0 || arg[0] == "" {
web.RenderMain(m) web.RenderMain(m)
} else if strings.HasPrefix(m.Option(ice.MSG_USERUA), "git/") { } else if strings.HasPrefix(m.Option(ice.MSG_USERUA), "git/") {

View File

@ -9,8 +9,6 @@ const PORTAL = "portal"
func init() { func init() {
Index.MergeCommands(ice.Commands{ Index.MergeCommands(ice.Commands{
PORTAL: {Actions: web.ApiAction(), Hand: func(m *ice.Message, arg ...string) { PORTAL: {Actions: web.ApiAction(), Hand: func(m *ice.Message, arg ...string) { web.RenderMain(m) }},
web.RenderMain(m)
}},
}) })
} }

View File

@ -46,7 +46,7 @@ func init() {
kit.If(m.Option(mdb.TYPE) == aaa.VOID, func() { 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) gdb.Event(m, RIVER_CREATE, RIVER, m.Option(ice.MSG_RIVER, h), arg)
}}, }},
}, web.ApiAction(), aaa.WhiteAction(), mdb.ImportantHashAction(mdb.FIELD, "time,hash,type,icon,name,text,template"), mdb.ExportHashAction()), Hand: func(m *ice.Message, arg ...string) { }, web.ApiWhiteAction(), 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) { if m.Warn(m.Option(ice.MSG_USERNAME) == "", ice.ErrNotLogin) || !aaa.Right(m, RIVER, arg) {
return return
} else if len(arg) == 0 { } else if len(arg) == 0 {

View File

@ -3,7 +3,6 @@ package chat
import ( import (
ice "shylinux.com/x/icebergs" ice "shylinux.com/x/icebergs"
"shylinux.com/x/icebergs/base/cli" "shylinux.com/x/icebergs/base/cli"
"shylinux.com/x/icebergs/base/ctx"
"shylinux.com/x/icebergs/base/web" "shylinux.com/x/icebergs/base/web"
) )
@ -13,7 +12,7 @@ func init() {
Index.MergeCommands(ice.Commands{ Index.MergeCommands(ice.Commands{
SEARCH: {Actions: ice.MergeActions(ice.Actions{ SEARCH: {Actions: ice.MergeActions(ice.Actions{
cli.OPENS: {Hand: func(m *ice.Message, arg ...string) { cli.Opens(m, arg...) }}, cli.OPENS: {Hand: func(m *ice.Message, arg ...string) { cli.Opens(m, arg...) }},
}, web.ApiAction(), ctx.CmdAction()), Hand: func(m *ice.Message, arg ...string) { }, web.ApiAction()), Hand: func(m *ice.Message, arg ...string) {
m.Cmdy(web.Space(m, m.Option(ice.POD)), "mdb.search", arg).StatusTimeCount() m.Cmdy(web.Space(m, m.Option(ice.POD)), "mdb.search", arg).StatusTimeCount()
}}, }},
}) })

View File

@ -16,7 +16,7 @@ const SSO = "sso"
func init() { func init() {
Index.MergeCommands(ice.Commands{ Index.MergeCommands(ice.Commands{
SSO: {Actions: ice.MergeActions(web.ApiAction(), aaa.WhiteAction()), Hand: func(m *ice.Message, arg ...string) { SSO: {Actions: web.ApiWhiteAction(), 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) { 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) web.RenderMain(m)
return return

View File

@ -16,7 +16,7 @@ const STORM = "storm"
func init() { func init() {
Index.MergeCommands(ice.Commands{ Index.MergeCommands(ice.Commands{
STORM: {Name: "storm hash id auto insert create", Help: "应用", Actions: ice.Actions{ STORM: {Name: "storm hash id auto", Help: "应用", Actions: ice.Actions{
mdb.CREATE: {Name: "create name=hi text=hello", 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) m.Cmdy(mdb.INSERT, RIVER, _river_key(m), mdb.HASH, arg)
}}, }},
@ -39,8 +39,10 @@ func init() {
}, Hand: func(m *ice.Message, arg ...string) { }, Hand: func(m *ice.Message, arg ...string) {
if m.Option(ice.MSG_STORM) == "" { if m.Option(ice.MSG_STORM) == "" {
m.Cmdy(mdb.SELECT, RIVER, _river_key(m), mdb.HASH, ice.OptionFields("time,hash,icon,name,text,count")) m.Cmdy(mdb.SELECT, RIVER, _river_key(m), mdb.HASH, ice.OptionFields("time,hash,icon,name,text,count"))
m.Action(mdb.CREATE)
} else if len(arg) == 0 || kit.Int(arg[0]) > 0 { } else if len(arg) == 0 || kit.Int(arg[0]) > 0 {
m.Cmdy(mdb.SELECT, RIVER, _storm_key(m), mdb.LIST, mdb.ID, arg, ice.OptionFields("time,id,space,icon,index,args,style,display,deleted")).SortInt(mdb.ID) m.Cmdy(mdb.SELECT, RIVER, _storm_key(m), mdb.LIST, mdb.ID, arg, ice.OptionFields("time,id,space,icon,index,args,style,display,deleted")).SortInt(mdb.ID)
m.Action(mdb.INSERT)
} else if aaa.Right(m, arg) { } else if aaa.Right(m, arg) {
m.Push(ctx.INDEX, arg[0]) m.Push(ctx.INDEX, arg[0])
} }

View File

@ -21,35 +21,28 @@ func init() {
TO = "to" TO = "to"
) )
Index.MergeCommands(ice.Commands{ Index.MergeCommands(ice.Commands{
TRANS: {Name: "trans from to auto", Help: "传输", Actions: ice.MergeActions(ice.Actions{ TRANS: {Name: "trans from@key to@key auto", Help: "传输", Icon: "Migration.png", Actions: ice.Actions{
SEND: {Name: "send", Help: "发送", Hand: func(m *ice.Message, arg ...string) { SEND: {Hand: func(m *ice.Message, arg ...string) {
m.Cmdy(web.SPACE, m.Option(TO), web.SPIDE, ice.DEV, web.SPIDE_SAVE, kit.Select(nfs.PWD, m.Option("to_path")), defer web.ToastProcess(m)()
web.MergeURL2(m, path.Join(web.SHARE_LOCAL, m.Option("from_path")), ice.POD, m.Option(FROM), p := web.ProxyUpload(m, m.Option(FROM), m.Option(nfs.PATH))
web.SHARE, m.Cmdx(web.SHARE, mdb.CREATE, mdb.TYPE, web.LOGIN), h := m.Cmdx(web.SHARE, mdb.CREATE, mdb.TYPE, web.DOWNLOAD, mdb.TEXT, p)
), defer m.Cmd(web.SHARE, mdb.REMOVE, mdb.HASH, h)
).ProcessHold() m.Cmdy(web.SPACE, m.Option(TO), web.SPIDE, ice.DEV, web.SPIDE_SAVE, path.Join(m.Option("to_path"), path.Base(m.Option(nfs.PATH))), web.MergeLink(m, "/share/"+h))
web.ToastSuccess(m, SEND)
}}, }},
ctx.RUN: {Name: "run", Help: "执行", Hand: func(m *ice.Message, arg ...string) { ctx.RUN: {Hand: func(m *ice.Message, arg ...string) {
m.Option(ice.POD, m.Option("_pod")) m.Options(ice.MSG_USERPOD, m.Option(FROM), ice.POD, m.Option(FROM))
m.Option(ice.MSG_USERPOD, m.Option("_pod")) kit.If(!ctx.PodCmd(m, arg) && aaa.Right(m, arg), func() { m.Cmdy(arg) })
if aaa.Right(m, arg) && !ctx.PodCmd(m, arg) { kit.If(arg[0] == nfs.DIR && len(arg) < 3, func() { m.PushAction(SEND, mdb.SHOW, nfs.TRASH) })
m.Cmdy(arg)
}
if arg[0] == nfs.DIR && m.Length() > 0 {
m.PushAction(SEND, nfs.TRASH)
}
}}, }},
}, ctx.CmdAction()), Hand: func(m *ice.Message, arg ...string) { }, Hand: func(m *ice.Message, arg ...string) {
defer m.Options(ice.MSG_ACTION, "")
if len(arg) == 0 { if len(arg) == 0 {
m.Cmdy(web.SPACE).RenameAppend(mdb.NAME, FROM) m.Cmdy(web.SPACE).RenameAppend(mdb.NAME, FROM).Toast("请选择空间1")
return } else if len(arg) == 1 {
m.Cmdy(web.SPACE).RenameAppend(mdb.NAME, TO).Toast("请选择空间2")
} else {
ctx.DisplayLocal(m, "")
} }
if len(arg) == 1 {
m.Cmdy(web.SPACE).RenameAppend(mdb.NAME, TO)
return
}
ctx.DisplayLocal(m, "")
}}, }},
}) })
} }

View File

@ -40,7 +40,7 @@ func init() {
VERSION = "version" VERSION = "version"
) )
Index.MergeCommands(ice.Commands{ Index.MergeCommands(ice.Commands{
COMPILE: {Name: "compile arch=amd64,386,arm,arm64,mipsle os=linux,darwin,windows src=src/main.go@key run binpack webpack devpack install", Icon: "usr/icons/go.png", Help: "编译", Actions: ice.MergeActions(ice.Actions{ COMPILE: {Name: "compile arch=amd64,386,arm,arm64,mipsle os=linux,darwin,windows src=src/main.go@key run binpack webpack devpack install", Icon: "go.png", Help: "编译", Actions: ice.MergeActions(ice.Actions{
ice.CTX_INIT: {Hand: func(m *ice.Message, arg ...string) { cli.IsAlpine(m, GO, "go git") }}, ice.CTX_INIT: {Hand: func(m *ice.Message, arg ...string) { cli.IsAlpine(m, GO, "go git") }},
mdb.SEARCH: {Hand: func(m *ice.Message, arg ...string) { mdb.SEARCH: {Hand: func(m *ice.Message, arg ...string) {
mdb.IsSearchPreview(m, arg, func() []string { mdb.IsSearchPreview(m, arg, func() []string {

View File

@ -124,7 +124,7 @@ func init() {
NAVIGATE: {Hand: func(m *ice.Message, arg ...string) { NAVIGATE: {Hand: func(m *ice.Message, arg ...string) {
m.Cmdy(NAVIGATE, kit.Ext(m.Option(mdb.FILE)), m.Option(nfs.FILE), m.Option(nfs.PATH)) m.Cmdy(NAVIGATE, kit.Ext(m.Option(mdb.FILE)), m.Option(nfs.FILE), m.Option(nfs.PATH))
}}, }},
}, ctx.CmdAction(), aaa.RoleAction()), Hand: func(m *ice.Message, arg ...string) { }, aaa.RoleAction()), Hand: func(m *ice.Message, arg ...string) {
if kit.HasPrefix(arg[0], "/volcanos/", "/require/", "http") { if kit.HasPrefix(arg[0], "/volcanos/", "/require/", "http") {
m.Echo(m.Cmdx(web.SPIDE, ice.DEV, web.SPIDE_RAW, arg[0])) m.Echo(m.Cmdx(web.SPIDE, ice.DEV, web.SPIDE_RAW, arg[0]))
ctx.DisplayLocal(m, "") ctx.DisplayLocal(m, "")

View File

@ -122,7 +122,7 @@ func init() {
nfs.TRASH: {Hand: func(m *ice.Message, arg ...string) { nfs.Trash(m, path.Join(ice.USR_PUBLISH, m.Option(nfs.PATH))) }}, nfs.TRASH: {Hand: func(m *ice.Message, arg ...string) { nfs.Trash(m, path.Join(ice.USR_PUBLISH, m.Option(nfs.PATH))) }},
}, ctx.ConfAction(mdb.FIELD, nfs.PATH), aaa.RoleAction()), Hand: func(m *ice.Message, arg ...string) { }, ctx.ConfAction(mdb.FIELD, nfs.PATH), aaa.RoleAction()), Hand: func(m *ice.Message, arg ...string) {
if m.Option(nfs.DIR_ROOT, ice.USR_PUBLISH); len(arg) == 0 { if m.Option(nfs.DIR_ROOT, ice.USR_PUBLISH); len(arg) == 0 {
_publish_list(m).Cmdy("", ice.CONTEXTS, "app") _publish_list(m).Cmdy("", ice.CONTEXTS, ice.APP)
} else { } else {
m.Cmdy(nfs.DIR, arg[0], "time,path,size,hash,link,action", ice.OptionFields(mdb.DETAIL)) m.Cmdy(nfs.DIR, arg[0], "time,path,size,hash,link,action", ice.OptionFields(mdb.DETAIL))
web.PushImages(m, web.P(PUBLISH, arg[0])) web.PushImages(m, web.P(PUBLISH, arg[0]))

View File

@ -50,7 +50,7 @@ const VIMER = "vimer"
func init() { func init() {
web.Index.MergeCommands(ice.Commands{ice.CTX_INIT: {Hand: func(m *ice.Message, arg ...string) { aaa.White(m, nfs.REQUIRE) }}, web.Index.MergeCommands(ice.Commands{ice.CTX_INIT: {Hand: func(m *ice.Message, arg ...string) { aaa.White(m, nfs.REQUIRE) }},
ice.REQUIRE_SRC: {Actions: ctx.CmdAction(), Hand: func(m *ice.Message, arg ...string) { web.ShareLocalFile(m, ice.SRC, path.Join(arg...)) }}, ice.REQUIRE_SRC: {Hand: func(m *ice.Message, arg ...string) { web.ShareLocalFile(m, ice.SRC, path.Join(arg...)) }},
ice.REQUIRE_USR: {Hand: func(m *ice.Message, arg ...string) { web.ShareLocalFile(m, ice.USR, path.Join(arg...)) }}, ice.REQUIRE_USR: {Hand: func(m *ice.Message, arg ...string) { web.ShareLocalFile(m, ice.USR, path.Join(arg...)) }},
ice.REQUIRE_MODULES: {Hand: func(m *ice.Message, arg ...string) { ice.REQUIRE_MODULES: {Hand: func(m *ice.Message, arg ...string) {
p := path.Join(ice.USR_MODULES, path.Join(arg...)) p := path.Join(ice.USR_MODULES, path.Join(arg...))
@ -59,7 +59,7 @@ func init() {
}}, }},
}) })
Index.MergeCommands(ice.Commands{ Index.MergeCommands(ice.Commands{
VIMER: {Name: "vimer path=src/@key file=main.go@key line=1 list", Icon: "usr/icons/vimer.png", Help: "编辑器", Meta: kit.Dict(ctx.STYLE, INNER), Actions: ice.MergeActions(ice.Actions{ VIMER: {Name: "vimer path=src/@key file=main.go@key line=1 list", Icon: "vimer.png", Help: "编辑器", Meta: kit.Dict(ctx.STYLE, INNER), Actions: ice.MergeActions(ice.Actions{
mdb.SEARCH: {Hand: func(m *ice.Message, arg ...string) { mdb.SEARCH: {Hand: func(m *ice.Message, arg ...string) {
if mdb.IsSearchPreview(m, arg) { if mdb.IsSearchPreview(m, arg) {
m.PushSearch(mdb.TYPE, nfs.FILE, mdb.NAME, "main", mdb.TEXT, ice.SRC_MAIN_SH) m.PushSearch(mdb.TYPE, nfs.FILE, mdb.NAME, "main", mdb.TEXT, ice.SRC_MAIN_SH)
@ -192,7 +192,7 @@ func init() {
kit.Switch(m.Option(mdb.TYPE), kit.Simple(web.SERVER, web.WORKER), func() { m.PushButton(kit.Dict(m.CommandKey(), "编程")) }) kit.Switch(m.Option(mdb.TYPE), kit.Simple(web.SERVER, web.WORKER), func() { m.PushButton(kit.Dict(m.CommandKey(), "编程")) })
}}, }},
web.DREAM_ACTION: {Hand: func(m *ice.Message, arg ...string) { web.DreamProcess(m, []string{}, arg...) }}, web.DREAM_ACTION: {Hand: func(m *ice.Message, arg ...string) { web.DreamProcess(m, []string{}, arg...) }},
}, aaa.RoleAction(ctx.COMMAND), mdb.HashAction(mdb.SHORT, nfs.PATH, mdb.FIELD, "time,path", ctx.TOOLS, "xterm,compile,runtime")), Hand: func(m *ice.Message, arg ...string) { }, aaa.RoleAction(), mdb.HashAction(mdb.SHORT, nfs.PATH, mdb.FIELD, "time,path", ctx.TOOLS, "xterm,compile,runtime")), Hand: func(m *ice.Message, arg ...string) {
if m.Cmdy(INNER, arg); arg[0] != ctx.ACTION { if m.Cmdy(INNER, arg); arg[0] != ctx.ACTION {
kit.If(len(arg) > 1, func() { mdb.HashCreate(m.Spawn(), nfs.PATH, path.Join(kit.Slice(arg, 0, 2)...)) }) kit.If(len(arg) > 1, func() { mdb.HashCreate(m.Spawn(), nfs.PATH, path.Join(kit.Slice(arg, 0, 2)...)) })
m.Action(nfs.SAVE, COMPILE, "show", "exec") m.Action(nfs.SAVE, COMPILE, "show", "exec")

View File

@ -75,7 +75,7 @@ const XTERM = "xterm"
func init() { func init() {
Index.MergeCommands(ice.Commands{ Index.MergeCommands(ice.Commands{
XTERM: {Name: "xterm hash auto", Icon: "usr/icons/Terminal.png", Help: "命令行", Actions: ice.MergeActions(ice.Actions{ XTERM: {Name: "xterm hash auto", Icon: "Terminal.png", Help: "命令行", Actions: ice.MergeActions(ice.Actions{
ice.CTX_INIT: {Hand: func(m *ice.Message, arg ...string) { ice.CTX_INIT: {Hand: func(m *ice.Message, arg ...string) {
kit.If(m.Cmd("").Length() == 0, func() { m.Cmd("", mdb.CREATE, mdb.TYPE, ISH) }) kit.If(m.Cmd("").Length() == 0, func() { m.Cmd("", mdb.CREATE, mdb.TYPE, ISH) })
}}, }},
@ -150,7 +150,7 @@ func init() {
} }
m.ProcessHold() m.ProcessHold()
}}, }},
}, ctx.CmdAction(), ctx.ProcessAction(), mdb.ImportantHashAction(mdb.FIELD, "time,hash,type,name,text,path,theme,daemon")), Hand: func(m *ice.Message, arg ...string) { }, ctx.ProcessAction(), mdb.ImportantHashAction(mdb.FIELD, "time,hash,type,name,text,path,theme,daemon")), Hand: func(m *ice.Message, arg ...string) {
if mdb.HashSelect(m, arg...); len(arg) == 0 { if mdb.HashSelect(m, arg...); len(arg) == 0 {
if m.Length() == 0 { if m.Length() == 0 {
m.Action(mdb.CREATE) m.Action(mdb.CREATE)

View File

@ -2,7 +2,6 @@ package mall
import ( import (
ice "shylinux.com/x/icebergs" ice "shylinux.com/x/icebergs"
"shylinux.com/x/icebergs/base/ctx"
"shylinux.com/x/icebergs/base/mdb" "shylinux.com/x/icebergs/base/mdb"
"shylinux.com/x/icebergs/base/web" "shylinux.com/x/icebergs/base/web"
kit "shylinux.com/x/toolkits" kit "shylinux.com/x/toolkits"
@ -92,7 +91,7 @@ func init() {
} }
web.Toast(m, "核算成功") web.Toast(m, "核算成功")
}}, }},
}, mdb.ZoneAction(), ctx.CmdAction()), Hand: func(m *ice.Message, arg ...string) { }, mdb.ZoneAction()), Hand: func(m *ice.Message, arg ...string) {
m.Fields(len(arg), "time,account,amount,count", mdb.ZoneField(m)) m.Fields(len(arg), "time,account,amount,count", mdb.ZoneField(m))
amount, count := 0, 0 amount, count := 0, 0
if mdb.ZoneSelect(m, arg...); len(arg) == 0 { if mdb.ZoneSelect(m, arg...); len(arg) == 0 {

View File

@ -55,7 +55,7 @@ const PLAN = "plan"
func init() { func init() {
Index.MergeCommands(ice.Commands{ Index.MergeCommands(ice.Commands{
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{ PLAN: {Name: "plan scale=month,day,week,month,year,long begin_time@date list prev next", Icon: "Calendar.png", Help: "计划表", Actions: ice.MergeActions(ice.Actions{
mdb.INPUTS: {Hand: func(m *ice.Message, arg ...string) { m.Cmdy(TODO, mdb.INPUTS, arg) }}, 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) }}, mdb.PLUGIN: {Name: "plugin extra.index extra.args", Hand: func(m *ice.Message, arg ...string) { m.Cmdy(TASK, mdb.MODIFY, arg) }},
ctx.RUN: {Hand: func(m *ice.Message, arg ...string) { ctx.RUN: {Hand: func(m *ice.Message, arg ...string) {
@ -71,7 +71,7 @@ func init() {
web.DREAM_TABLES: {Hand: func(m *ice.Message, arg ...string) { web.DREAM_TABLES: {Hand: func(m *ice.Message, arg ...string) {
kit.Switch(m.Option(mdb.TYPE), kit.Simple(web.SERVER, web.WORKER), func() { m.PushButton(kit.Dict(m.CommandKey(), "计划")) }) kit.Switch(m.Option(mdb.TYPE), kit.Simple(web.SERVER, web.WORKER), func() { m.PushButton(kit.Dict(m.CommandKey(), "计划")) })
}}, }},
}, aaa.RoleAction(ctx.COMMAND), ctx.CmdAction(), TASK), Hand: func(m *ice.Message, arg ...string) { }, aaa.RoleAction(), TASK), Hand: func(m *ice.Message, arg ...string) {
begin_time, end_time := _plan_scope(m, kit.Slice(arg, 0, 2)...) begin_time, end_time := _plan_scope(m, kit.Slice(arg, 0, 2)...)
_plan_list(m, begin_time.Format(ice.MOD_TIME), end_time.Format(ice.MOD_TIME)) _plan_list(m, begin_time.Format(ice.MOD_TIME), end_time.Format(ice.MOD_TIME))
web.PushPodCmd(m, "", arg...) web.PushPodCmd(m, "", arg...)

View File

@ -5,7 +5,6 @@ import (
ice "shylinux.com/x/icebergs" ice "shylinux.com/x/icebergs"
"shylinux.com/x/icebergs/base/aaa" "shylinux.com/x/icebergs/base/aaa"
"shylinux.com/x/icebergs/base/ctx"
"shylinux.com/x/icebergs/base/mdb" "shylinux.com/x/icebergs/base/mdb"
"shylinux.com/x/icebergs/base/nfs" "shylinux.com/x/icebergs/base/nfs"
"shylinux.com/x/icebergs/base/web" "shylinux.com/x/icebergs/base/web"
@ -16,7 +15,7 @@ const DRAW = "draw"
func init() { func init() {
Index.MergeCommands(ice.Commands{ Index.MergeCommands(ice.Commands{
DRAW: {Name: "draw path=src/main.svg@key pid refresh save actions", Icon: "usr/icons/Grapher.png", Help: "思维导图", Actions: ice.MergeActions(ice.Actions{ DRAW: {Name: "draw path=src/main.svg@key pid refresh save actions", Icon: "Grapher.png", Help: "思维导图", Actions: ice.MergeActions(ice.Actions{
ice.CTX_INIT: {Hand: func(m *ice.Message, arg ...string) { ice.CTX_INIT: {Hand: func(m *ice.Message, arg ...string) {
m.Cmd(mdb.RENDER, mdb.CREATE, mdb.TYPE, nfs.SVG, mdb.NAME, m.PrefixKey()) m.Cmd(mdb.RENDER, mdb.CREATE, mdb.TYPE, nfs.SVG, mdb.NAME, m.PrefixKey())
}}, }},
@ -27,7 +26,7 @@ func init() {
web.DREAM_TABLES: {Hand: func(m *ice.Message, arg ...string) { web.DREAM_TABLES: {Hand: func(m *ice.Message, arg ...string) {
kit.Switch(m.Option(mdb.TYPE), kit.Simple(web.SERVER, web.WORKER), func() { m.PushButton(kit.Dict(m.CommandKey(), "导图")) }) kit.Switch(m.Option(mdb.TYPE), kit.Simple(web.SERVER, web.WORKER), func() { m.PushButton(kit.Dict(m.CommandKey(), "导图")) })
}}, }},
}, aaa.RoleAction(ctx.COMMAND, ctx.RUN), ctx.CmdAction(), WikiAction("", nfs.SVG)), Hand: func(m *ice.Message, arg ...string) { }, aaa.RoleAction(), WikiAction("", nfs.SVG)), Hand: func(m *ice.Message, arg ...string) {
kit.If(!_wiki_list(m, arg...), func() { kit.If(!_wiki_list(m, arg...), func() {
_wiki_show(m, arg[0]) _wiki_show(m, arg[0])
kit.If(m.IsErr(), func() { m.Option(ice.MSG_OUTPUT, "") }) kit.If(m.IsErr(), func() { m.Option(ice.MSG_OUTPUT, "") })

View File

@ -22,7 +22,7 @@ const FEEL = "feel"
func init() { func init() {
Index.MergeCommands(ice.Commands{ Index.MergeCommands(ice.Commands{
FEEL: {Name: "feel path auto prev next record1 record2 upload actions", Icon: "usr/icons/Photos.png", Help: "影音媒体", Actions: ice.MergeActions(ice.Actions{ FEEL: {Name: "feel path auto prev next record1 record2 upload actions", Icon: "Photos.png", Help: "影音媒体", Actions: ice.MergeActions(ice.Actions{
"record1": {Help: "截图"}, "record2": {Help: "录屏"}, "record1": {Help: "截图"}, "record2": {Help: "录屏"},
web.UPLOAD: {Hand: func(m *ice.Message, arg ...string) { web.UPLOAD: {Hand: func(m *ice.Message, arg ...string) {
m.Option(nfs.PATH, _feel_path(m, m.Option(nfs.PATH))) m.Option(nfs.PATH, _feel_path(m, m.Option(nfs.PATH)))

View File

@ -39,7 +39,7 @@ const FIELD = "field"
func init() { func init() {
Index.MergeCommands(ice.Commands{ Index.MergeCommands(ice.Commands{
FIELD: {Name: "field name cmd", Help: "插件", Actions: ctx.CmdAction(), Hand: func(m *ice.Message, arg ...string) { FIELD: {Name: "field name cmd", Help: "插件", Hand: func(m *ice.Message, arg ...string) {
kit.If(kit.IsIn(kit.Select("", arg, 1), ctx.ARGS, ice.MSG_RESULT), func() { arg = kit.Simple("", arg) }) kit.If(kit.IsIn(kit.Select("", arg, 1), ctx.ARGS, ice.MSG_RESULT), func() { arg = kit.Simple("", arg) })
if arg = _name(m, arg); arg[0] == "inner" { if arg = _name(m, arg); arg[0] == "inner" {
arg = append([]string{"", web.CODE_INNER, ctx.ARGS, "src/ main.go", ice.MSG_RESULT, arg[1], "meta.display", "/plugin/local/code/inner.js", ctx.STYLE, "output"}, arg[2:]...) arg = append([]string{"", web.CODE_INNER, ctx.ARGS, "src/ main.go", ice.MSG_RESULT, arg[1], "meta.display", "/plugin/local/code/inner.js", ctx.STYLE, "output"}, arg[2:]...)

View File

@ -85,7 +85,7 @@ func init() {
kit.Switch(m.Option(mdb.TYPE), kit.Simple(web.SERVER, web.WORKER), func() { m.PushButton(ice.Maps{PORTAL: "官网"}) }) kit.Switch(m.Option(mdb.TYPE), kit.Simple(web.SERVER, web.WORKER), func() { m.PushButton(ice.Maps{PORTAL: "官网"}) })
}}, }},
web.DREAM_ACTION: {Hand: func(m *ice.Message, arg ...string) { web.DreamProcess(m, []string{}, arg...) }}, web.DREAM_ACTION: {Hand: func(m *ice.Message, arg ...string) { web.DreamProcess(m, []string{}, arg...) }},
}, aaa.WhiteAction(ctx.COMMAND, ctx.RUN), aaa.RoleAction(ctx.COMMAND, ctx.RUN), ctx.CmdAction()), Hand: func(m *ice.Message, arg ...string) { }, aaa.WhiteAction(), aaa.RoleAction()), Hand: func(m *ice.Message, arg ...string) {
if m.Push(HEADER, m.Cmdx(WORD, path.Join(nfs.SRC_DOCUMENT, INDEX_SHY))); len(arg) > 0 { if m.Push(HEADER, m.Cmdx(WORD, path.Join(nfs.SRC_DOCUMENT, INDEX_SHY))); len(arg) > 0 {
kit.If(path.Join(arg...) == "commands", func() { _portal_commands(m, arg...) }) kit.If(path.Join(arg...) == "commands", func() { _portal_commands(m, arg...) })
m.Push(NAV, m.Cmdx(WORD, path.Join(nfs.SRC_DOCUMENT, path.Join(arg...), INDEX_SHY))) m.Push(NAV, m.Cmdx(WORD, path.Join(nfs.SRC_DOCUMENT, path.Join(arg...), INDEX_SHY)))

View File

@ -3,7 +3,6 @@ package wiki
import ( import (
ice "shylinux.com/x/icebergs" ice "shylinux.com/x/icebergs"
"shylinux.com/x/icebergs/base/aaa" "shylinux.com/x/icebergs/base/aaa"
"shylinux.com/x/icebergs/base/ctx"
"shylinux.com/x/icebergs/base/mdb" "shylinux.com/x/icebergs/base/mdb"
"shylinux.com/x/icebergs/base/nfs" "shylinux.com/x/icebergs/base/nfs"
"shylinux.com/x/icebergs/base/ssh" "shylinux.com/x/icebergs/base/ssh"
@ -21,7 +20,7 @@ const WORD = "word"
func init() { func init() {
Index.MergeCommands(ice.Commands{ Index.MergeCommands(ice.Commands{
WORD: {Name: "word path=src/main.shy@key auto play", Icon: "usr/icons/Books.png", Help: "上下文", Actions: ice.MergeActions(ice.Actions{ WORD: {Name: "word path=src/main.shy@key auto play", Icon: "Books.png", Help: "上下文", Actions: ice.MergeActions(ice.Actions{
ice.CTX_INIT: {Hand: func(m *ice.Message, arg ...string) { ice.CTX_INIT: {Hand: func(m *ice.Message, arg ...string) {
WordAlias(m, NAVMENU, TITLE, NAVMENU) WordAlias(m, NAVMENU, TITLE, NAVMENU)
WordAlias(m, PREMENU, TITLE, PREMENU) WordAlias(m, PREMENU, TITLE, PREMENU)
@ -47,7 +46,7 @@ func init() {
ls := kit.Split(m.Option(mdb.TEXT)) ls := kit.Split(m.Option(mdb.TEXT))
kit.If(kit.IsIn(ls[0], IMAGE, VIDEO, AUDIO), func() { m.Cmdy(FEEL).CutTo(nfs.PATH, mdb.NAME) }) kit.If(kit.IsIn(ls[0], IMAGE, VIDEO, AUDIO), func() { m.Cmdy(FEEL).CutTo(nfs.PATH, mdb.NAME) })
}}, }},
}, aaa.RoleAction(ctx.COMMAND, ctx.RUN), ctx.CmdAction(), WikiAction("", nfs.SHY)), Hand: func(m *ice.Message, arg ...string) { }, aaa.RoleAction(), WikiAction("", nfs.SHY)), Hand: func(m *ice.Message, arg ...string) {
if m.Option(nfs.DIR_DEEP, ice.TRUE); len(arg) == 0 { if m.Option(nfs.DIR_DEEP, ice.TRUE); len(arg) == 0 {
arg = append(arg, nfs.SRC) arg = append(arg, nfs.SRC)
} }

View File

@ -13,7 +13,7 @@ const SPIDE = "spide"
func init() { func init() {
Index.MergeCommands(ice.Commands{ Index.MergeCommands(ice.Commands{
SPIDE: {Name: "spide repos auto", Help: "构架图", Actions: ctx.CmdAction(), Hand: func(m *ice.Message, arg ...string) { SPIDE: {Name: "spide repos auto", Help: "构架图", Hand: func(m *ice.Message, arg ...string) {
if len(kit.Slice(arg, 0, 1)) == 0 { if len(kit.Slice(arg, 0, 1)) == 0 {
m.Cmdy(REPOS) m.Cmdy(REPOS)
} else if len(arg) == 1 { } else if len(arg) == 1 {

View File

@ -103,7 +103,7 @@ const STATUS = "status"
func init() { func init() {
Index.MergeCommands(ice.Commands{ Index.MergeCommands(ice.Commands{
STATUS: {Name: "status repos:text auto", Icon: "usr/icons/git.png", Help: "代码库", Actions: ice.MergeActions(ice.Actions{ STATUS: {Name: "status repos:text auto", Icon: "git.png", Help: "代码库", Actions: ice.MergeActions(ice.Actions{
mdb.INPUTS: {Hand: func(m *ice.Message, arg ...string) { mdb.INPUTS: {Hand: func(m *ice.Message, arg ...string) {
switch m.Option(ctx.ACTION) { switch m.Option(ctx.ACTION) {
case INIT: case INIT:

View File

@ -13,7 +13,7 @@ const TREND = "trend"
func init() { func init() {
Index.MergeCommands(ice.Commands{ Index.MergeCommands(ice.Commands{
TREND: {Name: "trend repos@key begin_time@date auto", Help: "趋势图", Actions: ice.MergeActions(ice.Actions{ TREND: {Name: "trend repos@key begin_time@date auto", Help: "趋势图", Actions: ice.Actions{
mdb.INPUTS: {Hand: func(m *ice.Message, arg ...string) { m.Cmdy(REPOS, ice.OptionFields("repos,time")) }}, mdb.INPUTS: {Hand: func(m *ice.Message, arg ...string) { m.Cmdy(REPOS, ice.OptionFields("repos,time")) }},
mdb.DETAIL: {Hand: func(m *ice.Message, arg ...string) { mdb.DETAIL: {Hand: func(m *ice.Message, arg ...string) {
m.Cmdy("", code.INNER, m.Option(REPOS), MASTER, m.Option(mdb.HASH), m.Cmdv(REPOS, m.Option(REPOS), MASTER, m.Option(mdb.HASH), nfs.FILE)) m.Cmdy("", code.INNER, m.Option(REPOS), MASTER, m.Option(mdb.HASH), m.Cmdv(REPOS, m.Option(REPOS), MASTER, m.Option(mdb.HASH), nfs.FILE))
@ -22,7 +22,7 @@ func init() {
m.Cmdy(REPOS, code.INNER, arg) m.Cmdy(REPOS, code.INNER, arg)
ctx.DisplayLocal(m, "code/inner.js", "style", "float") ctx.DisplayLocal(m, "code/inner.js", "style", "float")
}}, }},
}, ctx.CmdAction()), Hand: func(m *ice.Message, arg ...string) { }, Hand: func(m *ice.Message, arg ...string) {
if len(arg) == 0 { if len(arg) == 0 {
m.Cmdy(REPOS) m.Cmdy(REPOS)
} else { } else {

View File

@ -70,7 +70,7 @@ func init() {
} }
} }
}}, }},
web.P(OAUTH): {Name: "/oauth", Help: "授权", Actions: ice.MergeActions(ice.Actions{}, ctx.CmdAction()), Hand: func(m *ice.Message, arg ...string) { web.P(OAUTH): {Name: "/oauth", Help: "授权", Hand: func(m *ice.Message, arg ...string) {
if m.Warn(m.Option(CODE) == "", ice.ErrNotValid) { if m.Warn(m.Option(CODE) == "", ice.ErrNotValid) {
return return
} }

View File

@ -145,7 +145,7 @@ const SERVICE = "service"
func init() { func init() {
psh.Index.MergeCommands(ice.Commands{ psh.Index.MergeCommands(ice.Commands{
SERVICE: {Name: "service port id auto listen prunes", Icon: "usr/icons/ssh.png", Help: "服务", Actions: ice.MergeActions(ice.Actions{ SERVICE: {Name: "service port id auto listen prunes", Icon: "ssh.png", Help: "服务", Actions: ice.MergeActions(ice.Actions{
ice.CTX_INIT: {Hand: func(m *ice.Message, arg ...string) { ice.CTX_INIT: {Hand: func(m *ice.Message, arg ...string) {
mdb.HashSelect(m).Table(func(value ice.Maps) { mdb.HashSelect(m).Table(func(value ice.Maps) {
if value[mdb.STATUS] == tcp.OPEN { if value[mdb.STATUS] == tcp.OPEN {

View File

@ -80,7 +80,7 @@ func init() {
FIELDS, "id,tag,pane,tty,height,width,cmd", FIELDS, "id,tag,pane,tty,height,width,cmd",
)}, )},
}, Commands: ice.Commands{ }, Commands: ice.Commands{
SESSION: {Name: "session session window pane cmds auto", Help: "会话", Actions: ice.MergeActions(ice.Actions{ SESSION: {Name: "session session window pane cmds auto", Help: "会话", Actions: ice.Actions{
web.DREAM_CREATE: {Hand: func(m *ice.Message, arg ...string) { web.DREAM_CREATE: {Hand: func(m *ice.Message, arg ...string) {
if !m.Warn(!nfs.Exists(m, path.Join(ice.USR_LOCAL_WORK, m.Option(mdb.NAME))), ice.ErrNotFound) { if !m.Warn(!nfs.Exists(m, path.Join(ice.USR_LOCAL_WORK, m.Option(mdb.NAME))), ice.ErrNotFound) {
m.Cmd("", mdb.CREATE) m.Cmd("", mdb.CREATE)
@ -165,7 +165,7 @@ func init() {
}) })
}).Sleep30ms() }).Sleep30ms()
}}, }},
}, ctx.CmdAction()), Hand: func(m *ice.Message, arg ...string) { }, Hand: func(m *ice.Message, arg ...string) {
if m.Action(SCRIPT); len(arg) > 3 { if m.Action(SCRIPT); len(arg) > 3 {
m.Cmd(CMD, _tmux_key(arg[0], arg[1], arg[2]), arg[3:]) m.Cmd(CMD, _tmux_key(arg[0], arg[1], arg[2]), arg[3:])
} }

View File

@ -37,6 +37,7 @@ type Config struct {
type Action struct { type Action struct {
Name string Name string
Help string Help string
Icon string
Hand Handler Hand Handler
List List List List
} }
@ -168,14 +169,15 @@ func (c *Context) Merge(s *Context) *Context {
kit.Value(cmd.Meta, kit.Keys("_title", sub), help[1]) kit.Value(cmd.Meta, kit.Keys("_title", sub), help[1])
} }
} }
kit.Value(cmd.Meta, kit.Keys("_icons", sub), action.Icon)
if action.Hand == nil { if action.Hand == nil {
continue continue
} }
kit.If(action.List == nil, func() { action.List = SplitCmd(action.Name, nil) }) 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(len(action.List) > 0, func() { cmd.Meta[sub] = action.List })
} }
kit.If(cmd.Name == "", func() { cmd.Name = "list auto" }) kit.If(cmd.Name == "", func() { cmd.Name = "list list" })
kit.If(strings.HasPrefix(cmd.Name, "list"), func() { cmd.Name = strings.Replace(cmd.Name, "list", key, 1) }) 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) }) kit.If(cmd.List == nil, func() { cmd.List = SplitCmd(cmd.Name, cmd.Actions) })
} }
kit.If(c.Configs == nil, func() { c.Configs = Configs{} }) kit.If(c.Configs == nil, func() { c.Configs = Configs{} })