forked from x/icebergs
add some
This commit is contained in:
parent
e4d0d98702
commit
a840ff12ea
@ -262,9 +262,11 @@ func init() {
|
||||
})
|
||||
}
|
||||
func NodeInfo(m *ice.Message, arg ...string) {
|
||||
m.Info("what %v %v", arg, m.FormatStack(1, 100))
|
||||
mdb.Conf(m, RUNTIME, kit.Keys(NODE, mdb.TIME), m.Time())
|
||||
ice.Info.NodeName = mdb.Conf(m, RUNTIME, kit.Keys(NODE, mdb.NAME), kit.Select(ice.Info.NodeName, arg, 0))
|
||||
ice.Info.NodeType = mdb.Conf(m, RUNTIME, kit.Keys(NODE, mdb.TYPE), kit.Select(ice.Info.NodeType, arg, 1))
|
||||
ice.Info.NodeIcon = mdb.Conf(m, RUNTIME, kit.Keys(NODE, mdb.ICON), kit.Select(ice.Info.NodeIcon, arg, 2))
|
||||
}
|
||||
func IsWindows() bool { return runtime.GOOS == WINDOWS }
|
||||
func ParseMake(str string) []string {
|
||||
|
@ -233,19 +233,36 @@ func HashShort(m *ice.Message) string {
|
||||
if m.Option(SHORT) != "" {
|
||||
return m.Option(SHORT)
|
||||
}
|
||||
return kit.Select(HASH, Config(m, SHORT), Config(m, SHORT) != UNIQ)
|
||||
short := ""
|
||||
if m.Option(SUBKEY) != "" {
|
||||
if short = Conf(m, m.PrefixKey(), kit.Keys(m.Option(SUBKEY), META, SHORT)); short == "" {
|
||||
short = Config(m, SHORTS)
|
||||
}
|
||||
} else {
|
||||
short = Config(m, SHORT)
|
||||
}
|
||||
return kit.Select(HASH, short, short != UNIQ)
|
||||
}
|
||||
func HashField(m *ice.Message) string {
|
||||
if m.Option(FIELD) != "" {
|
||||
return m.Option(FIELD)
|
||||
}
|
||||
return kit.Select(HASH_FIELD, Config(m, FIELD))
|
||||
field := ""
|
||||
if m.Option(SUBKEY) != "" {
|
||||
if field = Conf(m, m.PrefixKey(), kit.Keys(m.Option(SUBKEY), META, FIELDS)); field == "" {
|
||||
field = Config(m, FIELDS)
|
||||
}
|
||||
} else {
|
||||
field = Config(m, FIELD)
|
||||
}
|
||||
return kit.Select(HASH_FIELD, field)
|
||||
}
|
||||
func HashInputs(m *ice.Message, arg ...Any) *ice.Message {
|
||||
return m.Cmdy(INPUTS, m.PrefixKey(), m.Option(SUBKEY), HASH, arg)
|
||||
}
|
||||
func HashCreate(m *ice.Message, arg ...Any) string {
|
||||
kit.If(len(arg) == 0 || len(kit.Simple(arg...)) == 0, func() { arg = append(arg, m.OptionSimple(strings.Replace(HashField(m), "hash,", "", 1))) })
|
||||
kit.If(m.Option(SUBKEY) == "", func() { kit.If(Config(m, SHORTS), func(p string) { arg = append([]ice.Any{SHORT, p}, arg) }) })
|
||||
return m.Echo(m.Cmdx(append(kit.List(INSERT, m.PrefixKey(), m.Option(SUBKEY), HASH, logs.FileLineMeta(-1)), arg...)...)).Result()
|
||||
}
|
||||
func HashRemove(m *ice.Message, arg ...Any) *ice.Message {
|
||||
|
@ -123,6 +123,7 @@ const (
|
||||
|
||||
DETAIL = "detail"
|
||||
FIELDS = "fields"
|
||||
SHORTS = "shorts"
|
||||
PARAMS = "params"
|
||||
OFFEND = "offend"
|
||||
OFFSET = "offset"
|
||||
|
@ -298,7 +298,7 @@ func init() {
|
||||
gdb.Event(m, DREAM_INPUTS, arg)
|
||||
}
|
||||
}},
|
||||
mdb.CREATE: {Name: "create name*=hi icons repos binary template", Hand: func(m *ice.Message, arg ...string) {
|
||||
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)) })
|
||||
|
@ -134,6 +134,7 @@ func RenderMain(m *ice.Message) *ice.Message {
|
||||
return m.RenderDownload(path.Join(ice.USR_INTSHELL, ice.INDEX_SH))
|
||||
}
|
||||
m.Options(nfs.SCRIPT, ice.SRC_MAIN_JS, nfs.VERSION, RenderVersion(m))
|
||||
m.OptionDefault(mdb.ICONS, "/require/"+ice.Info.NodeIcon)
|
||||
return m.RenderResult(kit.Renders(m.Cmdx(nfs.CAT, ice.SRC_MAIN_HTML), m))
|
||||
}
|
||||
func RenderCmds(m *ice.Message, cmds ...ice.Any) {
|
||||
|
@ -30,7 +30,7 @@ func _serve_start(m *ice.Message) {
|
||||
aaa.UserRoot(m, "", m.Option(aaa.USERNAME), m.Option(aaa.USERNICK), m.Option(aaa.LANGUAGE))
|
||||
})
|
||||
kit.If(m.Option(tcp.PORT) == tcp.RANDOM, func() { m.Option(tcp.PORT, m.Cmdx(tcp.PORT, aaa.RIGHT)) })
|
||||
cli.NodeInfo(m, kit.Select(kit.Split(ice.Info.Hostname, nfs.PT)[0], m.Option(tcp.NODENAME)), SERVER)
|
||||
cli.NodeInfo(m, kit.Select(kit.Split(ice.Info.Hostname, nfs.PT)[0], m.Option(tcp.NODENAME)), SERVER, mdb.Config(m, mdb.ICONS))
|
||||
m.Go(func() {
|
||||
m.Cmd(SPIDE, ice.OPS, _serve_address(m)+"/exit", ice.Maps{CLIENT_TIMEOUT: cli.TIME_30ms, ice.LOG_DISABLE: ice.TRUE})
|
||||
}).Sleep(cli.TIME_1s)
|
||||
@ -218,7 +218,6 @@ const SERVE = "serve"
|
||||
func init() {
|
||||
Index.MergeCommands(ice.Commands{P(ice.EXIT): {Hand: func(m *ice.Message, arg ...string) { m.Cmd(ice.EXIT) }},
|
||||
SERVE: {Name: "serve name auto main host system", Help: "服务器", Actions: ice.MergeActions(ice.Actions{
|
||||
ice.CTX_INIT: {Hand: func(m *ice.Message, arg ...string) { cli.NodeInfo(m, ice.Info.Pathname, WORKER) }},
|
||||
ice.MAIN: {Name: "main index", Help: "首页", Hand: func(m *ice.Message, arg ...string) {
|
||||
if m.Option(ctx.INDEX) == "" {
|
||||
mdb.Config(m, ice.MAIN, "")
|
||||
@ -262,7 +261,9 @@ func init() {
|
||||
}
|
||||
}
|
||||
}},
|
||||
}, gdb.EventsAction(SERVE_START), mdb.HashAction(mdb.SHORT, mdb.NAME, mdb.FIELD, "time,status,name,proto,host,port"), mdb.ClearOnExitHashAction()), Hand: func(m *ice.Message, arg ...string) {
|
||||
}, gdb.EventsAction(SERVE_START), mdb.HashAction(
|
||||
mdb.ICONS, ice.SRC_MAIN_ICO,
|
||||
mdb.SHORT, mdb.NAME, mdb.FIELD, "time,status,name,proto,host,port"), mdb.ClearOnExitHashAction()), Hand: func(m *ice.Message, arg ...string) {
|
||||
mdb.HashSelect(m, arg...).Action().StatusTimeCount(kit.Dict(ice.MAIN, mdb.Config(m, ice.MAIN)))
|
||||
}},
|
||||
})
|
||||
|
@ -29,7 +29,7 @@ func _space_qrcode(m *ice.Message, dev string) {
|
||||
}
|
||||
func _space_dial(m *ice.Message, dev, name string, arg ...string) {
|
||||
origin := m.Cmdv(SPIDE, dev, CLIENT_ORIGIN)
|
||||
u := kit.ParseURL(kit.MergeURL2(strings.Replace(origin, HTTP, "ws", 1), PP(SPACE), mdb.TYPE, ice.Info.NodeType, mdb.NAME, name, mdb.NAME, "", mdb.ICONS, mdb.Config(m, mdb.ICONS),
|
||||
u := kit.ParseURL(kit.MergeURL2(strings.Replace(origin, HTTP, "ws", 1), PP(SPACE), mdb.TYPE, ice.Info.NodeType, mdb.NAME, name, mdb.NAME, "", mdb.ICONS, ice.Info.NodeIcon,
|
||||
mdb.TIME, ice.Info.Make.Time, nfs.MODULE, ice.Info.Make.Module, nfs.VERSION, ice.Info.Make.Versions(), cli.GOOS, runtime.GOOS, cli.GOARCH, runtime.GOARCH, arg))
|
||||
args := kit.SimpleKV("type,name,host,port", u.Scheme, dev, u.Hostname(), kit.Select(kit.Select(tcp.PORT_443, tcp.PORT_80, u.Scheme == "ws"), u.Port()))
|
||||
gdb.Go(m, func() {
|
||||
@ -289,6 +289,7 @@ func init() {
|
||||
"c": {Help: "命令", Actions: ApiWhiteAction(), Hand: func(m *ice.Message, arg ...string) { m.Cmdy(CHAT_CMD, arg) }},
|
||||
SPACE: {Name: "space name cmds auto", Help: "空间站", Actions: ice.MergeActions(ice.Actions{
|
||||
ice.CTX_INIT: {Hand: func(m *ice.Message, arg ...string) { aaa.White(m, SPACE, ice.MAIN) }},
|
||||
mdb.ICONS: {Hand: func(m *ice.Message, arg ...string) { cli.NodeInfo(m, ice.Info.Pathname, WORKER, arg[0]) }},
|
||||
ice.MAIN: {Name: "main index", Help: "首页", Hand: func(m *ice.Message, arg ...string) {
|
||||
if len(arg) > 0 {
|
||||
mdb.Config(m, ice.MAIN, m.Option(ctx.INDEX))
|
||||
@ -300,7 +301,7 @@ func init() {
|
||||
ice.INFO: {Role: aaa.VOID, Hand: func(m *ice.Message, arg ...string) {
|
||||
m.Push(mdb.TIME, ice.Info.Make.Time)
|
||||
m.Push(mdb.NAME, ice.Info.NodeName)
|
||||
m.Push(mdb.ICONS, kit.Select(mdb.Config(m, mdb.ICONS)))
|
||||
m.Push(mdb.ICONS, ice.Info.NodeIcon)
|
||||
m.Push(nfs.MODULE, ice.Info.Make.Module)
|
||||
m.Push(nfs.VERSION, ice.Info.Make.Versions())
|
||||
m.Push(ORIGIN, m.Option(ice.MSG_USERHOST))
|
||||
|
@ -128,6 +128,7 @@ func init() {
|
||||
kit.If(m.Option(ice.MSG_USERPOD), func(p string) {
|
||||
m.Option(ice.MSG_NODETYPE, m.Cmdx(web.SPACE, p, cli.RUNTIME, ice.MSG_NODETYPE))
|
||||
})
|
||||
m.Option("favicon", "/require/"+m.Cmd(web.SPACE, m.Option(ice.MSG_USERPOD), web.SPACE, ice.INFO).Append(mdb.ICONS))
|
||||
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 { return kit.Select("", kit.Split(m.R.Header.Get(html.AcceptLanguage), ",;"), 0) },
|
||||
|
@ -125,6 +125,7 @@ Volcanos(chat.ONIMPORT, {
|
||||
},
|
||||
layout: function(can) { can.page.style(can, can._output, html.HEIGHT, can.ConfHeight(), html.WIDTH, can.ConfWidth())
|
||||
can.ui.dock && can.page.style(can, can.ui.dock._target, html.LEFT, can.base.Min((can.ConfWidth()-(can.ui.dock._target.offsetWidth||502))/2, 0))
|
||||
can.ui.menu && can.ui.menu.onimport.size(can.ui.menu, 25, can.ConfWidth(), false)
|
||||
},
|
||||
}, [""])
|
||||
Volcanos(chat.ONACTION, {
|
||||
|
@ -2,11 +2,10 @@ Volcanos(chat.ONIMPORT, {_init: function(can, msg) { can.page.style(can, can._ou
|
||||
can.page.Append(can, can._output, can.user.header(can.sup._desktop)), can.page.Append(can, can._output, [
|
||||
{view: [html.ITEM], list: [{icon: icon.notifications}], onclick: function(event) { can.sup.onexport.record(can, "notifications") }},
|
||||
{view: [html.ITEM], list: [{icon: icon.search}], onclick: function(event) { can.sup.onexport.record(can, "searchs") }},
|
||||
// {view: [html.ITEM], list: [{icon: icon.qrcode}], onclick: function(event) { can.sup.onexport.record(can, "qrcode") }},
|
||||
].concat(msg.Table(function(item) {
|
||||
return {view: [html.ITEM], list: [{img: can.page.drawText(can, item.name||item.index, 25, 0, 20)}], onclick: function(event) { can.sup.onexport.record(can, item) }}
|
||||
}), [
|
||||
{view: [[html.MENU, "title"]], list: [{img: can.misc.ResourceFavicon(can)}, {text: decodeURIComponent(can.ConfSpace()||can.misc.Search(can, ice.POD)||location.host)}],
|
||||
{view: [[html.MENU, html.TITLE]], list: [{img: can.misc.ResourceFavicon(can)}, {text: decodeURIComponent(can.ConfSpace()||can.misc.Search(can, ice.POD)||location.host)}],
|
||||
onclick: function(event) { can.sup.onexport.record(can, html.DESKTOP) }},
|
||||
{view: [[html.MENU, mdb.ICON, web.REFRESH], "", can.page.unicode.refresh], onclick: function(event) { can.user.reload(true) }},
|
||||
{view: [[html.MENU, mdb.ICON, mdb.CREATE], "", can.page.unicode.create], onclick: function(event) { can.sup.onexport.record(can, mdb.CREATE) }},
|
||||
|
1
info.go
1
info.go
@ -63,6 +63,7 @@ type info struct {
|
||||
Pathname string
|
||||
NodeName string
|
||||
NodeType string
|
||||
NodeIcon string
|
||||
|
||||
Pwd string
|
||||
Lang string
|
||||
|
@ -338,13 +338,11 @@ func (s relay) iframe(m *ice.Message, cmd string, arg ...string) {
|
||||
}
|
||||
}
|
||||
func (s relay) shell(m *ice.Message, init string, arg ...string) {
|
||||
m.ProcessXterm(kit.Keys(m.Option(MACHINE), m.ActionKey()), s.CmdArgs(m, init), arg...)
|
||||
return
|
||||
m.ProcessXterm(kit.Keys(m.Option(MACHINE), m.ActionKey()), []string{kit.JoinWord(
|
||||
RELAY, tcp.HOST, m.Option(tcp.HOST), aaa.USERNAME, m.Option(aaa.USERNAME),
|
||||
), mdb.TEXT, strings.ReplaceAll(init, lex.NL, "; ")}, arg...)
|
||||
return
|
||||
m.ProcessXterm(kit.Keys(m.Option(MACHINE), m.ActionKey()), []string{kit.JoinWord(kit.Simple(
|
||||
strings.TrimPrefix(os.Args[0], kit.Path("")+nfs.PS), "ssh.connect", tcp.OPEN, ssh.AUTHFILE, "", m.OptionSimple(aaa.USERNAME, tcp.HOST, tcp.PORT),
|
||||
)...), mdb.TEXT, strings.ReplaceAll(init, lex.NL, "; ")}, arg...)
|
||||
}
|
||||
func (s relay) foreachScript(m *ice.Message, script string, arg ...string) {
|
||||
m.Option(ice.MSG_TITLE, kit.Keys(m.Option(ice.MSG_USERPOD), m.CommandKey(), m.ActionKey()))
|
||||
@ -384,6 +382,12 @@ func (s relay) admin(m *ice.Message, arg ...string) string {
|
||||
func (s relay) param(m *ice.Message, arg ...string) string {
|
||||
return kit.JoinCmdArgs(ice.DEV, m.Option(ice.DEV), tcp.PORT, m.Option(web.PORTAL), tcp.NODENAME, m.OptionDefault(tcp.NODENAME, m.Option(MACHINE)), ice.TCP_DOMAIN, m.Option(tcp.HOST))
|
||||
}
|
||||
func (s relay) CmdArgs(m *ice.Message, init string, arg ...string) string {
|
||||
kit.If(m.Option(web.PORTAL), func() { init = kit.Format("%q", "cd "+path.Base(m.DreamPath(m.Option(web.DREAM)))) })
|
||||
return kit.JoinWord(kit.Simple(strings.TrimPrefix(os.Args[0], kit.Path("")+nfs.PS), "ssh.connect", tcp.OPEN,
|
||||
ssh.AUTHFILE, "", m.OptionSimple(aaa.USERNAME, tcp.HOST, tcp.PORT), ice.INIT, init,
|
||||
)...)
|
||||
}
|
||||
|
||||
type Relay struct {
|
||||
relay
|
||||
|
Loading…
x
Reference in New Issue
Block a user