diff --git a/base/ctx/command.go b/base/ctx/command.go index 21d5380a..c96a490c 100644 --- a/base/ctx/command.go +++ b/base/ctx/command.go @@ -2,12 +2,28 @@ package ctx import ( ice "github.com/shylinux/icebergs" + "github.com/shylinux/icebergs/base/mdb" kit "github.com/shylinux/toolkits" "sort" "strings" ) +func _command_search(m *ice.Message, arg ...string) { + ice.Pulse.Travel(func(p *ice.Context, s *ice.Context, key string, cmd *ice.Command) { + if strings.HasPrefix(key, "_") || strings.HasPrefix(key, "/") { + return + } + if arg[1] != "" && arg[1] != key && arg[1] != s.Name { + return + } + if arg[2] != "" && !strings.Contains(kit.Format(cmd.Name), arg[2]) && !strings.Contains(kit.Format(cmd.Help), arg[2]) { + return + } + + m.PushSearch("cmd", "command", "type", arg[0], "name", key, "text", s.Cap(ice.CTX_FOLLOW)) + }) +} func _command_list(m *ice.Message, name string) { p := m.Spawn(m.Source()) if name != "" { @@ -45,7 +61,11 @@ const COMMAND = "command" func init() { Index.Merge(&ice.Context{ Commands: map[string]*ice.Command{ - COMMAND: {Name: "command key auto", Help: "命令", Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) { + COMMAND: {Name: "command key auto", Help: "命令", Action: map[string]*ice.Action{ + mdb.SEARCH: {Name: "search type name text", Help: "搜索", Hand: func(m *ice.Message, arg ...string) { + _command_search(m, arg[0], arg[1], arg[2]) + }}, + }, Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) { _command_list(m, strings.Join(arg, ".")) }}, }, diff --git a/base/ctx/ctx.go b/base/ctx/ctx.go index d6ae1312..7854fd5f 100644 --- a/base/ctx/ctx.go +++ b/base/ctx/ctx.go @@ -3,52 +3,12 @@ package ctx import ( ice "github.com/shylinux/icebergs" "github.com/shylinux/icebergs/base/mdb" - kit "github.com/shylinux/toolkits" - - "strings" ) var Index = &ice.Context{Name: "ctx", Help: "配置模块", Commands: map[string]*ice.Command{ ice.CTX_INIT: {Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) { - m.Cmd(mdb.SEARCH, mdb.CREATE, COMMAND, m.AddCmd(&ice.Command{Hand: func(m *ice.Message, c *ice.Context, cc string, arg ...string) { - arg = arg[1:] - fields := kit.Split(m.Option(mdb.FIELDS)) - ice.Pulse.Travel(func(p *ice.Context, s *ice.Context, key string, cmd *ice.Command) { - if strings.HasPrefix(key, "_") || strings.HasPrefix(key, "/") { - return - } - if arg[1] != "" && arg[1] != key && arg[1] != s.Name { - return - } - if arg[2] != "" && !strings.Contains(kit.Format(cmd.Name), arg[2]) && !strings.Contains(kit.Format(cmd.Help), arg[2]) { - return - } - - for _, k := range fields { - switch k { - case kit.SSH_POD: - m.Push(k, m.Option(ice.MSG_USERPOD)) - case kit.SSH_CTX: - m.Push(k, m.Prefix()) - case kit.SSH_CMD: - m.Push(k, "_") - case kit.MDB_TIME: - m.Push(k, m.Time()) - case kit.MDB_SIZE: - m.Push(k, len(cmd.List)) - case kit.MDB_TYPE: - m.Push(k, COMMAND) - case kit.MDB_NAME: - m.Push(k, key) - case kit.MDB_TEXT: - m.Push(k, s.Cap(ice.CTX_FOLLOW)) - default: - m.Push(k, "") - } - } - }) - }})) + m.Cmd(mdb.SEARCH, mdb.CREATE, COMMAND, m.Prefix(COMMAND)) }}, ice.CTX_EXIT: {Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {}}, }, diff --git a/base/mdb/search.go b/base/mdb/search.go index 79c61e99..4678ce5e 100644 --- a/base/mdb/search.go +++ b/base/mdb/search.go @@ -30,7 +30,7 @@ func init() { if strings.Contains(arg[1], ";") { arg = strings.Split(arg[1], ";") } - m.Option(FIELDS, kit.Select("pod,ctx,cmd,time,size,type,name,text", m.Option(FIELDS))) + m.Option(FIELDS, kit.Select("pod,ctx,cmd,time,size,type,name,text", kit.Select(m.Option(FIELDS), arg, 2))) for _, k := range strings.Split(arg[0], ",") { m.Richs(SEARCH, nil, k, func(key string, value map[string]interface{}) { m.Cmdy(kit.Keys(value[kit.MDB_TEXT], value[kit.MDB_NAME]), SEARCH, arg[0], arg[1], kit.Select("", arg, 2)) diff --git a/base/nfs/nfs.go b/base/nfs/nfs.go index 45fe491c..25739213 100644 --- a/base/nfs/nfs.go +++ b/base/nfs/nfs.go @@ -270,14 +270,7 @@ func _file_search(m *ice.Message, kind, name, text string, arg ...string) { ext = value["type"] } - m.Push("pod", m.Option("pod")) - m.Push("ctx", "nfs") - m.Push("cmd", FILE) - m.Push(kit.MDB_TIME, value["time"]) - m.Push(kit.MDB_SIZE, value["size"]) - m.Push(kit.MDB_TYPE, ext) - m.Push(kit.MDB_NAME, value["path"]) - m.Push(kit.MDB_TEXT, "") + m.PushSearch("cmd", FILE, "time", value["time"], "size", value["size"], "type", ext, "name", value["path"], "text", "") }) } @@ -353,6 +346,7 @@ var Index = &ice.Context{Name: "nfs", Help: "存储模块", _file_list(m, arg[2], arg[1], 0, m.Option(DIR_DEEP) == "true", kit.Select(TYPE_BOTH, m.Option(DIR_TYPE)), nil, []string{"time", "size", "type", "path"}) }}, + "upload": {Name: "upload", Help: "上传", Hand: func(m *ice.Message, arg ...string) { up := kit.Simple(m.Optionv(ice.MSG_UPLOAD)) @@ -373,6 +367,13 @@ var Index = &ice.Context{Name: "nfs", Help: "存储模块", m.Sort(kit.MDB_TIME, "time_r") }}, FILE: {Name: "file path auto", Help: "文件", Action: map[string]*ice.Action{ + mdb.SEARCH: {Name: "search type name text", Help: "搜索", Hand: func(m *ice.Message, arg ...string) { + _file_search(m, arg[0], arg[1], arg[2], arg[3:]...) + }}, + mdb.RENDER: {Name: "render type name text", Help: "渲染", Hand: func(m *ice.Message, arg ...string) { + _file_show(m, path.Join(arg[2], arg[1])) + }}, + "append": {Name: "append", Help: "追加", Hand: func(m *ice.Message, arg ...string) { if strings.Contains(arg[0], "/") { os.MkdirAll(path.Dir(arg[0]), ice.MOD_DIR) @@ -388,13 +389,6 @@ var Index = &ice.Context{Name: "nfs", Help: "存储模块", } } }}, - - mdb.SEARCH: {Name: "search type name text", Help: "搜索", Hand: func(m *ice.Message, arg ...string) { - _file_search(m, arg[0], arg[1], arg[2], arg[3:]...) - }}, - mdb.RENDER: {Name: "render type name text", Help: "渲染", Hand: func(m *ice.Message, arg ...string) { - _file_show(m, path.Join(arg[2], arg[1])) - }}, }, Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) { if len(arg) == 0 || strings.HasSuffix(arg[0], "/") { m.Cmdy(DIR, arg) diff --git a/base/web/space.go b/base/web/space.go index 8d8d2a13..ac218d7f 100644 --- a/base/web/space.go +++ b/base/web/space.go @@ -174,7 +174,7 @@ func _space_handle(m *ice.Message, safe bool, send map[string]*ice.Message, c *w func _space_search(m *ice.Message, kind, name, text string, arg ...string) { m.Richs(SPACE, nil, kit.MDB_FOREACH, func(key string, val map[string]interface{}) { if val = kit.GetMeta(val); strings.Contains(kit.Format(val["name"]), name) { - m.PushSearch("cmd", SPACE, val) + m.PushSearch("cmd", SPACE, "type", val["type"], "name", val["name"], "text", kit.MergeURL(m.Option(ice.MSG_USERWEB), "pod", val["name"])) } }) } diff --git a/core/chat/chat.go b/core/chat/chat.go index 0dc38ce8..0f88124f 100644 --- a/core/chat/chat.go +++ b/core/chat/chat.go @@ -3,6 +3,7 @@ package chat import ( ice "github.com/shylinux/icebergs" "github.com/shylinux/icebergs/base/aaa" + "github.com/shylinux/icebergs/base/mdb" "github.com/shylinux/icebergs/base/web" kit "github.com/shylinux/toolkits" ) @@ -12,6 +13,7 @@ const CHAT = "chat" var Index = &ice.Context{Name: CHAT, Help: "聊天中心", Commands: map[string]*ice.Command{ ice.CTX_INIT: {Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) { + m.Cmd(mdb.SEARCH, mdb.CREATE, EMAIL, m.Prefix(EMAIL)) m.Load() m.Cmd(web.SERVE, aaa.WHITE, "header", "river", "action", "footer") diff --git a/core/chat/email.go b/core/chat/email.go new file mode 100644 index 00000000..18f38b5f --- /dev/null +++ b/core/chat/email.go @@ -0,0 +1,27 @@ +package chat + +import ( + ice "github.com/shylinux/icebergs" + "github.com/shylinux/icebergs/base/mdb" + kit "github.com/shylinux/toolkits" +) + +func _email_show(m *ice.Message, name, text string, arg ...string) { +} +func _email_search(m *ice.Message, kind, name, text string) { + m.PushSearch("cmd", EMAIL, "type", "163", "name", name, "text", kit.MergeURL("https://mail.163.com")) +} + +const EMAIL = "email" + +func init() { + Index.Merge(&ice.Context{Commands: map[string]*ice.Command{ + EMAIL: {Name: "email [name] word", Help: "百度", Action: map[string]*ice.Action{ + mdb.SEARCH: {Name: "search type name text", Help: "搜索", Hand: func(m *ice.Message, arg ...string) { + _email_search(m, arg[0], arg[1], arg[2]) + }}, + }, Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) { + _email_show(m, arg[0], kit.Select(arg[0], arg[1]), arg[2:]...) + }}, + }}) +} diff --git a/core/chat/header.go b/core/chat/header.go index 829b0598..554d3a37 100644 --- a/core/chat/header.go +++ b/core/chat/header.go @@ -36,6 +36,9 @@ func init() { m.Echo(aaa.UserRole(m, m.Option("who"))) }}, + "background": {Name: "background", Help: "背景图片", Hand: func(m *ice.Message, arg ...string) { + m.Option("background", m.Conf(HEADER, "background", arg[0])) + }}, "pack": {Name: "pack", Help: "打包", Hand: func(m *ice.Message, arg ...string) { m.Cmdy("web.code.webpack", "create") }}, @@ -43,6 +46,7 @@ func init() { m.Cmdy("web.chat.wx.access", "config") }}, }, Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) { + m.Option("background", m.Conf(HEADER, "background")) m.Echo(m.Conf(HEADER, TITLE)) }}, }, diff --git a/core/code/csdn.go b/core/code/csdn.go new file mode 100644 index 00000000..bf87ec35 --- /dev/null +++ b/core/code/csdn.go @@ -0,0 +1,54 @@ +package code + +import ( + ice "github.com/shylinux/icebergs" + "github.com/shylinux/icebergs/base/mdb" + kit "github.com/shylinux/toolkits" + "strings" +) + +func _csdn_show(m *ice.Message, name, text string, arg ...string) { +} +func _csdn_search(m *ice.Message, kind, name, text string) { + if !strings.Contains(kind, "*") && !strings.Contains(kind, "csdn") { + return + } + + m.PushSearch("cmd", CSDN, "type", "csdn", "name", name, "text", + kit.MergeURL("https://so.csdn.net/so/search/all", "q", name)) + + m.PushSearch("cmd", CSDN, "type", "juejin", "name", name, "text", + kit.MergeURL("https://juejin.cn/search?type=all", "query", name)) + + m.PushSearch("cmd", CSDN, "type", "51cto", "name", name, "text", + kit.MergeURL("http://so.51cto.com/?sort=time", "keywords", name)) + + m.PushSearch("cmd", CSDN, "type", "oschina", "name", name, "text", + kit.MergeURL("https://www.oschina.net/search?scope=project", "q", name)) + + m.PushSearch("cmd", CSDN, "type", "imooc", "name", name, "text", + kit.MergeURL("https://www.imooc.com/search/", "words", name)) + + m.PushSearch("cmd", CSDN, "type", "segmentfault", "name", name, "text", + kit.MergeURL("https://segmentfault.com/search", "q", name)) + + m.PushSearch("cmd", CSDN, "type", "nowcoder", "name", name, "text", + kit.MergeURL("https://www.nowcoder.com/search?type=all", "query", name)) + + m.PushSearch("cmd", CSDN, "type", "leetcode-cn", "name", name, "text", + kit.MergeURL("https://leetcode-cn.com/problemset/all/", "search", name)) +} + +const CSDN = "csdn" + +func init() { + Index.Merge(&ice.Context{Commands: map[string]*ice.Command{ + CSDN: {Name: "csdn [name] word", Help: "百度", Action: map[string]*ice.Action{ + mdb.SEARCH: {Name: "search type name text", Help: "搜索", Hand: func(m *ice.Message, arg ...string) { + _csdn_search(m, arg[0], arg[1], arg[2]) + }}, + }, Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) { + _csdn_show(m, arg[0], kit.Select(arg[0], arg[1]), arg[2:]...) + }}, + }}) +} diff --git a/core/code/github.go b/core/code/github.go new file mode 100644 index 00000000..13723006 --- /dev/null +++ b/core/code/github.go @@ -0,0 +1,28 @@ +package code + +import ( + ice "github.com/shylinux/icebergs" + "github.com/shylinux/icebergs/base/mdb" + kit "github.com/shylinux/toolkits" +) + +func _github_show(m *ice.Message, name, text string, arg ...string) { +} +func _github_search(m *ice.Message, kind, name, text string) { + m.PushSearch("cmd", GITHUB, "type", "github", "name", name, "text", + kit.MergeURL("https://github.com/search", "q", name)) +} + +const GITHUB = "github" + +func init() { + Index.Merge(&ice.Context{Commands: map[string]*ice.Command{ + GITHUB: {Name: "github [name] word", Help: "百度", Action: map[string]*ice.Action{ + mdb.SEARCH: {Name: "search type name text", Help: "搜索", Hand: func(m *ice.Message, arg ...string) { + _github_search(m, arg[0], arg[1], arg[2]) + }}, + }, Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) { + _github_show(m, arg[0], kit.Select(arg[0], arg[1]), arg[2:]...) + }}, + }}) +} diff --git a/core/mall/beike.go b/core/mall/beike.go new file mode 100644 index 00000000..d966dacb --- /dev/null +++ b/core/mall/beike.go @@ -0,0 +1,30 @@ +package mall + +import ( + ice "github.com/shylinux/icebergs" + "github.com/shylinux/icebergs/base/mdb" + kit "github.com/shylinux/toolkits" + + "net/url" +) + +func _beike_show(m *ice.Message, name, text string, arg ...string) { +} +func _beike_search(m *ice.Message, kind, name, text string) { + m.PushSearch("cmd", BEIKE, "type", kind, "name", name, "text", + kit.MergeURL("https://ke.com/ershoufang/rs"+url.QueryEscape(name))) +} + +const BEIKE = "beike" + +func init() { + Index.Merge(&ice.Context{Commands: map[string]*ice.Command{ + BEIKE: {Name: "beike [name] word", Help: "百度", Action: map[string]*ice.Action{ + mdb.SEARCH: {Name: "search type name text", Help: "搜索", Hand: func(m *ice.Message, arg ...string) { + _beike_search(m, arg[0], arg[1], arg[2]) + }}, + }, Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) { + _beike_show(m, arg[0], kit.Select(arg[0], arg[1]), arg[2:]...) + }}, + }}) +} diff --git a/core/mall/mall.go b/core/mall/mall.go index 76e14f22..2e3dc7a4 100644 --- a/core/mall/mall.go +++ b/core/mall/mall.go @@ -9,7 +9,9 @@ const MALL = "mall" var Index = &ice.Context{Name: MALL, Help: "贸易中心", Commands: map[string]*ice.Command{ - ice.CTX_INIT: {Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) { m.Load() }}, + ice.CTX_INIT: {Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) { + m.Load() + }}, ice.CTX_EXIT: {Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) { m.Save() }}, }, } diff --git a/core/mall/taobao.go b/core/mall/taobao.go new file mode 100644 index 00000000..43de7ee9 --- /dev/null +++ b/core/mall/taobao.go @@ -0,0 +1,27 @@ +package mall + +import ( + ice "github.com/shylinux/icebergs" + "github.com/shylinux/icebergs/base/mdb" + kit "github.com/shylinux/toolkits" +) + +func _taobao_show(m *ice.Message, name, text string, arg ...string) { +} +func _taobao_search(m *ice.Message, kind, name, text string) { + m.PushSearch("cmd", TAOBAO, "type", kind, "name", name, "text", kit.MergeURL("https://s.taobao.com/search", "q", name)) +} + +const TAOBAO = "taobao" + +func init() { + Index.Merge(&ice.Context{Commands: map[string]*ice.Command{ + TAOBAO: {Name: "taobao [name] word", Help: "百度", Action: map[string]*ice.Action{ + mdb.SEARCH: {Name: "search type name text", Help: "搜索", Hand: func(m *ice.Message, arg ...string) { + _taobao_search(m, arg[0], arg[1], arg[2]) + }}, + }, Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) { + _taobao_show(m, arg[0], kit.Select(arg[0], arg[1]), arg[2:]...) + }}, + }}) +} diff --git a/core/wiki/baidu.go b/core/wiki/baidu.go new file mode 100644 index 00000000..2afb6601 --- /dev/null +++ b/core/wiki/baidu.go @@ -0,0 +1,50 @@ +package wiki + +import ( + ice "github.com/shylinux/icebergs" + "github.com/shylinux/icebergs/base/mdb" + kit "github.com/shylinux/toolkits" + + "net/url" + "strings" +) + +func _baidu_show(m *ice.Message, name, text string, arg ...string) { + _option(m, BAIDU, name, text, arg...) + // m.Cmdy(mdb.RENDER, web.RENDER.Frame, kit.Format("https://baidu.com/s?wd=%s", text)) +} +func _baidu_search(m *ice.Message, kind, name, text string) { + if !strings.Contains(kind, "*") && !strings.Contains(kind, "baidu") { + return + } + + m.PushSearch("cmd", BAIDU, "type", "web", "name", name, "text", + kit.MergeURL("https://www.baidu.com/s", "wd", name)) + + m.PushSearch("cmd", BAIDU, "type", "map", "name", name, "text", + kit.MergeURL("https://map.baidu.com/search?querytype=s", "wd", name)) + + m.PushSearch("cmd", BAIDU, "type", "zhihu", "name", name, "text", + kit.MergeURL("https://www.zhihu.com/search?type=content", "q", name)) + + m.PushSearch("cmd", BAIDU, "type", "weibo", "name", name, "text", + kit.MergeURL("https://s.weibo.com/weibo/"+url.QueryEscape(name))) + + m.PushSearch("cmd", BAIDU, "type", "taotiao", "name", name, "text", + kit.MergeURL("https://www.toutiao.com/search/", "keyword", name)) +} + +const BAIDU = "baidu" + +func init() { + Index.Merge(&ice.Context{Commands: map[string]*ice.Command{ + BAIDU: {Name: "baidu [name] word", Help: "百度", Action: map[string]*ice.Action{ + mdb.SEARCH: {Name: "search type name text", Help: "搜索", Hand: func(m *ice.Message, arg ...string) { + _baidu_search(m, arg[0], arg[1], arg[2]) + }}, + }, Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) { + arg = _name(m, arg) + _baidu_show(m, arg[0], kit.Select(arg[0], arg[1]), arg[2:]...) + }}, + }}) +} diff --git a/core/wiki/feel.go b/core/wiki/feel.go index d1ac951a..fa929664 100644 --- a/core/wiki/feel.go +++ b/core/wiki/feel.go @@ -16,12 +16,15 @@ func init() { )}, }, Commands: map[string]*ice.Command{ - FEEL: {Name: "feel path auto choose@chooseImage upload 上一页 下一页 下载 参数", Help: "影音媒体", Meta: kit.Dict( + FEEL: {Name: "feel path auto choose@chooseImage upload 上一页 下一页 下载 参数 background", Help: "影音媒体", Meta: kit.Dict( "display", "/plugin/local/wiki/feel.js", ), Action: map[string]*ice.Action{ "choose": {Name: "choose", Help: "本机照片", Hand: func(m *ice.Message, arg ...string) { _wiki_upload(m, FEEL, m.Option(kit.MDB_PATH)) }}, + "background": {Name: "background", Help: "背景", Hand: func(m *ice.Message, arg ...string) { + m.Conf("web.chat.header", "background") + }}, web.UPLOAD: {Name: "upload", Help: "上传", Hand: func(m *ice.Message, arg ...string) { _wiki_upload(m, FEEL, m.Option(kit.MDB_PATH)) }}, diff --git a/core/wiki/music.go b/core/wiki/music.go new file mode 100644 index 00000000..9f1337a8 --- /dev/null +++ b/core/wiki/music.go @@ -0,0 +1,30 @@ +package wiki + +import ( + ice "github.com/shylinux/icebergs" + "github.com/shylinux/icebergs/base/mdb" + kit "github.com/shylinux/toolkits" +) + +func _music_show(m *ice.Message, name, text string, arg ...string) { + _option(m, MUSIC, name, text, arg...) +} +func _music_search(m *ice.Message, kind, name, text string) { + m.PushSearch("cmd", MUSIC, "type", "163", "name", name, "text", + kit.MergeURL("https://music.163.com/#/search/m/", "s", name)) +} + +const MUSIC = "music" + +func init() { + Index.Merge(&ice.Context{Commands: map[string]*ice.Command{ + MUSIC: {Name: "music [name] url", Help: "视频", Action: map[string]*ice.Action{ + mdb.SEARCH: {Name: "search type name text", Help: "搜索", Hand: func(m *ice.Message, arg ...string) { + _music_search(m, arg[0], arg[1], arg[2]) + }}, + }, Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) { + arg = _name(m, arg) + _music_show(m, arg[0], kit.Select(arg[0], arg[1]), arg[2:]...) + }}, + }}) +} diff --git a/core/wiki/video.go b/core/wiki/video.go new file mode 100644 index 00000000..5a7785f6 --- /dev/null +++ b/core/wiki/video.go @@ -0,0 +1,43 @@ +package wiki + +import ( + ice "github.com/shylinux/icebergs" + "github.com/shylinux/icebergs/base/mdb" + kit "github.com/shylinux/toolkits" + + "net/url" +) + +func _video_show(m *ice.Message, name, text string, arg ...string) { + _option(m, VIDEO, name, text, arg...) + m.Render(ice.RENDER_TEMPLATE, m.Conf(VIDEO, "meta.template")) +} +func _video_search(m *ice.Message, kind, name, text string) { + m.PushSearch("cmd", VIDEO, "type", "v", "name", name, "text", + kit.MergeURL("https://v.qq.com/x/search/", "q", name)) + + m.PushSearch("cmd", VIDEO, "type", "iqiyi", "name", name, "text", + kit.MergeURL("https://so.iqiyi.com/so/q_"+url.QueryEscape(name))) + + m.PushSearch("cmd", VIDEO, "type", "kuaishou", "name", name, "text", + kit.MergeURL("https://video.kuaishou.com/search", "searchKey", name)) + + m.PushSearch("cmd", VIDEO, "type", "bilibili", "name", name, "text", + kit.MergeURL("https://search.bilibili.com/all", "keyword", name)) + +} + +const VIDEO = "video" + +func init() { + Index.Merge(&ice.Context{Commands: map[string]*ice.Command{ + VIDEO: {Name: "video [name] url", Help: "视频", Action: map[string]*ice.Action{ + mdb.SEARCH: {Name: "search type name text", Help: "搜索", Hand: func(m *ice.Message, arg ...string) { + _video_search(m, arg[0], arg[1], arg[2]) + }}, + }, Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) { + arg = _name(m, arg) + _video_show(m, arg[0], kit.Select(arg[0], arg[1]), arg[2:]...) + }}, + }}) +} diff --git a/core/wiki/wiki.go b/core/wiki/wiki.go index b96d26b3..684525af 100644 --- a/core/wiki/wiki.go +++ b/core/wiki/wiki.go @@ -2,6 +2,7 @@ package wiki import ( ice "github.com/shylinux/icebergs" + "github.com/shylinux/icebergs/base/mdb" "github.com/shylinux/icebergs/base/nfs" "github.com/shylinux/icebergs/base/web" kit "github.com/shylinux/toolkits" @@ -53,7 +54,11 @@ const WIKI = "wiki" var Index = &ice.Context{Name: WIKI, Help: "文档中心", Commands: map[string]*ice.Command{ - ice.CTX_INIT: {Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) { m.Load() }}, + ice.CTX_INIT: {Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) { + m.Cmd(mdb.SEARCH, mdb.CREATE, VIDEO, m.Prefix(VIDEO)) + m.Cmd(mdb.SEARCH, mdb.CREATE, MUSIC, m.Prefix(MUSIC)) + m.Load() + }}, ice.CTX_EXIT: {Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) { m.Save() }}, }, } diff --git a/core/wiki/word.go b/core/wiki/word.go index a2afc41f..763e7daf 100644 --- a/core/wiki/word.go +++ b/core/wiki/word.go @@ -271,14 +271,6 @@ func _image_show(m *ice.Message, name, text string, arg ...string) { _option(m, IMAGE, name, text, arg...) m.Render(ice.RENDER_TEMPLATE, m.Conf(IMAGE, "meta.template")) } -func _video_show(m *ice.Message, name, text string, arg ...string) { - _option(m, VIDEO, name, text, arg...) - m.Render(ice.RENDER_TEMPLATE, m.Conf(VIDEO, "meta.template")) -} -func _baidu_show(m *ice.Message, name, text string, arg ...string) { - _option(m, BAIDU, name, text, arg...) - // m.Cmdy(mdb.RENDER, web.RENDER.Frame, kit.Format("https://baidu.com/s?wd=%s", text)) -} func _other_show(m *ice.Message, name, text string, arg ...string) { _option(m, OTHER, name, text, arg...) // m.Cmdy(mdb.RENDER, web.RENDER.Frame, text) @@ -309,9 +301,7 @@ const ( ORDER = "order" TABLE = "table" IMAGE = "image" - VIDEO = "video" - BAIDU = "baidu" OTHER = "other" PREMENU = "premenu" @@ -442,15 +432,7 @@ func init() { _image_show(m, arg[0], kit.Select(arg[0], arg[1]), arg[2:]...) m.Render("") }}, - VIDEO: {Name: "video [name] url", Help: "视频", Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) { - arg = _name(m, arg) - _video_show(m, arg[0], kit.Select(arg[0], arg[1]), arg[2:]...) - }}, - BAIDU: {Name: "baidu [name] word", Help: "百度", Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) { - arg = _name(m, arg) - _baidu_show(m, arg[0], kit.Select(arg[0], arg[1]), arg[2:]...) - }}, OTHER: {Name: "other [name] url", Help: "网页", Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) { arg = _name(m, arg) _other_show(m, arg[0], kit.Select(arg[0], arg[1]), arg[2:]...) diff --git a/go.sum b/go.sum index faeb4772..2349ebb1 100644 --- a/go.sum +++ b/go.sum @@ -1,11 +1,13 @@ github.com/AaronO/go-git-http v0.0.0-20161214145340-1d9485b3a98f/go.mod h1:+6Yuq73F9068Na+mSBNXCvyuxvgw4f/g5ii40e3U8Sc= github.com/Baozisoftware/qrcode-terminal-go v0.0.0-20170407111555-c0650d8dff0f h1:2dk3eOnYllh+wUOuDhOoC2vUVoJF/5z478ryJ+wzEII= github.com/Baozisoftware/qrcode-terminal-go v0.0.0-20170407111555-c0650d8dff0f/go.mod h1:4a58ifQTEe2uwwsaqbh3i2un5/CBPg+At/qHpt18Tmk= +github.com/creack/pty v1.1.7 h1:6pwm8kMQKCmgUg0ZHTm5+/YvRK0s3THD/28+T6/kk4A= github.com/creack/pty v1.1.7/go.mod h1:lj5s0c3V2DBrqTV7llrYr5NG6My20zk30Fl46Y7DoTY= github.com/google/uuid v1.1.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/gorilla/websocket v1.4.2 h1:+/TMaTYc4QFitKJxsQ7Yye35DkWvkdLcvGKqM+x0Ufc= github.com/gorilla/websocket v1.4.2/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE= github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= +github.com/kr/pty v1.1.8 h1:AkaSdXYQOWeaO3neb8EM634ahkXXe3jYbVh/F9lq+GI= github.com/kr/pty v1.1.8/go.mod h1:O1sed60cT9XZ5uDucP5qwvh+TE3NnUj51EiZO/lmSfw= github.com/maruel/rs v0.0.0-20150922171536-2c81c4312fe4/go.mod h1:kcRFpEzolcEklV6rD7W95mG49/sbdX/PlFmd7ni3RvA= github.com/mattn/go-colorable v0.1.8 h1:c1ghPdyEDarC70ftn0y+A/Ee++9zz8ljHG1b13eJ0s8= @@ -22,6 +24,7 @@ github.com/skip2/go-qrcode v0.0.0-20200617195104-da1b6568686e/go.mod h1:XV66xRDq github.com/tuotoo/qrcode v0.0.0-20190222102259-ac9c44189bf2/go.mod h1:lPnW9HVS0vJdeYyQtOvIvlXgZPNhUAhwz+z5r8AJk0Y= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= +golang.org/x/crypto v0.0.0-20201208171446-5f87f3452ae9 h1:sYNJzB4J8toYPQTM6pAkcmBRgw9SnQKP9oXCHfgy604= golang.org/x/crypto v0.0.0-20201208171446-5f87f3452ae9/go.mod h1:jdWPYTVW3xRLrWPugEBEK3UY2ZEsg3UU495nc5E+M+I= golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= @@ -30,5 +33,6 @@ golang.org/x/sys v0.0.0-20191026070338-33540a1f6037/go.mod h1:h1NjWce9XRLGQEsW7w golang.org/x/sys v0.0.0-20200116001909-b77594299b42/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200223170610-d5e6a3e2c0ae h1:/WDfKMnPU+m5M4xB+6x4kaepxRw6jWvR5iDRdvjHgy8= golang.org/x/sys v0.0.0-20200223170610-d5e6a3e2c0ae/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/term v0.0.0-20201117132131-f5c789dd3221 h1:/ZHdbVpdR/jk3g30/d4yUL0JU9kksj8+F/bnQUVLGDM= golang.org/x/term v0.0.0-20201117132131-f5c789dd3221/go.mod h1:Nr5EML6q2oocZ2LXRh80K7BxOlk5/8JxuGnuhpl+muw= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= diff --git a/misc.go b/misc.go index 7b03282a..2b8f5b7d 100644 --- a/misc.go +++ b/misc.go @@ -115,17 +115,9 @@ func (m *Message) PushSearch(args ...interface{}) { case kit.SSH_CMD: m.Push(k, data[kit.SSH_CMD]) case kit.MDB_TIME: - m.Push(k, m.Time()) - case kit.MDB_SIZE: - m.Push(k, "") - case kit.MDB_TYPE: - m.Push(k, data[kit.MDB_TYPE]) - case kit.MDB_NAME: - m.Push(k, data[kit.MDB_NAME]) - case kit.MDB_TEXT: - m.Push(k, data[kit.MDB_TEXT]) + m.Push(k, kit.Select(m.Time(), data[kit.MDB_TIME])) default: - m.Push(k, data[k]) + m.Push(k, kit.Select("", data[k])) } } }