1
0
mirror of https://shylinux.com/x/icebergs synced 2025-05-04 04:17:01 +08:00
This commit is contained in:
IT 老营长 @云轩领航-创始人 2023-10-08 09:15:16 +08:00
parent 914292f072
commit 2794463664
4 changed files with 21 additions and 13 deletions

View File

@ -112,9 +112,10 @@ func Command(m *ice.Message, arg ...string) {
} }
func FileURI(dir string) string { func FileURI(dir string) string {
kit.If(runtime.GOOS == ice.WINDOWS, func() { dir = strings.ReplaceAll(dir, "\\", nfs.PS) })
if dir == "" { if dir == "" {
return "" return ""
} else if kit.HasPrefix(dir, nfs.PS, ice.HTTP) {
return dir
} else if strings.Contains(dir, "/pkg/mod/") { } else if strings.Contains(dir, "/pkg/mod/") {
dir = strings.Split(dir, "/pkg/mod/")[1] dir = strings.Split(dir, "/pkg/mod/")[1]
} else if ice.Info.Make.Path != "" && strings.HasPrefix(dir, ice.Info.Make.Path) { } else if ice.Info.Make.Path != "" && strings.HasPrefix(dir, ice.Info.Make.Path) {
@ -123,11 +124,13 @@ func FileURI(dir string) string {
dir = strings.TrimPrefix(dir, kit.Path("")+nfs.PS) dir = strings.TrimPrefix(dir, kit.Path("")+nfs.PS)
} else if strings.HasPrefix(dir, ice.ISH_PLUGED) { } else if strings.HasPrefix(dir, ice.ISH_PLUGED) {
dir = strings.TrimPrefix(dir, ice.ISH_PLUGED) dir = strings.TrimPrefix(dir, ice.ISH_PLUGED)
} else if kit.HasPrefix(dir, nfs.PS, ice.HTTP) {
return dir
} }
if strings.HasPrefix(dir, ice.USR_VOLCANOS) {
return strings.TrimPrefix(dir, ice.USR)
} else {
return path.Join(nfs.PS, ice.REQUIRE, dir) return path.Join(nfs.PS, ice.REQUIRE, dir)
} }
}
func FileCmd(dir string) string { func FileCmd(dir string) string {
if strings.Index(dir, ":") == 1 { if strings.Index(dir, ":") == 1 {
return FileURI(kit.ExtChange(strings.Join(kit.Slice(strings.Split(dir, ":"), 0, 2), ":"), nfs.GO)) return FileURI(kit.ExtChange(strings.Join(kit.Slice(strings.Split(dir, ":"), 0, 2), ":"), nfs.GO))

View File

@ -211,6 +211,7 @@ var bind = []string{
} }
func Relative(m *ice.Message, p string) string { func Relative(m *ice.Message, p string) string {
p = kit.TrimPrefix(p, kit.Path("")+PS)
for i := 0; i < len(bind); i += 2 { for i := 0; i < len(bind); i += 2 {
if strings.HasPrefix(p, bind[i]) { if strings.HasPrefix(p, bind[i]) {
if _p := kit.ExtChange(strings.Replace(p, bind[i], bind[i+1], 1), JS); Exists(m, _p) { if _p := kit.ExtChange(strings.Replace(p, bind[i], bind[i+1], 1), JS); Exists(m, _p) {

View File

@ -7,7 +7,6 @@ import (
"shylinux.com/x/icebergs/base/aaa" "shylinux.com/x/icebergs/base/aaa"
"shylinux.com/x/icebergs/base/mdb" "shylinux.com/x/icebergs/base/mdb"
"shylinux.com/x/icebergs/base/nfs" "shylinux.com/x/icebergs/base/nfs"
kit "shylinux.com/x/toolkits"
) )
const DRAW = "draw" const DRAW = "draw"
@ -16,17 +15,12 @@ func init() {
Index.MergeCommands(ice.Commands{ Index.MergeCommands(ice.Commands{
DRAW: {Name: "draw path=src/main.svg pid list save actions", Icon: "Grapher.png", Help: "思维导图", Actions: ice.MergeActions(ice.Actions{ DRAW: {Name: "draw path=src/main.svg pid list save actions", Icon: "Grapher.png", Help: "思维导图", Actions: ice.MergeActions(ice.Actions{
ice.CTX_INIT: {Hand: func(m *ice.Message, arg ...string) { ice.CTX_INIT: {Hand: func(m *ice.Message, arg ...string) {
m.Cmd(mdb.RENDER, mdb.CREATE, mdb.TYPE, nfs.SVG, mdb.NAME, m.PrefixKey()) m.Cmd(mdb.RENDER, mdb.CREATE, nfs.SVG, m.PrefixKey())
}}, }},
mdb.RENDER: {Hand: func(m *ice.Message, arg ...string) { mdb.RENDER: {Hand: func(m *ice.Message, arg ...string) {
defer m.Echo("<!DOCTYPE html><html><body>").Echo("</body></html>") defer m.Echo("<!DOCTYPE html><html><body>").Echo("</body></html>")
m.Cmdy(nfs.CAT, path.Join(arg[2], arg[1])) m.Cmdy(nfs.CAT, path.Join(arg[2], arg[1]))
}}, }},
}, aaa.RoleAction(), WikiAction("", nfs.SVG)), Hand: func(m *ice.Message, arg ...string) { }, aaa.RoleAction(), WikiAction("", nfs.SVG))},
kit.If(!_wiki_list(m, arg...), func() {
_wiki_show(m, arg[0])
kit.If(m.IsErr(), func() { m.Option(ice.MSG_OUTPUT, "") })
})
}},
}) })
} }

View File

@ -40,7 +40,14 @@ func _wiki_list(m *ice.Message, arg ...string) bool {
m.Copy(m.Cmd(nfs.DIR, kit.Slice(arg, 0, 1), kit.Dict(nfs.DIR_TYPE, nfs.CAT, nfs.DIR_REG, mdb.Config(m, lex.REGEXP))).SortStr(nfs.PATH)) m.Copy(m.Cmd(nfs.DIR, kit.Slice(arg, 0, 1), kit.Dict(nfs.DIR_TYPE, nfs.CAT, nfs.DIR_REG, mdb.Config(m, lex.REGEXP))).SortStr(nfs.PATH))
return true return true
} else { } else {
ctx.DisplayLocal(m, path.Join(kit.PathName(2), kit.Keys(kit.FileName(2), nfs.JS))) p := ctx.GetCmdFile(m, m.PrefixKey())
m.Debug("what %v", p)
p = nfs.Relative(m, p)
m.Debug("what %v", p)
p = ctx.FileURI(p)
m.Debug("what %v", p)
ctx.Display(m, ctx.FileURI(nfs.Relative(m, ctx.GetCmdFile(m, m.PrefixKey()))))
// ctx.DisplayLocal(m, path.Join(kit.PathName(2), kit.Keys(kit.FileName(2), nfs.JS)))
return false return false
} }
} }
@ -89,6 +96,9 @@ func WikiAction(dir string, ext ...string) ice.Actions {
nfs.TRASH: {Hand: func(m *ice.Message, arg ...string) { nfs.TRASH: {Hand: func(m *ice.Message, arg ...string) {
nfs.Trash(m, _wiki_path(m, kit.Select("some", kit.Select(m.Option(nfs.PATH), arg, 0)))) nfs.Trash(m, _wiki_path(m, kit.Select("some", kit.Select(m.Option(nfs.PATH), arg, 0))))
}}, }},
mdb.SELECT: {Hand: func(m *ice.Message, arg ...string) {
kit.If(!_wiki_list(m, arg...), func() { _wiki_show(m, arg[0]) })
}},
} }
} }