mirror of
https://shylinux.com/x/icebergs
synced 2025-05-02 19:47:02 +08:00
add some
This commit is contained in:
parent
914292f072
commit
2794463664
@ -112,9 +112,10 @@ func Command(m *ice.Message, arg ...string) {
|
||||
}
|
||||
|
||||
func FileURI(dir string) string {
|
||||
kit.If(runtime.GOOS == ice.WINDOWS, func() { dir = strings.ReplaceAll(dir, "\\", nfs.PS) })
|
||||
if dir == "" {
|
||||
return ""
|
||||
} else if kit.HasPrefix(dir, nfs.PS, ice.HTTP) {
|
||||
return dir
|
||||
} else if strings.Contains(dir, "/pkg/mod/") {
|
||||
dir = strings.Split(dir, "/pkg/mod/")[1]
|
||||
} else if ice.Info.Make.Path != "" && strings.HasPrefix(dir, ice.Info.Make.Path) {
|
||||
@ -123,10 +124,12 @@ func FileURI(dir string) string {
|
||||
dir = strings.TrimPrefix(dir, kit.Path("")+nfs.PS)
|
||||
} else if strings.HasPrefix(dir, ice.ISH_PLUGED) {
|
||||
dir = strings.TrimPrefix(dir, ice.ISH_PLUGED)
|
||||
} else if kit.HasPrefix(dir, nfs.PS, ice.HTTP) {
|
||||
return dir
|
||||
}
|
||||
return path.Join(nfs.PS, ice.REQUIRE, dir)
|
||||
if strings.HasPrefix(dir, ice.USR_VOLCANOS) {
|
||||
return strings.TrimPrefix(dir, ice.USR)
|
||||
} else {
|
||||
return path.Join(nfs.PS, ice.REQUIRE, dir)
|
||||
}
|
||||
}
|
||||
func FileCmd(dir string) string {
|
||||
if strings.Index(dir, ":") == 1 {
|
||||
|
@ -211,6 +211,7 @@ var bind = []string{
|
||||
}
|
||||
|
||||
func Relative(m *ice.Message, p string) string {
|
||||
p = kit.TrimPrefix(p, kit.Path("")+PS)
|
||||
for i := 0; i < len(bind); i += 2 {
|
||||
if strings.HasPrefix(p, bind[i]) {
|
||||
if _p := kit.ExtChange(strings.Replace(p, bind[i], bind[i+1], 1), JS); Exists(m, _p) {
|
||||
|
@ -7,7 +7,6 @@ import (
|
||||
"shylinux.com/x/icebergs/base/aaa"
|
||||
"shylinux.com/x/icebergs/base/mdb"
|
||||
"shylinux.com/x/icebergs/base/nfs"
|
||||
kit "shylinux.com/x/toolkits"
|
||||
)
|
||||
|
||||
const DRAW = "draw"
|
||||
@ -16,17 +15,12 @@ func init() {
|
||||
Index.MergeCommands(ice.Commands{
|
||||
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) {
|
||||
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) {
|
||||
defer m.Echo("<!DOCTYPE html><html><body>").Echo("</body></html>")
|
||||
m.Cmdy(nfs.CAT, path.Join(arg[2], arg[1]))
|
||||
}},
|
||||
}, aaa.RoleAction(), WikiAction("", nfs.SVG)), Hand: func(m *ice.Message, arg ...string) {
|
||||
kit.If(!_wiki_list(m, arg...), func() {
|
||||
_wiki_show(m, arg[0])
|
||||
kit.If(m.IsErr(), func() { m.Option(ice.MSG_OUTPUT, "") })
|
||||
})
|
||||
}},
|
||||
}, aaa.RoleAction(), WikiAction("", nfs.SVG))},
|
||||
})
|
||||
}
|
||||
|
@ -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))
|
||||
return true
|
||||
} 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
|
||||
}
|
||||
}
|
||||
@ -89,6 +96,9 @@ func WikiAction(dir string, ext ...string) ice.Actions {
|
||||
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))))
|
||||
}},
|
||||
mdb.SELECT: {Hand: func(m *ice.Message, arg ...string) {
|
||||
kit.If(!_wiki_list(m, arg...), func() { _wiki_show(m, arg[0]) })
|
||||
}},
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user