forked from x/icebergs
opt search
This commit is contained in:
parent
8b0fcec681
commit
03f5c287cd
@ -157,6 +157,7 @@ func travel(m *ice.Message, root string, name string, cb func(name string)) {
|
|||||||
}
|
}
|
||||||
if f.IsDir() {
|
if f.IsDir() {
|
||||||
travel(m, root, path.Join(name, f.Name()), cb)
|
travel(m, root, path.Join(name, f.Name()), cb)
|
||||||
|
cb(path.Join(name, f.Name()))
|
||||||
} else {
|
} else {
|
||||||
cb(path.Join(name, f.Name()))
|
cb(path.Join(name, f.Name()))
|
||||||
}
|
}
|
||||||
@ -174,17 +175,19 @@ var Index = &ice.Context{Name: "nfs", Help: "存储模块",
|
|||||||
m.Cmd(ice.APP_SEARCH, "add", "dir", "base", m.AddCmd(&ice.Command{Name: "search word", Help: "搜索引擎", Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
|
m.Cmd(ice.APP_SEARCH, "add", "dir", "base", m.AddCmd(&ice.Command{Name: "search word", Help: "搜索引擎", Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
|
||||||
switch arg[0] {
|
switch arg[0] {
|
||||||
case "set":
|
case "set":
|
||||||
m.Cmdy("nfs.cat", arg[5])
|
m.Cmdy("nfs.dir", arg[5])
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
travel(m, "./", "", func(name string) {
|
travel(m, "./", "", func(name string) {
|
||||||
if strings.Contains(name, arg[0]) {
|
if strings.Contains(name, arg[0]) {
|
||||||
|
s, e := os.Stat(name)
|
||||||
|
m.Assert(e)
|
||||||
m.Push("pod", m.Option(ice.MSG_USERPOD))
|
m.Push("pod", m.Option(ice.MSG_USERPOD))
|
||||||
m.Push("engine", "dir")
|
m.Push("engine", "dir")
|
||||||
m.Push("favor", "./")
|
m.Push("favor", "file")
|
||||||
m.Push("id", "")
|
m.Push("id", kit.FmtSize(s.Size()))
|
||||||
m.Push("type", "file")
|
m.Push("type", strings.TrimPrefix(path.Ext(name), "."))
|
||||||
m.Push("name", path.Base(name))
|
m.Push("name", path.Base(name))
|
||||||
m.Push("text", name)
|
m.Push("text", name)
|
||||||
}
|
}
|
||||||
@ -192,7 +195,7 @@ var Index = &ice.Context{Name: "nfs", Help: "存储模块",
|
|||||||
}}))
|
}}))
|
||||||
}},
|
}},
|
||||||
|
|
||||||
"dir": {Name: "dir", Help: "目录", List: kit.List(
|
"dir": {Name: "dir name field auto", Help: "目录", List: kit.List(
|
||||||
kit.MDB_INPUT, "text", "name", "path", "action", "auto",
|
kit.MDB_INPUT, "text", "name", "path", "action", "auto",
|
||||||
kit.MDB_INPUT, "button", "name", "查看",
|
kit.MDB_INPUT, "button", "name", "查看",
|
||||||
kit.MDB_INPUT, "button", "name", "返回", "cb", "Last",
|
kit.MDB_INPUT, "button", "name", "返回", "cb", "Last",
|
||||||
|
@ -94,7 +94,6 @@ var Index = &ice.Context{Name: "chat", Help: "聊天中心",
|
|||||||
m.Load()
|
m.Load()
|
||||||
m.Watch(ice.SYSTEM_INIT, m.Prefix("init"))
|
m.Watch(ice.SYSTEM_INIT, m.Prefix("init"))
|
||||||
m.Watch(ice.USER_CREATE, m.Prefix("auto"))
|
m.Watch(ice.USER_CREATE, m.Prefix("auto"))
|
||||||
|
|
||||||
}},
|
}},
|
||||||
ice.ICE_EXIT: {Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
|
ice.ICE_EXIT: {Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
|
||||||
m.Save("river")
|
m.Save("river")
|
||||||
@ -545,6 +544,11 @@ var Index = &ice.Context{Name: "chat", Help: "聊天中心",
|
|||||||
}},
|
}},
|
||||||
|
|
||||||
"search": {Name: "search label pod engine word", Help: "搜索引擎", Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
|
"search": {Name: "search label pod engine word", Help: "搜索引擎", Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
|
||||||
|
if len(arg) < 2 {
|
||||||
|
m.Cmdy(ice.WEB_LABEL, arg)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
switch arg[0] {
|
switch arg[0] {
|
||||||
case "add":
|
case "add":
|
||||||
if m.Richs("search", nil, arg[1], nil) == nil {
|
if m.Richs("search", nil, arg[1], nil) == nil {
|
||||||
@ -579,6 +583,18 @@ var Index = &ice.Context{Name: "chat", Help: "聊天中心",
|
|||||||
})
|
})
|
||||||
})
|
})
|
||||||
default:
|
default:
|
||||||
|
if len(arg) == 2 {
|
||||||
|
m.Richs("search", nil, "*", func(key string, value map[string]interface{}) {
|
||||||
|
m.Push(key, value)
|
||||||
|
})
|
||||||
|
break
|
||||||
|
}
|
||||||
|
if len(arg) == 3 {
|
||||||
|
m.Richs("search", nil, "*", func(key string, value map[string]interface{}) {
|
||||||
|
m.Push(key, value)
|
||||||
|
})
|
||||||
|
break
|
||||||
|
}
|
||||||
m.Cmdy(ice.WEB_LABEL, arg[0], arg[1], "web.chat.search", "get", arg[2:])
|
m.Cmdy(ice.WEB_LABEL, arg[0], arg[1], "web.chat.search", "get", arg[2:])
|
||||||
}
|
}
|
||||||
}},
|
}},
|
||||||
|
@ -29,7 +29,7 @@ var Index = &ice.Context{Name: "vim", Help: "编辑器",
|
|||||||
m.Conf(ice.WEB_FAVOR, "meta.render.vimrc", m.AddCmd(&ice.Command{Name: "render favor id", Help: "渲染引擎", Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
|
m.Conf(ice.WEB_FAVOR, "meta.render.vimrc", m.AddCmd(&ice.Command{Name: "render favor id", Help: "渲染引擎", Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
|
||||||
value := m.Optionv("value").(map[string]interface{})
|
value := m.Optionv("value").(map[string]interface{})
|
||||||
switch value["name"] {
|
switch value["name"] {
|
||||||
case "read":
|
case "read", "write", "exec":
|
||||||
p := path.Join(kit.Format(kit.Value(value, "extra.pwd")), kit.Format(kit.Value(value, "extra.buf")))
|
p := path.Join(kit.Format(kit.Value(value, "extra.pwd")), kit.Format(kit.Value(value, "extra.buf")))
|
||||||
f, e := os.Open(p)
|
f, e := os.Open(p)
|
||||||
m.Assert(e)
|
m.Assert(e)
|
||||||
@ -37,8 +37,6 @@ var Index = &ice.Context{Name: "vim", Help: "编辑器",
|
|||||||
b, e := ioutil.ReadAll(f)
|
b, e := ioutil.ReadAll(f)
|
||||||
m.Assert(e)
|
m.Assert(e)
|
||||||
m.Echo(string(b))
|
m.Echo(string(b))
|
||||||
case "write":
|
|
||||||
case "exec":
|
|
||||||
}
|
}
|
||||||
}}))
|
}}))
|
||||||
}},
|
}},
|
||||||
|
@ -17,6 +17,17 @@ var Index = &ice.Context{Name: "zsh", Help: "命令行",
|
|||||||
"zsh": {Name: "zsh", Help: "命令行", Value: kit.Data("history", "zsh.history")},
|
"zsh": {Name: "zsh", Help: "命令行", Value: kit.Data("history", "zsh.history")},
|
||||||
},
|
},
|
||||||
Commands: map[string]*ice.Command{
|
Commands: map[string]*ice.Command{
|
||||||
|
ice.ICE_INIT: {Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
|
||||||
|
m.Conf(ice.WEB_FAVOR, "meta.render.shell", m.AddCmd(&ice.Command{Name: "render favor id", Help: "渲染引擎", Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
|
||||||
|
value := m.Optionv("value").(map[string]interface{})
|
||||||
|
m.Option("cmd_dir", kit.Value(value, "extra.pwd"))
|
||||||
|
m.Cmdy(ice.CLI_SYSTEM, value["text"])
|
||||||
|
}}))
|
||||||
|
m.Conf(ice.WEB_FAVOR, "meta.render.cmd", m.AddCmd(&ice.Command{Name: "render favor id", Help: "渲染引擎", Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
|
||||||
|
value := m.Optionv("value").(map[string]interface{})
|
||||||
|
m.Cmdy(kit.Split(kit.Format(value["text"])))
|
||||||
|
}}))
|
||||||
|
}},
|
||||||
ice.WEB_LOGIN: {Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
|
ice.WEB_LOGIN: {Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
|
||||||
if f, _, e := m.R.FormFile("sub"); e == nil {
|
if f, _, e := m.R.FormFile("sub"); e == nil {
|
||||||
defer f.Close()
|
defer f.Close()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user