diff --git a/base/nfs/nfs.go b/base/nfs/nfs.go
index b781b75c..be049405 100644
--- a/base/nfs/nfs.go
+++ b/base/nfs/nfs.go
@@ -3,6 +3,7 @@ package nfs
import (
ice "github.com/shylinux/icebergs"
"github.com/shylinux/icebergs/base/cli"
+ "github.com/shylinux/icebergs/base/mdb"
kit "github.com/shylinux/toolkits"
"bufio"
@@ -18,6 +19,10 @@ import (
"strings"
)
+func _file_ext(name string) string {
+ return strings.ToLower(kit.Select(path.Base(name), strings.TrimPrefix(path.Ext(name), ".")))
+}
+
func _file_list(m *ice.Message, root string, name string, level int, deep bool, dir_type string, dir_reg *regexp.Regexp, fields []string) {
if fs, e := ioutil.ReadDir(path.Join(root, name)); e != nil {
if f, e := os.Open(path.Join(root, name)); e == nil {
@@ -52,9 +57,9 @@ func _file_list(m *ice.Message, root string, name string, level int, deep bool,
m.Push("time", f.ModTime().Format(ice.MOD_TIME))
case "type":
if m.Assert(e) && f.IsDir() {
- m.Push("type", "dir")
+ m.Push("type", DIR)
} else {
- m.Push("type", "file")
+ m.Push("type", FILE)
}
case "full":
if f.IsDir() {
@@ -199,39 +204,50 @@ func _file_trash(m *ice.Message, name string) {
}
func _file_search(m *ice.Message, kind, name, text string, arg ...string) {
- if kind == FILE {
- msg := m.Spawn()
- rg, e := regexp.Compile("")
- m.Assert(e)
- _file_list(msg, "./", "", 0, true, "both", rg, []string{"path", "time", "size"})
- msg.Table(func(index int, value map[string]string, head []string) {
- if !strings.Contains(value["path"], name) {
- return
- }
- m.Push("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, FILE)
- m.Push(kit.MDB_NAME, value["path"])
- m.Push(kit.MDB_TEXT, "")
- })
- }
+ rg, e := regexp.Compile("")
+ m.Assert(e)
+
+ msg := m.Spawn()
+ _file_list(msg, "./", "", 0, true, "both", rg, []string{"time", "size", "type", "path"})
+ msg.Table(func(index int, value map[string]string, head []string) {
+ if !strings.Contains(value["path"], name) {
+ return
+ }
+ ext := _file_ext(value["path"])
+ if value["type"] == DIR {
+ ext = DIR
+ } else if m.Richs(mdb.RENDER, nil, ext, nil) == nil {
+ 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, "")
+ })
}
func _file_render(m *ice.Message, kind, name, text string, arg ...string) {
- _file_show(m, name)
+ if m.Conf(FILE, kit.Keys("meta.source", _file_ext(name))) == "true" {
+ _file_show(m, name)
+ } else {
+ m.Echo(name)
+ }
}
const (
- DIR = "dir"
CAT = "cat"
SAVE = "save"
COPY = "copy"
LINK = "link"
TRASH = "trash"
+ DIR = "dir"
FILE = "file"
+ NFS = "nfs"
)
const (
DIR_ROOT = "dir_root"
@@ -248,24 +264,54 @@ const (
var Index = &ice.Context{Name: "nfs", Help: "存储模块",
Configs: map[string]*ice.Config{
TRASH: {Name: "trash", Help: "删除", Value: kit.Data("path", "var/trash")},
+ FILE: {Name: "file", Help: "文件", Value: kit.Data(
+ "source", kit.Dict(
+ "makefile", "true",
+ "sh", "true",
+ "shy", "true",
+ "py", "true",
+ "js", "true",
+ "go", "true",
+ "vim", "true",
+ "conf", "true",
+ "json", "true",
+ ),
+ )},
},
Commands: map[string]*ice.Command{
ice.CTX_INIT: {Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
- m.Cmd("mdb.search", "create", "file", "file", "nfs")
- m.Cmd("mdb.render", "create", "file", "file", "nfs")
+ m.Cmd(mdb.SEARCH, mdb.CREATE, FILE, FILE, NFS)
+ m.Cmd(mdb.RENDER, mdb.CREATE, FILE, FILE, NFS)
+ m.Cmd(mdb.RENDER, mdb.CREATE, DIR)
+
+ m.Cmd(mdb.RENDER, mdb.CREATE, "bin", m.AddCmd(&ice.Command{Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
+ m.Echo("hello world")
+ }}))
+ m.Cmd(mdb.RENDER, mdb.CREATE, "m4v", m.AddCmd(&ice.Command{Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
+ if !strings.HasPrefix(arg[1], "http") {
+ arg[1] = path.Join("/share/local", kit.Path(arg[1]))
+ }
+ m.Echo(``, arg[1])
+ }}))
}},
FILE: {Name: "file", Help: "文件", Action: map[string]*ice.Action{
- "search": {Name: "search type name text", Help: "搜索", Hand: func(m *ice.Message, arg ...string) {
+ 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:]...)
}},
- "render": {Name: "render type name text", Help: "渲染", Hand: func(m *ice.Message, arg ...string) {
+ mdb.RENDER: {Name: "render type name text", Help: "渲染", Hand: func(m *ice.Message, arg ...string) {
_file_render(m, arg[0], arg[1], arg[2], arg[3:]...)
}},
}, Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
}},
-
- DIR: {Name: "dir path field...", Help: "目录", Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
+ DIR: {Name: "dir path field...", 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_list(m, "./", arg[1], 0, false, "both", nil, []string{"time", "size", "type", "path"})
+ }},
+ }, Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
rg, _ := regexp.Compile(m.Option("dir_reg"))
_file_list(m, kit.Select("./", m.Option("dir_root")), kit.Select("", arg, 0),
0, m.Options("dir_deep"), kit.Select("both", m.Option("dir_type")), rg,
diff --git a/base/web/favor.go b/base/web/favor.go
index 75fbba8d..f9d974b9 100644
--- a/base/web/favor.go
+++ b/base/web/favor.go
@@ -130,7 +130,7 @@ func _favor_search(m *ice.Message, kind, name, text string, arg ...string) {
}
m.Push("pod", m.Option("pod"))
m.Push("ctx", "web")
- m.Push("cmd", "favor")
+ m.Push("cmd", SPIDE)
m.Push(key, value, []string{kit.MDB_TIME}, val)
m.Push(kit.MDB_SIZE, kit.FmtSize(int64(len(kit.Format(value[kit.MDB_TEXT])))))
m.Push(key, value, []string{kit.MDB_TYPE, kit.MDB_NAME, kit.MDB_TEXT}, val)
diff --git a/base/web/render.go b/base/web/render.go
index 1ea5c37f..9fcd883a 100644
--- a/base/web/render.go
+++ b/base/web/render.go
@@ -14,6 +14,13 @@ import (
"time"
)
+func URL(m *ice.Message, path string, arg ...interface{}) string {
+ list := kit.Simple(arg)
+ if m.Option("pod") != "" {
+ list = append(list, "pod", m.Option("pod"))
+ }
+ return kit.MergeURL2(m.R.Header.Get("Origin"), path, list)
+}
func Count(m *ice.Message, cmd, key, name string) int {
count := kit.Int(m.Conf(cmd, kit.Keys(key, name)))
m.Conf(cmd, kit.Keys(key, name), count+1)
@@ -99,10 +106,12 @@ var RENDER = struct {
Button string
Field string
A string
+ IMG string
}{
Button: "button",
Field: "field",
A: "a",
+ IMG: "img",
}
func init() {
@@ -119,6 +128,9 @@ func init() {
u := kit.Select(m.Conf(SHARE, "meta.domain"), arg, 1)
m.Echo(`%s`, u, arg[0])
}},
+ RENDER.IMG: {Hand: func(m *ice.Message, arg ...string) {
+ m.Echo(`
`, arg[0])
+ }},
}, Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
m.Echo(``, arg[0], arg[1])
}},
diff --git a/base/web/share.go b/base/web/share.go
index dc85c8fc..d9d23800 100644
--- a/base/web/share.go
+++ b/base/web/share.go
@@ -27,11 +27,11 @@ func _share_list(m *ice.Message, key string, fields ...string) {
m.Push("detail", value)
m.Push(kit.MDB_KEY, kit.MDB_LINK)
- m.Push(kit.MDB_VALUE, fmt.Sprintf(m.Conf(SHARE, "meta.template.link"), m.Conf(SHARE, "meta.domain"), key, key))
+ m.Push(kit.MDB_VALUE, m.Cmdx(mdb.RENDER, RENDER.A, key, URL(m, kit.Format("/share/%s", key))))
m.Push(kit.MDB_KEY, kit.MDB_SHARE)
- m.Push(kit.MDB_VALUE, fmt.Sprintf(m.Conf(SHARE, "meta.template.share"), m.Conf(SHARE, "meta.domain"), key))
+ m.Push(kit.MDB_VALUE, m.Cmdx(mdb.RENDER, RENDER.IMG, URL(m, kit.Format("/share/%s/share", key))))
m.Push(kit.MDB_KEY, kit.MDB_VALUE)
- m.Push(kit.MDB_VALUE, fmt.Sprintf(m.Conf(SHARE, "meta.template.value"), m.Conf(SHARE, "meta.domain"), key))
+ m.Push(kit.MDB_VALUE, m.Cmdx(mdb.RENDER, RENDER.IMG, URL(m, kit.Format("/share/%s/value", key))))
})
}
func _share_show(m *ice.Message, key string, value map[string]interface{}, arg ...string) bool {
@@ -88,10 +88,6 @@ func _share_remote(m *ice.Message, pod string, arg ...string) {
m.Render(ice.RENDER_RESULT)
}
func _share_create(m *ice.Message, kind, name, text string, arg ...string) string {
- for _, k := range []string{"river", "storm"} {
- arg = append(arg, k, m.Option(k))
- }
-
h := m.Rich(SHARE, nil, kit.Dict(
kit.MDB_TIME, m.Time(m.Conf(SHARE, "meta.expire")),
kit.MDB_TYPE, kind, kit.MDB_NAME, name, kit.MDB_TEXT, text,
diff --git a/base/web/spide.go b/base/web/spide.go
index 84fd0d22..1ed51960 100644
--- a/base/web/spide.go
+++ b/base/web/spide.go
@@ -81,6 +81,26 @@ func _spide_create(m *ice.Message, name, address string, arg ...string) {
m.Log_CREATE(SPIDE, name, "address", address)
}
}
+func _spide_search(m *ice.Message, kind, name, text string, arg ...string) {
+ m.Richs(SPIDE, nil, kit.Select(kit.MDB_FOREACH, ""), func(key string, value map[string]interface{}) {
+ if kit.Format(kit.Value(value, "client.name")) != name && (text == "" || !strings.Contains(kit.Format(kit.Value(value, "client.url")), text)) {
+ return
+ }
+
+ m.Push("pod", m.Option("pod"))
+ m.Push("ctx", "web")
+ m.Push("cmd", SPIDE)
+ m.Push(key, value, []string{kit.MDB_TIME})
+ m.Push(kit.MDB_SIZE, 0)
+ m.Push("type", SPIDE)
+ // m.Push("type", kit.Format(kit.Value(value, "client.protocol")))
+ m.Push("name", kit.Format(kit.Value(value, "client.name")))
+ m.Push("text", kit.Format(kit.Value(value, "client.url")))
+ })
+}
+func _spide_render(m *ice.Message, kind, name, text string, arg ...string) {
+ m.Echo(``, text)
+}
const SPIDE = "spide"
@@ -94,6 +114,12 @@ func init() {
mdb.CREATE: {Name: "create name address", Help: "", Hand: func(m *ice.Message, arg ...string) {
_spide_create(m, arg[0], arg[1])
}},
+ mdb.SEARCH: {Name: "search type name text arg...", Help: "搜索", Hand: func(m *ice.Message, arg ...string) {
+ _spide_search(m, arg[0], arg[1], arg[2], arg[3:]...)
+ }},
+ mdb.RENDER: {Name: "render type name text arg...", Help: "渲染", Hand: func(m *ice.Message, arg ...string) {
+ _spide_render(m, arg[0], arg[1], arg[2], arg[3:]...)
+ }},
"login": {Name: "login name", Help: "", Hand: func(m *ice.Message, arg ...string) {
_spide_login(m, arg[0])
}},
diff --git a/base/web/web.go b/base/web/web.go
index 84aa9ea3..c75fdbf1 100644
--- a/base/web/web.go
+++ b/base/web/web.go
@@ -4,14 +4,13 @@ import (
ice "github.com/shylinux/icebergs"
"github.com/shylinux/icebergs/base/aaa"
"github.com/shylinux/icebergs/base/cli"
+ "github.com/shylinux/icebergs/base/ctx"
"github.com/shylinux/icebergs/base/gdb"
"github.com/shylinux/icebergs/base/mdb"
- "github.com/shylinux/icebergs/base/nfs"
kit "github.com/shylinux/toolkits"
"net/http"
"path"
- "strings"
)
type Frame struct {
@@ -98,67 +97,20 @@ var Index = &ice.Context{Name: "web", Help: "网络模块",
ice.CTX_INIT: {Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
m.Load()
+ m.Cmd(SPIDE, mdb.CREATE, "dev", kit.Select("http://:9020", m.Conf(cli.RUNTIME, "conf.ctx_dev")))
+ m.Cmd(SPIDE, mdb.CREATE, "self", kit.Select("http://:9020", m.Conf(cli.RUNTIME, "conf.ctx_self")))
+ m.Cmd(SPIDE, mdb.CREATE, "shy", kit.Select("https://shylinux.com:443", m.Conf(cli.RUNTIME, "conf.ctx_shy")))
+
+ m.Cmd(aaa.ROLE, aaa.White, aaa.VOID, "web", "/publish/")
+ m.Cmd(aaa.ROLE, aaa.White, aaa.VOID, ctx.COMMAND)
+
+ m.Cmd(mdb.SEARCH, mdb.CREATE, FAVOR)
+ m.Cmd(mdb.SEARCH, mdb.CREATE, SPIDE)
+ m.Cmd(mdb.RENDER, mdb.CREATE, SPIDE)
+
for k := range c.Commands[mdb.RENDER].Action {
m.Cmdy(mdb.RENDER, mdb.CREATE, k, mdb.RENDER, c.Cap(ice.CTX_FOLLOW))
}
-
- m.Cmd(SPIDE, mdb.CREATE, "self", kit.Select("http://:9020", m.Conf(cli.RUNTIME, "conf.ctx_self")))
- m.Cmd(SPIDE, mdb.CREATE, "dev", kit.Select("http://:9020", m.Conf(cli.RUNTIME, "conf.ctx_dev")))
- m.Cmd(SPIDE, mdb.CREATE, "shy", kit.Select("https://shylinux.com:443", m.Conf(cli.RUNTIME, "conf.ctx_shy")))
- m.Cmd(aaa.ROLE, aaa.White, aaa.VOID, "web", "/publish/")
- m.Cmd(aaa.ROLE, aaa.White, aaa.VOID, "command")
-
- m.Cmd("mdb.search", "create", "favor", "favor", "web")
-
- m.Cmd(nfs.SEARCH, "add", "story", "base", m.AddCmd(&ice.Command{Name: "search word", Help: "搜索引擎", Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
- switch arg[0] {
- case "set":
- m.Cmdy(STORY, "index", arg[2])
- return
- }
-
- m.Richs(STORY, "head", "*", func(key string, val map[string]interface{}) {
- if val["story"] == arg[0] {
- m.Push("pod", m.Option(ice.MSG_USERPOD))
- m.Push("engine", "story")
- m.Push("favor", val["story"])
- m.Push("id", val["list"])
-
- m.Push("time", val["time"])
- m.Push("type", val["scene"])
- m.Push("name", val["story"])
- m.Push("text", val["count"])
- }
- })
- }}))
-
- m.Cmd(nfs.SEARCH, "add", "share", "base", m.AddCmd(&ice.Command{Name: "search word", Help: "搜索引擎", Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
- switch arg[0] {
- case "set":
- m.Cmdy(SHARE, arg[2])
- return
- }
-
- m.Option("cache.limit", -2)
- m.Grows(SHARE, nil, "", "", func(index int, value map[string]interface{}) {
- if value["share"] == arg[0] || value["type"] == arg[0] ||
- strings.Contains(kit.Format(value["name"]), arg[0]) || strings.Contains(kit.Format(value["text"]), arg[0]) {
- m.Push("pod", m.Option(ice.MSG_USERPOD))
- m.Push("engine", "share")
- m.Push("favor", value["type"])
- m.Push("id", value["share"])
-
- m.Push("time", value["time"])
- m.Push("type", value["type"])
- m.Push("name", value["name"])
- m.Push("text", value["text"])
- }
- })
- }}))
-
- m.Conf(FAVOR, "meta.render.bench", m.AddCmd(&ice.Command{Name: "render type name text arg...", Help: "渲染引擎", Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
- m.Cmdy("web.code.bench", "action", "show", arg)
- }}))
}},
ice.CTX_EXIT: {Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
m.Save(SPIDE, SERVE, GROUP, LABEL,
diff --git a/core/chat/action.go b/core/chat/action.go
index fa297610..cc93c5aa 100644
--- a/core/chat/action.go
+++ b/core/chat/action.go
@@ -71,7 +71,9 @@ func _action_list(m *ice.Message, river, storm string) {
}
prefix := kit.Keys(kit.MDB_HASH, river, TOOL, kit.MDB_HASH, storm)
+ m.Debug("what %v", prefix)
m.Grows(RIVER, prefix, "", "", func(index int, value map[string]interface{}) {
+ m.Debug("what %v", value)
if meta, ok := kit.Value(value, kit.MDB_META).(map[string]interface{}); ok {
m.Push(RIVER, river)
m.Push(STORM, storm)
@@ -144,20 +146,21 @@ func init() {
msg := m.Cmd(web.STORY, web.UPLOAD)
m.Option(kit.MDB_NAME, msg.Append(kit.MDB_NAME))
m.Option(web.DATA, msg.Append(web.DATA))
- _action_show(m, m.Option(RIVER), m.Option(STORM), m.Option(ACTION),
+ _action_show(m, m.Option(ice.MSG_RIVER), m.Option(ice.MSG_STORM), m.Option(ice.MSG_ACTION),
append([]string{ACTION, web.UPLOAD}, arg...)...)
}},
ORDER: {Name: "order cmd...", Help: "定制", Hand: func(m *ice.Message, arg ...string) {
- _action_order_list(m, m.Option(RIVER), m.Option(STORM), arg...)
+ _action_order_list(m, m.Option(ice.MSG_RIVER), m.Option(ice.MSG_STORM), arg...)
}},
}, Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
if len(arg) == 0 {
// 命令列表
- _action_list(m, m.Option(RIVER), m.Option(STORM))
+ m.Debug("%v", m.Formats("meta"))
+ _action_list(m, m.Option(ice.MSG_RIVER), m.Option(ice.MSG_STORM))
return
}
// 执行命令
- _action_show(m, m.Option(RIVER), m.Option(STORM), arg[0], arg[1:]...)
+ _action_show(m, m.Option(ice.MSG_RIVER), m.Option(ice.MSG_STORM), arg[0], arg[1:]...)
}},
}}, nil)
}
diff --git a/core/chat/chat.go b/core/chat/chat.go
index b42fd9fe..5af78f56 100644
--- a/core/chat/chat.go
+++ b/core/chat/chat.go
@@ -5,90 +5,45 @@ import (
"github.com/shylinux/icebergs/base/aaa"
"github.com/shylinux/icebergs/base/ctx"
"github.com/shylinux/icebergs/base/gdb"
+ "github.com/shylinux/icebergs/base/mdb"
"github.com/shylinux/icebergs/base/web"
"github.com/shylinux/toolkits"
+
+ "strings"
)
var Index = &ice.Context{Name: "chat", Help: "聊天中心",
- Configs: map[string]*ice.Config{
- RIVER: {Name: "river", Help: "群组", Value: kit.Data(
- "template", kit.Dict("root", []interface{}{
- []interface{}{"river", `{{.Option "user.nick"|Format}}@{{.Conf "runtime" "node.name"|Format}}`, "mall"},
-
- []interface{}{"storm", "code", "code"},
- []interface{}{"field", "login", "web.code"},
- []interface{}{"field", "buffer", "web.code.tmux"},
- []interface{}{"field", "session", "web.code.tmux"},
- []interface{}{"field", "image", "web.code.docker"},
- []interface{}{"field", "container", "web.code.docker"},
- []interface{}{"field", "command", "web.code.docker"},
- []interface{}{"field", "repos", "web.code.git"},
- []interface{}{"field", "total", "web.code.git"},
- []interface{}{"field", "status", "web.code.git"},
-
- []interface{}{"storm", "wiki", "wiki"},
- []interface{}{"field", "draw", "web.wiki"},
- []interface{}{"field", "data", "web.wiki"},
- []interface{}{"field", "word", "web.wiki"},
- []interface{}{"field", "walk", "web.wiki"},
- []interface{}{"field", "feel", "web.wiki"},
-
- []interface{}{"storm", "root"},
- []interface{}{"field", "spide"},
- []interface{}{"field", "space"},
- []interface{}{"field", "dream"},
- []interface{}{"field", "favor"},
- []interface{}{"field", "story"},
- []interface{}{"field", "share"},
-
- []interface{}{"storm", "miss"},
- []interface{}{"field", "route"},
- []interface{}{"field", "group"},
- []interface{}{"field", "label"},
- []interface{}{"field", "search"},
- []interface{}{"field", "commend"},
-
- []interface{}{"storm", "team", "team"},
- []interface{}{"field", "plan", "web.team"},
- []interface{}{"field", "miss", "web.team"},
- []interface{}{"field", "stat", "web.team"},
- []interface{}{"field", "task", "web.team"},
-
- []interface{}{"storm", "mall", "mall"},
- []interface{}{"field", "asset", "web.mall"},
- []interface{}{"field", "spend", "web.mall"},
- []interface{}{"field", "trans", "web.mall"},
- []interface{}{"field", "bonus", "web.mall"},
- []interface{}{"field", "month", "web.mall"},
- }, "void", []interface{}{
- []interface{}{"storm", "wiki", "wiki"},
- []interface{}{"field", "note", "web.wiki"},
- }),
- "black", kit.Dict("tech", []interface{}{
- "/debug",
- "/river.add",
- "/river.share",
- "/river.rename",
- "/river.remove",
- "/storm.remove",
- "/storm.rename",
- "/storm.share",
- "/storm.add",
- }),
- "white", kit.Dict("void", []interface{}{
- "/header",
- "/river",
- "/storm",
- "/action",
- "/footer",
- }),
- )},
- },
+ Configs: map[string]*ice.Config{},
Commands: map[string]*ice.Command{
ice.CTX_INIT: {Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
m.Load()
m.Watch(gdb.SYSTEM_INIT, m.Prefix("init"))
m.Watch(gdb.USER_CREATE, m.Prefix("auto"))
+ m.Cmd(mdb.SEARCH, mdb.CREATE, ctx.COMMAND, m.AddCmd(&ice.Command{Hand: func(m *ice.Message, c *ice.Context, cc string, arg ...string) {
+ arg = arg[1:]
+ 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.Push("pod", "")
+ m.Push("ctx", "web.chat")
+ m.Push("cmd", cc)
+
+ m.Push("time", m.Time())
+ m.Push("size", "")
+
+ m.Push("type", ctx.COMMAND)
+ m.Push("name", key)
+ m.Push("text", s.Cap(ice.CTX_FOLLOW))
+ })
+ }}))
}},
ice.CTX_EXIT: {Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
m.Save(RIVER)
@@ -96,16 +51,6 @@ var Index = &ice.Context{Name: "chat", Help: "聊天中心",
"init": {Name: "init", Help: "初始化", Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
if len(m.Confm(RIVER, kit.MDB_HASH)) == 0 {
- // 默认群组
- kit.Fetch(m.Confv(RIVER, "meta.template"), func(key string, val map[string]interface{}) {
- if favor := kit.Keys(c.Cap(ice.CTX_FOLLOW), key); m.Richs(web.FAVOR, nil, favor, nil) == nil {
- kit.Fetch(val, func(index int, value interface{}) {
- v := kit.Simple(value)
- web.FavorInsert(m, favor, v[0], v[1], v[2])
- })
- }
- })
-
// 黑名单
kit.Fetch(m.Confv(RIVER, "meta.black.tech"), func(index int, value interface{}) {
m.Cmd(aaa.ROLE, aaa.Black, aaa.TECH, value)
@@ -169,7 +114,12 @@ var Index = &ice.Context{Name: "chat", Help: "聊天中心",
case "/action":
arg = arg[2:]
case "/storm":
- arg = arg[2:]
+ if len(arg) > 0 {
+ arg = arg[1:]
+ }
+ if len(arg) > 0 {
+ arg = arg[1:]
+ }
case "/river":
arg = arg[1:]
}
diff --git a/core/chat/river.go b/core/chat/river.go
index 664f0e8f..9ae87096 100644
--- a/core/chat/river.go
+++ b/core/chat/river.go
@@ -14,13 +14,12 @@ func _river_list(m *ice.Message) {
m.Set(ice.MSG_OPTION, kit.MDB_NAME)
m.Richs(RIVER, nil, kit.MDB_FOREACH, func(key string, value map[string]interface{}) {
m.Richs(RIVER, kit.Keys(kit.MDB_HASH, key, USER), m.Option(ice.MSG_USERNAME), func(k string, val map[string]interface{}) {
- m.Push(key, value[kit.MDB_META], []string{kit.MDB_KEY, kit.MDB_NAME})
+ m.Push(key, value[kit.MDB_META], []string{kit.MDB_KEY, kit.MDB_NAME}, val[kit.MDB_META])
})
})
}
func _river_user(m *ice.Message, river string, user ...string) {
prefix := kit.Keys(kit.MDB_HASH, river, USER)
- m.Rich(RIVER, prefix, kit.Data(aaa.USERNAME, cli.UserName))
for _, v := range user {
m.Rich(RIVER, prefix, kit.Data(aaa.USERNAME, v))
m.Log_INSERT(RIVER, river, USER, v)
@@ -29,17 +28,41 @@ func _river_user(m *ice.Message, river string, user ...string) {
func _river_share(m *ice.Message, river, name string, arg ...string) {
m.Cmdy(web.SHARE, RIVER, name, river, arg)
}
+func _river_remove(m *ice.Message, river string) {
+ m.Richs(RIVER, nil, river, func(value map[string]interface{}) {
+ m.Log_REMOVE(RIVER, river, kit.MDB_VALUE, kit.Format(value))
+ })
+ m.Conf(RIVER, kit.Keys(kit.MDB_HASH, river), "")
+}
func _river_rename(m *ice.Message, river string, name string) {
prefix := kit.Keys(kit.MDB_HASH, river, kit.MDB_META, kit.MDB_NAME)
old := m.Conf(RIVER, prefix)
m.Log_MODIFY(RIVER, river, kit.MDB_VALUE, name, "old", old)
m.Conf(RIVER, prefix, name)
}
-func _river_remove(m *ice.Message, river string) {
- m.Richs(RIVER, nil, river, func(value map[string]interface{}) {
- m.Log_REMOVE(RIVER, river, kit.MDB_VALUE, kit.Format(value))
+func _river_create(m *ice.Message, kind, name, text string, arg ...string) {
+ h := m.Rich(RIVER, nil, kit.Dict(kit.MDB_META, kit.Dict(
+ kit.MDB_TYPE, kind, kit.MDB_NAME, name, kit.MDB_TEXT, text,
+ kit.MDB_EXTRA, kit.Dict(arg),
+ ),
+ USER, kit.Data(kit.MDB_SHORT, aaa.USERNAME),
+ TOOL, kit.Data(),
+ ))
+ m.Log_CREATE(kit.MDB_META, RIVER, kit.MDB_TYPE, kind, kit.MDB_NAME, name)
+
+ _river_user(m, h, cli.UserName)
+ kit.Fetch(m.Confv(RIVER, kit.Keys("meta.template", "base")), func(storm string, value interface{}) {
+ list := []string{}
+ kit.Fetch(value, func(index int, value string) {
+ m.Search(value, func(p *ice.Context, s *ice.Context, key string, cmd *ice.Command) {
+ list = append(list, "", s.Cap(ice.CTX_FOLLOW), key, kit.Simple(cmd.Help)[0])
+ })
+ })
+ storm = _storm_create(m, h, "", storm, "")
+ _storm_tool(m, h, storm, list...)
})
- m.Conf(RIVER, kit.Keys(kit.MDB_HASH, river), "")
+ m.Set(ice.MSG_RESULT)
+ m.Echo(h)
}
const (
@@ -49,23 +72,58 @@ const (
const RIVER = "river"
func init() {
- Index.Merge(&ice.Context{Commands: map[string]*ice.Command{
- "/" + RIVER: {Name: "/river", Help: "小河流",
- Action: map[string]*ice.Action{
- mdb.REMOVE: {Name: "remove", Help: "删除", Hand: func(m *ice.Message, arg ...string) {
- _river_remove(m, m.Option(RIVER))
+ Index.Merge(&ice.Context{
+ Configs: map[string]*ice.Config{
+ RIVER: {Name: "river", Help: "群组", Value: kit.Data(
+ "template", kit.Dict(
+ "base", kit.Dict(
+ "main", []interface{}{
+ "web.code.inner",
+ "web.code.dream",
+ "web.code.space",
+ },
+ ),
+ ),
+ aaa.Black, kit.Dict(aaa.TECH, []interface{}{
+ "/river.create",
+ "/river.rename",
+ "/river.remove",
+ "/river.share",
+ "/storm.share",
+ "/storm.remove",
+ "/storm.rename",
+ "/storm.create",
+ }),
+ aaa.White, kit.Dict(aaa.VOID, []interface{}{
+ "/header",
+ "/river",
+ "/storm",
+ "/action",
+ "/footer",
+ }),
+ )},
+ },
+ Commands: map[string]*ice.Command{
+ "/" + RIVER: {Name: "/river", Help: "小河流",
+ Action: map[string]*ice.Action{
+ mdb.CREATE: {Name: "create type name text arg...", Help: "创建", Hand: func(m *ice.Message, arg ...string) {
+ _river_create(m, arg[0], arg[1], arg[2], arg[3:]...)
+ }},
+ mdb.RENAME: {Name: "rename name", Help: "更名", Hand: func(m *ice.Message, arg ...string) {
+ _river_rename(m, m.Option(ice.MSG_RIVER), arg[0])
+ }},
+ mdb.REMOVE: {Name: "remove", Help: "删除", Hand: func(m *ice.Message, arg ...string) {
+ _river_remove(m, m.Option(ice.MSG_RIVER))
+ }},
+ web.SHARE: {Name: "share name", Help: "共享", Hand: func(m *ice.Message, arg ...string) {
+ _river_share(m, m.Option(ice.MSG_RIVER), arg[0])
+ }},
+ USER: {Name: "user user...", Help: "添加用户", Hand: func(m *ice.Message, arg ...string) {
+ _river_user(m, m.Option(ice.MSG_RIVER), arg...)
+ }},
+ }, Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
+ _river_list(m)
}},
- mdb.RENAME: {Name: "rename name", Help: "重命名", Hand: func(m *ice.Message, arg ...string) {
- _river_rename(m, m.Option(RIVER), arg[0])
- }},
- web.SHARE: {Name: "share name", Help: "共享", Hand: func(m *ice.Message, arg ...string) {
- _river_share(m, m.Option(RIVER), arg[0])
- }},
- USER: {Name: "user user...", Help: "添加用户", Hand: func(m *ice.Message, arg ...string) {
- _river_user(m, m.Option(RIVER), arg...)
- }},
- }, Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
- _river_list(m)
- }},
- }}, nil)
+ },
+ }, nil)
}
diff --git a/core/chat/storm.go b/core/chat/storm.go
index 9554f704..508995a1 100644
--- a/core/chat/storm.go
+++ b/core/chat/storm.go
@@ -10,29 +10,26 @@ import (
func _storm_list(m *ice.Message, river string) {
m.Set(ice.MSG_OPTION, kit.MDB_KEY)
m.Set(ice.MSG_OPTION, kit.MDB_NAME)
- m.Richs(RIVER, kit.Keys(kit.MDB_HASH, river, TOOL), kit.MDB_FOREACH, func(key string, value map[string]interface{}) {
- m.Push(key, value[kit.MDB_META], []string{kit.MDB_KEY, kit.MDB_NAME})
+ m.Set(ice.MSG_OPTION, kit.MDB_COUNT)
+ m.Richs(RIVER, kit.Keys(kit.MDB_HASH, river, USER), m.Option(ice.MSG_USERNAME), func(k string, val map[string]interface{}) {
+ m.Richs(RIVER, kit.Keys(kit.MDB_HASH, river, TOOL), kit.MDB_FOREACH, func(key string, value map[string]interface{}) {
+ m.Push(key, value[kit.MDB_META], []string{kit.MDB_KEY, kit.MDB_NAME, kit.MDB_COUNT}, val[kit.MDB_META])
+ })
})
m.Sort(kit.MDB_NAME)
}
-func _storm_tool(m *ice.Message, river, storm string, arg ...string) {
+func _storm_tool(m *ice.Message, river, storm string, arg ...string) { // pod ctx cmd help
prefix := kit.Keys(kit.MDB_HASH, river, TOOL, kit.MDB_HASH, storm)
for i := 0; i < len(arg)-3; i += 4 {
- id := m.Grow(RIVER, kit.Keys(prefix), kit.Data(
+ m.Grow(RIVER, kit.Keys(prefix), kit.Data(
POD, arg[i], CTX, arg[i+1], CMD, arg[i+2], "help", arg[i+3],
))
- m.Log_INSERT(RIVER, river, STORM, storm, kit.MDB_HASH, id, TOOL, arg[i:i+4])
+ m.Log_INSERT(RIVER, river, STORM, storm, TOOL, arg[i:i+4])
}
}
func _storm_share(m *ice.Message, river, storm, name string, arg ...string) {
m.Cmdy(web.SHARE, STORM, name, storm, RIVER, river, arg)
}
-func _storm_rename(m *ice.Message, river, storm string, name string) {
- prefix := kit.Keys(kit.MDB_HASH, river, TOOL, kit.MDB_HASH, storm)
- old := m.Conf(RIVER, kit.Keys(prefix, kit.MDB_META, kit.MDB_NAME))
- m.Log_MODIFY(RIVER, river, STORM, storm, kit.MDB_VALUE, name, "old", old)
- m.Conf(RIVER, kit.Keys(prefix, kit.MDB_META, kit.MDB_NAME), name)
-}
func _storm_remove(m *ice.Message, river string, storm string) {
prefix := kit.Keys(kit.MDB_HASH, river, TOOL)
m.Richs(RIVER, kit.Keys(prefix), storm, func(value map[string]interface{}) {
@@ -40,6 +37,23 @@ func _storm_remove(m *ice.Message, river string, storm string) {
})
m.Conf(RIVER, kit.Keys(prefix, kit.MDB_HASH, storm), "")
}
+func _storm_rename(m *ice.Message, river, storm string, name string) {
+ prefix := kit.Keys(kit.MDB_HASH, river, TOOL, kit.MDB_HASH, storm)
+ old := m.Conf(RIVER, kit.Keys(prefix, kit.MDB_META, kit.MDB_NAME))
+ m.Log_MODIFY(RIVER, river, STORM, storm, kit.MDB_VALUE, name, "old", old)
+ m.Conf(RIVER, kit.Keys(prefix, kit.MDB_META, kit.MDB_NAME), name)
+}
+func _storm_create(m *ice.Message, river string, kind, name, text string, arg ...string) string {
+ h := m.Rich(RIVER, kit.Keys(kit.MDB_HASH, river, TOOL), kit.Dict(
+ kit.MDB_META, kit.Dict(
+ kit.MDB_TYPE, kind, kit.MDB_NAME, name, kit.MDB_TEXT, text,
+ kit.MDB_EXTRA, kit.Dict(arg),
+ ),
+ ))
+ m.Log_CREATE(kit.MDB_META, STORM, RIVER, river, kit.MDB_TYPE, kind, kit.MDB_NAME, name)
+ m.Echo(h)
+ return h
+}
const (
POD = "pod"
@@ -53,22 +67,28 @@ const STORM = "storm"
func init() {
Index.Merge(&ice.Context{
+ Configs: map[string]*ice.Config{
+ STORM: {Name: "storm", Help: "应用", Value: kit.Data()},
+ },
Commands: map[string]*ice.Command{
"/" + STORM: {Name: "/storm", Help: "暴风雨", Action: map[string]*ice.Action{
- mdb.REMOVE: {Name: "remove", Help: "删除", Hand: func(m *ice.Message, arg ...string) {
- _storm_remove(m, m.Option(RIVER), m.Option(STORM))
+ mdb.CREATE: {Name: "create type name text arg...", Help: "创建", Hand: func(m *ice.Message, arg ...string) {
+ _storm_create(m, m.Option(ice.MSG_RIVER), arg[0], arg[1], arg[2], arg[3:]...)
}},
- mdb.RENAME: {Name: "rename name", Help: "重命名", Hand: func(m *ice.Message, arg ...string) {
- _storm_rename(m, m.Option(RIVER), m.Option(STORM), arg[0])
+ mdb.RENAME: {Name: "rename name", Help: "更名", Hand: func(m *ice.Message, arg ...string) {
+ _storm_rename(m, m.Option(ice.MSG_RIVER), m.Option(ice.MSG_STORM), arg[0])
+ }},
+ mdb.REMOVE: {Name: "remove", Help: "删除", Hand: func(m *ice.Message, arg ...string) {
+ _storm_remove(m, m.Option(ice.MSG_RIVER), m.Option(ice.MSG_STORM))
}},
web.SHARE: {Name: "share name", Help: "共享", Hand: func(m *ice.Message, arg ...string) {
- _storm_share(m, m.Option(RIVER), m.Option(STORM), arg[0])
+ _storm_share(m, m.Option(ice.MSG_RIVER), m.Option(ice.MSG_STORM), arg[0])
}},
TOOL: {Name: "tool [pod ctx cmd help]...", Help: "添加工具", Hand: func(m *ice.Message, arg ...string) {
- _storm_tool(m, m.Option(RIVER), m.Option(STORM), arg...)
+ _storm_tool(m, m.Option(ice.MSG_RIVER), m.Option(ice.MSG_STORM), arg...)
}},
}, Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
- _storm_list(m, m.Option(RIVER))
+ _storm_list(m, m.Option(ice.MSG_RIVER))
}},
},
}, nil)
diff --git a/core/code/inner.go b/core/code/inner.go
index f3b7f485..e4225408 100644
--- a/core/code/inner.go
+++ b/core/code/inner.go
@@ -127,6 +127,8 @@ func init() {
INNER: {Name: "inner", Help: "编辑器", Value: kit.Data(
"protect", kit.Dict("etc", "true", "var", "true", "usr", "true"),
"source", kit.Dict(
+ "url", "true",
+ "sh", "true",
"sh", "true",
"py", "true",
"shy", "true",
diff --git a/core/wiki/draw.go b/core/wiki/draw.go
index 51d5721b..59e6da2b 100644
--- a/core/wiki/draw.go
+++ b/core/wiki/draw.go
@@ -35,7 +35,7 @@ func init() {
Commands: map[string]*ice.Command{
DRAW: {Name: "draw path=hi.svg auto", Help: "思维导图", Meta: kit.Dict(mdb.PLUGIN, DrawPlugin), Action: map[string]*ice.Action{
nfs.SAVE: {Name: "save path text", Help: "保存", Hand: func(m *ice.Message, arg ...string) {
- _wiki_save(m, DATA, arg[0], arg[1])
+ _wiki_save(m, DATA, arg[0], kit.Select(m.Option("content"), arg, 1))
}},
"run": {Name: "show zone type name text", Help: "运行", Hand: func(m *ice.Message, arg ...string) {
_draw_show(m, arg[0], arg[1], arg[2], arg[3], arg[4:]...)
diff --git a/type.go b/type.go
index 7e4299a9..b883ed09 100644
--- a/type.go
+++ b/type.go
@@ -109,9 +109,6 @@ func (c *Context) cmd(m *Message, cmd *Command, key string, arg ...string) *Mess
}
}
- if len(arg) > 0 && arg[0] == "render" {
- arg = arg[1:]
- }
m.Log(LOG_CMDS, "%s.%s %d %v %s", c.Name, key, len(arg), arg, kit.FileLine(cmd.Hand, 3))
cmd.Hand(m, c, key, arg...)
return m