1
0
forked from x/icebergs
This commit is contained in:
IT 老营长 @云轩领航-创始人 2024-01-10 21:06:41 +08:00
parent cc503e37b9
commit 9baed62ec9
17 changed files with 49 additions and 61 deletions

View File

@ -152,13 +152,13 @@ const (
SRC_TEMPLATE = ice.SRC_TEMPLATE
USR_PACKAGE = "usr/package.json"
USR_MODULES = "usr/node_modules/"
SHARE_LOCAL = "/share/local/"
REQUIRE_MODULES = "/require/modules/"
REQUIRE_SRC = "/require/src/"
REQUIRE_USR = "/require/usr/"
REQUIRE = "/require/"
VOLCANOS = "/volcanos/"
INTSHELL = "/intshell/"
SHARE_LOCAL = "/share/local/"
PATHNAME = "pathname"
FILENAME = "filename"

View File

@ -5,6 +5,8 @@ import (
"path"
ice "shylinux.com/x/icebergs"
"shylinux.com/x/icebergs/base/ctx"
"shylinux.com/x/icebergs/base/mdb"
kit "shylinux.com/x/toolkits"
)
@ -12,9 +14,21 @@ const ADMIN = "admin"
func init() {
Index.MergeCommands(ice.Commands{
ADMIN: {Name: "admin index list", Help: "管理", Hand: func(m *ice.Message, arg ...string) {
kit.If(len(arg) == 0, func() { arg = append(arg, SPACE, DOMAIN) })
m.Cmdy(SPIDE, ice.OPS, SPIDE_RAW, http.MethodPost, CHAT_CMD+path.Join(arg...), "pwd", kit.Path(""))
ADMIN: {Name: "admin index list", Help: "管理", Actions: ice.Actions{
DREAM_TABLES: {Hand: func(m *ice.Message, arg ...string) { m.PushButton(kit.Dict(ADMIN, "后台")) }},
DREAM_ACTION: {Hand: func(m *ice.Message, arg ...string) {
if kit.HasPrefixList(arg, ctx.ACTION, ADMIN) && len(arg) == 2 {
ctx.ProcessField(m, CHAT_IFRAME, m.MergePodCmd(m.Option(mdb.NAME), ""), arg...)
m.ProcessField(ctx.ACTION, ctx.RUN, CHAT_IFRAME)
}
}},
}, Hand: func(m *ice.Message, arg ...string) {
if m.Option(ice.MSG_SOURCE) != "" {
RenderMain(m)
} else {
kit.If(len(arg) == 0, func() { arg = append(arg, SPACE, DOMAIN) })
m.Cmdy(SPIDE, ice.OPS, SPIDE_RAW, http.MethodPost, C(path.Join(arg...)), "pwd", kit.Path(""))
}
}},
})
}

View File

@ -75,6 +75,7 @@ func _dream_start(m *ice.Message, name string) {
cli.CTX_ROOT, kit.Path(""), cli.PATH, cli.BinPath(p, ""), cli.USER, ice.Info.Username,
)...), cli.CMD_OUTPUT, path.Join(p, ice.VAR_LOG_BOOT_LOG), mdb.CACHE_CLEAR_ONEXIT, ice.TRUE)
gdb.Event(m, DREAM_CREATE, m.OptionSimple(mdb.NAME, mdb.TYPE, cli.CMD_DIR))
kit.If(m.Option(nfs.BINARY) == "", func(p string) { m.Option(nfs.BINARY, SpideOrigin(m, ice.DEV)+S(name)) })
kit.If(m.Option(nfs.BINARY), func(p string) { _dream_binary(m, p) })
kit.If(m.Option(nfs.TEMPLATE), func(p string) { _dream_template(m, p) })
bin := kit.Select(kit.Path(os.Args[0]), cli.SystemFind(m, ice.ICE_BIN, nfs.PWD+path.Join(p, ice.BIN), nfs.PWD+ice.BIN))
@ -141,7 +142,7 @@ const DREAM = "dream"
func init() {
Index.MergeCommands(ice.Commands{
DREAM: {Name: "dream name@key auto create startall stopall build publish", Help: "梦想家", Icon: "Launchpad.png", Role: aaa.VOID, Actions: ice.MergeActions(ice.Actions{
DREAM: {Name: "dream refresh", Help: "梦想家", Icon: "Launchpad.png", Role: aaa.VOID, Actions: ice.MergeActions(ice.Actions{
ice.CTX_INIT: {Hand: func(m *ice.Message, arg ...string) {
m = m.Spawn()
m.GoSleep("10s", func() {
@ -228,15 +229,15 @@ func init() {
m.Cmd("", cli.STOP, ice.Maps{mdb.NAME: name, ice.MSG_DAEMON: ""})
})
}},
cli.BUILD: {Hand: func(m *ice.Message, arg ...string) {
m.Cmd("", FOR_FLOW, kit.JoinWord(cli.SH, ice.ETC_MISS_SH))
cli.BUILD: {Name: "build name", Hand: func(m *ice.Message, arg ...string) {
m.Cmd("", FOR_FLOW, m.Option(mdb.NAME), kit.JoinWord(cli.SH, ice.ETC_MISS_SH))
m.Sleep3s().Cmdy(ROUTE, cli.BUILD).ProcessInner()
}},
PUBLISH: {Name: "publish name", Help: "发布", Icon: "bi bi-send-check", Hand: func(m *ice.Message, arg ...string) {
defer ToastProcess(m)()
m.Cmd(CODE_AUTOGEN, "binpack")
list := []string{cli.LINUX, cli.DARWIN, cli.WINDOWS}
msg := m.Spawn(ice.Maps{ice.MSG_DAEMON: ""})
m.Cmd(CODE_AUTOGEN, "binpack")
kit.For(list, func(goos string) {
PushNoticeRich(m, mdb.NAME, ice.Info.NodeName, msg.Cmd(CODE_COMPILE, goos, cli.AMD64).AppendSimple())
})
@ -248,13 +249,13 @@ func init() {
})
m.ProcessHold()
}},
FOR_FLOW: {Name: "forFlow cmd*='sh etc/miss.sh'", Help: "流程", Icon: "bi bi-terminal", Hand: func(m *ice.Message, arg ...string) {
FOR_FLOW: {Name: "forFlow name cmd*='sh etc/miss.sh'", Help: "流程", Icon: "bi bi-terminal", Hand: func(m *ice.Message, arg ...string) {
m.Options(ctx.DISPLAY, PLUGIN_XTERM, cli.CMD_OUTPUT, nfs.NewWriteCloser(func(buf []byte) (int, error) {
m.Option(ice.MSG_COUNT, "0")
PushNoticeGrow(m, strings.ReplaceAll(string(buf), lex.NL, "\r\n"))
return len(buf), nil
}, func() error { return nil }))
msg := mdb.HashSelects(m.Spawn())
msg := mdb.HashSelects(m.Spawn(), m.Option(mdb.NAME))
GoToast(m, "", func(toast func(string, int, int)) []string {
msg.Table(func(index int, value ice.Maps) {
toast(value[mdb.NAME], index, msg.Length())
@ -318,7 +319,7 @@ func init() {
}
}},
}, StatsAction(), DreamAction(), mdb.ImportantHashAction(
html.BUTTON, "web.wiki.portal web.chat.portal web.chat.macos.desktop web.code.git.status web.code.vimer web.code.xterm web.code.compile",
html.BUTTON, "web.wiki.portal web.admin web.chat.macos.desktop web.code.git.status web.code.vimer web.code.xterm web.code.compile",
ctx.TOOLS, "web.code.git.search,route", mdb.SHORT, mdb.NAME, mdb.FIELD, "time,name,icon,repos,binary,template,restart")), Hand: func(m *ice.Message, arg ...string) {
if len(arg) == 0 {
_dream_list(m).RewriteAppend(func(value, key string, index int) string {
@ -334,8 +335,13 @@ func init() {
}
}
return value
}).Option(ice.MSG_ACTION, "")
})
ctx.DisplayTableCard(m)
kit.If(cli.SystemFind(m, "go"), func() {
m.Action(mdb.CREATE, STARTALL, STOPALL, cli.BUILD, PUBLISH)
}, func() {
m.Action(mdb.CREATE, STARTALL, STOPALL)
})
return
m.Cmds(SPACE, func(value ice.Maps) {
if value[mdb.TYPE] == SERVER {

View File

@ -157,14 +157,7 @@ func RenderVersion(m *ice.Message) string {
}
const (
CHAT = "chat"
CHAT_POD = "/chat/pod/"
CHAT_CMD = "/chat/cmd/"
REQUIRE_SRC = "/require/src/"
REQUIRE_USR = "/require/usr/"
REQUIRE_MODULES = "/require/modules/"
VOLCANOS = "/volcanos/"
INTSHELL = "/intshell/"
CHAT = "chat"
CODE_GIT_SERVICE = "web.code.git.service"
CODE_GIT_SEARCH = "web.code.git.search"
@ -181,7 +174,6 @@ const (
WIKI_DRAW = "web.wiki.draw"
WIKI_WORD = "web.wiki.word"
WIKI_PORTAL = "web.wiki.portal"
CHAT_PORTAL = "web.chat.portal"
CHAT_HEADER = "web.chat.header"
CHAT_IFRAME = "web.chat.iframe"
CHAT_OAUTH_CLIENT = "web.chat.oauth.client"

View File

@ -59,7 +59,7 @@ func _serve_main(m *ice.Message, w http.ResponseWriter, r *http.Request) bool {
} else {
r.Header.Set(ice.MSG_USERIP, strings.Split(r.RemoteAddr, nfs.DF)[0])
}
if !kit.HasPrefix(r.URL.String(), VOLCANOS, REQUIRE_MODULES, INTSHELL) {
if !kit.HasPrefix(r.URL.String(), nfs.VOLCANOS, nfs.REQUIRE_MODULES, nfs.INTSHELL) {
r.Header.Set(ice.LOG_TRACEID, log.Traceid())
m.Logs(r.Header.Get(ice.MSG_USERIP), r.Method, r.URL.String(), logs.TraceidMeta(r.Header.Get(ice.LOG_TRACEID)))
}
@ -85,7 +85,7 @@ func _serve_static(msg *ice.Message, w http.ResponseWriter, r *http.Request) boo
} else if p = path.Join(nfs.USR, r.URL.Path); kit.HasPrefix(r.URL.Path, nfs.VOLCANOS, nfs.INTSHELL) && nfs.Exists(msg, p) {
return Render(msg, ice.RENDER_DOWNLOAD, p)
} else if p = strings.TrimPrefix(r.URL.Path, nfs.REQUIRE); kit.HasPrefix(r.URL.Path, nfs.REQUIRE_SRC, nfs.REQUIRE+ice.USR_ICONS, nfs.REQUIRE+ice.USR_ICEBERGS) && nfs.Exists(msg, p) {
ispod := kit.Contains(r.URL.String(), CHAT_POD, "pod=") || kit.Contains(r.Header.Get(html.Referer), CHAT_POD, "pod=")
ispod := kit.Contains(r.URL.String(), "/s/", "pod=") || kit.Contains(r.Header.Get(html.Referer), "/s/", "pod=")
return !ispod && Render(msg, ice.RENDER_DOWNLOAD, p)
} else if p = path.Join(nfs.USR_MODULES, strings.TrimPrefix(r.URL.Path, nfs.REQUIRE_MODULES)); kit.HasPrefix(r.URL.Path, nfs.REQUIRE_MODULES) && nfs.Exists(msg, p) {
return Render(msg, ice.RENDER_DOWNLOAD, p)
@ -214,7 +214,7 @@ func init() {
if m.Option(ctx.INDEX) == "" {
mdb.Config(m, ice.MAIN, "")
} else {
mdb.Config(m, ice.MAIN, CHAT_CMD+m.Option(ctx.INDEX)+nfs.PS)
mdb.Config(m, ice.MAIN, C(m.Option(ctx.INDEX)+nfs.PS))
}
}},
log.TRACEID: {Help: "日志", Hand: func(m *ice.Message, arg ...string) {

View File

@ -294,7 +294,7 @@ func init() {
ice.CTX_INIT: {Hand: func(m *ice.Message, arg ...string) {
conf := mdb.Confm(m, cli.RUNTIME, cli.CONF)
m.Cmd("", mdb.CREATE, ice.SHY, kit.Select("https://shylinux.com", conf[cli.CTX_SHY]))
m.Cmd("", mdb.CREATE, ice.DEV, kit.Select(kit.Select("https://2021.shylinux.com", ice.Info.Make.Domain), conf[cli.CTX_DEV]))
m.Cmd("", mdb.CREATE, ice.DEV, kit.Select("https://2021.shylinux.com", ice.Info.Make.Domain, conf[cli.CTX_DEV]))
m.Cmd("", mdb.CREATE, ice.OPS, kit.Select("http://localhost:9020", conf[cli.CTX_OPS]))
m.Cmd("", mdb.CREATE, ice.DEMO, kit.Select("http://localhost:20000", conf[cli.CTX_DEMO]))
m.Cmd("", mdb.CREATE, ice.MAIL, kit.Select("https://mail.shylinux.com", conf[cli.CTX_MAIL]))

View File

@ -12,7 +12,7 @@ func init() {
Index.MergeCommands(ice.Commands{
CMD: {Help: "命令", Actions: web.ApiWhiteAction(), Hand: func(m *ice.Message, arg ...string) {
switch cmd := kit.Select(web.WIKI_WORD, arg, 0); cmd {
case web.CHAT_PORTAL:
case web.ADMIN:
web.RenderMain(m)
default:
if m.IsCliUA() {

View File

@ -24,7 +24,7 @@ func init() {
m.Cmd(web.SPACE, m.Option(mdb.NAME), cli.PWD, m.Option(mdb.NAME), link, m.Cmdx(cli.QRCODE, link))
})
}},
web.HOME: {Help: "首页", Hand: func(m *ice.Message, arg ...string) { m.ProcessOpen(m.MergeLink(web.CHAT_PORTAL)) }},
web.HOME: {Help: "首页", Hand: func(m *ice.Message, arg ...string) { m.ProcessOpen(web.C(web.ADMIN)) }},
aaa.CONFIRM: {Help: "授权", Role: aaa.VOID, Hand: func(m *ice.Message, arg ...string) {
// if m.Warn(m.R.Method == http.MethodGet, ice.ErrNotAllow) {
// return

View File

@ -65,7 +65,7 @@ func init() {
}},
}, FavorAction(), mdb.HashAction(mdb.SHORT, web.LINK, mdb.FIELD, "time,hash,type,name,link")), Hand: func(m *ice.Message, arg ...string) {
list := []string{m.MergePodCmd("", web.WIKI_PORTAL)}
list = append(list, m.MergePodCmd("", web.CHAT_PORTAL))
list = append(list, m.MergePodCmd("", web.ADMIN))
if mdb.HashSelect(m, arg...); len(arg) == 0 {
for _, link := range list {
if u := kit.ParseURL(link); u != nil {

View File

@ -45,7 +45,7 @@ func init() {
if m.Option(ice.MSG_USERPOD, arg[0]); len(arg) == 1 {
m.Cmdy(web.SPACE, arg[0], web.SPACE, ice.MAIN)
} else if kit.IsIn(arg[1], CMD, "c") {
if arg[2] == web.CHAT_PORTAL {
if kit.IsIn(arg[2], web.ADMIN) {
m.Cmdy(web.SPACE, arg[0], arg[2])
} else {
web.RenderPodCmd(m, arg[0], arg[2], arg[3:])

View File

@ -1,25 +0,0 @@
package chat
import (
ice "shylinux.com/x/icebergs"
"shylinux.com/x/icebergs/base/ctx"
"shylinux.com/x/icebergs/base/mdb"
"shylinux.com/x/icebergs/base/web"
kit "shylinux.com/x/toolkits"
)
const PORTAL = "portal"
func init() {
Index.MergeCommands(ice.Commands{
PORTAL: {Help: "门户", Actions: ice.MergeActions(ice.Actions{
web.DREAM_TABLES: {Hand: func(m *ice.Message, arg ...string) { m.PushButton(kit.Dict(web.ADMIN, "后台")) }},
web.DREAM_ACTION: {Hand: func(m *ice.Message, arg ...string) {
if kit.HasPrefixList(arg, ctx.ACTION, web.ADMIN) && len(arg) == 2 {
ctx.ProcessField(m, web.CHAT_IFRAME, m.MergePodCmd(m.Option(mdb.NAME), m.PrefixKey()), arg...)
m.ProcessField(ctx.ACTION, ctx.RUN, web.CHAT_IFRAME)
}
}},
}, web.ApiAction()), Hand: func(m *ice.Message, arg ...string) { web.RenderMain(m) }},
})
}

View File

@ -43,7 +43,7 @@ func init() {
}
uri := "/publish/" + kit.Format(value[nfs.FILE])
kit.If(os.Getenv(cli.CTX_POD), func(p string) {
uri = kit.MergeURL2(os.Getenv(cli.CTX_DEV), web.CHAT_POD+p, cli.GOOS, runtime.GOOS, cli.GOARCH, runtime.GOARCH)
uri = kit.MergeURL2(os.Getenv(cli.CTX_DEV), web.S(p), cli.GOOS, runtime.GOOS, cli.GOARCH, runtime.GOARCH)
})
dir := path.Join(kit.Format(value[nfs.PATH]), kit.Format(value[nfs.FILE]))
web.GoToast(m, m.PrefixKey(), func(toast func(name string, count, total int)) []string {

View File

@ -1,7 +1,7 @@
Volcanos(chat.ONIMPORT, {
_init: function(can, msg) { can.isCmdMode() && (can.user.toast = function() {})
var p = "/cmd/"+web.WIKI_PORTAL; can.db.prefix = location.pathname.indexOf(p) > -1? location.pathname.split(p)[0]+p: nfs.WIKI_PORTAL
var p = "/c/"+web.WIKI_PORTAL; can.db.prefix = location.pathname.indexOf(p) > -1? location.pathname.split(p)[0]+p: nfs.WIKI_PORTAL
var p = "/cmd/"+web.PORTAL; can.db.prefix = location.pathname.indexOf(p) > -1? location.pathname.split(p)[0]+p: nfs.WIKI_PORTAL
var p = "/c/"+web.PORTAL; can.db.prefix = location.pathname.indexOf(p) > -1? location.pathname.split(p)[0]+p: nfs.WIKI_PORTAL
can.db.current = can.isCmdMode()? can.base.trimPrefix(location.pathname, can.db.prefix+nfs.PS, can.db.prefix): can.Option(nfs.PATH)
can.sup.onexport.link = function() { return can.misc.MergeURL(can, {pod: can.ConfSpace(), cmd: can.ConfIndex()}) }
can.require(["/plugin/local/wiki/word.js"])

View File

@ -509,9 +509,9 @@ func init() {
mdb.HashRemove(m, m.Option(REPOS))
}
}},
CLONE: {Name: "clone origin* name", Help: "克隆", Icon: "bi bi-copy", Hand: func(m *ice.Message, arg ...string) {
CLONE: {Name: "clone origin* name path", Help: "克隆", Icon: "bi bi-copy", Hand: func(m *ice.Message, arg ...string) {
m.OptionDefault(mdb.NAME, path.Base(m.Option(ORIGIN)))
m.Option(nfs.PATH, path.Join(nfs.USR, m.Option(mdb.NAME))+nfs.PS)
m.OptionDefault(nfs.PATH, path.Join(nfs.USR, m.Option(mdb.NAME))+nfs.PS)
defer m.Cmdy(nfs.DIR, m.Option(nfs.PATH))
if nfs.Exists(m, path.Join(m.Option(nfs.PATH), _GIT)) {
return

View File

@ -54,6 +54,7 @@ func init() {
web.DREAM_TABLES: {Hand: func(m *ice.Message, arg ...string) {
if !nfs.Exists(m, path.Join(ice.USR_LOCAL_WORK, m.Option(mdb.NAME), _GIT)) {
m.Push(mdb.TEXT, "")
m.PushButton(kit.Dict(m.CommandKey(), "源码"))
return
}
text := []string{}

View File

@ -18,7 +18,7 @@ func (s npm) Init(m *ice.Message) {
cli.IsRedhat(m.Message, NPM, "nodejs")
}
func (s npm) List(m *ice.Message) {
m.Cmdy(nfs.DIR, ice.USR_MODULES)
m.Cmdy(nfs.DIR, nfs.USR_MODULES)
}
func init() { ice.CodeCtxCmd(npm{}) }

View File

@ -316,7 +316,7 @@ func (s relay) AdminCmd(m *ice.Message, arg ...string) {
func (s relay) Xterm(m *ice.Message, arg ...string) { s.Code.Xterm(m, m.Option(MACHINE), arg...) }
func (s relay) Repos(m *ice.Message, arg ...string) { s.iframeCmd(m, web.CODE_GIT_STATUS, arg...) }
func (s relay) Vimer(m *ice.Message, arg ...string) { s.iframeCmd(m, web.CODE_VIMER, arg...) }
func (s relay) Admin(m *ice.Message, arg ...string) { s.iframeCmd(m, web.CHAT_PORTAL, arg...) }
func (s relay) Admin(m *ice.Message, arg ...string) { s.iframeCmd(m, web.ADMIN, arg...) }
func init() { ice.Cmd(SSH_RELAY, relay{}) }