1
0
mirror of https://shylinux.com/x/icebergs synced 2025-04-25 09:08:06 +08:00
This commit is contained in:
IT 老营长 @云轩领航-创始人 2024-04-20 21:57:46 +08:00
parent a404a7cb08
commit cfec29c68d
14 changed files with 24 additions and 42 deletions

View File

@ -145,7 +145,7 @@ func FileCmd(dir string) string {
func AddFileCmd(dir, key string) {
if ls := strings.SplitN(path.Join(kit.Slice(kit.Split(FileCmd(dir), nfs.PS), 1, 4)...), mdb.AT, 2); len(ls) > 1 {
_ls := strings.Split(FileCmd(dir), mdb.AT+ls[1]+nfs.PS)
ice.Info.File[path.Join(nfs.REQUIRE_USR, path.Base(_ls[0]), _ls[1])] = key
ice.Info.File[path.Join(nfs.P, nfs.USR, path.Base(_ls[0]), _ls[1])] = key
ice.Info.Gomod[ls[0]] = ls[1]
} else {
ice.Info.File[FileCmd(dir)] = key
@ -155,9 +155,9 @@ func GetFileCmd(dir string) string {
if strings.HasPrefix(dir, ice.REQUIRE+nfs.PS) {
dir = nfs.PS + dir
} else if strings.HasPrefix(dir, ice.ISH_PLUGED) {
dir = path.Join(nfs.PS, ice.REQUIRE, strings.TrimPrefix(dir, ice.ISH_PLUGED))
dir = path.Join(nfs.P, strings.TrimPrefix(dir, ice.ISH_PLUGED))
}
for _, dir := range []string{dir, path.Join(nfs.PS, ice.REQUIRE, ice.Info.Make.Module, dir), path.Join(nfs.PS, ice.REQUIRE, ice.Info.Make.Module, ice.SRC, dir)} {
for _, dir := range []string{dir, path.Join(nfs.P, ice.Info.Make.Module, dir), path.Join(nfs.P, ice.Info.Make.Module, ice.SRC, dir)} {
if cmd, ok := ice.Info.File[FileCmd(dir)]; ok {
return cmd
}
@ -169,7 +169,7 @@ func GetFileCmd(dir string) string {
return ""
}
func GetCmdHelp(m *ice.Message, cmds string) (file string) {
file = strings.TrimPrefix(m.FileURI(kit.ExtChange(GetCmdFile(m, cmds), nfs.SHY)), nfs.REQUIRE)
file = kit.TrimPrefix(m.FileURI(kit.ExtChange(GetCmdFile(m, cmds), nfs.SHY)), nfs.P, nfs.REQUIRE)
if !nfs.Exists(m, path.Join(nfs.USR_LEARNING_PORTAL, "commands", strings.TrimPrefix(file, nfs.USR_ICEBERGS)), func(p string) { file = p }) {
kit.If(!nfs.Exists(m, file), func() { file = "" })
}
@ -177,8 +177,8 @@ func GetCmdHelp(m *ice.Message, cmds string) (file string) {
}
func GetCmdFile(m *ice.Message, cmds string) (file string) {
m.Search(kit.Select(m.PrefixKey(), cmds), func(key string, cmd *ice.Command) {
if file = strings.TrimPrefix(m.FileURI(kit.Split(cmd.FileLine(), nfs.DF)[0]), nfs.REQUIRE); !nfs.Exists(m, file) {
file = path.Join(nfs.REQUIRE, file)
if file = kit.TrimPrefix(m.FileURI(kit.Split(cmd.FileLine(), nfs.DF)[0]), nfs.P); !nfs.Exists(m, file) {
file = path.Join(nfs.P, file)
}
})
return

View File

@ -269,8 +269,8 @@ func SplitPath(m *ice.Message, p string) []string {
p = strings.TrimPrefix(p, P)
}
line := kit.Select("1", strings.Split(p, DF), 1)
p = strings.TrimPrefix(p, kit.Path("")+PS)
p = strings.Split(p, DF)[0]
p = strings.Split(p, "?")[0]
if ls := kit.Split(kit.Select(ice.SRC_MAIN_GO, p), PS); len(ls) == 1 {
return []string{PWD, ls[0], line}
} else if ls[0] == ice.USR {

View File

@ -1,8 +1,6 @@
package web
import (
"strings"
ice "shylinux.com/x/icebergs"
"shylinux.com/x/icebergs/base/aaa"
"shylinux.com/x/icebergs/base/cli"
@ -150,7 +148,7 @@ func init() {
}, field...)
})
m.RewriteAppend(func(value, key string, index int) string {
if key == mdb.ICONS && strings.HasPrefix(value, nfs.REQUIRE) {
if key == mdb.ICONS && kit.HasPrefix(value, nfs.P, nfs.REQUIRE) {
if domain := m.Appendv(DOMAIN)[index]; domain != "" {
value = kit.MergeURL2(space[domain][mdb.TEXT], value, ice.POD, m.Appendv(mdb.NAME)[index])
}

View File

@ -150,7 +150,7 @@ func IsNotValidFieldShare(m *ice.Message, msg *ice.Message) bool {
func SharePath(m *ice.Message, p string) string {
kit.If(!kit.HasPrefix(p, nfs.PS, ice.HTTP), func() {
if kit.HasPrefix(p, nfs.SRC, nfs.USR) && !kit.HasPrefix(p, nfs.USR_LOCAL) {
p = m.MergeLink(path.Join(nfs.REQUIRE, p), ice.POD, m.Option(ice.MSG_USERPOD))
p = m.MergeLink(path.Join(nfs.P, p), ice.POD, m.Option(ice.MSG_USERPOD))
} else {
p = m.MergeLink(path.Join(SHARE_LOCAL, p), ice.POD, m.Option(ice.MSG_USERPOD))
}

View File

@ -85,7 +85,7 @@ func _space_fork(m *ice.Message) {
}
}
if m.Option(mdb.ICONS) != "" && !kit.HasPrefix(m.Option(mdb.ICONS), nfs.PS, HTTP) {
m.Option(mdb.ICONS, kit.MergeURL(nfs.REQUIRE+m.Option(mdb.ICONS), ice.POD, name))
m.Option(mdb.ICONS, kit.MergeURL(nfs.P+m.Option(mdb.ICONS), ice.POD, name))
}
args := kit.Simple(mdb.TYPE, m.Option(mdb.TYPE), mdb.NAME, name, mdb.TEXT, text, m.OptionSimple(mdb.ICONS, mdb.TIME, nfs.MODULE, nfs.VERSION, cli.DAEMON))
args = append(args, aaa.USERNICK, m.Option(ice.MSG_USERNICK), aaa.USERNAME, m.Option(ice.MSG_USERNAME), aaa.USERROLE, m.Option(ice.MSG_USERROLE))
@ -295,6 +295,7 @@ const SPACE = "space"
func init() {
Index.MergeCommands(ice.Commands{
"m": {Help: "模块", Actions: ApiWhiteAction(), Hand: func(m *ice.Message, arg ...string) { m.Cmdy(nfs.REQUIRE_MODULES, arg) }},
"p": {Help: "资源", Actions: ApiWhiteAction(), Hand: func(m *ice.Message, arg ...string) { ShareLocalFile(m, arg...) }},
"s": {Help: "空间", Actions: ApiWhiteAction(), Hand: func(m *ice.Message, arg ...string) { m.Cmdy(CHAT_POD, arg) }},
"c": {Help: "命令", Actions: ApiWhiteAction(), Hand: func(m *ice.Message, arg ...string) { m.Cmdy(CHAT_CMD, arg) }},

View File

@ -405,7 +405,7 @@ func init() {
}},
})
nfs.TemplateText = func(m *ice.Message, p string) string {
if p := kit.Select(nfs.TemplatePath(m, path.Base(p)), m.Option("_template")); kit.HasPrefix(p, "/require/", ice.HTTP) {
if p := kit.Select(nfs.TemplatePath(m, path.Base(p)), m.Option("_template")); kit.HasPrefix(p, nfs.P, nfs.REQUIRE, ice.HTTP) {
return m.Cmdx(SPIDE, ice.OPS, SPIDE_RAW, http.MethodGet, p)
} else if p == "" {
return ""
@ -418,7 +418,7 @@ func init() {
return p + kit.Select("", nfs.PS, len(arg) == 0)
} else {
p := m.FileURI(ctx.GetCmdFile(m, m.PrefixKey()))
if p := strings.TrimPrefix(path.Join(path.Dir(p), path.Join(arg...)), "/require/"); nfs.Exists(m, p) {
if p := kit.TrimPrefix(path.Join(path.Dir(p), path.Join(arg...)), nfs.P, nfs.REQUIRE); nfs.Exists(m, p) {
return p
}
if ice.Info.Important {
@ -435,7 +435,7 @@ func init() {
}
}
nfs.DocumentText = func(m *ice.Message, p string) string {
if p := nfs.DocumentPath(m, path.Base(p)); kit.HasPrefix(p, "/require/", ice.HTTP) {
if p := nfs.DocumentPath(m, path.Base(p)); kit.HasPrefix(p, nfs.P, nfs.REQUIRE, ice.HTTP) {
return m.Cmdx(SPIDE, ice.DEV, SPIDE_RAW, http.MethodGet, p)
} else {
return m.Cmdx(nfs.CAT, p)

View File

@ -28,8 +28,8 @@ func init() {
}},
INSTALL: {Hand: func(m *ice.Message, arg ...string) {
if !kit.HasPrefixList(arg, ctx.RUN) {
if strings.HasPrefix(m.Option(mdb.ICON), nfs.REQUIRE) {
m.Option(mdb.ICON, strings.TrimSuffix(strings.TrimPrefix(m.Option(mdb.ICON), nfs.REQUIRE), "?pod="+m.Option(mdb.NAME)))
if kit.HasPrefix(m.Option(mdb.ICON), nfs.P, nfs.REQUIRE) {
m.Option(mdb.ICON, strings.TrimSuffix(kit.TrimPrefix(m.Option(mdb.ICON), nfs.P, nfs.REQUIRE), "?pod="+m.Option(mdb.NAME)))
}
m.OptionDefault(nfs.BINARY, m.Option(ORIGIN)+S(m.Option(mdb.NAME)))
m.Cmdy(DREAM, mdb.CREATE, m.OptionSimple(mdb.NAME, mdb.ICON, nfs.REPOS, nfs.BINARY))

View File

@ -608,7 +608,7 @@ func StackHandler(m *ice.Message, arg ...string) {
if len(script) > 0 {
p := ice.USR_SCRIPT + m.PrefixKey() + nfs.PS + "list.js"
m.Cmd(nfs.SAVE, p, kit.Dict(nfs.CONTENT, strings.Join(script, lex.NL)))
s.value(m, "_script", "/require/"+p)
s.value(m, "_script", nfs.P+p)
}
cmd := m.Commands("")
kit.For(s.peekf().value, func(k string, v Any) {

View File

@ -10,7 +10,7 @@ import (
kit "shylinux.com/x/toolkits"
)
func require(arg ...string) string { return path.Join(nfs.PS, ice.REQUIRE, path.Join(arg...)) }
func require(arg ...string) string { return nfs.P+path.Join(arg...) }
const HTML = "html"

View File

@ -104,24 +104,9 @@ func init() {
}},
}), Hand: func(m *ice.Message, arg ...string) {
if kit.HasPrefix(arg[0], nfs.VOLCANOS, nfs.REQUIRE, nfs.P, ice.HTTP) {
if kit.HasPrefix(arg[0], ice.HTTP) && strings.Contains(arg[0], nfs.PLUGIN) && !strings.Contains(arg[0], nfs.VOLCANOS_PLUGIN) {
arg[0] = strings.Replace(arg[0], nfs.PLUGIN, nfs.VOLCANOS_PLUGIN, 1)
} else if kit.HasPrefix(arg[0], nfs.REQUIRE_SRC) {
m.Options(nfs.PATH, nfs.SRC, nfs.FILE, strings.Split(strings.TrimPrefix(arg[0], nfs.REQUIRE_SRC), "?")[0])
} else if kit.HasPrefix(arg[0], nfs.REQUIRE_USR) {
ls := kit.Split(arg[0], nfs.PS)
m.Options(nfs.PATH, nfs.USR+ls[2]+nfs.PS, nfs.FILE, strings.Split(strings.TrimPrefix(arg[0], nfs.REQUIRE_USR+ls[2]+nfs.PS), "?")[0])
} else if kit.HasPrefix(arg[0], nfs.REQUIRE) {
ls := strings.Split(strings.Split(strings.TrimPrefix(arg[0], nfs.REQUIRE), "?")[0], nfs.SRC)
m.Options(nfs.PATH, kit.Join(kit.Slice(ls, 0, -1), nfs.PS)+nfs.SRC, nfs.FILE, kit.Select("", ls, -1))
} else if kit.HasPrefix(arg[0], nfs.P) {
ls := kit.Split(arg[0], nfs.PS)
m.Debug("what %v", ls)
if ls[1] == ice.SRC {
m.Options(nfs.PATH, nfs.SRC, nfs.FILE, kit.Join(kit.Slice(ls, 2, -1), nfs.PS))
} else {
m.Options(nfs.PATH, kit.Join(kit.Slice(ls, 1, 3), nfs.PS)+nfs.PS, nfs.FILE, kit.Join(kit.Slice(ls, 3, -1), nfs.PS))
}
if !kit.HasPrefix(arg[0], ice.HTTP) {
ls := nfs.SplitPath(m, arg[0])
m.Options(nfs.PATH, ls[0], nfs.FILE, ls[1])
}
m.Echo(m.Cmdx(web.SPIDE, ice.OPS, web.SPIDE_RAW, http.MethodGet, arg[0]))
m.Options("mode", "simple", lex.PARSE, kit.Ext(kit.ParseURL(arg[0]).Path))

View File

@ -60,8 +60,6 @@ func init() {
web.Index.MergeCommands(ice.Commands{ice.CTX_INIT: {Hand: func(m *ice.Message, arg ...string) { aaa.White(m, nfs.REQUIRE) }},
nfs.REQUIRE_SRC: {Hand: func(m *ice.Message, arg ...string) { web.ShareLocalFile(m, ice.SRC, path.Join(arg...)) }},
nfs.REQUIRE_USR: {Hand: func(m *ice.Message, arg ...string) { web.ShareLocalFile(m, ice.USR, path.Join(arg...)) }},
"m": {Actions: web.ApiWhiteAction(), Hand: func(m *ice.Message, arg ...string) { m.Cmdy(nfs.REQUIRE_MODULES, arg) }},
"/p/modules/": {Hand: func(m *ice.Message, arg ...string) { m.Cmdy(nfs.REQUIRE_MODULES, arg) }},
nfs.REQUIRE_MODULES: {Hand: func(m *ice.Message, arg ...string) {
p := path.Join(nfs.USR_MODULES, path.Join(arg...))
kit.If(!nfs.Exists(m, p), func() {

View File

@ -52,7 +52,7 @@ func _portal_commands(m *ice.Message, arg ...string) {
if p := path.Join(nfs.USR_LEARNING_PORTAL, path.Join(arg...), mod, last, strings.Replace(cmd, nfs.PT, nfs.PS, -1)+".shy"); nfs.Exists(m, p) {
text = append(text, kit.Format(" %s %s.shy", cmd, cmd))
} else if p, ok := help[last+nfs.PT+cmd]; ok {
text = append(text, kit.Format(" %s %s", cmd, strings.TrimPrefix(m.FileURI(p), "/require/")))
text = append(text, kit.Format(" %s %s", cmd, kit.TrimPrefix(m.FileURI(p), nfs.P, nfs.REQUIRE)))
}
}
}

View File

@ -639,7 +639,7 @@ func init() {
m.Cmd(web.DREAM).Table(func(value ice.Maps) {
if value[cli.RESTART] == "always" {
value[nfs.BINARY] = web.UserHost(m) + web.S(value[mdb.NAME])
value[mdb.ICON] = strings.TrimPrefix(kit.Split(value[mdb.ICON], "?")[0], "/require/")
value[mdb.ICON] = kit.TrimPrefix(kit.Split(value[mdb.ICON], "?")[0], nfs.P, nfs.REQUIRE)
value[nfs.REPOS] = _repos_remote(m, _repos_origin(m, _repos_open(m, path.Join(ice.USR_LOCAL_WORK, value[mdb.NAME]))))
m.Cmd(web.SPACE, m.Option(mdb.NAME), web.DREAM, mdb.CREATE, mdb.NAME, value[mdb.NAME], value)
}

View File

@ -58,7 +58,7 @@ func _ide_autogen_pages(m *ice.Message) {
head_wxml, foot_wxml, wxml := nfs.TemplateText(m, "pages_head.wxml"), nfs.TemplateText(m, "pages_foot.wxml"), nfs.TemplateText(m, "pages.wxml")
m.Travel(func(_ *ice.Context, s *ice.Context, key string, cmd *ice.Command) {
if h, ok := cmd.Actions[PAGES]; ok {
file := path.Join(path.Dir(strings.TrimPrefix(m.Resource(m.FileURI(cmd.FileLine())), nfs.REQUIRE)), kit.Select(key+".js", h.Name))
file := path.Join(path.Dir(kit.TrimPrefix(m.Resource(m.FileURI(cmd.FileLine())), nfs.P, nfs.REQUIRE)), kit.Select(key+".js", h.Name))
if !nfs.Exists(m, file) {
return
}