From 8df81a51a8fdd94649394bee248b20c3669b006b Mon Sep 17 00:00:00 2001 From: harveyshao Date: Mon, 25 Apr 2022 15:11:39 +0800 Subject: [PATCH] opt some --- base/aaa/user.go | 3 ++- base/cli/system.go | 2 -- base/web/serve.go | 4 ++-- base/web/share.go | 13 +++++++------ base/web/spide.go | 10 +++++++--- core/code/vimer.go | 12 ++++++++---- core/wiki/refer.go | 2 +- misc/git/server.go | 9 +++++++-- misc/git/status.go | 6 +++--- 9 files changed, 37 insertions(+), 24 deletions(-) diff --git a/base/aaa/user.go b/base/aaa/user.go index 26b1cb88..97455826 100644 --- a/base/aaa/user.go +++ b/base/aaa/user.go @@ -47,12 +47,13 @@ func _user_search(m *ice.Message, name, text string) { }) } -func UserRoot(m *ice.Message, arg ...string) { // password username userrole +func UserRoot(m *ice.Message, arg ...string) *ice.Message { // password username userrole username := m.Option(ice.MSG_USERNAME, kit.Select(ice.Info.UserName, arg, 1)) userrole := m.Option(ice.MSG_USERROLE, kit.Select(ROOT, arg, 2)) if len(arg) > 0 { _user_create(m, userrole, username, kit.Select("", arg, 0)) } + return m } func UserRole(m *ice.Message, username interface{}) (role string) { if role = VOID; username == ice.Info.UserName { diff --git a/base/cli/system.go b/base/cli/system.go index 885c221f..08dad4c4 100644 --- a/base/cli/system.go +++ b/base/cli/system.go @@ -3,7 +3,6 @@ package cli import ( "bytes" "io" - "os" "os/exec" "path" "strings" @@ -59,7 +58,6 @@ func _system_cmd(m *ice.Message, arg ...string) *exec.Cmd { if len(cmd.Env) > 0 { m.Log_EXPORT(CMD_ENV, cmd.Env) } - m.Debug("wht%v", os.Getenv(PATH)) return cmd } func _system_out(m *ice.Message, out string) io.Writer { diff --git a/base/web/serve.go b/base/web/serve.go index 312a559a..0b689e9e 100644 --- a/base/web/serve.go +++ b/base/web/serve.go @@ -391,8 +391,8 @@ func init() { } } if strings.HasPrefix(arg[0], "ice.") && m.Option(ice.POD) != "" { - aaa.UserRoot(m) - _share_local(m, "bin/ice.bin") + _share_local(aaa.UserRoot(m), ice.BIN_ICE_BIN) + // _share_local(aaa.UserRoot(m), arg[0]) return } _share_local(m, m.Conf(SERVE, kit.Keym(ice.PUBLISH)), path.Join(arg...)) diff --git a/base/web/share.go b/base/web/share.go index 2f7da20e..0741b4db 100644 --- a/base/web/share.go +++ b/base/web/share.go @@ -81,13 +81,14 @@ func _share_local(m *ice.Message, arg ...string) { size = s.Size() } - if p == "bin/ice.bin" { - aaa.UserRoot(m) - } - // 上传文件 - m.Cmd(SPACE, m.Option(ice.POD), SPIDE, ice.DEV, SPIDE_RAW, m.MergeURL2(SHARE_PROXY, nfs.PATH, ""), - SPIDE_PART, m.OptionSimple(ice.POD), nfs.PATH, p, nfs.SIZE, size, CACHE, cache.Format(ice.MOD_TIME), UPLOAD, "@"+p) + if p == "bin/ice.bin" { + aaa.UserRoot(m).Cmd(SPACE, m.Option(ice.POD), SPIDE, "submit", m.MergeURL2(SHARE_PROXY, nfs.PATH, ""), m.Option(ice.POD), p, size, cache.Format(ice.MOD_TIME)) + } else { + m.Cmd(SPACE, m.Option(ice.POD), SPIDE, ice.DEV, SPIDE_RAW, m.MergeURL2(SHARE_PROXY, nfs.PATH, ""), + SPIDE_PART, m.OptionSimple(ice.POD), nfs.PATH, p, nfs.SIZE, size, CACHE, cache.Format(ice.MOD_TIME), UPLOAD, "@"+p) + + } if s, e := os.Stat(pp); e == nil && !s.IsDir() { p = pp diff --git a/base/web/spide.go b/base/web/spide.go index 89bd45b7..97d9f788 100644 --- a/base/web/spide.go +++ b/base/web/spide.go @@ -14,6 +14,7 @@ import ( "time" ice "shylinux.com/x/icebergs" + "shylinux.com/x/icebergs/base/aaa" "shylinux.com/x/icebergs/base/cli" "shylinux.com/x/icebergs/base/mdb" "shylinux.com/x/icebergs/base/nfs" @@ -350,15 +351,18 @@ func init() { conf := m.Confm(cli.RUNTIME, "conf") m.Cmd(SPIDE, mdb.CREATE, ice.OPS, kit.Select("http://127.0.0.1:9020", conf["ctx_ops"])) m.Cmd(SPIDE, mdb.CREATE, ice.DEV, kit.Select("http://contexts.woa.com:80", conf["ctx_dev"])) - m.Cmd(SPIDE, mdb.CREATE, ice.SHY, kit.Select("https://contexts.com.cn:443", conf["ctx_shy"])) - // m.Cmd(SPIDE, mdb.CREATE, ice.SHY, kit.Select("https://shylinux.com:443", conf["ctx_shy"])) + m.Cmd(SPIDE, mdb.CREATE, ice.SHY, kit.Select("https://shylinux.com:443", conf["ctx_shy"])) + m.Cmd(aaa.ROLE, aaa.WHITE, aaa.VOID, SPIDE, "submit") }}, mdb.CREATE: {Name: "create name address", Help: "添加", Hand: func(m *ice.Message, arg ...string) { _spide_create(m, m.Option(mdb.NAME), m.Option(ADDRESS)) }}, - MERGE: {Name: "merge name path", Help: "添加", Hand: func(m *ice.Message, arg ...string) { + MERGE: {Name: "merge name path", Help: "拼接", Hand: func(m *ice.Message, arg ...string) { m.Echo(kit.MergeURL2(m.Cmd(SPIDE, arg[0], ice.OptionFields("")).Append(CLIENT_URL), arg[1], arg[2:])) }}, + "submit": {Name: "submit dev pod path size cache", Help: "发布", Hand: func(m *ice.Message, arg ...string) { + m.Cmdy(SPIDE, ice.DEV, SPIDE_RAW, m.Option("dev"), SPIDE_PART, "pod", m.Option("pod"), nfs.PATH, "bin/ice.bin", UPLOAD, "@"+"bin/ice.bin") + }}, }, mdb.HashAction()), Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) { if len(arg) < 2 || arg[0] == "" || (len(arg) > 3 && arg[3] == "") { mdb.HashSelect(m, kit.Slice(arg, 0, 1)...) diff --git a/core/code/vimer.go b/core/code/vimer.go index 409f2492..7f1ec4d7 100644 --- a/core/code/vimer.go +++ b/core/code/vimer.go @@ -59,16 +59,20 @@ func init() { m.Cmdy(BINPACK, mdb.EXPORT) }}, BINPACK: {Name: "binpack", Help: "打包模式", Hand: func(m *ice.Message, arg ...string) { - m.Cmd(nfs.LINK, ice.GO_MOD, path.Join(ice.SRC_RELEASE, ice.GO_MOD)) - m.Cmd(nfs.LINK, ice.GO_SUM, path.Join(ice.SRC_RELEASE, ice.GO_SUM)) + if kit.FileExists(ice.SRC_RELEASE) { + m.Cmd(nfs.LINK, ice.GO_MOD, path.Join(ice.SRC_RELEASE, ice.GO_MOD)) + m.Cmd(nfs.LINK, ice.GO_SUM, path.Join(ice.SRC_RELEASE, ice.GO_SUM)) + } m.Cmdy(nfs.CAT, ice.GO_MOD) m.Cmdy(AUTOGEN, BINPACK) m.ToastSuccess() m.ProcessInner() }}, DEVPACK: {Name: "devpack", Help: "开发模式", Hand: func(m *ice.Message, arg ...string) { - m.Cmd(nfs.LINK, ice.GO_MOD, path.Join(ice.SRC_DEBUG, ice.GO_MOD)) - m.Cmd(nfs.LINK, ice.GO_SUM, path.Join(ice.SRC_DEBUG, ice.GO_SUM)) + if kit.FileExists(ice.SRC_DEBUG) { + m.Cmd(nfs.LINK, ice.GO_MOD, path.Join(ice.SRC_DEBUG, ice.GO_MOD)) + m.Cmd(nfs.LINK, ice.GO_SUM, path.Join(ice.SRC_DEBUG, ice.GO_SUM)) + } m.Cmdy(nfs.CAT, ice.GO_MOD) m.Cmdy(WEBPACK, mdb.REMOVE) m.ToastSuccess() diff --git a/core/wiki/refer.go b/core/wiki/refer.go index d72350e3..c961a374 100644 --- a/core/wiki/refer.go +++ b/core/wiki/refer.go @@ -13,7 +13,7 @@ import ( func _refer_show(m *ice.Message, text string, arg ...string) { list := [][]string{} for _, v := range kit.Split(strings.TrimSpace(text), ice.NL, ice.NL) { - if ls := kit.Split(v); len(ls) == 1 { + if ls := kit.Split(v, " ", " "); len(ls) == 1 { list = append(list, []string{path.Base(ls[0]), ls[0]}) } else { list = append(list, ls) diff --git a/misc/git/server.go b/misc/git/server.go index f78022e6..23b887d4 100644 --- a/misc/git/server.go +++ b/misc/git/server.go @@ -128,7 +128,7 @@ func init() { if ls := strings.Split(p, ice.PS); m.Cmd(web.DREAM, ls[3]).Length() > 0 { r.URL.RawQuery += kit.Select("", "&", len(r.URL.RawQuery) > 1) + "pod=" + ls[3] } - r.URL.Path = "/share/local/bin/ice.bin" + r.URL.Path = "/publish/ice.bin" m.Info("rewrite %v -> %v", p, r.URL.Path) } } else if strings.HasPrefix(p, "/x/") { @@ -162,8 +162,13 @@ func init() { m.Log_CREATE(REPOS, repos) } case "upload-pack": // 下载代码 + aaa.UserRoot(m) + if kit.Select("", arg, 1) == "info" && m.Cmd(web.DREAM, arg[0]).Length() > 0 { + m.Cmd(web.SPACE, arg[0], "web.code.git.status", "submit", m.MergeURL2("/x/")+arg[0]) + } if !kit.FileExists(path.Join(repos)) { - + web.RenderStatus(m, 404, kit.Format("not found: %s", arg[0])) + return } } diff --git a/misc/git/status.go b/misc/git/status.go index 306fe02c..3a34f2eb 100644 --- a/misc/git/status.go +++ b/misc/git/status.go @@ -276,8 +276,8 @@ func init() { "branch_switch": {Name: "branch_switch", Help: "切换", Hand: func(m *ice.Message, arg ...string) { _repos_cmd(m.Spawn(), m.Option(REPOS), "checkout", m.Option(BRANCH)) }}, - "upload": {Name: "upload", Help: "发布", Hand: func(m *ice.Message, arg ...string) { - m.Cmdy(cli.SYSTEM, GIT, PUSH, "-u", m.MergeURL2("/x/")+kit.Select(ice.CONTEXTS, m.Option(ice.MSG_USERPOD))) + "submit": {Name: "submit", Help: "发布", Hand: func(m *ice.Message, arg ...string) { + m.Cmdy(cli.SYSTEM, GIT, PUSH, "-u", kit.Select(m.MergeURL2("/x/")+kit.Select(ice.CONTEXTS, m.Option(ice.MSG_USERPOD)), arg, 0)) m.Cmdy(code.PUBLISH, ice.CONTEXTS, ice.MISC, ice.CORE) }}, BRANCH: {Name: "branch", Help: "分支", Hand: func(m *ice.Message, arg ...string) { @@ -307,7 +307,7 @@ func init() { }}, }, Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) { if len(arg) == 0 { - m.Action(PULL, MAKE, PUSH, TAGS, STASH, PIE, "upload") + m.Action(PULL, MAKE, PUSH, TAGS, STASH, PIE, "submit") files, adds, dels, last := _status_list(m) m.Status("files", files, "adds", adds, "dels", dels, "last", last.Format(ice.MOD_TIME))