forked from x/icebergs
fix story
This commit is contained in:
parent
ff04e585a6
commit
8e8d487541
@ -514,7 +514,7 @@ var Index = &ice.Context{Name: "web", Help: "网络模块",
|
|||||||
if len(arg) == 0 {
|
if len(arg) == 0 {
|
||||||
// 爬虫列表
|
// 爬虫列表
|
||||||
m.Richs(ice.WEB_SPIDE, nil, "*", func(key string, value map[string]interface{}) {
|
m.Richs(ice.WEB_SPIDE, nil, "*", func(key string, value map[string]interface{}) {
|
||||||
m.Push(key, value["client"], []string{"name", "login", "share", "method", "url"})
|
m.Push(key, value["client"], []string{"name", "share", "login", "method", "url"})
|
||||||
})
|
})
|
||||||
m.Sort("name")
|
m.Sort("name")
|
||||||
return
|
return
|
||||||
@ -557,10 +557,20 @@ var Index = &ice.Context{Name: "web", Help: "网络模块",
|
|||||||
return
|
return
|
||||||
case "login":
|
case "login":
|
||||||
m.Richs(ice.WEB_SPIDE, nil, arg[1], func(key string, value map[string]interface{}) {
|
m.Richs(ice.WEB_SPIDE, nil, arg[1], func(key string, value map[string]interface{}) {
|
||||||
kit.Value(value, "client.login", m.Cmdx(ice.WEB_SPIDE, arg[1], "raw", "/route/login", "login", kit.Value(value, "client.login")))
|
msg := m.Cmd(ice.WEB_SPIDE, arg[1], "msg", "/route/login", "login")
|
||||||
|
if msg.Append(ice.MSG_USERNAME) != "" {
|
||||||
|
m.Echo(msg.Append(ice.MSG_USERNAME))
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if msg.Result() != "" {
|
||||||
|
kit.Value(value, "client.login", msg.Result())
|
||||||
kit.Value(value, "client.share", m.Cmdx(ice.WEB_SHARE, "add", ice.TYPE_SPIDE, arg[1],
|
kit.Value(value, "client.share", m.Cmdx(ice.WEB_SHARE, "add", ice.TYPE_SPIDE, arg[1],
|
||||||
kit.Format("%s?sessid=%s", kit.Value(value, "client.url"), kit.Value(value, "cookie.sessid"))))
|
kit.Format("%s?sessid=%s", kit.Value(value, "client.url"), kit.Value(value, "cookie.sessid"))))
|
||||||
m.Echo("%s", kit.Value(value, "client.login"))
|
}
|
||||||
|
m.Render(ice.RENDER_QRCODE, kit.Dict(
|
||||||
|
kit.MDB_TYPE, "login", kit.MDB_NAME, arg[1],
|
||||||
|
kit.MDB_TEXT, kit.Value(value, "cookie.sessid"),
|
||||||
|
))
|
||||||
})
|
})
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@ -731,28 +741,12 @@ var Index = &ice.Context{Name: "web", Help: "网络模块",
|
|||||||
})
|
})
|
||||||
}},
|
}},
|
||||||
ice.WEB_SERVE: {Name: "serve [shy|dev|self]", Help: "服务器", Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
|
ice.WEB_SERVE: {Name: "serve [shy|dev|self]", Help: "服务器", Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
|
||||||
// 节点信息
|
|
||||||
// m.Conf(ice.CLI_RUNTIME, "node.name", m.Conf(ice.CLI_RUNTIME, "boot.hostname"))
|
|
||||||
m.Conf(ice.CLI_RUNTIME, "node.type", ice.WEB_SERVER)
|
|
||||||
|
|
||||||
switch kit.Select("def", arg, 0) {
|
|
||||||
case "shy":
|
|
||||||
// 连接根服务
|
|
||||||
m.Richs(ice.WEB_SPIDE, nil, "shy", func(key string, value map[string]interface{}) {
|
|
||||||
m.Cmd(ice.WEB_SPACE, "connect", "shy")
|
|
||||||
})
|
|
||||||
fallthrough
|
|
||||||
case "dev":
|
|
||||||
// 连接上游服务
|
|
||||||
m.Richs(ice.WEB_SPIDE, nil, "dev", func(key string, value map[string]interface{}) {
|
|
||||||
m.Cmd(ice.WEB_SPACE, "connect", "dev")
|
|
||||||
})
|
|
||||||
fallthrough
|
|
||||||
default:
|
|
||||||
// 启动服务
|
// 启动服务
|
||||||
|
m.Conf(ice.CLI_RUNTIME, "node.name", m.Conf(ice.CLI_RUNTIME, "boot.hostname"))
|
||||||
|
m.Conf(ice.CLI_RUNTIME, "node.type", ice.WEB_SERVER)
|
||||||
m.Target().Start(m, "self")
|
m.Target().Start(m, "self")
|
||||||
|
// 连接服务
|
||||||
m.Cmd(ice.WEB_SPACE, "connect", "self")
|
m.Cmd(ice.WEB_SPACE, "connect", "self")
|
||||||
}
|
|
||||||
}},
|
}},
|
||||||
ice.WEB_SPACE: {Name: "space", Help: "空间站", Meta: kit.Dict("exports", []string{"pod", "name"}), List: kit.List(
|
ice.WEB_SPACE: {Name: "space", Help: "空间站", Meta: kit.Dict("exports", []string{"pod", "name"}), List: kit.List(
|
||||||
kit.MDB_INPUT, "text", "name", "name",
|
kit.MDB_INPUT, "text", "name", "name",
|
||||||
@ -1028,33 +1022,30 @@ var Index = &ice.Context{Name: "web", Help: "网络模块",
|
|||||||
|
|
||||||
switch arg[0] {
|
switch arg[0] {
|
||||||
case "sync":
|
case "sync":
|
||||||
m.Richs(ice.WEB_FAVOR, nil, arg[1], func(key string, value map[string]interface{}) {
|
m.Richs(ice.WEB_FAVOR, nil, arg[1], func(key string, val map[string]interface{}) {
|
||||||
count := kit.Int(kit.Value(value, kit.Keys("meta.count")))
|
remote := kit.Keys("meta.remote", arg[2], arg[3])
|
||||||
|
count := kit.Int(kit.Value(val, kit.Keys("meta.count")))
|
||||||
|
|
||||||
pull := kit.Int(kit.Value(value, kit.Keys("meta.remote", arg[2], "pull"))) + 1
|
pull := kit.Int(kit.Value(val, kit.Keys(remote, "pull")))
|
||||||
pull = 1
|
m.Cmd(ice.WEB_SPIDE, arg[2], "msg", "/favor/pull", "favor", arg[3], "begin", pull+1).Table(func(index int, value map[string]string, head []string) {
|
||||||
m.Cmd(ice.WEB_SPIDE, arg[2], "msg", "/favor/pull", "favor", arg[3], "begin", pull).Table(func(index int, value map[string]string, head []string) {
|
m.Cmd(ice.WEB_FAVOR, arg[1], value["type"], value["name"], value["text"], value["extra"])
|
||||||
kit.Value(value, kit.Keys("meta.remote", arg[2], arg[3], "pull"), value["id"])
|
pull = kit.Int(value["id"])
|
||||||
m.Log(ice.LOG_IMPORT, "%v", value)
|
|
||||||
m.Grow(ice.WEB_FAVOR, kit.Keys(kit.MDB_HASH, key), kit.Dict(
|
|
||||||
kit.MDB_TYPE, value["type"], kit.MDB_NAME, value["name"], kit.MDB_TEXT, value["text"],
|
|
||||||
"extra", kit.UnMarshal(value["extra"]),
|
|
||||||
))
|
|
||||||
})
|
})
|
||||||
|
|
||||||
push := kit.Int(kit.Value(value, kit.Keys("meta.remote", arg[0], "push"))) + 1
|
m.Option("cache.limit", count-kit.Int(kit.Value(val, kit.Keys(remote, "push"))))
|
||||||
push = 1
|
m.Grows(ice.WEB_FAVOR, kit.Keys(kit.MDB_HASH, key), "", "", func(index int, value map[string]interface{}) {
|
||||||
for i := push; i <= count; i++ {
|
|
||||||
m.Grows(ice.WEB_FAVOR, kit.Keys(kit.MDB_HASH, key), "id", kit.Format(i), func(index int, value map[string]interface{}) {
|
|
||||||
kit.Value(value, kit.Keys("meta.remote", arg[2], arg[3], "push"), value["id"])
|
|
||||||
m.Cmd(ice.WEB_SPIDE, arg[2], "msg", "/favor/push", "favor", arg[3],
|
m.Cmd(ice.WEB_SPIDE, arg[2], "msg", "/favor/push", "favor", arg[3],
|
||||||
"type", value["type"], "name", value["name"], "text", value["text"],
|
"type", value["type"], "name", value["name"], "text", value["text"],
|
||||||
"time", value["time"], "extra", kit.Format(value["extra"]),
|
"extra", kit.Format(value["extra"]),
|
||||||
)
|
)
|
||||||
|
pull++
|
||||||
})
|
})
|
||||||
}
|
kit.Value(val, kit.Keys(remote, "pull"), pull)
|
||||||
|
kit.Value(val, kit.Keys(remote, "push"), kit.Value(val, "meta.count"))
|
||||||
|
m.Echo("%d", kit.Value(val, "meta.count"))
|
||||||
return
|
return
|
||||||
})
|
})
|
||||||
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
m.Option("favor", arg[0])
|
m.Option("favor", arg[0])
|
||||||
@ -1250,9 +1241,9 @@ var Index = &ice.Context{Name: "web", Help: "网络模块",
|
|||||||
case ice.STORY_PULL: // story [spide [story]]
|
case ice.STORY_PULL: // story [spide [story]]
|
||||||
// 起止节点
|
// 起止节点
|
||||||
prev, begin, end := "", arg[3], ""
|
prev, begin, end := "", arg[3], ""
|
||||||
|
repos := kit.Keys("remote", arg[2], arg[3])
|
||||||
m.Richs(ice.WEB_STORY, "head", arg[1], func(key string, val map[string]interface{}) {
|
m.Richs(ice.WEB_STORY, "head", arg[1], func(key string, val map[string]interface{}) {
|
||||||
begin = kit.Select(kit.Format(kit.Value(val, kit.Keys("remote", kit.Select("dev", arg, 2), "pull", "head"))), arg, 3)
|
end = kit.Format(kit.Value(val, kit.Keys(repos, "pull", "list")))
|
||||||
end = kit.Format(kit.Value(val, kit.Keys("remote", kit.Select("dev", arg, 2), "pull", "list")))
|
|
||||||
prev = kit.Format(val["list"])
|
prev = kit.Format(val["list"])
|
||||||
})
|
})
|
||||||
|
|
||||||
@ -1291,10 +1282,10 @@ var Index = &ice.Context{Name: "web", Help: "网络模块",
|
|||||||
pull, first = kit.Format(value["list"]), node
|
pull, first = kit.Format(value["list"]), node
|
||||||
m.Richs(ice.WEB_STORY, "head", arg[1], func(key string, val map[string]interface{}) {
|
m.Richs(ice.WEB_STORY, "head", arg[1], func(key string, val map[string]interface{}) {
|
||||||
prev = kit.Format(val["list"])
|
prev = kit.Format(val["list"])
|
||||||
if kit.Int(node["count"]) > kit.Int(kit.Value(val, kit.Keys("remote", arg[2], "pull", "count"))) {
|
if kit.Int(node["count"]) > kit.Int(kit.Value(val, kit.Keys(repos, "pull", "count"))) {
|
||||||
// 更新分支
|
// 更新分支
|
||||||
m.Log(ice.LOG_IMPORT, "%v: %v", arg[2], pull)
|
m.Log(ice.LOG_IMPORT, "%v: %v", arg[2], pull)
|
||||||
kit.Value(val, kit.Keys("remote", arg[2], "pull"), kit.Dict(
|
kit.Value(val, kit.Keys(repos, "pull"), kit.Dict(
|
||||||
"head", arg[3], "time", node["time"], "list", pull, "count", node["count"],
|
"head", arg[3], "time", node["time"], "list", pull, "count", node["count"],
|
||||||
))
|
))
|
||||||
}
|
}
|
||||||
@ -1322,11 +1313,12 @@ var Index = &ice.Context{Name: "web", Help: "网络模块",
|
|||||||
// 更新分支
|
// 更新分支
|
||||||
m.Cmdx(ice.WEB_STORY, "pull", arg[1:])
|
m.Cmdx(ice.WEB_STORY, "pull", arg[1:])
|
||||||
|
|
||||||
|
repos := kit.Keys("remote", arg[2], arg[3])
|
||||||
// 查询索引
|
// 查询索引
|
||||||
prev, pull, some, list := "", "", "", ""
|
prev, pull, some, list := "", "", "", ""
|
||||||
m.Richs(ice.WEB_STORY, "head", arg[1], func(key string, val map[string]interface{}) {
|
m.Richs(ice.WEB_STORY, "head", arg[1], func(key string, val map[string]interface{}) {
|
||||||
prev = kit.Format(val["list"])
|
prev = kit.Format(val["list"])
|
||||||
pull = kit.Format(kit.Value(val, kit.Keys("remote", arg[2], "pull", "list")))
|
pull = kit.Format(kit.Value(val, kit.Keys(repos, "pull", "list")))
|
||||||
for some = pull; prev != some && some != ""; {
|
for some = pull; prev != some && some != ""; {
|
||||||
local := m.Richs(ice.WEB_STORY, nil, prev, nil)
|
local := m.Richs(ice.WEB_STORY, nil, prev, nil)
|
||||||
remote := m.Richs(ice.WEB_STORY, nil, some, nil)
|
remote := m.Richs(ice.WEB_STORY, nil, some, nil)
|
||||||
@ -1342,7 +1334,7 @@ var Index = &ice.Context{Name: "web", Help: "网络模块",
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if pull != "" || some != pull {
|
if some != pull {
|
||||||
// 合并节点
|
// 合并节点
|
||||||
local := m.Richs(ice.WEB_STORY, nil, prev, nil)
|
local := m.Richs(ice.WEB_STORY, nil, prev, nil)
|
||||||
remote := m.Richs(ice.WEB_STORY, nil, pull, nil)
|
remote := m.Richs(ice.WEB_STORY, nil, pull, nil)
|
||||||
@ -1352,11 +1344,13 @@ var Index = &ice.Context{Name: "web", Help: "网络模块",
|
|||||||
))
|
))
|
||||||
m.Log(ice.LOG_CREATE, "merge: %s %s->%s", list, prev, pull)
|
m.Log(ice.LOG_CREATE, "merge: %s %s->%s", list, prev, pull)
|
||||||
val["list"] = list
|
val["list"] = list
|
||||||
|
prev = list
|
||||||
|
val["count"] = kit.Int(remote["count"]) + 1
|
||||||
}
|
}
|
||||||
|
|
||||||
// 查询节点
|
// 查询节点
|
||||||
nodes := []string{}
|
nodes := []string{}
|
||||||
for list != "" && list != some {
|
for list = prev; list != some; {
|
||||||
m.Richs(ice.WEB_STORY, nil, list, func(key string, value map[string]interface{}) {
|
m.Richs(ice.WEB_STORY, nil, list, func(key string, value map[string]interface{}) {
|
||||||
nodes, list = append(nodes, list), kit.Format(value["prev"])
|
nodes, list = append(nodes, list), kit.Format(value["prev"])
|
||||||
})
|
})
|
||||||
|
@ -31,6 +31,13 @@ var Index = &ice.Context{Name: "zsh", Help: "命令行",
|
|||||||
// 查找空间
|
// 查找空间
|
||||||
m.Option("you", value["you"])
|
m.Option("you", value["you"])
|
||||||
})
|
})
|
||||||
|
if m.Option("you") == "" {
|
||||||
|
m.Cmd("web.code.tmux.session").Table(func(index int, value map[string]string, head []string) {
|
||||||
|
if value["tag"] == "1" {
|
||||||
|
m.Option("you", value["session"])
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
m.Info("%s %s cmd: %v sub: %v", m.Option("you"), m.Option(ice.MSG_USERURL), m.Optionv("cmds"), m.Optionv("sub"))
|
m.Info("%s %s cmd: %v sub: %v", m.Option("you"), m.Option(ice.MSG_USERURL), m.Optionv("cmds"), m.Optionv("sub"))
|
||||||
m.Option(ice.MSG_OUTPUT, ice.RENDER_RESULT)
|
m.Option(ice.MSG_OUTPUT, ice.RENDER_RESULT)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user