mirror of
https://shylinux.com/x/icebergs
synced 2025-04-25 17:18:05 +08:00
Compare commits
No commits in common. "master" and "v1.9.67" have entirely different histories.
@ -149,15 +149,16 @@ const (
|
||||
)
|
||||
const (
|
||||
CTX_SHY = "ctx_shy"
|
||||
CTX_DEV = "ctx_dev"
|
||||
CTX_WEB = "ctx_web"
|
||||
CTX_GIT = "ctx_git"
|
||||
CTX_DEV_IP = "ctx_dev_ip"
|
||||
CTX_DEV = "ctx_dev"
|
||||
CTX_OPS = "ctx_ops"
|
||||
CTX_REPOS = "ctx_repos"
|
||||
CTX_NAME = "ctx_name"
|
||||
CTX_DEMO = "ctx_demo"
|
||||
CTX_MAIL = "ctx_mail"
|
||||
CTX_ROOT = "ctx_root"
|
||||
CTX_DOMAIN = "ctx_domain"
|
||||
|
||||
CTX_PID = "ctx_pid"
|
||||
CTX_LOG = "ctx_log"
|
||||
|
@ -51,9 +51,6 @@ func DisplayStoryForm(m *ice.Message, arg ...ice.Any) *ice.Message {
|
||||
func DisplayInputKey(m *ice.Message, arg ...ice.Any) *ice.Message {
|
||||
return DisplayInput(m, "key", arg...)
|
||||
}
|
||||
func DisplayStoryWeight(m *ice.Message, arg ...ice.Any) *ice.Message {
|
||||
return DisplayStory(m, "weight", arg...)
|
||||
}
|
||||
func DisplayStoryPie(m *ice.Message, arg ...ice.Any) *ice.Message {
|
||||
return DisplayStory(m, "pie", arg...)
|
||||
}
|
||||
|
@ -1,6 +1,7 @@
|
||||
package web
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
"os"
|
||||
"path"
|
||||
"regexp"
|
||||
@ -21,7 +22,7 @@ import (
|
||||
kit "shylinux.com/x/toolkits"
|
||||
)
|
||||
|
||||
func _dream_list(m *ice.Message) *ice.Message {
|
||||
func _dream_list(m *ice.Message, simple bool) *ice.Message {
|
||||
list := m.CmdMap(SPACE, mdb.NAME)
|
||||
mdb.HashSelects(m.Spawn()).Table(func(value ice.Maps, index int, head []string) {
|
||||
if value[aaa.ACCESS] == aaa.PRIVATE && (m.Option(ice.FROM_SPACE) != "" || !aaa.IsTechOrRoot(m)) {
|
||||
@ -31,35 +32,46 @@ func _dream_list(m *ice.Message) *ice.Message {
|
||||
value[ice.MAIN] = space[ice.MAIN]
|
||||
value[mdb.ICONS] = space[mdb.ICONS]
|
||||
m.Push("", value, kit.Slice(head, 0, -1))
|
||||
m.Push(mdb.TYPE, space[mdb.TYPE]).Push(cli.STATUS, cli.START)
|
||||
m.Push(nfs.MODULE, space[nfs.MODULE]).Push(nfs.VERSION, space[nfs.VERSION])
|
||||
button := []ice.Any{PORTAL, DESKTOP, ADMIN, WORD}
|
||||
text := space[nfs.MODULE]
|
||||
kit.If(m.Option(ice.DREAM_SIMPLE) != ice.TRUE && aaa.IsTechOrRoot(m), func() {
|
||||
kit.If(m.IsDebug(), func() {
|
||||
button = append(button, VIMER, STATUS, COMPILE, cli.RUNTIME, XTERM)
|
||||
text += "\n" + DreamStat(m, value[mdb.NAME])
|
||||
})
|
||||
button = append(button, "settings", cli.STOP)
|
||||
})
|
||||
m.Push(mdb.TEXT, text)
|
||||
m.PushButton(append(button, OPEN)...)
|
||||
if m.IsCliUA() || simple {
|
||||
m.Push(mdb.TYPE, space[mdb.TYPE]).Push(cli.STATUS, cli.START)
|
||||
m.Push(nfs.MODULE, space[nfs.MODULE]).Push(nfs.VERSION, space[nfs.VERSION])
|
||||
// m.Push(mdb.TEXT, DreamStat(m, value[mdb.NAME]))
|
||||
m.Push(mdb.TEXT, "")
|
||||
button := []ice.Any{PORTAL, DESKTOP, ADMIN, WORD, OPEN}
|
||||
kit.If(aaa.IsTechOrRoot(m), func() { button = append(button, cli.STOP) })
|
||||
m.PushButton(button...)
|
||||
} else {
|
||||
msg := gdb.Event(m.Spawn(value, space), DREAM_TABLES)
|
||||
kit.If(aaa.IsTechOrRoot(m), func() { msg.Copy(m.Spawn().PushButton(cli.STOP)) })
|
||||
m.Push(mdb.TYPE, space[mdb.TYPE]).Push(cli.STATUS, cli.START)
|
||||
m.Push(nfs.MODULE, space[nfs.MODULE]).Push(nfs.VERSION, space[nfs.VERSION])
|
||||
m.Push(mdb.TEXT, space[nfs.MODULE]+"\n"+msg.Append(mdb.TEXT))
|
||||
m.PushButton(strings.Join(msg.Appendv(ctx.ACTION), ""))
|
||||
}
|
||||
} else if aaa.IsTechOrRoot(m) {
|
||||
m.Push("", value, kit.Slice(head, 0, -1))
|
||||
m.Push(nfs.MODULE, "").Push(nfs.VERSION, "").Push(mdb.TEXT, "")
|
||||
if m.Push(mdb.TYPE, WORKER); nfs.Exists(m, path.Join(ice.USR_LOCAL_WORK, value[mdb.NAME])) {
|
||||
m.Push(cli.STATUS, cli.STOP).PushButton(cli.START, nfs.TRASH)
|
||||
m.Push(cli.STATUS, cli.STOP).Push(nfs.MODULE, "").Push(nfs.VERSION, "").Push(mdb.TEXT, "")
|
||||
kit.If(aaa.IsTechOrRoot(m), func() { m.PushButton(cli.START, nfs.TRASH) }, func() { m.PushButton() })
|
||||
} else {
|
||||
m.Push(cli.STATUS, cli.BEGIN).PushButton(cli.START, mdb.REMOVE)
|
||||
m.Push(cli.STATUS, cli.BEGIN).Push(nfs.MODULE, "").Push(nfs.VERSION, "").Push(mdb.TEXT, "")
|
||||
kit.If(aaa.IsTechOrRoot(m), func() { m.PushButton(cli.START, mdb.REMOVE) }, func() { m.PushButton() })
|
||||
}
|
||||
}
|
||||
})
|
||||
m.RewriteAppend(func(value, key string, index int) string {
|
||||
if key == mdb.TIME {
|
||||
if space, ok := list[m.Appendv(mdb.NAME)[index]]; ok {
|
||||
return space[mdb.TIME]
|
||||
value = space[mdb.TIME]
|
||||
}
|
||||
} else if key == mdb.ICONS {
|
||||
}
|
||||
return value
|
||||
})
|
||||
return m
|
||||
}
|
||||
func _dream_list_icon(m *ice.Message) {
|
||||
m.RewriteAppend(func(value, key string, index int) string {
|
||||
if key == mdb.ICONS {
|
||||
if kit.HasPrefix(value, HTTP, nfs.PS) {
|
||||
return value
|
||||
} else if nfs.ExistsFile(m, path.Join(ice.USR_LOCAL_WORK, m.Appendv(mdb.NAME)[index], value)) {
|
||||
@ -70,42 +82,34 @@ func _dream_list(m *ice.Message) *ice.Message {
|
||||
}
|
||||
return value
|
||||
})
|
||||
return m
|
||||
}
|
||||
func _dream_list_more(m *ice.Message) *ice.Message {
|
||||
func _dream_list_more(m *ice.Message, simple bool) *ice.Message {
|
||||
field := kit.Split(mdb.Config(m, mdb.FIELD) + ",type,status,module,version,text")
|
||||
m.Cmds(SPACE).Table(func(value ice.Maps) {
|
||||
value[nfs.REPOS] = "https://" + value[nfs.MODULE]
|
||||
value[aaa.ACCESS] = kit.Select("", value[aaa.USERROLE], value[aaa.USERROLE] != aaa.VOID)
|
||||
value[mdb.STATUS] = cli.START
|
||||
button := []ice.Any{PORTAL, DESKTOP, ADMIN, WORD}
|
||||
kit.If(m.IsDebug(), func() { button = append(button, VIMER, STATUS, COMPILE, cli.RUNTIME, XTERM) })
|
||||
button := []ice.Any{PORTAL, DESKTOP, ADMIN, WORD, VIMER, STATUS, COMPILE, cli.RUNTIME, XTERM, OPEN}
|
||||
switch value[mdb.TYPE] {
|
||||
case ORIGIN:
|
||||
if m.IsCliUA() {
|
||||
return
|
||||
}
|
||||
value[mdb.TEXT] = kit.JoinLine(value[nfs.MODULE], value[mdb.TEXT])
|
||||
button = append(button, GETTOKEN, OPEN)
|
||||
kit.If(value[aaa.ACCESS] == "", func() { button = []ice.Any{PORTAL, OPEN} })
|
||||
button = append(button, "gettoken")
|
||||
if value[aaa.ACCESS] == "" {
|
||||
defer m.PushButton(PORTAL, OPEN)
|
||||
} else {
|
||||
defer m.PushButton(button...)
|
||||
}
|
||||
case SERVER:
|
||||
if !m.IsCliUA() {
|
||||
value[mdb.TEXT] = kit.JoinLine(value[nfs.MODULE], value[mdb.TEXT])
|
||||
} else if !strings.HasPrefix(value[mdb.TEXT], ice.HTTP) {
|
||||
return
|
||||
}
|
||||
button = append(button, SETTOKEN, OPEN)
|
||||
button = append(button, "settoken")
|
||||
value[mdb.TEXT] = kit.JoinLine(value[nfs.MODULE], value[mdb.TEXT])
|
||||
defer m.PushButton(button...)
|
||||
case aaa.LOGIN:
|
||||
if m.IsCliUA() {
|
||||
return
|
||||
}
|
||||
value[mdb.TEXT] = kit.JoinWord(value[AGENT], value[cli.SYSTEM], value[aaa.IP], kit.Format(PublicIP(m, value[aaa.IP])))
|
||||
button = []ice.Any{GRANT}
|
||||
defer m.PushButton(GRANT)
|
||||
default:
|
||||
return
|
||||
}
|
||||
m.Push("", value, field)
|
||||
m.PushButton(button...)
|
||||
})
|
||||
return m
|
||||
}
|
||||
@ -174,8 +178,7 @@ func _dream_binary(m *ice.Message, p string) {
|
||||
if bin := path.Join(m.Option(cli.CMD_DIR), ice.BIN_ICE_BIN); nfs.Exists(m, bin) {
|
||||
return
|
||||
} else if kit.IsUrl(p) || strings.HasPrefix(p, S()) {
|
||||
// m.Cmd(DREAM, DOWNLOAD, bin, kit.MergeURL2(p, kit.Format("/publish/ice.%s.%s", runtime.GOOS, runtime.GOARCH), ice.POD, m.Option(mdb.NAME)))
|
||||
m.Cmd(DREAM, DOWNLOAD, bin, kit.MergeURL(p, cli.GOOS, runtime.GOOS, cli.GOARCH, runtime.GOARCH))
|
||||
m.Cmd(DREAM, DOWNLOAD, bin, kit.MergeURL2(p, kit.Format("/publish/ice.%s.%s", runtime.GOOS, runtime.GOARCH), ice.POD, m.Option(mdb.NAME)))
|
||||
} else {
|
||||
m.Cmd(nfs.LINK, bin, kit.Path(p))
|
||||
}
|
||||
@ -204,8 +207,6 @@ const (
|
||||
STOPALL = "stopall"
|
||||
FOR_EACH = "forEach"
|
||||
FOR_FLOW = "forFlow"
|
||||
GETTOKEN = "gettoken"
|
||||
SETTOKEN = "settoken"
|
||||
|
||||
DREAM_INPUTS = "dream.inputs"
|
||||
DREAM_CREATE = "dream.create"
|
||||
@ -215,6 +216,7 @@ const (
|
||||
DREAM_STOP = "dream.stop"
|
||||
DREAM_OPEN = "dream.open"
|
||||
DREAM_CLOSE = "dream.close"
|
||||
|
||||
DREAM_TABLES = "dream.tables"
|
||||
DREAM_ACTION = "dream.action"
|
||||
|
||||
@ -235,28 +237,66 @@ func init() {
|
||||
每个空间都自带软件开发工具,也可以随时编程添加新的功能。
|
||||
`, 200.0)
|
||||
}},
|
||||
html.BUTTON: {Hand: func(m *ice.Message, arg ...string) {
|
||||
mdb.Config(m, html.BUTTON, kit.Join(arg))
|
||||
}},
|
||||
mdb.SEARCH: {Hand: func(m *ice.Message, arg ...string) {
|
||||
if mdb.IsSearchPreview(m, arg) {
|
||||
mdb.HashSelects(m.Spawn()).Table(func(value ice.Maps) { m.PushSearch(mdb.TYPE, WORKER, mdb.TEXT, m.MergePod(value[mdb.NAME]), value) })
|
||||
}
|
||||
}},
|
||||
mdb.INPUTS: {Hand: func(m *ice.Message, arg ...string) {
|
||||
switch arg[0] {
|
||||
case mdb.NAME:
|
||||
DreamEach(m, "", kit.Select(cli.START, cli.STOP, m.Option(ctx.ACTION) == STARTALL), func(name string) { m.Push(arg[0], name) })
|
||||
case tcp.NODENAME:
|
||||
m.Cmdy(SPACE, m.Option(mdb.NAME), SPACE, ice.INFO).CutTo(mdb.NAME, arg[0])
|
||||
case aaa.USERNAME:
|
||||
if aaa.IsTechOrRoot(m) && m.Option(ctx.ACTION) == GRANT {
|
||||
m.Cmdy(aaa.USER).Cut(aaa.USERNAME, aaa.USERNICK).Option(ice.TABLE_CHECKBOX, ice.FALSE)
|
||||
} else {
|
||||
m.Push(arg[0], m.Option(tcp.NODENAME))
|
||||
m.Push(arg[0], m.Option(ice.MSG_USERNAME))
|
||||
switch m.Option(ctx.ACTION) {
|
||||
case mdb.CREATE:
|
||||
switch arg[0] {
|
||||
case mdb.NAME:
|
||||
_dream_list(m, true).Cut("name,status,time")
|
||||
case mdb.ICONS:
|
||||
mdb.HashInputs(m, arg)
|
||||
case nfs.REPOS:
|
||||
defer ctx.DisplayInputKey(m, ctx.STYLE, "_nameicon")
|
||||
m.Cmd(STORE).Table(func(value ice.Maps) {
|
||||
m.Spawn().SplitIndex(m.Cmdx(SPIDE, value[mdb.NAME], SPIDE_RAW, http.MethodGet, C(DREAM))).Table(func(value ice.Maps) {
|
||||
m.PushRecord(value, mdb.ICONS, nfs.REPOS, nfs.VERSION, mdb.NAME)
|
||||
})
|
||||
})
|
||||
case nfs.BINARY:
|
||||
defer ctx.DisplayInputKey(m, ctx.STYLE, "_nameicon")
|
||||
m.Cmd(STORE).Table(func(val ice.Maps) {
|
||||
m.Spawn().SplitIndex(m.Cmdx(SPIDE, val[mdb.NAME], SPIDE_RAW, http.MethodGet, S(), cli.GOOS, runtime.GOOS, cli.GOARCH, runtime.GOARCH)).Table(func(value ice.Maps) {
|
||||
m.Push(mdb.ICONS, value[mdb.ICONS])
|
||||
m.Push(arg[0], val[ORIGIN]+S(value[mdb.NAME])).Push(nfs.SIZE, value[nfs.SIZE]).Push(mdb.TIME, value[mdb.TIME])
|
||||
})
|
||||
})
|
||||
}
|
||||
case nfs.REPOS:
|
||||
case nfs.BINARY:
|
||||
case STARTALL:
|
||||
DreamEach(m, "", cli.STOP, func(name string) { m.Push(arg[0], name) })
|
||||
case tcp.SEND:
|
||||
m.Cmd(SPACE, func(value ice.Maps) {
|
||||
kit.If(kit.IsIn(value[mdb.TYPE], SERVER), func() { m.Push(arg[0], value[mdb.NAME]) })
|
||||
})
|
||||
default:
|
||||
gdb.Event(m, DREAM_INPUTS, arg)
|
||||
switch arg[0] {
|
||||
case mdb.NAME:
|
||||
DreamEach(m, "", cli.START, func(name string) { m.Push(arg[0], name) })
|
||||
case ctx.CMDS:
|
||||
m.Cmdy(ctx.COMMAND)
|
||||
case nfs.FILE:
|
||||
m.Options(nfs.DIR_TYPE, nfs.TYPE_CAT, ice.MSG_FIELDS, nfs.PATH)
|
||||
m.Cmdy(nfs.DIR, nfs.SRC).Cmdy(nfs.DIR, nfs.ETC).Cmdy(nfs.DIR, "")
|
||||
case tcp.NODENAME:
|
||||
m.Cmdy(SPACE, m.Option(mdb.NAME), SPACE, ice.INFO).CutTo(mdb.NAME, tcp.NODENAME)
|
||||
case aaa.USERNAME:
|
||||
if aaa.IsTechOrRoot(m) && m.Option(ctx.ACTION) == GRANT {
|
||||
m.Cmdy(aaa.USER).Cut(aaa.USERNAME, aaa.USERNICK)
|
||||
m.Option(ice.TABLE_CHECKBOX, ice.FALSE)
|
||||
} else {
|
||||
m.Push(arg[0], m.Option(ice.MSG_USERNAME))
|
||||
m.Push(arg[0], m.Option(tcp.NODENAME))
|
||||
}
|
||||
default:
|
||||
gdb.Event(m, DREAM_INPUTS, arg)
|
||||
}
|
||||
}
|
||||
}},
|
||||
nfs.SCAN: {Hand: func(m *ice.Message, arg ...string) {
|
||||
@ -269,9 +309,12 @@ func init() {
|
||||
}},
|
||||
mdb.CREATE: {Name: "create name*=hi repos binary", Hand: func(m *ice.Message, arg ...string) {
|
||||
kit.If(!strings.Contains(m.Option(mdb.NAME), "-") || !strings.HasPrefix(m.Option(mdb.NAME), "20"), func() { m.Option(mdb.NAME, m.Time("20060102-")+m.Option(mdb.NAME)) })
|
||||
kit.If(mdb.Config(m, nfs.BINARY), func(p string) { m.OptionDefault(nfs.BINARY, p+m.Option(mdb.NAME)) })
|
||||
kit.If(mdb.Config(m, nfs.REPOS), func(p string) { m.OptionDefault(nfs.REPOS, p+m.Option(mdb.NAME)) })
|
||||
m.Option(nfs.REPOS, kit.Select("", kit.Split(m.Option(nfs.REPOS)), -1))
|
||||
if mdb.HashCreate(m); ice.Info.Important == true {
|
||||
_dream_start(m, m.Option(mdb.NAME))
|
||||
StreamPushRefreshConfirm(m, m.Trans("refresh for new space ", "刷新列表查看新空间 ")+m.Option(mdb.NAME))
|
||||
SpaceEvent(m, OPS_DREAM_CREATE, m.Option(mdb.NAME), m.OptionSimple(mdb.NAME, nfs.REPOS, nfs.BINARY)...)
|
||||
}
|
||||
}},
|
||||
@ -299,17 +342,15 @@ func init() {
|
||||
m.Cmd(SPACE, path.Base(p), cli.RUNTIME, UPGRADE)
|
||||
return true
|
||||
}
|
||||
}).Sleep3s()
|
||||
m.ProcessHold()
|
||||
})
|
||||
m.Sleep("3s")
|
||||
// kit.If(m.Option(mdb.NAME) == "", func() { m.Sleep("5s").Cmdy(ROUTE, cli.BUILD).ProcessInner() })
|
||||
}},
|
||||
PUBLISH: {Name: "publish name", Hand: func(m *ice.Message, arg ...string) {
|
||||
m.Option(ice.MSG_TITLE, kit.Keys(m.Option(ice.MSG_USERPOD0), m.Option(ice.MSG_USERPOD), m.CommandKey(), m.ActionKey()))
|
||||
list := []string{cli.LINUX, cli.DARWIN, cli.WINDOWS}
|
||||
msg := m.Spawn(ice.Maps{ice.MSG_DAEMON: ""})
|
||||
func() {
|
||||
if m.Option(mdb.NAME) != "" {
|
||||
return
|
||||
}
|
||||
defer ToastProcess(m, PUBLISH, ice.Info.Pathname)()
|
||||
m.Cmd(AUTOGEN, BINPACK)
|
||||
kit.For(list, func(goos string) {
|
||||
@ -326,7 +367,8 @@ func init() {
|
||||
list := []string{cli.AMD64}
|
||||
kit.If(goos == cli.DARWIN, func() { list = append(list, cli.ARM64) })
|
||||
kit.For(list, func(arch string) {
|
||||
PushNoticeRich(m.Options(ice.MSG_COUNT, "0", ice.LOG_DISABLE, ice.TRUE), mdb.NAME, name, msg.Cmd(SPACE, name, COMPILE, goos, arch, kit.Dict(ice.MSG_USERPOD, name)).AppendSimple())
|
||||
PushNoticeRich(m.Options(ice.MSG_COUNT, "0", ice.LOG_DISABLE, ice.TRUE), mdb.NAME, name,
|
||||
msg.Cmd(SPACE, name, COMPILE, goos, arch, kit.Dict(ice.MSG_USERPOD, name)).AppendSimple())
|
||||
})
|
||||
})
|
||||
})
|
||||
@ -343,46 +385,66 @@ func init() {
|
||||
if cb, ok := m.OptionCB("").(func(string) bool); ok && cb(p) {
|
||||
return
|
||||
}
|
||||
defer PushNoticeGrow(msg, "\r\n\r\n")
|
||||
PushNoticeGrow(msg, kit.Format("\033[33m[%s]%s$\033[0m %s\r\n", time.Now().Format(ice.MOD_TIME_ONLY), name, m.Option(ice.CMD)))
|
||||
defer PushNoticeGrow(msg, "\r\n\r\n\r\n")
|
||||
PushNoticeGrow(msg, kit.Format("[%s]%s$ %s\r\n", time.Now().Format(ice.MOD_TIME_ONLY), name, m.Option(ice.CMD)))
|
||||
m.Cmd(cli.SYSTEM, kit.Split(m.Option(ice.CMD)), kit.Dict(cli.CMD_DIR, p)).Sleep300ms()
|
||||
})
|
||||
}},
|
||||
ctx.CMDS: {Name: "cmds name cmds*", Help: "命令", Icon: "bi bi-terminal", Hand: func(m *ice.Message, arg ...string) {
|
||||
DreamEach(m, m.Option(mdb.NAME), "", func(name string) {
|
||||
m.Push(mdb.NAME, name).Push(mdb.TEXT, m.Cmdx(SPACE, name, kit.Split(m.Option(ctx.CMDS))))
|
||||
}).StatusTimeCount(m.OptionSimple(ctx.CMDS)).ProcessInner()
|
||||
}},
|
||||
nfs.FILE: {Name: "file name file*", Help: "文件", Icon: "bi bi-file-earmark-code", Hand: func(m *ice.Message, arg ...string) {
|
||||
DreamEach(m, m.Option(mdb.NAME), "", func(name string) {
|
||||
m.Push(mdb.NAME, name).Push(mdb.TEXT, m.Cmdx(SPACE, name, nfs.CAT, m.Option(nfs.FILE)))
|
||||
}).StatusTimeCount(m.OptionSimple(nfs.FILE)).ProcessInner()
|
||||
}},
|
||||
|
||||
cli.START: {Hand: func(m *ice.Message, arg ...string) {
|
||||
_dream_start(m, m.Option(mdb.NAME))
|
||||
gdb.Event(m, DREAM_START, arg)
|
||||
}},
|
||||
cli.STOP: {Hand: func(m *ice.Message, arg ...string) {
|
||||
defer ToastProcess(m)()
|
||||
gdb.Event(m, DREAM_STOP, arg)
|
||||
m.Cmd(SPACE, mdb.MODIFY, m.OptionSimple(mdb.NAME), mdb.STATUS, cli.STOP)
|
||||
m.Cmd(SPACE, m.Option(mdb.NAME), ice.EXIT).Sleep3s()
|
||||
}},
|
||||
cli.RUNTIME: {Hand: func(m *ice.Message, arg ...string) {
|
||||
ProcessPodCmd(m, m.Option(mdb.NAME), "", nil, arg...)
|
||||
}},
|
||||
nfs.TRASH: {Hand: func(m *ice.Message, arg ...string) {
|
||||
gdb.Event(m, DREAM_TRASH, arg)
|
||||
nfs.Trash(m, path.Join(ice.USR_LOCAL_WORK, m.Option(mdb.NAME)))
|
||||
}},
|
||||
cli.RUNTIME: {Hand: func(m *ice.Message, arg ...string) {
|
||||
ProcessPodCmd(m, m.Option(mdb.NAME), "", nil, arg...)
|
||||
nfs.COPY: {Name: "copy to*", Help: "复制", Hand: func(m *ice.Message, arg ...string) {
|
||||
m.Cmdy("", mdb.CREATE, mdb.NAME, m.Option(nfs.TO), nfs.BINARY, path.Join(ice.USR_LOCAL_WORK, m.Option(mdb.NAME), ice.BIN_ICE_BIN))
|
||||
}},
|
||||
"settings": {Name: "settings restart=manual,always access=public,private", Help: "设置", Style: html.DANGER, Hand: func(m *ice.Message, arg ...string) {
|
||||
tcp.SEND: {Name: "send to*", Hand: func(m *ice.Message, arg ...string) {
|
||||
m.Cmd(SPACE, m.Option(nfs.TO), DREAM, mdb.CREATE, m.OptionSimple(mdb.NAME, mdb.ICONS, nfs.REPOS, nfs.BINARY))
|
||||
m.Cmd(SPACE, m.Option(nfs.TO), DREAM, cli.START, m.OptionSimple(mdb.NAME))
|
||||
ProcessIframe(m, "", m.MergePod(kit.Keys(m.Option(nfs.TO), m.Option(mdb.NAME))))
|
||||
}},
|
||||
"settings": {Name: "settings restart=manual,always access=public,private", Help: "设置", Style: "danger", Hand: func(m *ice.Message, arg ...string) {
|
||||
kit.If(m.Option(cli.RESTART) == "manual", func() { m.Option(cli.RESTART, "") })
|
||||
kit.If(m.Option(aaa.ACCESS) == aaa.PUBLIC, func() { m.Option(aaa.ACCESS, "") })
|
||||
mdb.HashModify(m, m.OptionSimple(mdb.NAME, cli.RESTART, aaa.ACCESS))
|
||||
}},
|
||||
SETTOKEN: {Name: "settoken nodename* username*", Help: "令牌", Style: html.DANGER, Hand: func(m *ice.Message, arg ...string) {
|
||||
"settoken": {Name: "settoken nodename* username*", Help: "令牌", Style: "danger", Hand: func(m *ice.Message, arg ...string) {
|
||||
token := m.Cmdx(TOKEN, mdb.CREATE, mdb.TYPE, SERVER, mdb.NAME, m.Option(aaa.USERNAME), mdb.TEXT, m.Option(tcp.NODENAME))
|
||||
m.Cmd(SPACE, m.Option(mdb.NAME), SPIDE, DEV_CREATE_TOKEN, ice.Maps{TOKEN: token})
|
||||
m.Cmd(SPACE, m.Option(mdb.NAME), SPIDE, DEV_CREATE_TOKEN, ice.Maps{CLIENT_NAME: ice.DEV, TOKEN: token})
|
||||
}},
|
||||
GETTOKEN: {Help: "令牌", Style: html.DANGER, Hand: func(m *ice.Message, arg ...string) {
|
||||
"gettoken": {Help: "令牌", Style: "danger", Hand: func(m *ice.Message, arg ...string) {
|
||||
m.Options(m.Cmd(SPIDE, m.Option(mdb.NAME)).AppendSimple()).Cmdy(SPIDE, mdb.DEV_REQUEST)
|
||||
}},
|
||||
GRANT: {Name: "grant username", Role: aaa.VOID, Hand: func(m *ice.Message, arg ...string) {
|
||||
GRANT: {Name: "grant username", Hand: func(m *ice.Message, arg ...string) {
|
||||
if aaa.IsTechOrRoot(m) && m.Option(aaa.USERNAME) != "" {
|
||||
m.Option(ice.MSG_USERNAME, m.Option(aaa.USERNAME))
|
||||
}
|
||||
m.Cmd(CHAT_GRANT, aaa.CONFIRM, kit.Dict(SPACE, m.Option(mdb.NAME)))
|
||||
}},
|
||||
OPEN: {Style: html.NOTICE, Role: aaa.VOID, Hand: func(m *ice.Message, arg ...string) {
|
||||
OPEN: {Style: "notice", Role: aaa.VOID, Hand: func(m *ice.Message, arg ...string) {
|
||||
if strings.HasSuffix(m.Option(ice.MAIN), ".portal") || kit.HasPrefixList(arg, ctx.RUN) {
|
||||
if !kit.HasPrefixList(arg, ctx.RUN) {
|
||||
defer m.Push(TITLE, m.Option(mdb.NAME))
|
||||
@ -412,15 +474,17 @@ func init() {
|
||||
button := []ice.Any{}
|
||||
if aaa.IsTechOrRoot(m) {
|
||||
switch m.Option(mdb.TYPE) {
|
||||
case ORIGIN:
|
||||
button = append(button, DREAM, GETTOKEN)
|
||||
case SERVER:
|
||||
button = append(button, DREAM, SETTOKEN)
|
||||
case WORKER:
|
||||
button = append(button, "settings")
|
||||
button = append(button, OPEN, "settings")
|
||||
case SERVER:
|
||||
button = append(button, DREAM, OPEN, "settoken")
|
||||
default:
|
||||
button = append(button, DREAM, OPEN, "gettoken")
|
||||
}
|
||||
} else {
|
||||
button = append(button, OPEN)
|
||||
}
|
||||
m.PushButton(append(button, OPEN)...)
|
||||
m.PushButton(button...)
|
||||
}},
|
||||
SERVE_START: {Hand: func(m *ice.Message, arg ...string) {
|
||||
for _, cmd := range kit.Reverse(kit.Split(mdb.Config(m, html.BUTTON))) {
|
||||
@ -435,7 +499,7 @@ func init() {
|
||||
})
|
||||
}},
|
||||
STATS_TABLES: {Hand: func(m *ice.Message, arg ...string) {
|
||||
if msg := _dream_list(m.Spawn()); msg.Length() > 0 {
|
||||
if msg := _dream_list(m.Spawn(), true); msg.Length() > 0 {
|
||||
stat := map[string]int{}
|
||||
msg.Table(func(value ice.Maps) { stat[value[mdb.TYPE]]++; stat[value[mdb.STATUS]]++ })
|
||||
PushStats(m, kit.Keys(m.CommandKey(), cli.START), stat[cli.START], "", "已启动空间")
|
||||
@ -447,8 +511,6 @@ func init() {
|
||||
m.Cmd(SPACE).Table(func(value ice.Maps, index int, head []string) {
|
||||
kit.If(value[mdb.TYPE] == m.ActionKey(), func() { m.PushRecord(value, head...) })
|
||||
})
|
||||
m.SortStrR(mdb.NAME)
|
||||
kit.If(len(arg) > 0, func() { m.Cut(arg...) })
|
||||
}},
|
||||
SERVER: {Hand: func(m *ice.Message, arg ...string) {
|
||||
m.Cmd(SPACE).Table(func(value ice.Maps, index int, head []string) {
|
||||
@ -480,35 +542,53 @@ func init() {
|
||||
m.Cmd(cli.SYSTEM, cli.GO, "work", "init")
|
||||
kit.For([]string{".", nfs.USR_RELEASE, nfs.USR_ICEBERGS, nfs.USR_TOOLKITS}, func(p string) { m.Cmd(cli.SYSTEM, cli.GO, "work", "use", p) })
|
||||
DreamEach(m, m.Option(mdb.NAME), "", func(name string) { m.Cmd(cli.SYSTEM, cli.GO, "work", "use", path.Join(ice.USR_LOCAL_WORK, name)) })
|
||||
m.Cmdy(nfs.CAT, "go.work")
|
||||
}},
|
||||
}, StatsAction(), DreamAction(), DreamTablesAction(), mdb.ImportantHashAction(
|
||||
mdb.SHORT, mdb.NAME, mdb.FIELD, "time,name,main,icons,repos,binary,template,restart,access",
|
||||
html.BUTTON, kit.JoinWord(PORTAL, DESKTOP, ADMIN, WORD, VIMER, STATUS, COMPILE, XTERM, DREAM),
|
||||
ONLINE, ice.TRUE,
|
||||
)), Hand: func(m *ice.Message, arg ...string) {
|
||||
if len(arg) == 0 {
|
||||
if ice.Info.NodeType == WORKER {
|
||||
return
|
||||
simple := m.Option(ice.DREAM_SIMPLE) == ice.TRUE || m.Option(ice.MSG_DEBUG) != ice.TRUE
|
||||
if ice.Info.NodeType != WORKER {
|
||||
_dream_list(m, simple)
|
||||
_dream_list_icon(m)
|
||||
if m.Length() == 0 {
|
||||
m.EchoInfoButton(m.Trans("please scan or create new dream", "请扫描或创建新空间"), mdb.CREATE, nfs.SCAN)
|
||||
return
|
||||
}
|
||||
}
|
||||
_dream_list(m)
|
||||
if _dream_list_more(m); !aaa.IsTechOrRoot(m) || m.IsCliUA() {
|
||||
if !m.IsCliUA() && aaa.IsTechOrRoot(m) {
|
||||
_dream_list_more(m, simple)
|
||||
} else {
|
||||
msg := m.Spawn(kit.Dict(ice.MSG_USERROLE, aaa.TECH))
|
||||
m.Cmds(SPACE).Table(func(value ice.Maps) {
|
||||
if value[mdb.TYPE] == SERVER {
|
||||
if p := ProxyDomain(msg, value[mdb.NAME]); p != "" {
|
||||
value[mdb.TEXT] = p
|
||||
m.PushRecord(value, mdb.TIME, mdb.TYPE, mdb.NAME, mdb.ICONS, nfs.MODULE, nfs.VERSION, mdb.TEXT)
|
||||
m.PushButton(PORTAL, DESKTOP)
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
if ice.Info.NodeType == WORKER || !aaa.IsTechOrRoot(m) || m.IsCliUA() {
|
||||
m.Action()
|
||||
} else if m.IsDebug() && cli.SystemFindGo(m) {
|
||||
m.Action(mdb.CREATE, STARTALL, STOPALL, cli.BUILD, PUBLISH)
|
||||
} else {
|
||||
m.Action(mdb.CREATE, STARTALL, STOPALL)
|
||||
}
|
||||
if m.Length() == 0 {
|
||||
m.EchoInfoButton(m.Trans("please scan or create new dream", "请扫描或创建新空间"), mdb.CREATE, nfs.SCAN)
|
||||
return
|
||||
}
|
||||
ctx.DisplayTableCard(m)
|
||||
m.Options(ice.MSG_TOOLKIT, "web.code.compose.insight")
|
||||
m.Sort("type,status,name", []string{aaa.LOGIN, WORKER, SERVER, ORIGIN}, []string{cli.START, cli.STOP, cli.BEGIN}, ice.STR_R)
|
||||
m.StatusTimeCountStats(mdb.TYPE, mdb.STATUS)
|
||||
ctx.DisplayTableCard(m)
|
||||
// kit.If(!aaa.IsTechOrRoot(m), func() { m.Options(ice.MSG_TOOLKIT, "", ice.MSG_ONLINE, ice.FALSE) })
|
||||
// kit.If(!m.IsDebug(), func() { m.Options(ice.MSG_TOOLKIT, "") })
|
||||
m.Options(ice.MSG_TOOLKIT, "web.code.compose.insight")
|
||||
} else if arg[0] == ctx.ACTION {
|
||||
m.Cmdy(arg[1], DREAM_ACTION, arg)
|
||||
// gdb.Event(m, DREAM_ACTION, arg)
|
||||
gdb.Event(m, DREAM_ACTION, arg)
|
||||
} else {
|
||||
mdb.HashSelects(m, arg[0]).PushAction(PORTAL, DESKTOP, ADMIN, OPEN, mdb.REMOVE)
|
||||
}
|
||||
}},
|
||||
})
|
||||
|
@ -84,7 +84,6 @@ func Render(m *ice.Message, cmd string, args ...ice.Any) bool {
|
||||
"$output", fieldset+">div.output",
|
||||
"$status", fieldset+">div.status",
|
||||
"$fieldset", fieldset,
|
||||
"$body", "body.cmd."+m.Option(ctx.INDEX),
|
||||
"$index", m.Option(ctx.INDEX),
|
||||
"$input", "body>div.input.float."+m.Option(ctx.INDEX),
|
||||
)))
|
||||
@ -172,7 +171,7 @@ func RenderPodCmd(m *ice.Message, pod, cmd string, arg ...ice.Any) {
|
||||
m.Option(mdb.ICONS, msg.Option(ice.MSG_NODEICON))
|
||||
}
|
||||
m.OptionDefault(mdb.ICONS, m.Resource(kit.Select(ice.Info.NodeIcon, msg.Option(ice.MSG_NODEICON), msg.Append(mdb.ICONS))))
|
||||
serve := strings.Split(UserHost(m), "://")[1]
|
||||
serve := kit.Select("localhost:9020", UserWeb(m).Host)
|
||||
pod = kit.Select(pod, msg.Option(ice.MSG_NODENAME), m.Option(ice.MSG_USERPOD) != "")
|
||||
m.OptionDefault(TITLE, kit.Select(cmd, msg.Append(mdb.HELP), !m.IsEnglish())+" "+kit.Select(serve, pod))
|
||||
RenderCmds(m, kit.Dict(msg.AppendSimple(), ctx.ARGS, kit.Simple(arg), ctx.DISPLAY, m.Option(ice.MSG_DISPLAY)))
|
||||
|
@ -35,6 +35,10 @@ func _serve_start(m *ice.Message) {
|
||||
}).Sleep(cli.TIME_1s)
|
||||
cli.NodeInfo(m, kit.Select(kit.Split(ice.Info.Hostname, nfs.PT)[0], m.Option(tcp.NODENAME)), SERVER, mdb.Config(m, mdb.ICONS))
|
||||
kit.If(ice.HasVar(), func() { m.Cmd(nfs.SAVE, ice.VAR_LOG_ICE_PORT, m.Option(tcp.PORT)) })
|
||||
m.Spawn(ice.Maps{TOKEN: ""}).Start("", m.OptionSimple(tcp.HOST, tcp.PORT)...)
|
||||
if m.Cmd(tcp.HOST).Length() == 0 {
|
||||
return
|
||||
}
|
||||
kit.For(kit.Split(m.Option(ice.DEV)), func(dev string) {
|
||||
if strings.HasPrefix(dev, HTTP) {
|
||||
m.Cmd(SPIDE, mdb.CREATE, dev, ice.DEV, "", nfs.REPOS)
|
||||
@ -43,16 +47,12 @@ func _serve_start(m *ice.Message) {
|
||||
}
|
||||
if msg := m.Cmd(SPIDE, dev); msg.Append(TOKEN) == "" {
|
||||
if m.Option(TOKEN) != "" {
|
||||
m.Cmd(SPACE, tcp.DIAL, ice.DEV, dev, TOKEN, m.Option(TOKEN))
|
||||
m.Sleep300ms(SPACE, tcp.DIAL, ice.DEV, dev, TOKEN, m.Option(TOKEN))
|
||||
} else {
|
||||
m.Cmd(SPACE, tcp.DIAL, ice.DEV, dev)
|
||||
m.Sleep300ms(SPACE, tcp.DIAL, ice.DEV, dev)
|
||||
}
|
||||
}
|
||||
})
|
||||
m.Spawn(ice.Maps{TOKEN: ""}).Start("", m.OptionSimple(tcp.HOST, tcp.PORT)...)
|
||||
if m.Cmd(tcp.HOST).Length() == 0 {
|
||||
return
|
||||
}
|
||||
}
|
||||
func _serve_main(m *ice.Message, w http.ResponseWriter, r *http.Request) bool {
|
||||
const (
|
||||
@ -65,10 +65,6 @@ func _serve_main(m *ice.Message, w http.ResponseWriter, r *http.Request) bool {
|
||||
} else {
|
||||
return true
|
||||
}
|
||||
func() {
|
||||
defer InfoLock.Lock()()
|
||||
Info.ServeMainCount++
|
||||
}()
|
||||
if ip := r.Header.Get(X_REAL_IP); ip != "" {
|
||||
if r.Header.Set(ice.MSG_USERIP, ip); r.Header.Get(X_REAL_PORT) != "" {
|
||||
r.Header.Set(ice.MSG_USERADDR, ip+nfs.DF+r.Header.Get(X_REAL_PORT))
|
||||
@ -218,20 +214,6 @@ func _serve_handle(key string, cmd *ice.Command, m *ice.Message, w http.Response
|
||||
} else {
|
||||
m.CmdHand(cmd, key, cmds...)
|
||||
}
|
||||
func() {
|
||||
defer InfoLock.Lock()()
|
||||
Info.Commands[kit.Select(kit.Select("", cmds, 0), m.Option(ice.MSG_INDEX))]++
|
||||
switch r.Method {
|
||||
case http.MethodGet:
|
||||
Info.ServeGetCount++
|
||||
case http.MethodPut:
|
||||
Info.ServePutCount++
|
||||
case http.MethodPost:
|
||||
Info.ServePostCount++
|
||||
case http.MethodDelete:
|
||||
Info.ServeDeleteCount++
|
||||
}
|
||||
}()
|
||||
}
|
||||
}
|
||||
func _serve_domain(m *ice.Message) string {
|
||||
|
@ -23,26 +23,8 @@ import (
|
||||
"shylinux.com/x/icebergs/base/web/html"
|
||||
"shylinux.com/x/icebergs/misc/websocket"
|
||||
kit "shylinux.com/x/toolkits"
|
||||
"shylinux.com/x/toolkits/task"
|
||||
)
|
||||
|
||||
var Info = struct {
|
||||
ServeMainCount int
|
||||
ServeGetCount int
|
||||
ServePutCount int
|
||||
ServePostCount int
|
||||
ServeDeleteCount int
|
||||
SpaceCmdCount int
|
||||
SpaceReadCount int
|
||||
SpaceReadByte int
|
||||
SpaceWriteCount int
|
||||
SpaceWriteByte int
|
||||
Commands map[string]int
|
||||
}{
|
||||
Commands: map[string]int{},
|
||||
}
|
||||
var InfoLock = &task.Lock{}
|
||||
|
||||
func _space_qrcode(m *ice.Message, dev string) {
|
||||
ssh.PrintQRCode(m, m.Cmdv(SPACE, dev, cli.PWD, mdb.LINK))
|
||||
}
|
||||
@ -98,7 +80,6 @@ func _space_fork(m *ice.Message) {
|
||||
if msg := m.Cmd(TOKEN, m.Option(TOKEN)); msg.Append(mdb.TIME) > m.Time() && kit.IsIn(msg.Append(mdb.TYPE), SERVER, SPIDE) {
|
||||
aaa.SessAuth(m, kit.Dict(m.Cmd(aaa.USER, m.Option(ice.MSG_USERNAME, msg.Append(mdb.NAME))).AppendSimple()))
|
||||
name = SpaceName(kit.Select(name, msg.Append(mdb.TEXT)))
|
||||
// kit.If(ProxyDomain(m.Spawn(kit.Dict(ice.MSG_USERROLE, aaa.TECH)), name), func(p string) { text = p })
|
||||
kit.If(ProxyDomain(m, name), func(p string) { text = p })
|
||||
safe = aaa.IsTechOrRoot(m)
|
||||
}
|
||||
@ -146,11 +127,6 @@ func _space_handle(m *ice.Message, safe bool, name string, c *websocket.Conn) {
|
||||
if e != nil {
|
||||
break
|
||||
}
|
||||
func() {
|
||||
defer InfoLock.Lock()()
|
||||
Info.SpaceReadCount++
|
||||
Info.SpaceReadByte += len(b)
|
||||
}()
|
||||
msg := m.Spawn(b)
|
||||
if safe && msg.Option(ice.MSG_UNSAFE) != ice.TRUE { // 下行权限
|
||||
if !aaa.IsTechOrRoot(msg) && msg.Option(ice.MSG_HANDLE) != ice.TRUE {
|
||||
@ -232,11 +208,6 @@ func _space_exec(m *ice.Message, name string, source, target []string, c *websoc
|
||||
if m.IsErr() {
|
||||
return
|
||||
}
|
||||
func() {
|
||||
defer InfoLock.Lock()()
|
||||
Info.SpaceCmdCount++
|
||||
Info.Commands[kit.Select(kit.Select("", m.Detailv(), 0), m.Option(ice.MSG_INDEX))]++
|
||||
}()
|
||||
m.Options(ice.MSG_ARGS, "", ice.MSG_COUNT, "0")
|
||||
kit.If(m.Option(ice.MSG_DAEMON), func(p string) {
|
||||
m.Option(ice.MSG_DAEMON0, m.Option(ice.MSG_DAEMON))
|
||||
@ -258,11 +229,6 @@ func _space_echo(m *ice.Message, source, target []string, c *websocket.Conn) {
|
||||
m.Options(ice.MSG_SOURCE, source, ice.MSG_TARGET, target[1:])
|
||||
data := m.FormatMeta()
|
||||
if !m.WarnNotValid(c.WriteMessage(1, []byte(data))) {
|
||||
func() {
|
||||
defer InfoLock.Lock()()
|
||||
Info.SpaceWriteCount++
|
||||
Info.SpaceWriteByte += len(data)
|
||||
}()
|
||||
if source != nil {
|
||||
m.Log(kit.Select(tcp.SEND, tcp.DONE, m.Option(ice.MSG_HANDLE) == ice.TRUE), "%d %v->%v %v %v", len(data), source, target,
|
||||
kit.ReplaceAll(kit.Format("%v", m.Detailv()), "\r\n", "\\r\\n", "\t", "\\t", "\n", "\\n"), data)
|
||||
|
@ -311,6 +311,7 @@ func init() {
|
||||
m.Cmd("", mdb.CREATE, kit.Select(dev, os.Getenv("ctx_dev_ip")), ice.DEV_IP, ice.SRC_MAIN_ICO, "dev_ip")
|
||||
m.Cmd("", mdb.CREATE, kit.Select("http://localhost:9020", conf[cli.CTX_OPS]), ice.OPS, ice.SRC_MAIN_ICO, nfs.REPOS)
|
||||
m.Cmd("", mdb.CREATE, kit.Select("https://shylinux.com", conf[cli.CTX_SHY]), ice.SHY, ice.SRC_MAIN_ICO, nfs.REPOS)
|
||||
m.Cmd("", mdb.CREATE, kit.Select("https://web.shylinux.com", conf[cli.CTX_WEB]), ice.WEB, ice.SRC_MAIN_ICO, nfs.REPOS)
|
||||
m.Cmd("", mdb.CREATE, kit.Select("https://mail.shylinux.com", conf[cli.CTX_MAIL]), ice.MAIL, "usr/icons/Mail.png", "mail")
|
||||
m.Cmd("", mdb.CREATE, kit.Select("https://demo.shylinux.com", conf[cli.CTX_DEMO]), ice.DEMO, ice.SRC_MAIN_ICO, "demo")
|
||||
m.Cmd("", mdb.CREATE, "https://2023.shylinux.com", "2023-ContextOS", ice.SRC_MAIN_ICO, nfs.REPOS)
|
||||
@ -388,9 +389,8 @@ func init() {
|
||||
mdb.HashModify(m, mdb.NAME, m.Option(CLIENT_NAME), TOKEN, "")
|
||||
}},
|
||||
DEV_CREATE_TOKEN: {Hand: func(m *ice.Message, arg ...string) {
|
||||
m.OptionDefault(CLIENT_NAME, m.Option(ice.FROM_SPACE))
|
||||
mdb.HashModify(m, m.OptionSimple(CLIENT_NAME, TOKEN))
|
||||
m.Cmd(SPACE, tcp.DIAL, m.Option(CLIENT_NAME)).Sleep300ms()
|
||||
m.Cmd(SPACE, tcp.DIAL, ice.DEV, m.Option(CLIENT_NAME), m.OptionSimple(TOKEN)).Sleep300ms()
|
||||
}},
|
||||
DEV_REQUEST_TEXT: {Hand: func(m *ice.Message, arg ...string) { m.Echo(SpaceName(ice.Info.NodeName)) }},
|
||||
}, DevTokenAction(CLIENT_NAME, CLIENT_URL), mdb.ImportantHashAction(mdb.SHORT, CLIENT_NAME, mdb.FIELD, "time,icons,client.name,client.url,client.type,token")), Hand: func(m *ice.Message, arg ...string) {
|
||||
@ -431,17 +431,8 @@ func init() {
|
||||
return kit.Format(mdb.Cache(ice.Pulse, p, func() ice.Any { return m.Cmdx(SPIDE, ice.OPS, SPIDE_RAW, http.MethodGet, p) }))
|
||||
} else if p == "" {
|
||||
return ""
|
||||
} else if nfs.Exists(m, p) {
|
||||
return m.Cmdx(nfs.CAT, p)
|
||||
} else if strings.Contains(p, "/pkg/mod/") {
|
||||
ls := strings.Split(p, "/pkg/mod/")
|
||||
return kit.Format(mdb.Cache(ice.Pulse, p, func() ice.Any { return m.Cmdx(SPIDE, ice.OPS, SPIDE_RAW, http.MethodGet, nfs.REQUIRE+ls[1]) }))
|
||||
} else if strings.Contains(p, "/usr/local/work/") {
|
||||
ls := strings.Split(strings.Split(p, "/usr/local/work/")[1], "/src/")
|
||||
pp := kit.MergeURL2(ice.Info.Make.Domain, "/p/src/"+ls[1]+"?pod="+ls[0])
|
||||
return kit.Format(mdb.Cache(ice.Pulse, p, func() ice.Any { return m.Cmdx(SPIDE, ice.OPS, SPIDE_RAW, http.MethodGet, pp) }))
|
||||
} else {
|
||||
return ""
|
||||
return m.Cmdx(nfs.CAT, p)
|
||||
}
|
||||
}
|
||||
nfs.TemplatePath = func(m *ice.Message, arg ...string) string {
|
||||
|
@ -37,10 +37,6 @@ func init() {
|
||||
mdb.REMOVE: {Hand: func(m *ice.Message, arg ...string) {
|
||||
m.Cmd(SPIDE, mdb.REMOVE, CLIENT_NAME, m.Option(mdb.NAME))
|
||||
}},
|
||||
tcp.DIAL: {Hand: func(m *ice.Message, arg ...string) {
|
||||
m.Options(m.Cmd(SPIDE, m.Option(mdb.NAME)).AppendSimple())
|
||||
m.Cmdy(SPIDE, mdb.DEV_REQUEST)
|
||||
}},
|
||||
INSTALL: {Name: "install name*", Hand: func(m *ice.Message, arg ...string) {
|
||||
if !kit.HasPrefixList(arg, ctx.RUN) {
|
||||
m.Cmdy(DREAM, mdb.CREATE, m.OptionSimple(mdb.NAME, nfs.REPOS, nfs.BINARY))
|
||||
@ -51,6 +47,12 @@ func init() {
|
||||
PORTAL: {Role: aaa.VOID, Hand: func(m *ice.Message, arg ...string) {
|
||||
ProcessIframe(m, m.Option(mdb.NAME), m.Option(ORIGIN)+S(m.Option(mdb.NAME))+C(m.ActionKey()), arg...)
|
||||
}},
|
||||
DESKTOP: {Role: aaa.VOID, Hand: func(m *ice.Message, arg ...string) {
|
||||
ProcessIframe(m, kit.Keys(m.Option(mdb.NAME), m.ActionKey()), S(m.Option(mdb.NAME))+C(m.ActionKey()), arg...)
|
||||
}},
|
||||
ADMIN: {Role: aaa.VOID, Hand: func(m *ice.Message, arg ...string) {
|
||||
ProcessIframe(m, kit.Keys(m.Option(mdb.NAME), m.ActionKey()), S(m.Option(mdb.NAME))+C(m.ActionKey()), arg...)
|
||||
}},
|
||||
OPEN: {Hand: func(m *ice.Message, arg ...string) {
|
||||
if m.Option(mdb.TYPE) == ORIGIN {
|
||||
m.ProcessOpen(m.Option(ORIGIN))
|
||||
@ -58,6 +60,10 @@ func init() {
|
||||
m.ProcessOpen(S(m.Option(mdb.NAME)))
|
||||
}
|
||||
}},
|
||||
"connect": {Help: "连接", Hand: func(m *ice.Message, arg ...string) {
|
||||
m.Options(m.Cmd(SPIDE, m.Option(mdb.NAME)).AppendSimple())
|
||||
m.Cmdy(SPIDE, mdb.DEV_REQUEST)
|
||||
}},
|
||||
}, ctx.ConfAction(CLIENT_TIMEOUT, cli.TIME_3s), DREAM), Hand: func(m *ice.Message, arg ...string) {
|
||||
if kit.HasPrefixList(arg, ctx.ACTION) {
|
||||
m.Cmdy(DREAM, arg)
|
||||
@ -66,7 +72,8 @@ func init() {
|
||||
m.Cmd(SPIDE, arg, kit.Dict(ice.MSG_FIELDS, "time,icons,client.type,client.name,client.origin")).Table(func(value ice.Maps) {
|
||||
kit.If(value[CLIENT_TYPE] == nfs.REPOS && value[CLIENT_NAME] != ice.SHY, func() {
|
||||
kit.If(value[CLIENT_NAME] == ice.OPS, func() { value[CLIENT_ORIGIN] = UserHost(m) })
|
||||
m.Push(mdb.TYPE, ORIGIN).Push(mdb.NAME, value[CLIENT_NAME]).Push(mdb.ICONS, value[mdb.ICONS]).Push(ORIGIN, value[CLIENT_ORIGIN])
|
||||
m.Push(mdb.TYPE, ORIGIN)
|
||||
m.Push(mdb.NAME, value[CLIENT_NAME]).Push(mdb.ICONS, value[mdb.ICONS]).Push(ORIGIN, value[CLIENT_ORIGIN])
|
||||
if _, ok := list[value[CLIENT_NAME]]; ok || kit.IsIn(value[CLIENT_NAME], ice.OPS, ice.DEV) {
|
||||
m.Push(mdb.STATUS, ice.TRUE)
|
||||
} else {
|
||||
@ -74,10 +81,11 @@ func init() {
|
||||
}
|
||||
})
|
||||
})
|
||||
if m.SortStrR(mdb.NAME); ice.Info.NodeType == WORKER || !aaa.IsTechOrRoot(m) {
|
||||
m.SortStrR(mdb.NAME)
|
||||
if ice.Info.NodeType == WORKER || !aaa.IsTechOrRoot(m) {
|
||||
m.Action()
|
||||
} else {
|
||||
m.PushAction(OPEN, tcp.DIAL, mdb.REMOVE).Action(mdb.CREATE)
|
||||
m.PushAction(OPEN, "connect", mdb.REMOVE).Action(mdb.CREATE)
|
||||
}
|
||||
} else {
|
||||
defer ToastProcess(m, ice.LIST, arg[0])()
|
||||
@ -94,17 +102,14 @@ func init() {
|
||||
// } else {
|
||||
// origin = tcp.PublishLocalhost(m, origin)
|
||||
// }
|
||||
// origin = tcp.PublishLocalhost(m, origin)
|
||||
origin = tcp.PublishLocalhost(m, origin)
|
||||
stat := map[string]int{}
|
||||
list := m.Spawn(ice.Maps{ice.MSG_FIELDS: ""}).CmdMap(SPACE, mdb.NAME)
|
||||
m.SetAppend().Spawn().SplitIndex(m.Cmdx(SPIDE, arg[0], dream, kit.Dict(mdb.ConfigSimple(m, CLIENT_TIMEOUT)))).Table(func(value ice.Maps) {
|
||||
if value[mdb.TYPE] == ORIGIN {
|
||||
return
|
||||
}
|
||||
stat[value[mdb.TYPE]]++
|
||||
if value[nfs.BINARY] == "" {
|
||||
value[nfs.BINARY] = origin + S(value[mdb.NAME])
|
||||
}
|
||||
// if value[nfs.BINARY] == "" {
|
||||
value[nfs.BINARY] = origin + S(value[mdb.NAME])
|
||||
// }
|
||||
m.Push("", value, kit.Split("time,type,name,icons,repos,binary,module,version"))
|
||||
if _, ok := list[value[mdb.NAME]]; ok {
|
||||
m.Push(mdb.STATUS, ice.TRUE)
|
||||
|
@ -164,12 +164,7 @@ func init() {
|
||||
}
|
||||
m.Option(aaa.LANGUAGE, strings.ReplaceAll(strings.ToLower(kit.Select("", kit.Split(kit.GetValid(
|
||||
func() string { return kit.Select("", "zh-cn", strings.Contains(m.Option(ice.MSG_USERUA), "zh_CN")) },
|
||||
func() string {
|
||||
if m.R != nil {
|
||||
return kit.Select("", kit.Split(m.R.Header.Get(html.AcceptLanguage), ",;"), 0)
|
||||
}
|
||||
return ""
|
||||
},
|
||||
func() string { return kit.Select("", kit.Split(m.R.Header.Get(html.AcceptLanguage), ",;"), 0) },
|
||||
func() string { return ice.Info.Lang },
|
||||
), " ."), 0)), "_", "-"))
|
||||
m.Option("language.list", m.Cmd(nfs.DIR, nfs.TemplatePath(m, aaa.LANGUAGE)+nfs.PS, nfs.FILE).Appendv(nfs.FILE))
|
||||
|
@ -6,7 +6,7 @@ Volcanos(chat.ONIMPORT, {
|
||||
can.sup.onexport.link = function() { return can.misc.MergeURL(can, {pod: can.ConfSpace()||can.misc.Search(can, ice.POD), cmd: web.DESKTOP}) }
|
||||
can.onexport.title(can, can.ConfHelp(), can.user.titles)
|
||||
},
|
||||
_menu: function(can) { can.onappend.plugin(can, {index: "web.chat.macos.menu", style: html.OUTPUT, title: can.Conf("title")}, function(sub) { can.ui.menu = sub, sub._desktop = can
|
||||
_menu: function(can) { can.onappend.plugin(can, {index: "web.chat.macos.menu", style: html.OUTPUT}, function(sub) { can.ui.menu = sub, sub._desktop = can
|
||||
var tabs = can.misc.sessionStorage(can, [can.ConfIndex(), html.TABS])
|
||||
sub.onexport.output = function() { can.onimport._desktop(can, can._msg)
|
||||
var sess = can.misc.SearchHash(can)[0]||can.Conf("session")
|
||||
|
@ -8,7 +8,6 @@ Volcanos(chat.ONIMPORT, {_init: function(can, msg) { can.page.style(can, can._ou
|
||||
{view: [[html.MENU, html.TITLE]], list: [
|
||||
{img: can.misc.ResourceFavicon(can, msg.Option(html.FAVICON), can.ConfSpace())},
|
||||
{text: decodeURIComponent(
|
||||
can.Conf("title")||
|
||||
(window == top? can.user.info.titles: "")||can.ConfSpace()||can.misc.Search(can, ice.POD)||location.host
|
||||
)},
|
||||
], onclick: function(event) { can.sup.onexport.record(can, html.DESKTOP) }},
|
||||
|
@ -49,9 +49,6 @@ func _autogen_import(m *ice.Message, main string, ctx string, mod string) string
|
||||
_autogen_defs(m, ice.SRC_MAIN_GO, ice.ETC_MISS_SH, ice.README_MD, ice.MAKEFILE, ice.LICENSE)
|
||||
begin, done, list := false, false, []string{}
|
||||
imports := kit.Format(`_ "%s/src/%s"`, mod, ctx)
|
||||
if mod == "shylinux.com/x/ice" {
|
||||
imports = kit.Format(`_ "%s/%s"`, mod, ctx)
|
||||
}
|
||||
m.Cmd(nfs.CAT, main, func(line string, index int) {
|
||||
if strings.HasSuffix(line, imports) {
|
||||
done = true
|
||||
@ -197,12 +194,14 @@ func init() {
|
||||
}
|
||||
}},
|
||||
DEVPACK: {Help: "开发", Hand: func(m *ice.Message, arg ...string) {
|
||||
if m.Cmdy(WEBPACK, mdb.REMOVE); ice.Info.NodeType == web.SERVER {
|
||||
m.Cmdy(web.DREAM, nfs.GOWORK)
|
||||
m.Cmdy(WEBPACK, mdb.REMOVE)
|
||||
if ice.Info.NodeType == web.SERVER {
|
||||
m.Cmd(web.DREAM, nfs.GOWORK)
|
||||
}
|
||||
}},
|
||||
WEBPACK: {Help: "打包", Hand: func(m *ice.Message, arg ...string) {
|
||||
if m.Cmdy(WEBPACK, mdb.CREATE); ice.Info.NodeType == web.SERVER {
|
||||
m.Cmdy(WEBPACK, mdb.CREATE)
|
||||
if ice.Info.NodeType == web.SERVER {
|
||||
nfs.Trash(m, ice.GO_WORK_SUM)
|
||||
nfs.Trash(m, ice.GO_WORK)
|
||||
}
|
||||
|
@ -1,6 +1,7 @@
|
||||
package code
|
||||
|
||||
import (
|
||||
"os"
|
||||
"path"
|
||||
"runtime"
|
||||
"strings"
|
||||
@ -118,9 +119,10 @@ func init() {
|
||||
m.Options(cli.CMD_ENV, env).Cmd(AUTOGEN, VERSION)
|
||||
_compile_get(m, main)
|
||||
defer m.StatusTime(VERSION, strings.TrimPrefix(GoVersion(m), "go version"))
|
||||
args := []string{main, ice.SRC_VERSION_GO}
|
||||
nfs.Exists(m, "src/option.go", func(p string) { args = append(args, p) })
|
||||
kit.If(file != ice.BIN_ICE_BIN, func() { args = append(args, ice.SRC_BINPACK_GO, ice.SRC_BINPACK_USR_GO) })
|
||||
args := []string{main, ice.SRC_VERSION_GO, ice.SRC_BINPACK_GO, ice.SRC_BINPACK_USR_GO}
|
||||
if _, e := os.Stat("src/option.go"); e == nil {
|
||||
args = append(args, "src/option.go")
|
||||
}
|
||||
if msg := GoBuild(m.Spawn(), file, args...); !cli.IsSuccess(msg) {
|
||||
m.Copy(msg)
|
||||
} else {
|
||||
|
@ -74,7 +74,7 @@ func _go_show(m *ice.Message, arg ...string) {
|
||||
// ctx.ProcessField(m, "web.code.xterm", kit.Simple())
|
||||
ctx.ProcessField(m, "log.debug", kit.Simple("bench"))
|
||||
} else if cmd := ctx.GetFileCmd(path.Join(arg[2], arg[1])); cmd != "" {
|
||||
if p := path.Join(arg[2], strings.Split(arg[1], "/")[0], "portal.go"); path.Base(arg[1]) != "portal.go" &&
|
||||
if p := path.Join(arg[2], strings.Split(arg[1], "/")[0], "portal.go"); path.Base(arg[1]) != "portal.go" && nfs.Exists(m, p) &&
|
||||
!kit.IsIn(arg[1],
|
||||
"gonganxitong/user.go",
|
||||
"gonganxitong/sess.go",
|
||||
@ -82,8 +82,7 @@ func _go_show(m *ice.Message, arg ...string) {
|
||||
"gonganxitong/domain.go",
|
||||
"gonganxitong/command.go",
|
||||
"gonganxitong/quotalist.go",
|
||||
"operation/studio.go",
|
||||
) && nfs.Exists(m, p) {
|
||||
) {
|
||||
if cmd := ctx.GetFileCmd(p); cmd != "" {
|
||||
if m.ActionKey() == mdb.RENDER {
|
||||
ctx.ProcessField(m, cmd, kit.Simple())
|
||||
@ -229,7 +228,7 @@ func TableName(model string) string {
|
||||
}
|
||||
if kit.IsIn(model, "sms", "equipment") {
|
||||
|
||||
} else if kit.HasSuffix(model, "y") && !kit.HasSuffix(model, "way") {
|
||||
} else if kit.HasSuffix(model, "y") {
|
||||
model = model[:len(model)-1] + "ies"
|
||||
} else if kit.HasSuffix(model, "s") {
|
||||
if !kit.HasSuffix(model, "os") {
|
||||
|
@ -22,9 +22,7 @@ func _js_show(m *ice.Message, arg ...string) {
|
||||
ctx.ProcessField(m, kit.Select(ice.CAN_PLUGIN, "web."+strings.Replace(strings.TrimSuffix(strings.TrimPrefix(arg[1], "plugin/local/"), nfs.PT+JS), nfs.PS, nfs.PT, -1)), nil)
|
||||
}
|
||||
} else {
|
||||
if p := path.Join(arg[2], strings.Split(arg[1], "/")[0], "portal.go"); !kit.IsIn(arg[1],
|
||||
"operation/studio.js",
|
||||
) && nfs.Exists(m, p) {
|
||||
if p := path.Join(arg[2], strings.Split(arg[1], "/")[0], "portal.go"); nfs.Exists(m, p) {
|
||||
if cmd := ctx.GetFileCmd(p); cmd != "" {
|
||||
ctx.ProcessField(m, cmd, kit.Simple())
|
||||
return
|
||||
|
2
go.mod
2
go.mod
@ -5,6 +5,6 @@ go 1.13
|
||||
require (
|
||||
shylinux.com/x/go-git/v5 v5.6.7
|
||||
shylinux.com/x/go-qrcode v0.0.3
|
||||
shylinux.com/x/toolkits v1.0.19
|
||||
shylinux.com/x/toolkits v1.0.18
|
||||
shylinux.com/x/websocket v0.0.4
|
||||
)
|
||||
|
4
go.sum
4
go.sum
@ -4,7 +4,7 @@ shylinux.com/x/go-qrcode v0.0.3 h1:RMo+Vidbgq3HatLBj7DDXcTbTLFUwzis5K7TqBkD38U=
|
||||
shylinux.com/x/go-qrcode v0.0.3/go.mod h1:KAbtU+KwiiABMZ/CJ0zh9PI2AX82Uf9rRYcQ4ODm4po=
|
||||
shylinux.com/x/toolkits v0.7.10 h1:65d5rkQXQ71MD8FzYnZ9DFxb1XcOYSYfmRc4j8qQsUw=
|
||||
shylinux.com/x/toolkits v0.7.10/go.mod h1:CHDJarGlDkg60kVsvMLYL/a5hAnRLEOShiEsMOuEp0Q=
|
||||
shylinux.com/x/toolkits v1.0.19 h1:Nrx0xYRc5ph1WS66EZ1hJUCe+2FdSWQ4QP6tBlguikQ=
|
||||
shylinux.com/x/toolkits v1.0.19/go.mod h1:CHDJarGlDkg60kVsvMLYL/a5hAnRLEOShiEsMOuEp0Q=
|
||||
shylinux.com/x/toolkits v1.0.18 h1:jtQZhmvU10Ajegc87tU0cYFUBSviaODo5TsCXpYb2O4=
|
||||
shylinux.com/x/toolkits v1.0.18/go.mod h1:CHDJarGlDkg60kVsvMLYL/a5hAnRLEOShiEsMOuEp0Q=
|
||||
shylinux.com/x/websocket v0.0.4 h1:AJpwblePoOpiE6C8NrvgNYpKTotXMLrDDX2chTvx44Q=
|
||||
shylinux.com/x/websocket v0.0.4/go.mod h1:3UGWkjTu3ie5NAZen7J+uLPBrO7DFeKloj6Jxo13Oiw=
|
||||
|
4
meta.go
4
meta.go
@ -130,10 +130,6 @@ func (m *Message) Push(key string, value Any, arg ...Any) *Message {
|
||||
k = strings.TrimSuffix(k, "*")
|
||||
m.Push(k, kit.Select(kit.Format(val[k]), value[k]))
|
||||
})
|
||||
case map[string]int:
|
||||
kit.For(value, func(key string, value int) {
|
||||
m.Push(key, value)
|
||||
})
|
||||
default:
|
||||
keys := strings.Split(key, ",")
|
||||
kit.For(kit.Simple(value, arg), func(v string, i int) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user