mirror of
https://shylinux.com/x/icebergs
synced 2025-04-26 01:24:05 +08:00
add pod
This commit is contained in:
parent
305b5845ac
commit
7481bb0fb9
@ -34,8 +34,7 @@ func _route_travel(m *ice.Message, route string) {
|
||||
func _route_list(m *ice.Message) {
|
||||
// 链接操作
|
||||
m.Table(func(index int, value map[string]string, field []string) {
|
||||
m.PushAnchor(value[kit.SSH_ROUTE], kit.MergeURL(m.Option(ice.MSG_USERWEB),
|
||||
cli.POD, kit.Keys(m.Option(ice.MSG_USERPOD), value[kit.SSH_ROUTE])))
|
||||
m.PushAnchor(value[kit.SSH_ROUTE], _space_link(m, kit.Keys(m.Option(ice.MSG_USERPOD), value[kit.SSH_ROUTE])))
|
||||
|
||||
switch value[kit.MDB_TYPE] {
|
||||
case WORKER:
|
||||
|
@ -70,6 +70,19 @@ func _serve_main(m *ice.Message, w http.ResponseWriter, r *http.Request) bool {
|
||||
}
|
||||
return true
|
||||
}
|
||||
func _serve_params(msg *ice.Message, path string) {
|
||||
switch ls := strings.Split(path, "/"); kit.Select("", ls, 1) {
|
||||
case "share":
|
||||
msg.Logs("refer", ls[1], ls[2])
|
||||
msg.Option(ls[1], ls[2])
|
||||
case "chat":
|
||||
switch kit.Select("", ls, 2) {
|
||||
case "pod":
|
||||
msg.Logs("refer", ls[2], ls[3])
|
||||
msg.Option(ls[2], ls[3])
|
||||
}
|
||||
}
|
||||
}
|
||||
func _serve_handle(key string, cmd *ice.Command, msg *ice.Message, w http.ResponseWriter, r *http.Request) {
|
||||
// 环境变量
|
||||
msg.Option(mdb.CACHE_LIMIT, "10")
|
||||
@ -79,24 +92,14 @@ func _serve_handle(key string, cmd *ice.Command, msg *ice.Message, w http.Respon
|
||||
msg.Option(v.Name, v.Value)
|
||||
}
|
||||
|
||||
if ls := strings.Split(r.URL.Path, "/"); len(ls) > 2 && ls[1] == "share" {
|
||||
msg.Logs("refer", ls[1], ls[2])
|
||||
msg.Option(ls[1], ls[2])
|
||||
} else {
|
||||
msg.Debug("%v", ls)
|
||||
}
|
||||
// 请求变量
|
||||
_serve_params(msg, r.URL.Path)
|
||||
if u, e := url.Parse(r.Header.Get("Referer")); e == nil {
|
||||
_serve_params(msg, u.Path)
|
||||
for k, v := range u.Query() {
|
||||
msg.Logs("refer", k, v)
|
||||
msg.Option(k, v)
|
||||
}
|
||||
if ls := strings.Split(u.Path, "/"); len(ls) > 2 && ls[1] == "share" {
|
||||
msg.Logs("refer", ls[1], ls[2])
|
||||
msg.Option(ls[1], ls[2])
|
||||
} else {
|
||||
msg.Debug("%v", ls)
|
||||
}
|
||||
}
|
||||
|
||||
// 请求地址
|
||||
|
@ -16,6 +16,9 @@ import (
|
||||
kit "github.com/shylinux/toolkits"
|
||||
)
|
||||
|
||||
func _space_link(m *ice.Message, pod string, arg ...interface{}) string {
|
||||
return kit.MergeURL2(m.Option(ice.MSG_USERWEB), "/chat/pod/"+pod, arg...)
|
||||
}
|
||||
func _space_list(m *ice.Message, space string) {
|
||||
if space == "" {
|
||||
m.Fields(0, "time,type,name,text")
|
||||
@ -195,7 +198,7 @@ func _space_search(m *ice.Message, kind, name, text string, arg ...string) {
|
||||
|
||||
default:
|
||||
m.PushSearch(cli.CMD, SPACE, kit.MDB_TYPE, value[kit.MDB_TYPE], kit.MDB_NAME, value[kit.MDB_NAME],
|
||||
kit.MDB_TEXT, kit.MergeURL(m.Option(ice.MSG_USERWEB), cli.POD, kit.Keys(m.Option(ice.MSG_USERPOD), value[kit.MDB_NAME])), value)
|
||||
kit.MDB_TEXT, _space_link(m, kit.Keys(m.Option(ice.MSG_USERPOD), value[kit.MDB_NAME])), value)
|
||||
}
|
||||
})
|
||||
|
||||
|
48
core/chat/pod.go
Normal file
48
core/chat/pod.go
Normal file
@ -0,0 +1,48 @@
|
||||
package chat
|
||||
|
||||
import (
|
||||
"path"
|
||||
|
||||
ice "github.com/shylinux/icebergs"
|
||||
"github.com/shylinux/icebergs/base/cli"
|
||||
"github.com/shylinux/icebergs/base/ctx"
|
||||
"github.com/shylinux/icebergs/base/web"
|
||||
kit "github.com/shylinux/toolkits"
|
||||
)
|
||||
|
||||
const POD = "pod"
|
||||
|
||||
func init() {
|
||||
Index.Merge(&ice.Context{
|
||||
Commands: map[string]*ice.Command{
|
||||
"/pod/": {Name: "/pod/", Help: "节点", Action: map[string]*ice.Action{
|
||||
ctx.COMMAND: {Name: "command", Help: "命令", Hand: func(m *ice.Message, arg ...string) {
|
||||
if len(arg) == 0 {
|
||||
m.Push("index", CMD)
|
||||
m.Push("args", "")
|
||||
return
|
||||
}
|
||||
m.Cmdy(ctx.COMMAND, arg[0])
|
||||
}},
|
||||
cli.RUN: {Name: "command", Help: "执行", Hand: func(m *ice.Message, arg ...string) {
|
||||
m.Cmdy(arg)
|
||||
}},
|
||||
}, Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
|
||||
m.RenderDownload(path.Join(m.Conf(web.SERVE, kit.Keym(ice.VOLCANOS, kit.MDB_PATH)), m.Conf(web.SERVE, kit.Keym(ice.VOLCANOS, kit.MDB_INDEX))))
|
||||
}},
|
||||
},
|
||||
Configs: map[string]*ice.Config{
|
||||
POD: {Name: POD, Help: "节点", Value: kit.Data(
|
||||
kit.MDB_PATH, "./", kit.MDB_INDEX, "page/cmd.html", kit.MDB_TEMPLATE, `<!DOCTYPE html>
|
||||
<head>
|
||||
<link rel="stylesheet" type="text/css" href="/page/cmd.css">
|
||||
</head>
|
||||
<body>
|
||||
<script src="/page/cmd.js"></script>
|
||||
<script>cmd(%s)</script>
|
||||
</body>
|
||||
`,
|
||||
)},
|
||||
},
|
||||
})
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user