diff --git a/base/ctx/ctx.go b/base/ctx/ctx.go
index 5f6e5dec..d13a4997 100644
--- a/base/ctx/ctx.go
+++ b/base/ctx/ctx.go
@@ -67,7 +67,7 @@ var Index = &ice.Context{Name: "ctx", Help: "配置模块",
m.Push("key", s.Cap(ice.CTX_FOLLOW))
m.Push("index", k)
m.Push("name", v.Name)
- m.Push("help", v.Help)
+ m.Push("help", kit.Format(v.Help))
}
})
return
@@ -83,13 +83,13 @@ var Index = &ice.Context{Name: "ctx", Help: "配置模块",
if len(arg) == 0 {
// 命令列表
m.Push("name", cmd.Name)
- m.Push("help", cmd.Help)
+ m.Push("help", kit.Format(cmd.Help))
m.Push("meta", kit.Format(cmd.Meta))
m.Push("list", kit.Format(cmd.List))
} else {
if you := m.Option(kit.Format(kit.Value(cmd.Meta, "remote"))); you != "" {
// 远程命令
- m.Copy(m.Spawns(s).Cmd("web.space", you, "ctx.command", chain, "run", arg[1:]))
+ m.Copy(m.Spawns(s).Cmd(ice.WEB_SPACE, you, "ctx.command", chain, "run", arg[1:]))
} else {
// 本地命令
m.Copy(s.Run(m.Spawns(s), cmd, key, arg[1:]...))
diff --git a/base/ssh/ssh.go b/base/ssh/ssh.go
index 5613355c..f0657b9d 100644
--- a/base/ssh/ssh.go
+++ b/base/ssh/ssh.go
@@ -210,7 +210,7 @@ var Index = &ice.Context{Name: "ssh", Help: "终端模块",
})
}},
"scan": {Name: "scan name help file", Help: "解析", Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
- buf := bytes.NewBuffer(make([]byte, 4096))
+ buf := bytes.NewBuffer(make([]byte, 0, 4096))
m.Optionv(ice.MSG_STDOUT, buf)
m.Starts(strings.Replace(arg[0], ".", "_", -1), arg[1], arg[2:]...)
diff --git a/base/web/web.go b/base/web/web.go
index 59bbcfed..d33c0360 100644
--- a/base/web/web.go
+++ b/base/web/web.go
@@ -229,6 +229,9 @@ func (web *Frame) HandleCmd(m *ice.Message, key string, cmd *ice.Command) {
msg.Info("status %s", msg.Result())
w.WriteHeader(kit.Int(kit.Select("200", msg.Result())))
+ case "redirect":
+ http.Redirect(w, r, msg.Result(), 302)
+
case "file":
msg.Info("_output: %s %s", msg.Append("_output"), msg.Append("file"))
w.Header().Set("Content-Disposition", fmt.Sprintf("filename=%s", kit.Select(msg.Append("name"), msg.Append("story"))))
@@ -816,7 +819,7 @@ var Index = &ice.Context{Name: "web", Help: "网络模块",
case "启动":
arg = arg[:1]
case "停止", "stop":
- m.Cmd(ice.WEB_SPACE, arg[0], "exit", "1")
+ m.Cmd(ice.WEB_SPACE, m.Option("name"), "exit", "1")
time.Sleep(time.Second * 3)
m.Event(ice.DREAM_CLOSE, arg[0])
arg = arg[:0]
@@ -1517,6 +1520,72 @@ var Index = &ice.Context{Name: "web", Help: "网络模块",
}
}
+ case "storm":
+ if len(arg) == 1 {
+ m.Push("_output", "redirect")
+ m.Echo("/share/%s/", arg[0])
+ break
+ }
+
+ if arg[1] == "" {
+ http.ServeFile(m.W, m.R, "usr/volcanos/share.html")
+ break
+ }
+
+ if len(arg) == 2 {
+ kit.Fetch(kit.Value(value, "extra.tool"), func(index int, value map[string]interface{}) {
+ m.Push("river", arg[0])
+ m.Push("storm", arg[1])
+ m.Push("action", index)
+
+ m.Push("node", value["pod"])
+ m.Push("group", value["ctx"])
+ m.Push("index", value["cmd"])
+
+ m.Push("args", value["args"])
+
+ msg := m.Cmd(m.Space(value["pod"]), ice.CTX_COMMAND, value["ctx"], value["cmd"])
+ m.Push("name", value["cmd"])
+ m.Push("help", kit.Select(msg.Append("help"), kit.Format(value["help"])))
+ m.Push("inputs", msg.Append("list"))
+ m.Push("feature", msg.Append("meta"))
+ })
+ break
+ }
+
+ meta := kit.Value(value, kit.Format("extra.tool.%s", arg[2])).(map[string]interface{})
+ cmds := kit.Simple(m.Space(meta["pod"]), kit.Keys(meta["ctx"], meta["cmd"]), arg[3:])
+ m.Cmdy(cmds).Option("cmds", cmds)
+
+ case "action":
+ if len(arg) == 1 {
+ m.Push("_output", "redirect")
+ m.Echo("/share/%s/", arg[0])
+ break
+ }
+
+ if arg[1] == "" {
+ http.ServeFile(m.W, m.R, "usr/volcanos/share.html")
+ break
+ }
+
+ meta := kit.Value(value, "extra").(map[string]interface{})
+ if len(arg) == 2 {
+ m.Push("river", arg[0])
+ m.Push("storm", arg[1])
+ m.Push("action", "0")
+
+ msg := m.Cmd(m.Space(meta["pod"]), ice.CTX_COMMAND, meta["ctx"], meta["cmd"])
+ m.Push("name", meta["cmd"])
+ m.Push("help", kit.Select(msg.Append("help"), kit.Format(meta["help"])))
+ m.Push("inputs", msg.Append("list"))
+ m.Push("feature", msg.Append("meta"))
+ break
+ }
+
+ cmds := kit.Simple(m.Space(meta["pod"]), kit.Keys(meta["ctx"], meta["cmd"]), arg[3:])
+ m.Cmdy(cmds).Option("cmds", cmds)
+
case "active":
m.Push("_output", "qrcode")
m.Echo(kit.Format(value))
diff --git a/core/chat/chat.go b/core/chat/chat.go
index 6c3fac4c..35184bca 100644
--- a/core/chat/chat.go
+++ b/core/chat/chat.go
@@ -35,6 +35,7 @@ var Index = &ice.Context{Name: "chat", Help: "聊天中心",
m.Cmd(ice.WEB_FAVOR, "river.root", "field", "spend", "web.mall")
m.Cmd(ice.WEB_FAVOR, "river.root", "storm", "team", "team")
+ m.Cmd(ice.WEB_FAVOR, "river.root", "field", "miss", "web.team")
m.Cmd(ice.WEB_FAVOR, "river.root", "field", "task", "web.team")
m.Cmd(ice.WEB_FAVOR, "river.root", "field", "stat", "web.team")
m.Cmd(ice.WEB_FAVOR, "river.root", "field", "plan", "web.team")
@@ -228,7 +229,7 @@ var Index = &ice.Context{Name: "chat", Help: "聊天中心",
// 添加命令
for i := 3; i < len(arg)-3; i += 4 {
id := m.Grow(ice.CHAT_RIVER, kit.Keys(prefix, kit.MDB_HASH, arg[1]), kit.Data(
- "pod", arg[i], "ctx", arg[i+1], "cmd", arg[i+2], "key", arg[i+3],
+ "pod", arg[i], "ctx", arg[i+1], "cmd", arg[i+2], "help", arg[i+3],
))
m.Log("insert", "storm: %s %d: %v", arg[1], id, arg[i:i+4])
}
@@ -268,6 +269,9 @@ var Index = &ice.Context{Name: "chat", Help: "聊天中心",
m.Cmd("/storm", arg[0], storm, "add", arg[3:])
m.Echo(storm)
+ case "append":
+ m.Cmd("/storm", arg[0], arg[2], "add", arg[3:])
+
default:
// 命令列表
m.Cmdy(ice.WEB_SPACE, arg[2], ice.CTX_COMMAND)
@@ -289,9 +293,11 @@ var Index = &ice.Context{Name: "chat", Help: "聊天中心",
m.Push("group", meta["ctx"])
m.Push("index", meta["cmd"])
+ m.Push("args", kit.Select("[]", kit.Format(meta["args"])))
+
msg := m.Cmd(m.Space(meta["pod"]), ice.CTX_COMMAND, meta["ctx"], meta["cmd"])
- m.Push("name", kit.Select(kit.Format(meta["key"]), meta["cmd"]))
- m.Push("help", msg.Append("help"))
+ m.Push("name", meta["cmd"])
+ m.Push("help", kit.Select(msg.Append("help"), kit.Format(meta["help"])))
m.Push("inputs", msg.Append("list"))
m.Push("feature", msg.Append("meta"))
}
@@ -300,13 +306,23 @@ var Index = &ice.Context{Name: "chat", Help: "聊天中心",
}
switch arg[2] {
+ case "share":
+ list := []string{}
+ m.Grows(ice.CHAT_RIVER, prefix, "", "", func(index int, value map[string]interface{}) {
+ for k, v := range value["meta"].(map[string]interface{}) {
+ list = append(list, kit.Format("tool.%d.%v", index, k), kit.Format(v))
+ }
+ })
+ m.Cmdy(ice.WEB_SHARE, "add", "storm", arg[3], arg[4], list)
+
case "save":
- m.Conf(ice.CHAT_RIVER, kit.Keys(prefix), "")
- for i := 3; i < len(arg)-3; i += 4 {
+ m.Conf(ice.CHAT_RIVER, kit.Keys(prefix, "list"), "")
+ for i := 3; i < len(arg)-4; i += 5 {
id := m.Grow(ice.CHAT_RIVER, kit.Keys(prefix), kit.Data(
- "pod", arg[i], "ctx", arg[i+1], "cmd", arg[i+2], "key", arg[i+3],
+ "pod", arg[i], "ctx", arg[i+1], "cmd", arg[i+2],
+ "help", arg[i+3], "args", arg[i+4],
))
- m.Log("insert", "storm: %s %d: %v", arg[1], id, arg[i:i+4])
+ m.Log("insert", "storm: %s %d: %v", arg[1], id, arg[i:i+5])
}
return
}
@@ -316,28 +332,35 @@ var Index = &ice.Context{Name: "chat", Help: "聊天中心",
m.Grows(ice.CHAT_RIVER, prefix, kit.MDB_ID, kit.Format(kit.Int(arg[2])+1), func(index int, value map[string]interface{}) {
if meta, ok := kit.Value(value, "meta").(map[string]interface{}); ok {
cmds = kit.Simple(m.Space(meta["pod"]), kit.Keys(meta["ctx"], meta["cmd"]), arg[3:])
+
+ // 命令补全
+ if len(arg) > 3 && arg[3] == "action" {
+ switch arg[4] {
+ case "location":
+ // 记录位置
+ m.Cmdy("aaa.location", arg[5:])
+ return
+ case "input":
+ switch arg[5] {
+ case "location":
+ // 查询位置
+ m.Copy(m.Cmd("aaa.location"), "append", "name")
+ return
+ }
+ case "share":
+ list := []string{}
+ for k, v := range meta {
+ list = append(list, k, kit.Format(v))
+ }
+ m.Cmdy(ice.WEB_SHARE, "add", "action", arg[5], arg[6], list)
+ return
+ }
+ }
}
})
- // 命令补全
- if len(cmds) > 1 && cmds[1] == "action" {
- switch cmds[2] {
- case "location":
- // 记录位置
- m.Cmdy("aaa.location", cmds[3:])
- return
- case "input":
- switch cmds[3] {
- case "location":
- // 查询位置
- m.Copy(m.Cmd("aaa.location"), "append", "name")
- return
- }
- }
- }
-
// 执行命令
- if m.Right(cmds) {
+ if len(cmds) > 0 && m.Right(cmds) {
m.Cmdy(cmds).Option("cmds", cmds)
}
}},
diff --git a/core/team/team.go b/core/team/team.go
index b1f4282e..4fedefa8 100644
--- a/core/team/team.go
+++ b/core/team/team.go
@@ -6,7 +6,7 @@ import (
"github.com/shylinux/icebergs/base/web"
"github.com/shylinux/toolkits"
- "fmt"
+ "encoding/csv"
"strings"
"time"
)
@@ -14,7 +14,16 @@ import (
var Index = &ice.Context{Name: "team", Help: "团队中心",
Caches: map[string]*ice.Cache{},
Configs: map[string]*ice.Config{
- "task": {Name: "task", Help: "任务", Value: kit.Data(kit.MDB_SHORT, "zone")},
+ "task": {Name: "task", Help: "任务", Value: kit.Data(kit.MDB_SHORT, "zone")},
+ "plan": {Name: "plan", Help: "计划", Value: kit.Data(kit.MDB_SHORT, "zone",
+ "head", []interface{}{"周日", "周一", "周二", "周三", "周四", "周五", "周六"},
+ "template", kit.Dict(
+ "day", `
{{.name}}: {{.text}}
`,
+ "week", `{{.name}}
`,
+ "year", `{{.name}}: {{.text}}
`,
+ ),
+ )},
+
"location": {Name: "location", Help: "位置", Value: kit.Data(kit.MDB_SHORT, "name")},
},
Commands: map[string]*ice.Command{
@@ -22,45 +31,146 @@ var Index = &ice.Context{Name: "team", Help: "团队中心",
m.Cmd(ice.CTX_CONFIG, "load", kit.Keys(m.Cap(ice.CTX_FOLLOW), "json"))
}},
ice.ICE_EXIT: {Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
- m.Cmd(ice.CTX_CONFIG, "save", kit.Keys(m.Cap(ice.CTX_FOLLOW), "json"), kit.Keys(m.Cap(ice.CTX_FOLLOW), "task"))
+ m.Cmd(ice.CTX_CONFIG, "save", kit.Keys(m.Cap(ice.CTX_FOLLOW), "json"),
+ kit.Keys(m.Cap(ice.CTX_FOLLOW), "task"))
}},
- "task": {Name: "task", Help: "任务", Meta: kit.Dict("remote", "you"), List: kit.List(
+ "miss": {Name: "miss zone type name text", Help: "任务", List: kit.List(
+ kit.MDB_INPUT, "text", "name", "zone", "action", "auto", "figure", "key",
+ kit.MDB_INPUT, "text", "name", "type", "figure", "key",
+ kit.MDB_INPUT, "text", "name", "name", "figure", "key",
+ kit.MDB_INPUT, "button", "name", "添加",
+ kit.MDB_INPUT, "textarea", "name", "text",
+ kit.MDB_INPUT, "text", "name", "location", "figure", "key", "cb", "location",
+ ), Hand: func(m *ice.Message, c *ice.Context, key string, arg ...string) {
+ if len(arg) > 0 && arg[0] == "action" {
+ switch arg[1] {
+ case "input":
+ switch arg[2] {
+ case "type", "name":
+ m.Confm("task", kit.Keys("meta.word", arg[2]), func(key string, value string) {
+ m.Push(arg[2], key)
+ m.Push("count", value)
+ })
+ m.Sort("count", "int_r")
+ case "zone":
+ m.Richs("task", nil, "*", func(key string, value map[string]interface{}) {
+ m.Push("zone", kit.Value(value, "meta.zone"))
+ m.Push("count", kit.Value(value, "meta.count"))
+ })
+ }
+ return
+ }
+ }
+
+ if len(arg) < 2 {
+ m.Cmdy("task", arg)
+ return
+ }
+ m.Cmdy("task", arg[0], "", arg[1:])
+ }},
+ "task": {Name: "task [zone [id [type [name [text args...]]]]]", Help: "任务", Meta: kit.Dict("remote", "you"), List: kit.List(
kit.MDB_INPUT, "text", "name", "zone", "action", "auto",
kit.MDB_INPUT, "text", "name", "id", "action", "auto",
kit.MDB_INPUT, "button", "name", "查看", "action", "auto",
kit.MDB_INPUT, "button", "name", "返回", "cb", "Last",
), Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
- m.Option("cache.limit", "10000")
-
if len(arg) > 0 && arg[0] == "action" {
switch arg[1] {
+ case "export":
+ // 导出数据
+ m.Option("cache.limit", "10000")
+ if f, p, e := kit.Create(arg[2]); m.Assert(e) {
+ defer f.Close()
+
+ w := csv.NewWriter(f)
+ defer w.Flush()
+
+ w.Write([]string{"begin_time", "close_time", "status", "type", "name", "text", "extra", "zone"})
+ m.Richs(cmd, nil, kit.Select("*", arg, 3), func(key string, zone map[string]interface{}) {
+ m.Grows(cmd, kit.Keys("hash", key), kit.Select("", arg, 4), kit.Select("", arg, 5), func(index int, task map[string]interface{}) {
+ w.Write([]string{
+ kit.Format(task["begin_time"]),
+ kit.Format(task["close_time"]),
+ kit.Format(task["status"]),
+ kit.Format(task["type"]),
+ kit.Format(task["name"]),
+ kit.Format(task["text"]),
+ kit.Format(task["extra"]),
+ kit.Format(kit.Value(zone, "meta.zone")),
+ })
+ })
+ })
+ m.Log(ice.LOG_EXPORT, "%s", p)
+ }
+
+ case "import":
+ // 导入数据
+ m.Option("cache.limit", "10000")
+ m.CSV(m.Cmdx("nfs.cat", arg[2])).Table(func(index int, data map[string]string, head []string) {
+ item := kit.Dict("time", data["time"],
+ "type", data["type"], "name", data["name"], "text", data["text"], "extra", kit.UnMarshal(data["extra"]),
+ "begin_time", data["begin_time"], "close_time", data["close_time"], "status", data["status"],
+ )
+
+ if m.Richs(cmd, nil, data["zone"], nil) == nil {
+ // 添加领域
+ m.Log(ice.LOG_CREATE, "zone: %s", data["zone"])
+ m.Rich(cmd, nil, kit.Data("zone", data["zone"]))
+ }
+
+ m.Richs(cmd, nil, data["zone"], func(key string, value map[string]interface{}) {
+ // 添加任务
+ n := m.Grow(cmd, kit.Keys("hash", key), item)
+ m.Log(ice.LOG_IMPORT, "%s: %d %s: %s", data["zone"], n, data["type"], data["name"])
+ })
+ })
case "modify":
- m.Richs(cmd, nil, m.Option("zone"), func(key string, account map[string]interface{}) {
+ // 任务修改
+ m.Richs(cmd, nil, kit.Select(m.Option("zone"), arg, 6), func(key string, account map[string]interface{}) {
m.Grows(cmd, kit.Keys("hash", key), "id", arg[5], func(index int, current map[string]interface{}) {
+ m.Log(ice.LOG_MODIFY, "%s: %s %s: %s->%s", key, index, kit.Value(current, arg[2]), arg[2], arg[3])
kit.Value(current, arg[2], arg[3])
})
})
+ case "process":
+ m.Richs(cmd, nil, kit.Select(m.Option("zone"), arg, 3), func(key string, account map[string]interface{}) {
+ m.Grows(cmd, kit.Keys("hash", key), "id", arg[2], func(index int, current map[string]interface{}) {
+ if kit.Format(kit.Value(current, "status")) == "prepare" {
+ m.Log(ice.LOG_MODIFY, "%s: %s %s: %s->%s", key, index, kit.Value(current, "status"), "status", "process")
+ kit.Value(current, "begin_time", m.Time())
+ kit.Value(current, "status", "process")
+ }
+ })
+ })
+ case "finish", "cancel":
+ m.Richs(cmd, nil, kit.Select(m.Option("zone"), arg, 3), func(key string, account map[string]interface{}) {
+ m.Grows(cmd, kit.Keys("hash", key), "id", arg[2], func(index int, current map[string]interface{}) {
+ m.Log(ice.LOG_MODIFY, "%s: %s %s: %s->%s", key, index, kit.Value(current, "status"), "status", arg[1])
+ kit.Value(current, "close_time", m.Time())
+ kit.Value(current, "status", arg[1])
+ })
+ })
}
return
}
if len(arg) == 0 {
- // 任务列表
+ // 分类列表
m.Richs(cmd, nil, "*", func(key string, value map[string]interface{}) {
- m.Push(key, value["meta"])
+ m.Push(key, value["meta"], []string{"time", "count", "zone"})
})
return
}
if m.Richs(cmd, nil, arg[0], nil) == nil {
- // 添加任务
+ // 添加分类
m.Rich(cmd, nil, kit.Data("zone", arg[0]))
m.Log(ice.LOG_CREATE, "zone: %s", arg[0])
}
+ field := []string{"begin_time", "close_time", "id", "status", "type", "name", "text"}
m.Richs(cmd, nil, arg[0], func(key string, value map[string]interface{}) {
- field := []string{"begin_time", "id", "status", "type", "name", "text"}
if len(arg) == 1 {
// 任务列表
m.Grows(cmd, kit.Keys("hash", key), "", "", func(index int, value map[string]interface{}) {
@@ -69,43 +179,47 @@ var Index = &ice.Context{Name: "team", Help: "团队中心",
m.Sort("time", "time_r")
return
}
+
if len(arg) == 2 {
- // 消费详情
+ // 任务详情
m.Grows(cmd, kit.Keys("hash", key), "id", arg[1], func(index int, value map[string]interface{}) {
m.Push("detail", value)
})
m.Sort("time", "time_r")
return
}
+
if len(arg) < 5 {
+ // 任务查询
name, value := "type", arg[2]
switch len(arg) {
case 3:
- // 消费分类
+ // 分类查询
name, value = "type", arg[2]
case 4:
- // 消费对象
+ // 名称查询
name, value = "name", arg[3]
}
m.Grows(cmd, kit.Keys("hash", key), name, value, func(index int, value map[string]interface{}) {
- m.Push("", value, []string{"time", "id", "status", "type", "name", "text"})
+ m.Push("", value, field)
})
m.Sort("time", "time_r")
return
}
- // 添加任务
+ // 词汇统计
+ count := kit.Int(m.Conf(cmd, kit.Keys("meta.word", "type", arg[2])))
+ m.Conf(cmd, kit.Keys("meta.word", "type", arg[2]), count+1)
+ count = kit.Int(m.Conf(cmd, kit.Keys("meta.word", "name", arg[3])))
+ m.Conf(cmd, kit.Keys("meta.word", "name", arg[3]), count+1)
+
+ // 数据结构
extra := kit.Dict()
- data := kit.Dict("type", arg[2], "name", arg[3], "text", arg[4],
- "begin_time", m.Time(), "close_time", m.Time(),
- "status", "prepare", "extra", extra,
+ data := kit.Dict("type", arg[2], "name", arg[3], "text", arg[4], "extra", extra,
+ "begin_time", m.Time(), "close_time", m.Time(), "status", "prepare",
)
- count := kit.Int(m.Conf("task", kit.Keys("meta.word", "type", arg[2])))
- m.Conf("task", kit.Keys("meta.word", "type", arg[2]), count+1)
- count = kit.Int(m.Conf("task", kit.Keys("meta.word", "name", arg[3])))
- m.Conf("task", kit.Keys("meta.word", "name", arg[3]), count+1)
-
+ // 扩展字段
for i := 5; i < len(arg); i += 2 {
switch arg[i] {
case "begin_time", "close_time", "status":
@@ -114,18 +228,19 @@ var Index = &ice.Context{Name: "team", Help: "团队中心",
kit.Value(extra, arg[i], arg[i+1])
}
}
+
+ // 添加任务
n := m.Grow(cmd, kit.Keys("hash", key), data)
- m.Echo("%s: %d", key, n)
+ m.Echo("%s: %d", kit.Value(value, "meta.zone"), n)
})
}},
"plan": {Name: "plan day|week|month|year", Help: "计划", Meta: kit.Dict("display", "team/plan"), List: kit.List(
- kit.MDB_INPUT, "select", "name", "scale", "values", []string{"day", "week", "month"}, "action", "auto",
- kit.MDB_INPUT, "text", "name", "begin_time", "action", "auto", "figure", "date",
+ kit.MDB_INPUT, "select", "name", "scale", "value", "week", "values", []string{"day", "week", "month", "year", "long"}, "action", "auto",
+ kit.MDB_INPUT, "text", "name", "begin_time", "figure", "date", "action", "auto",
+ kit.MDB_INPUT, "text", "name", "end_time", "figure", "date", "action", "auto",
kit.MDB_INPUT, "button", "name", "查看", "action", "auto",
), Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
- if len(arg) == 0 {
- arg = append(arg, "day")
- }
+ m.Option("cache.limit", "10000")
// 起始日期
first := time.Now()
@@ -139,50 +254,49 @@ var Index = &ice.Context{Name: "team", Help: "团队中心",
last = time.Unix(int64(kit.Time(arg[2])), 0)
}
- meta := map[int]string{0: "周日", 1: "周一", 2: "周二", 3: "周三", 4: "周四", 5: "周五", 6: "周六"}
-
- switch arg[0] {
+ switch head := kit.Simple(m.Confv(cmd, "meta.head")); arg[0] {
case "action":
switch arg[1] {
case "insert":
+ // 创建任务
m.Cmdy("task", arg[2], "", arg[3:])
- case "modify":
- switch arg[2] {
- case "begin_time":
- m.Richs("task", nil, arg[6], func(key string, value map[string]interface{}) {
- m.Grows("task", kit.Keys("hash", key), "id", arg[5], func(index int, value map[string]interface{}) {
- m.Log(ice.LOG_MODIFY, "%s: %s begin_time: %s", arg[6], arg[5], arg[3])
- value["begin_time"] = arg[3]
- })
- })
- }
+ default:
+ // 其它操作
+ m.Cmdy("task", arg)
}
case "day":
+ // 日计划
for i := 6; i < 24; i++ {
- m.Push("hour", i)
+ m.Push("hour", kit.Format("%02d", i))
m.Push("task", "")
}
match := first.Format("2006-01-02")
+ template := m.Conf("plan", kit.Keys("meta.template", kit.Select("day", m.Option("template"))))
m.Richs("task", nil, "*", func(key string, value map[string]interface{}) {
m.Grows("task", kit.Keys("hash", key), "", "", func(index int, value map[string]interface{}) {
if now := kit.Format(value["begin_time"]); strings.Split(now, " ")[0] == match {
+ b, _ := kit.Render(kit.Format(template, key), value)
m.Push("hour", strings.Split(now, " ")[1][:2])
- m.Push("task", kit.Format(`%s: %s
`,
- key, kit.Int(value["id"]), value["begin_time"], value["name"], value["text"]))
+ m.Push("task", string(b))
+ } else {
+ m.Info("what %v->%v %v:%v", match, now, value["name"], value["text"])
}
})
})
m.Sort("hour", "int")
case "week":
+ // 周计划
+ first = first.Add(-time.Duration((first.Hour()*int(time.Hour) + first.Minute()*int(time.Minute) + first.Second()*int(time.Second))))
one := first.AddDate(0, 0, -int(first.Weekday()))
end := first.AddDate(0, 0, 7-int(first.Weekday()))
- list := map[int][]map[string]interface{}{}
+ // 查询任务
name := map[int][]string{}
+ list := map[int][]map[string]interface{}{}
m.Richs("task", nil, "*", func(key string, value map[string]interface{}) {
m.Grows("task", kit.Keys("hash", key), "", "", func(index int, value map[string]interface{}) {
if t, e := time.ParseInLocation(ice.ICE_TIME, kit.Format(value["begin_time"]), time.Local); e == nil {
@@ -195,30 +309,33 @@ var Index = &ice.Context{Name: "team", Help: "团队中心",
})
})
+ // 展示任务
+ template := m.Conf("plan", kit.Keys("meta.template", kit.Select("week", m.Option("template"))))
for i := 6; i < 24; i++ {
- m.Push("hour", i)
+ m.Push("hour", kit.Format("%02d", i))
for t := one; t.Before(end); t = t.AddDate(0, 0, 1) {
index := i*10 + int(t.Weekday())
+
note := []string{}
for i, v := range list[index] {
- note = append(note, kit.Format(`%s
`,
- name[index][i], kit.Int(v["id"]), v["begin_time"], v["text"], v["name"]))
+ b, _ := kit.Render(kit.Format(template, name[index][i]), v)
+ note = append(note, string(b))
}
- m.Push(meta[int(t.Weekday())], strings.Join(note, ""))
+ m.Push(head[int(t.Weekday())], strings.Join(note, ""))
}
}
case "month":
- // 本月日期
+ // 月计划
one := first.AddDate(0, 0, -first.Day()+1)
end := last.AddDate(0, 1, -last.Day()+1)
+ // 查询任务
list := map[string][]map[string]interface{}{}
m.Richs("task", nil, "*", func(key string, value map[string]interface{}) {
m.Grows("task", kit.Keys("hash", key), "", "", func(index int, value map[string]interface{}) {
if t, e := time.ParseInLocation(ice.ICE_TIME, kit.Format(value["begin_time"]), time.Local); e == nil {
- if t.After(one) && t.Before(end) {
- index := t.Format("2006-01-02")
+ if index := t.Format("2006-01-02"); t.After(one) && t.Before(end) {
list[index] = append(list[index], value)
}
}
@@ -226,9 +343,9 @@ var Index = &ice.Context{Name: "team", Help: "团队中心",
})
// 上月结尾
- head := one.AddDate(0, 0, -int(one.Weekday()))
- for day := head; day.Before(one); day = day.AddDate(0, 0, 1) {
- m.Push(meta[int(day.Weekday())], day.Day())
+ last := one.AddDate(0, 0, -int(one.Weekday()))
+ for day := last; day.Before(one); day = day.AddDate(0, 0, 1) {
+ m.Push(head[int(day.Weekday())], day.Day())
}
// 本月日期
for day := one; day.Before(end); day = day.AddDate(0, 0, 1) {
@@ -248,72 +365,75 @@ var Index = &ice.Context{Name: "team", Help: "团队中心",
} else {
note[0] = kit.Format(`%s%s`, note[0], "")
}
- m.Push(meta[int(day.Weekday())], note[0])
+ m.Push(head[int(day.Weekday())], note[0])
}
// 下月开头
tail := end.AddDate(0, 0, 6-int(end.Weekday())+1)
for day := end; end.Weekday() != 0 && day.Before(tail); day = day.AddDate(0, 0, 1) {
- m.Push(meta[int(day.Weekday())], day.Day())
+ m.Push(head[int(day.Weekday())], day.Day())
}
case "year":
+ // 年计划
+ for i := 1; i < 13; i++ {
+ m.Push("month", kit.Format("%02d", i))
+ m.Push("task", "")
+ }
+
+ // 查询任务
+ match := first.Format("2006")
+ template := m.Conf("plan", kit.Keys("meta.template", kit.Select("year", m.Option("template"))))
+ m.Richs("task", nil, "*", func(key string, value map[string]interface{}) {
+ m.Grows("task", kit.Keys("hash", key), "", "", func(index int, value map[string]interface{}) {
+ if now := kit.Format(value["begin_time"]); now[0:4] == match && kit.Format(value["type"]) == "年度目标" {
+ b, _ := kit.Render(kit.Format(template, key), value)
+ m.Push("month", now[5:7])
+ m.Push("task", string(b))
+ }
+ })
+ })
+ m.Sort("month", "int")
+
+ case "long":
+ // 长计划
+ one := time.Unix(int64(kit.Time(kit.Select(kit.Format("%d-01-01", first.Year()-5), arg, 1))), 0)
+ end := time.Unix(int64(kit.Time(kit.Select(kit.Format("%d-12-31", first.Year()+5), arg, 2))), 0)
+ for day := one; day.Before(end); day = day.AddDate(1, 0, 0) {
+ m.Push("year", day.Year())
+ m.Push("task", "")
+ }
+
+ // 查询任务
+ template := m.Conf("plan", kit.Keys("meta.template", kit.Select("year", m.Option("template"))))
+ m.Richs("task", nil, "*", func(key string, value map[string]interface{}) {
+ m.Grows("task", kit.Keys("hash", key), "", "", func(index int, value map[string]interface{}) {
+ if t, e := time.ParseInLocation(ice.ICE_TIME, kit.Format(value["begin_time"]), time.Local); e == nil {
+ if t.After(one) && t.Before(end) && kit.Format(value["type"]) == "年度目标" {
+ b, _ := kit.Render(kit.Format(template, key), value)
+ m.Push("year", t.Year())
+ m.Push("task", string(b))
+ }
+ }
+ })
+ })
+ m.Sort("year", "int")
}
}},
"stat": {Name: "stat", Help: "统计", Meta: kit.Dict(), Hand: func(m *ice.Message, c *ice.Context, key string, arg ...string) {
+ m.Option("cache.limit", "10000")
m.Richs("task", nil, kit.Select("*", arg, 0), func(key string, value map[string]interface{}) {
stat := map[string]int{}
m.Grows("task", kit.Keys("hash", key), "", "", func(index int, value map[string]interface{}) {
stat[kit.Format(value["status"])] += 1
})
- m.Push("task", kit.Value(value, "meta.task"))
+ m.Push("zone", kit.Value(value, "meta.zone"))
for _, k := range []string{"prepare", "process", "cancel", "finish"} {
m.Push(k, stat[k])
}
})
}},
- "date": {Name: "date", Help: "日历", Hand: func(m *ice.Message, c *ice.Context, key string, arg ...string) {
- show := map[int]string{0: "周日", 1: "周一", 2: "周二", 3: "周三", 4: "周四", 5: "周五", 6: "周六"}
- space := m.Options("space")
- today := time.Now()
- now := today
- n := kit.Int(kit.Select("1", m.Option("count")))
-
- cur := now
- for i := 0; i < n; i, now = i+1, now.AddDate(0, 1, 0) {
- begin := time.Unix(now.Unix()-int64(now.Day()-1)*24*3600, 0)
- last := time.Unix(begin.Unix()-int64(begin.Weekday())*24*3600, 0)
- cur = last
-
- if last.Month() != now.Month() {
- for month := cur.Month(); cur.Month() == month; cur = cur.AddDate(0, 0, 1) {
- if space || i == 0 {
- m.Push(show[int(cur.Weekday())], "")
- }
- }
- }
- for month := cur.Month(); cur.Month() == month; cur = cur.AddDate(0, 0, 1) {
- data := fmt.Sprintf("%d", cur.Day())
- if cur.Year() == today.Year() && cur.YearDay() == today.YearDay() {
- data = fmt.Sprintf(">%d<", cur.Day())
- }
- if cur.Day() == 1 {
- if cur.Month() == 1 {
- data = fmt.Sprintf("%d年", cur.Year())
- } else {
- data = fmt.Sprintf("%d月", cur.Month())
- }
- }
- m.Push(show[int(cur.Weekday())], data)
- }
- if space || i == n-1 {
- for ; cur.Weekday() > 0; cur = cur.AddDate(0, 0, 1) {
- m.Push(show[int(cur.Weekday())], "")
- }
- }
- }
- }},
"progress": {Name: "progress", Help: "进度", Meta: kit.Dict(
"remote", "you", "display", "team/miss",
"detail", []string{"回退", "前进", "取消", "完成"},
@@ -366,42 +486,6 @@ var Index = &ice.Context{Name: "team", Help: "团队中心",
})
})
}},
-
- "miss": {Name: "miss zone type name text", Help: "任务", List: kit.List(
- kit.MDB_INPUT, "text", "name", "zone", "action", "auto", "figure", "key",
- kit.MDB_INPUT, "text", "name", "type", "figure", "key",
- kit.MDB_INPUT, "text", "name", "name", "figure", "key",
- kit.MDB_INPUT, "button", "name", "添加",
- kit.MDB_INPUT, "textarea", "name", "text",
- kit.MDB_INPUT, "text", "name", "location", "figure", "key", "cb", "location",
- ), Hand: func(m *ice.Message, c *ice.Context, key string, arg ...string) {
- if len(arg) > 0 && arg[0] == "action" {
- switch arg[1] {
- case "input":
- switch arg[2] {
- case "type", "name":
- m.Confm("task", kit.Keys("meta.word", arg[2]), func(key string, value string) {
- m.Push(arg[2], key)
- m.Push("count", value)
- })
- m.Sort("count", "int_r")
- case "zone":
- m.Richs("task", nil, "*", func(key string, value map[string]interface{}) {
- m.Push("zone", kit.Value(value, "meta.zone"))
- m.Push("count", kit.Value(value, "meta.count"))
- })
- }
- return
- }
- }
-
- if len(arg) < 2 {
- m.Cmdy("task", arg)
- return
- }
- m.Cmd("task", arg[0], "", arg[1:])
- m.Cmdy("task", arg[0])
- }},
},
}
diff --git a/core/wiki/wiki.go b/core/wiki/wiki.go
index 5131a5d5..417157e1 100644
--- a/core/wiki/wiki.go
+++ b/core/wiki/wiki.go
@@ -45,7 +45,7 @@ var Index = &ice.Context{Name: "wiki", Help: "文档中心",
"chart": {Name: "chart", Help: "绘图", Value: kit.Data("prefix", prefix, "suffix", ``)},
"draw": {Name: "draw", Help: "思维导图", Value: kit.Data(kit.MDB_SHORT, "name", "path", "usr/local", "regs", ".*\\.svg", "prefix", ``)},
- "word": {Name: "word", Help: "语言文字", Value: kit.Data(kit.MDB_SHORT, "name", "path", "usr/learning", "regs", ".*\\.shy")},
+ "word": {Name: "word", Help: "语言文字", Value: kit.Data(kit.MDB_SHORT, "name", "path", "usr/local", "regs", ".*\\.shy")},
"data": {Name: "data", Help: "数据表格", Value: kit.Data(kit.MDB_SHORT, "name", "path", "usr/local", "regs", ".*\\.csv")},
"feel": {Name: "feel", Help: "影音媒体", Value: kit.Data(kit.MDB_SHORT, "name", "path", "usr/local", "regs", ".*\\.(png|JPG|MOV|m4v)")},
"walk": {Name: "walk", Help: "走遍世界", Value: kit.Data(kit.MDB_SHORT, "name", "path", "usr/local", "regs", ".*\\.csv")},
@@ -166,6 +166,13 @@ var Index = &ice.Context{Name: "wiki", Help: "文档中心",
m.Render(m.Conf("title", "meta.template"))
}},
"brief": {Name: "brief name text", Help: "摘要", Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
+ if len(arg) == 0 {
+ m.Echo(`
`)
+ return
+ }
+ if len(arg) == 1 {
+ arg = []string{"", arg[0]}
+ }
m.Option(kit.MDB_TYPE, cmd)
m.Option(kit.MDB_NAME, arg[0])
m.Option(kit.MDB_TEXT, arg[1])
@@ -367,8 +374,8 @@ var Index = &ice.Context{Name: "wiki", Help: "文档中心",
m.Cmdy("nfs.dir", kit.Select("./", arg, 0))
}
}},
- "word": {Name: "word", Help: "语言文字", Meta: kit.Dict("display", "wiki/word"), List: kit.List(
- kit.MDB_INPUT, "text", "name", "name", "value", "what/hi.shy",
+ "word": {Name: "word", Help: "语言文字", Meta: kit.Dict("remote", "pod", "display", "wiki/word"), List: kit.List(
+ kit.MDB_INPUT, "text", "name", "name", "value", "自然/编程/hi.shy",
kit.MDB_INPUT, "button", "name", "执行", "action", "auto",
kit.MDB_INPUT, "button", "name", "返回", "cb", "Last",
kit.MDB_INPUT, "button", "name", "上传", "cb", "upload",
diff --git a/misc/git/git.go b/misc/git/git.go
index fcb0289d..32e05aff 100644
--- a/misc/git/git.go
+++ b/misc/git/git.go
@@ -18,34 +18,31 @@ var Index = &ice.Context{Name: "git", Help: "代码管理",
},
Commands: map[string]*ice.Command{
ice.ICE_INIT: {Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
- // 前端代码
- for _, repos := range []string{"volcanos"} {
+ // 系统项目
+ wd, _ := os.Getwd()
+ if s, e := os.Stat(".git"); e == nil && s.IsDir() {
m.Rich("repos", nil, kit.Data(
- "name", repos, "path", "usr/"+repos, "branch", "master",
- "remote", m.Conf("repos", "meta.owner")+"/"+repos,
- ))
- }
- // 后端代码
- for _, repos := range []string{"contexts", "icebergs", "toolkits"} {
- m.Rich("repos", nil, kit.Data(
- "name", repos, "path", "../"+repos, "branch", "master",
- "remote", m.Conf("repos", "meta.owner")+"/"+repos,
+ "name", path.Base(wd), "path", wd, "branch", "master",
+ "remote", strings.TrimSpace(m.Cmdx(ice.CLI_SYSTEM, "git", "remote", "get-url", "origin")),
))
}
+
+ // 官方项目
m.Cmd("nfs.dir", "usr", "name path").Table(func(index int, value map[string]string, head []string) {
if s, e := os.Stat(m.Option("cmd_dir", path.Join(value["path"], ".git"))); e == nil && s.IsDir() {
m.Rich("repos", nil, kit.Data(
"name", value["name"], "path", value["path"], "branch", "master",
- "remote", m.Cmdx(ice.CLI_SYSTEM, "git", "remote", "get-url", "origin"),
+ "remote", strings.TrimSpace(m.Cmdx(ice.CLI_SYSTEM, "git", "remote", "get-url", "origin")),
))
}
})
- // 应用代码
+
+ // 应用项目
m.Cmd("nfs.dir", m.Conf(ice.WEB_DREAM, "meta.path"), "name path").Table(func(index int, value map[string]string, head []string) {
if s, e := os.Stat(m.Option("cmd_dir", path.Join(value["path"], ".git"))); e == nil && s.IsDir() {
m.Rich("repos", nil, kit.Data(
"name", value["name"], "path", value["path"], "branch", "master",
- "remote", m.Cmdx(ice.CLI_SYSTEM, "git", "remote", "get-url", "origin"),
+ "remote", strings.TrimSpace(m.Cmdx(ice.CLI_SYSTEM, "git", "remote", "get-url", "origin")),
))
}
})
@@ -56,8 +53,8 @@ var Index = &ice.Context{Name: "git", Help: "代码管理",
"repos": {Name: "repos [name [path]]", Help: "仓库", Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
if len(arg) > 0 {
m.Rich("repos", nil, kit.Data(
- "name", arg[0], "path", "usr/"+kit.Select(arg[0], arg, 1), "branch", "master",
- "remote", m.Conf("repos", "meta.owner")+"/"+arg[0],
+ "name", arg[0], "path", kit.Select(path.Join("usr", arg[0]), arg, 1), "branch", "master",
+ "remote", kit.Select(m.Conf("repos", "meta.owner")+"/"+arg[0], arg, 2),
))
}
m.Richs("repos", nil, "*", func(key string, value map[string]interface{}) {
@@ -119,7 +116,11 @@ var Index = &ice.Context{Name: "git", Help: "代码管理",
m.Push("rest", rest)
m.Sort("adds", "int_r")
}},
- "check": {Name: "check", Help: "检查", Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
+ "check": {Name: "check name [path [repos]]", Help: "检查", Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
+ if len(arg) > 1 {
+ m.Cmd("repos", arg)
+ }
+
m.Richs("repos", nil, arg[0], func(key string, value map[string]interface{}) {
if _, e := os.Stat(kit.Format(kit.Value(value, "meta.path"))); e != nil && os.IsNotExist(e) {
m.Cmd(ice.CLI_SYSTEM, "git", "clone", kit.Value(value, "meta.remote"),
diff --git a/template.sh b/template.sh
index abe9752e..e73d01be 100755
--- a/template.sh
+++ b/template.sh
@@ -103,16 +103,17 @@ build() {
}
tutor() {
- mkdir $1
- [ -f "$1/$1.md" ] || cat >> "$1/$1.md" <> "$1/$1.shy" <> "$1/$1.go" <