forked from x/icebergs
opt some
This commit is contained in:
parent
ab7ab6eb19
commit
a17a4fce6e
@ -35,6 +35,7 @@ func _split_list(m *ice.Message, file string, arg ...string) map[string]interfac
|
||||
const DEEP = "_deep"
|
||||
stack, deep := []int{}, 0
|
||||
list := kit.List(kit.Data(DEEP, -1))
|
||||
line := ""
|
||||
m.Cmd(nfs.CAT, file, func(text string) {
|
||||
if strings.HasPrefix(strings.TrimSpace(text), "# ") {
|
||||
return // 注释
|
||||
@ -42,6 +43,9 @@ func _split_list(m *ice.Message, file string, arg ...string) map[string]interfac
|
||||
if strings.TrimSpace(text) == "" {
|
||||
return // 空行
|
||||
}
|
||||
if line += text; strings.Count(text, "`")%2 == 1 {
|
||||
return // 多行
|
||||
}
|
||||
|
||||
stack, deep = _split_deep(stack, text)
|
||||
data := kit.Data(DEEP, deep)
|
||||
@ -76,6 +80,7 @@ func _split_list(m *ice.Message, file string, arg ...string) map[string]interfac
|
||||
}
|
||||
list = list[:len(list)-1]
|
||||
}
|
||||
line = ""
|
||||
})
|
||||
return list[0].(map[string]interface{})
|
||||
}
|
||||
|
@ -154,10 +154,7 @@ const ACTION = "action"
|
||||
|
||||
func init() {
|
||||
Index.Merge(&ice.Context{Configs: map[string]*ice.Config{
|
||||
ACTION: {Name: ACTION, Help: "应用", Value: kit.Data(
|
||||
MENUS, kit.List(kit.List("help", "tutor", "manual", "service", "devops", "refer")),
|
||||
nfs.PATH, ice.USR_LOCAL_RIVER,
|
||||
)},
|
||||
ACTION: {Name: ACTION, Help: "应用", Value: kit.Data(nfs.PATH, ice.USR_LOCAL_RIVER)},
|
||||
}, Commands: map[string]*ice.Command{
|
||||
"/action": {Name: "/action river storm action arg...", Help: "工作台", Action: ice.MergeAction(map[string]*ice.Action{
|
||||
ice.CTX_INIT: {Hand: func(m *ice.Message, arg ...string) {
|
||||
|
@ -79,11 +79,7 @@ const HEADER = "header"
|
||||
|
||||
func init() {
|
||||
Index.Merge(&ice.Context{Configs: map[string]*ice.Config{
|
||||
HEADER: {Name: HEADER, Help: "标题栏", Value: kit.Data(
|
||||
TITLE, "shylinux.com/x/contexts", MENUS, kit.List(
|
||||
"header", kit.List("setting", "black", "white", "print", "webpack", "devpack"),
|
||||
), aaa.LOGIN, kit.List("登录", "扫码", "授权"),
|
||||
)},
|
||||
HEADER: {Name: HEADER, Help: "标题栏", Value: kit.Data(aaa.LOGIN, kit.List("登录", "扫码", "授权"))},
|
||||
}, Commands: map[string]*ice.Command{
|
||||
web.WEB_LOGIN: {Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
|
||||
switch arg[0] {
|
||||
|
@ -54,10 +54,7 @@ const RIVER = "river"
|
||||
|
||||
func init() {
|
||||
Index.Merge(&ice.Context{Configs: map[string]*ice.Config{
|
||||
RIVER: {Name: RIVER, Help: "群组", Value: kit.Data(
|
||||
mdb.FIELD, "time,hash,type,name,text,template",
|
||||
MENUS, kit.List(RIVER, kit.List("create", "创建群组", "添加应用", "添加工具", "添加设备", "创建空间"), kit.List("share", "共享群组", "共享应用", "共享工具", "共享主机", "访问空间")),
|
||||
)},
|
||||
RIVER: {Name: RIVER, Help: "群组", Value: kit.Data(mdb.FIELD, "time,hash,type,name,text,template")},
|
||||
}, Commands: map[string]*ice.Command{
|
||||
"/river": {Name: "/river", Help: "小河流", Action: map[string]*ice.Action{
|
||||
ice.CTX_INIT: {Hand: func(m *ice.Message, arg ...string) {
|
||||
|
@ -17,7 +17,12 @@ import (
|
||||
|
||||
func _website_parse(m *ice.Message, text string) map[string]interface{} {
|
||||
m.Option(nfs.CAT_CONTENT, text)
|
||||
river, storm, last := kit.Dict(), kit.Dict(), kit.Dict()
|
||||
river, storm, last := kit.Dict(
|
||||
"Header", kit.Dict("menus", kit.List(), "style", kit.Dict("display", "none")),
|
||||
"River", kit.Dict("menus", kit.List(), "action", kit.List()),
|
||||
"Action", kit.Dict("menus", kit.List(), "action", kit.List()),
|
||||
"Footer", kit.Dict("style", kit.Dict("display", "none")),
|
||||
), kit.Dict(), kit.Dict()
|
||||
m.Cmd(lex.SPLIT, "", mdb.KEY, mdb.NAME, func(deep int, ls []string, meta map[string]interface{}) []string {
|
||||
if len(ls) == 1 {
|
||||
ls = append(ls, ls[0])
|
||||
@ -27,7 +32,8 @@ func _website_parse(m *ice.Message, text string) map[string]interface{} {
|
||||
switch ls[i] {
|
||||
case ctx.ARGS:
|
||||
data[ls[i]] = kit.Split(ls[i+1])
|
||||
// data[ls[i]] = kit.UnMarshal(ls[i+1])
|
||||
case "title", "menus", "action", "style":
|
||||
data[ls[i]] = kit.UnMarshal(ls[i+1])
|
||||
default:
|
||||
data[ls[i]] = ls[i+1]
|
||||
}
|
||||
@ -35,7 +41,7 @@ func _website_parse(m *ice.Message, text string) map[string]interface{} {
|
||||
switch deep {
|
||||
case 1:
|
||||
storm = kit.Dict()
|
||||
river[ls[0]] = kit.Dict(mdb.NAME, ls[1], "storm", storm, data)
|
||||
river[ls[0]] = kit.Dict(mdb.NAME, ls[1], STORM, storm, data)
|
||||
case 2:
|
||||
last = kit.Dict(mdb.NAME, ls[1], mdb.LIST, kit.List(), data)
|
||||
storm[ls[0]] = last
|
||||
@ -60,7 +66,10 @@ func _website_render(m *ice.Message, w http.ResponseWriter, r *http.Request, kin
|
||||
return false
|
||||
}
|
||||
case "txt":
|
||||
m.Debug("what %v", text)
|
||||
res := _website_parse(msg, text)
|
||||
m.Debug("what %v", res)
|
||||
m.Debug("what %v", kit.Format(res))
|
||||
msg.RenderResult(_website_template2, kit.Format(res))
|
||||
case "json":
|
||||
msg.RenderResult(_website_template2, kit.Format(kit.UnMarshal(text)))
|
||||
@ -78,6 +87,10 @@ func _website_render(m *ice.Message, w http.ResponseWriter, r *http.Request, kin
|
||||
const WEBSITE = "website"
|
||||
|
||||
func init() {
|
||||
const (
|
||||
SRC_WEBSITE = "src/website/"
|
||||
CHAT_WEBSITE = "/chat/website/"
|
||||
)
|
||||
Index.Merge(&ice.Context{Configs: map[string]*ice.Config{
|
||||
WEBSITE: {Name: "website", Help: "网站", Value: kit.Data(mdb.SHORT, nfs.PATH, mdb.FIELD, "time,path,type,name,text")},
|
||||
}, Commands: map[string]*ice.Command{
|
||||
@ -93,18 +106,18 @@ func init() {
|
||||
}) != nil && ok {
|
||||
return true
|
||||
}
|
||||
if strings.HasPrefix(r.URL.Path, "/chat/website/") {
|
||||
_website_render(m, w, r, kit.Ext(r.URL.Path), m.Cmdx(nfs.CAT, strings.Replace(r.URL.Path, "/chat/website/", "src/website/", 1)))
|
||||
if strings.HasPrefix(r.URL.Path, CHAT_WEBSITE) {
|
||||
_website_render(m, w, r, kit.Ext(r.URL.Path), m.Cmdx(nfs.CAT, strings.Replace(r.URL.Path, CHAT_WEBSITE, SRC_WEBSITE, 1)))
|
||||
return true
|
||||
}
|
||||
return false
|
||||
})
|
||||
}},
|
||||
mdb.RENDER: {Hand: func(m *ice.Message, arg ...string) {
|
||||
m.EchoIFrame(path.Join("/chat/website/", strings.TrimPrefix(path.Join(arg[2], arg[1]), "src/website/")))
|
||||
m.EchoIFrame(path.Join(CHAT_WEBSITE, strings.TrimPrefix(path.Join(arg[2], arg[1]), SRC_WEBSITE)))
|
||||
}},
|
||||
mdb.ENGINE: {Hand: func(m *ice.Message, arg ...string) {
|
||||
m.Echo(kit.MergeURL2(m.Option(ice.MSG_USERWEB), path.Join("/chat/website/", strings.TrimPrefix(path.Join(arg[2], arg[1]), "src/website/"))))
|
||||
m.Echo(strings.Split(kit.MergeURL2(m.Option(ice.MSG_USERWEB), path.Join(CHAT_WEBSITE, strings.TrimPrefix(path.Join(arg[2], arg[1]), SRC_WEBSITE))), "?")[0])
|
||||
}},
|
||||
mdb.INPUTS: {Name: "inputs", Help: "补全", Hand: func(m *ice.Message, arg ...string) {
|
||||
switch m.Option(ctx.ACTION) {
|
||||
@ -132,7 +145,7 @@ func init() {
|
||||
}},
|
||||
}, mdb.HashAction()), Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
|
||||
if mdb.HashSelect(m, arg...); len(arg) == 0 {
|
||||
dir := "src/website/"
|
||||
dir := SRC_WEBSITE
|
||||
m.Cmd(nfs.DIR, dir, func(f os.FileInfo, p string) {
|
||||
m.Push("", kit.Dict(
|
||||
mdb.TIME, f.ModTime().Format(ice.MOD_TIME),
|
||||
@ -148,8 +161,8 @@ func init() {
|
||||
m.PushAnchor(strings.Split(m.MergeURL2(value[nfs.PATH]), "?")[0])
|
||||
})
|
||||
if m.Length() == 0 && len(arg) > 0 {
|
||||
m.Push(mdb.TEXT, m.Cmdx(nfs.CAT, path.Join("src/website", path.Join(arg...))))
|
||||
m.Push(nfs.PATH, path.Join("/chat/website/", path.Join(arg...)))
|
||||
m.Push(mdb.TEXT, m.Cmdx(nfs.CAT, path.Join(SRC_WEBSITE, path.Join(arg...))))
|
||||
m.Push(nfs.PATH, path.Join(CHAT_WEBSITE, path.Join(arg...)))
|
||||
} else {
|
||||
m.Sort(nfs.PATH)
|
||||
}
|
||||
|
3
meta.go
3
meta.go
@ -171,6 +171,9 @@ func (m *Message) Push(key string, value interface{}, arg ...interface{}) *Messa
|
||||
return m
|
||||
}
|
||||
func (m *Message) Echo(str string, arg ...interface{}) *Message {
|
||||
if str == "" {
|
||||
return m
|
||||
}
|
||||
m.meta[MSG_RESULT] = append(m.meta[MSG_RESULT], kit.Format(str, arg...))
|
||||
return m
|
||||
}
|
||||
|
@ -50,7 +50,7 @@ func init() {
|
||||
REPOS, "https://shylinux.com/x", nfs.PATH, ice.USR_LOCAL,
|
||||
)},
|
||||
}, Commands: map[string]*ice.Command{
|
||||
REPOS: {Name: "repos name path auto create", Help: "代码库", Action: ice.MergeAction(map[string]*ice.Action{
|
||||
REPOS: {Name: "repos repos path auto create", Help: "代码库", Action: ice.MergeAction(map[string]*ice.Action{
|
||||
ice.CTX_INIT: {Hand: func(m *ice.Message, arg ...string) {
|
||||
m.Conf(REPOS, mdb.HASH, "")
|
||||
_repos_insert(m, path.Base(kit.Pwd()), kit.Pwd())
|
||||
@ -84,6 +84,7 @@ func init() {
|
||||
if len(arg) == 0 { // 仓库列表
|
||||
mdb.HashSelect(m, arg...)
|
||||
m.Sort(mdb.NAME)
|
||||
m.RenameAppend(mdb.NAME, "repos")
|
||||
return
|
||||
}
|
||||
|
||||
|
@ -61,10 +61,8 @@ const SPIDE = "spide"
|
||||
|
||||
func init() {
|
||||
Index.Merge(&ice.Context{Commands: map[string]*ice.Command{
|
||||
SPIDE: {Name: "spide name auto depend", Help: "构架图", Action: ice.MergeAction(map[string]*ice.Action{
|
||||
mdb.INPUTS: {Name: "inputs", Help: "补全", Hand: func(m *ice.Message, arg ...string) {
|
||||
m.Cmdy(REPOS, ice.OptionFields("name,time"))
|
||||
}}, code.INNER: {Name: "web.code.inner"},
|
||||
SPIDE: {Name: "spide repos auto depend", Help: "构架图", Action: ice.MergeAction(map[string]*ice.Action{
|
||||
code.INNER: {Name: "web.code.inner"},
|
||||
"depend": {Name: "depend path=icebergs/base", Help: "依赖", Hand: func(m *ice.Message, arg ...string) {
|
||||
keys := map[string]bool{}
|
||||
list := map[string]map[string]bool{}
|
||||
@ -109,8 +107,7 @@ func init() {
|
||||
return
|
||||
}
|
||||
|
||||
arg[0] = kit.Replace(arg[0], "src", "contexts")
|
||||
if arg[0] == path.Base(kit.Pwd()) {
|
||||
if arg[0] = kit.Replace(arg[0], "src", "contexts"); arg[0] == path.Base(kit.Pwd()) {
|
||||
m.Option(nfs.DIR_ROOT, path.Join(ice.SRC)+ice.PS)
|
||||
} else {
|
||||
m.Option(nfs.DIR_ROOT, path.Join(ice.USR, arg[0])+ice.PS)
|
||||
|
@ -29,10 +29,10 @@ func _status_tags(m *ice.Message) {
|
||||
vs := map[string]string{}
|
||||
m.Cmd(STATUS).Table(func(index int, value map[string]string, head []string) {
|
||||
if value[mdb.TYPE] == "##" {
|
||||
if value[mdb.NAME] == ice.RELEASE {
|
||||
value[mdb.NAME] = ice.ICE
|
||||
if value[REPOS] == ice.RELEASE {
|
||||
value[REPOS] = ice.ICE
|
||||
}
|
||||
vs[value[mdb.NAME]] = strings.Split(value[TAGS], "-")[0]
|
||||
vs[value[REPOS]] = strings.Split(value[TAGS], "-")[0]
|
||||
}
|
||||
})
|
||||
|
||||
@ -89,11 +89,11 @@ func _status_each(m *ice.Message, title string, cmds ...string) {
|
||||
|
||||
list := []string{}
|
||||
m.Cmd(REPOS, ice.OptionFields("name,path")).Table(func(index int, value map[string]string, head []string) {
|
||||
toast(value[mdb.NAME], count, total)
|
||||
toast(value[REPOS], count, total)
|
||||
|
||||
if msg := m.Cmd(cmds, ice.Option{cli.CMD_DIR, value[nfs.PATH]}); !cli.IsSuccess(msg) {
|
||||
m.Toast3s(msg.Append(cli.CMD_ERR), "error: "+value[mdb.NAME])
|
||||
list = append(list, value[mdb.NAME])
|
||||
m.Toast3s(msg.Append(cli.CMD_ERR), "error: "+value[REPOS])
|
||||
list = append(list, value[REPOS])
|
||||
m.Sleep3s()
|
||||
}
|
||||
count++
|
||||
@ -136,7 +136,7 @@ func _status_list(m *ice.Message) (files, adds, dels int, last time.Time) {
|
||||
continue
|
||||
}
|
||||
|
||||
m.Push(mdb.NAME, value[mdb.NAME])
|
||||
m.Push(REPOS, value[REPOS])
|
||||
m.Push(mdb.TYPE, vs[0])
|
||||
m.Push(nfs.FILE, vs[1])
|
||||
|
||||
@ -194,7 +194,7 @@ const STATUS = "status"
|
||||
|
||||
func init() {
|
||||
Index.Merge(&ice.Context{Commands: map[string]*ice.Command{
|
||||
STATUS: {Name: "status name auto", Help: "状态机", Action: map[string]*ice.Action{
|
||||
STATUS: {Name: "status repos auto", Help: "状态机", Action: map[string]*ice.Action{
|
||||
PULL: {Name: "pull", Help: "下载", Hand: func(m *ice.Message, arg ...string) {
|
||||
_status_each(m, PULL, cli.SYSTEM, GIT, PULL)
|
||||
m.ProcessHold()
|
||||
@ -210,25 +210,25 @@ func init() {
|
||||
m.ProcessHold()
|
||||
}},
|
||||
PUSH: {Name: "push", Help: "上传", Hand: func(m *ice.Message, arg ...string) {
|
||||
if m.Option(mdb.NAME) == "" {
|
||||
if m.Option(REPOS) == "" {
|
||||
_status_each(m, PUSH, cli.SYSTEM, GIT, PUSH)
|
||||
m.ProcessHold()
|
||||
return
|
||||
}
|
||||
|
||||
_repos_cmd(m, m.Option(mdb.NAME), PUSH)
|
||||
_repos_cmd(m, m.Option(mdb.NAME), PUSH, "--tags")
|
||||
_repos_cmd(m, m.Option(REPOS), PUSH)
|
||||
_repos_cmd(m, m.Option(REPOS), PUSH, "--tags")
|
||||
}},
|
||||
|
||||
TAG: {Name: "tag version@key", Help: "标签", Hand: func(m *ice.Message, arg ...string) {
|
||||
if m.Option(VERSION) == "" {
|
||||
m.Option(VERSION, _status_tag(m, m.Option(TAGS)))
|
||||
}
|
||||
_repos_cmd(m, m.Option(mdb.NAME), TAG, m.Option(VERSION))
|
||||
_repos_cmd(m, m.Option(mdb.NAME), PUSH, "--tags")
|
||||
_repos_cmd(m, m.Option(REPOS), TAG, m.Option(VERSION))
|
||||
_repos_cmd(m, m.Option(REPOS), PUSH, "--tags")
|
||||
}},
|
||||
ADD: {Name: "add", Help: "添加", Hand: func(m *ice.Message, arg ...string) {
|
||||
_repos_cmd(m, m.Option(mdb.NAME), ADD, m.Option(nfs.FILE))
|
||||
_repos_cmd(m, m.Option(REPOS), ADD, m.Option(nfs.FILE))
|
||||
}}, OPT: {Name: "opt", Help: "优化"}, PRO: {Name: "pro", Help: "升级"},
|
||||
COMMIT: {Name: "commit action=opt,add,pro comment=some@key", Help: "提交", Hand: func(m *ice.Message, arg ...string) {
|
||||
if arg[0] == ctx.ACTION {
|
||||
@ -237,7 +237,7 @@ func init() {
|
||||
m.Option(mdb.TEXT, kit.Select("opt some", strings.Join(arg, ice.SP)))
|
||||
}
|
||||
|
||||
_repos_cmd(m, m.Option(mdb.NAME), COMMIT, "-am", m.Option(mdb.TEXT))
|
||||
_repos_cmd(m, m.Option(REPOS), COMMIT, "-am", m.Option(mdb.TEXT))
|
||||
m.ProcessBack()
|
||||
}},
|
||||
mdb.INPUTS: {Name: "inputs", Help: "补全", Hand: func(m *ice.Message, arg ...string) {
|
||||
|
@ -19,7 +19,7 @@ const TOTAL = "total"
|
||||
func init() {
|
||||
Index.Merge(&ice.Context{Configs: map[string]*ice.Config{
|
||||
TOTAL: {Name: TOTAL, Help: "统计量", Value: kit.Data(
|
||||
mdb.SHORT, mdb.NAME, "skip", kit.Dict(
|
||||
"skip", kit.Dict(
|
||||
"wubi-dict", ice.TRUE, "word-dict", ice.TRUE,
|
||||
"websocket", ice.TRUE, "go-sql-mysql", ice.TRUE,
|
||||
"echarts", ice.TRUE, "go-qrcode", ice.TRUE,
|
||||
@ -30,11 +30,11 @@ func init() {
|
||||
PIE: {Name: "pie", Help: "饼图", Hand: func(m *ice.Message, arg ...string) {
|
||||
defer m.Display("/plugin/story/pie.js")
|
||||
m.Cmd(TOTAL).Table(func(index int, value map[string]string, head []string) {
|
||||
if value["name"] == "total" {
|
||||
m.StatusTimeCount("name", "total", "value", "1", "total", value["rest"])
|
||||
if value[REPOS] == "total" {
|
||||
m.StatusTimeCount(REPOS, "total", "value", "1", "total", value["rest"])
|
||||
return
|
||||
}
|
||||
m.Push("name", value["name"])
|
||||
m.Push(REPOS, value[REPOS])
|
||||
m.Push("value", value["rest"])
|
||||
})
|
||||
}},
|
||||
@ -42,7 +42,7 @@ func init() {
|
||||
if len(arg) > 0 { // 提交详情
|
||||
arg[0] = kit.Replace(arg[0], "src", "contexts")
|
||||
m.Cmd(REPOS, ice.OptionFields("name,path")).Table(func(index int, value map[string]string, head []string) {
|
||||
if value[mdb.NAME] == arg[0] {
|
||||
if value[REPOS] == arg[0] {
|
||||
m.Cmdy("_sum", value[nfs.PATH], arg[1:])
|
||||
}
|
||||
})
|
||||
@ -72,11 +72,11 @@ func init() {
|
||||
rest += kit.Int(value["rest"])
|
||||
})
|
||||
|
||||
m.Push(mdb.NAME, value[mdb.NAME])
|
||||
m.Push(REPOS, value[mdb.NAME])
|
||||
m.Copy(msg)
|
||||
})
|
||||
|
||||
m.Push("name", "total")
|
||||
m.Push(REPOS, "total")
|
||||
m.Push("tags", "v3.0.0")
|
||||
m.Push("days", days)
|
||||
m.Push("commit", commit)
|
||||
|
Loading…
x
Reference in New Issue
Block a user