forked from x/icebergs
opt website
This commit is contained in:
parent
55529c00f0
commit
20ad3d9cf1
@ -91,6 +91,7 @@ const (
|
||||
COST = "cost"
|
||||
BACK = "back"
|
||||
FROM = "from"
|
||||
MAIN = "main"
|
||||
|
||||
OPEN = "open"
|
||||
CLOSE = "close"
|
||||
|
@ -127,13 +127,18 @@ const (
|
||||
TAGS = "tags"
|
||||
)
|
||||
const (
|
||||
HTML = "html"
|
||||
CSS = "css"
|
||||
JS = "js"
|
||||
GO = "go"
|
||||
SH = "sh"
|
||||
CSV = "csv"
|
||||
JSON = "json"
|
||||
HTML = ice.HTML
|
||||
CSS = ice.CSS
|
||||
JS = ice.JS
|
||||
GO = ice.GO
|
||||
SH = ice.SH
|
||||
CSV = ice.CSV
|
||||
JSON = ice.JSON
|
||||
TXT = "txt"
|
||||
SHY = "shy"
|
||||
SVG = "svg"
|
||||
|
||||
PWD = "./"
|
||||
)
|
||||
|
||||
const (
|
||||
|
@ -155,7 +155,7 @@ func _dir_list(m *ice.Message, root string, name string, level int, deep bool, d
|
||||
return m
|
||||
}
|
||||
func _dir_search(m *ice.Message, kind, name string) {
|
||||
msg := _dir_list(m.Spawn(), ice.PWD, "", 0, true, TYPE_BOTH, nil, kit.Split("time,type,name"))
|
||||
msg := _dir_list(m.Spawn(), PWD, "", 0, true, TYPE_BOTH, nil, kit.Split("time,type,name"))
|
||||
msg.Table(func(index int, value map[string]string, head []string) {
|
||||
if !strings.Contains(value[mdb.NAME], name) {
|
||||
return
|
||||
@ -169,10 +169,10 @@ func _dir_search(m *ice.Message, kind, name string) {
|
||||
|
||||
func Dir(m *ice.Message, sort string) *ice.Message {
|
||||
m.Option(DIR_TYPE, TYPE_DIR)
|
||||
m.Copy(m.Cmd(DIR, ice.PWD).Sort(sort))
|
||||
m.Copy(m.Cmd(DIR, PWD).Sort(sort))
|
||||
|
||||
m.Option(DIR_TYPE, TYPE_CAT)
|
||||
m.Copy(m.Cmd(DIR, ice.PWD).Sort(sort))
|
||||
m.Copy(m.Cmd(DIR, PWD).Sort(sort))
|
||||
return m
|
||||
}
|
||||
|
||||
@ -222,7 +222,7 @@ func init() {
|
||||
if m.Option(DIR_ROOT) != "" {
|
||||
m.Info("dir_root: %v", m.Option(DIR_ROOT))
|
||||
}
|
||||
_dir_list(m, kit.Select(ice.PWD, m.Option(DIR_ROOT)), kit.Select(ice.PWD, arg, 0),
|
||||
_dir_list(m, kit.Select(PWD, m.Option(DIR_ROOT)), kit.Select(PWD, arg, 0),
|
||||
0, m.Option(DIR_DEEP) == ice.TRUE, kit.Select(TYPE_BOTH, m.Option(DIR_TYPE)), kit.Regexp(m.Option(DIR_REG)),
|
||||
kit.Split(kit.Select(kit.Select("time,path,size,action", m.OptionFields()), kit.Join(kit.Slice(arg, 1)))))
|
||||
m.SortTimeR(mdb.TIME)
|
||||
|
@ -11,8 +11,8 @@ const FIND = "find"
|
||||
func init() {
|
||||
Index.Merge(&ice.Context{Commands: map[string]*ice.Command{
|
||||
FIND: {Name: "find path word auto", Help: "搜索", Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
|
||||
for _, file := range strings.Split(m.Cmdx("cli.system", FIND, ice.PWD, "-name", arg[1]), ice.NL) {
|
||||
m.Push(FILE, strings.TrimPrefix(file, ice.PWD))
|
||||
for _, file := range strings.Split(m.Cmdx("cli.system", FIND, PWD, "-name", arg[1]), ice.NL) {
|
||||
m.Push(FILE, strings.TrimPrefix(file, PWD))
|
||||
}
|
||||
}},
|
||||
}})
|
||||
|
@ -51,7 +51,7 @@ func init() {
|
||||
mdb.INPUTS: {Name: "inputs", Help: "补全", Hand: func(m *ice.Message, arg ...string) {
|
||||
switch arg[0] {
|
||||
case FILE:
|
||||
m.Cmdy(DIR, kit.Select(ice.PWD, arg, 1), PATH).RenameAppend(PATH, FILE)
|
||||
m.Cmdy(DIR, kit.Select(PWD, arg, 1), PATH).RenameAppend(PATH, FILE)
|
||||
m.ProcessAgain()
|
||||
case mdb.NAME:
|
||||
m.Push(arg[0], kit.Split(m.Option(FILE), ice.PS))
|
||||
|
@ -57,7 +57,7 @@ func init() {
|
||||
}, Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
|
||||
if len(arg) == 0 {
|
||||
m.Option(nfs.DIR_ROOT, m.Conf(cli.DAEMON, kit.Keym(nfs.PATH)))
|
||||
m.Cmd(nfs.DIR, ice.PWD, "time,path,size").Table(func(index int, value map[string]string, head []string) {
|
||||
m.Cmd(nfs.DIR, nfs.PWD, "time,path,size").Table(func(index int, value map[string]string, head []string) {
|
||||
m.Push(mdb.TIME, value[mdb.TIME])
|
||||
m.Push(PORT, path.Base(value[nfs.PATH]))
|
||||
m.Push(nfs.SIZE, value[nfs.SIZE])
|
||||
|
@ -75,6 +75,9 @@ func _dream_show(m *ice.Message, name string) {
|
||||
return // 已经启动
|
||||
}
|
||||
|
||||
m.ToastProcess()
|
||||
defer m.ToastSuccess()
|
||||
|
||||
m.Optionv(cli.CMD_DIR, p)
|
||||
m.Optionv(cli.CMD_ENV, kit.Simple(
|
||||
cli.CTX_DEV, "http://:"+m.Cmd(SERVE, ice.OptionFields("")).Append(tcp.PORT),
|
||||
|
@ -207,6 +207,47 @@ func _space_search(m *ice.Message, kind, name, text string, arg ...string) {
|
||||
})
|
||||
})
|
||||
}
|
||||
func _space_fork(m *ice.Message) {
|
||||
if s, e := websocket.Upgrade(m.W, m.R, nil, kit.Int(m.Config("buffer.r")), kit.Int(m.Config("buffer.w"))); m.Assert(e) {
|
||||
text := kit.Select(s.RemoteAddr().String(), m.Option(ice.MSG_USERADDR))
|
||||
name := m.Option(mdb.NAME, kit.ReplaceAll(kit.Select(text, m.Option(mdb.NAME)), ".", "_", ":", "_"))
|
||||
kind := kit.Select(WORKER, m.Option(mdb.TYPE))
|
||||
args := append([]string{mdb.TYPE, kind, mdb.NAME, name}, m.OptionSimple(SHARE, RIVER)...)
|
||||
|
||||
m.Go(func() {
|
||||
h := m.Rich(SPACE, nil, kit.Dict(SOCKET, s, mdb.TEXT, text, args))
|
||||
m.Log_CREATE(SPACE, name, mdb.TYPE, kind)
|
||||
|
||||
switch kind {
|
||||
case CHROME: // 交互节点
|
||||
defer m.Confv(SPACE, kit.Keys(mdb.HASH, h), "")
|
||||
m.Go(func(msg *ice.Message) {
|
||||
switch m.Option(ice.CMD) {
|
||||
case cli.PWD:
|
||||
link := kit.MergeURL(_space_domain(msg), aaa.GRANT, name)
|
||||
msg.Sleep300ms(SPACE, name, cli.PWD, name, link, msg.Cmdx(cli.QRCODE, link))
|
||||
case "sso":
|
||||
link := _space_domain(msg)
|
||||
ls := strings.Split(kit.ParseURL(link).Path, ice.PS)
|
||||
link = kit.MergeURL2(_space_domain(msg), "/chat/sso", "space", kit.Select("", ls, 3), "back", m.Option(ice.MSG_USERWEB))
|
||||
msg.Sleep300ms(SPACE, name, cli.PWD, name, link, msg.Cmdx(cli.QRCODE, link))
|
||||
default:
|
||||
msg.Sleep300ms(SPACE, name, cli.PWD, name)
|
||||
}
|
||||
})
|
||||
case WORKER: // 工作节点
|
||||
m.Event(DREAM_START, args...)
|
||||
defer m.Event(DREAM_STOP, args...)
|
||||
defer m.Cmd(DREAM, DREAM_STOP, args)
|
||||
default: // 服务节点
|
||||
m.Event(SPACE_START, args...)
|
||||
defer m.Event(SPACE_STOP, args...)
|
||||
}
|
||||
|
||||
_space_handle(m, false, m.Target().Server().(*Frame).send, s, name)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
const (
|
||||
CHROME = "chrome"
|
||||
@ -268,46 +309,7 @@ func init() {
|
||||
_space_send(m, arg[0], arg[1:]...)
|
||||
}},
|
||||
"/space/": {Name: "/space/ type name share river", Help: "空间站", Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
|
||||
if s, e := websocket.Upgrade(m.W, m.R, nil, kit.Int(m.Config("buffer.r")), kit.Int(m.Config("buffer.w"))); m.Assert(e) {
|
||||
text := kit.Select(s.RemoteAddr().String(), m.Option(ice.MSG_USERADDR))
|
||||
name := m.Option(mdb.NAME, kit.ReplaceAll(kit.Select(text, m.Option(mdb.NAME)), ".", "_", ":", "_"))
|
||||
kind := kit.Select(WORKER, m.Option(mdb.TYPE))
|
||||
args := append([]string{mdb.TYPE, kind, mdb.NAME, name}, m.OptionSimple(SHARE, RIVER)...)
|
||||
|
||||
m.Go(func() {
|
||||
m.Rich(SPACE, nil, kit.Dict(SOCKET, s, mdb.TEXT, text, args))
|
||||
// h := m.Rich(SPACE, nil, kit.Dict(SOCKET, s, mdb.TEXT, text, args))
|
||||
// defer m.Confv(SPACE, kit.Keys(mdb.HASH, h), "")
|
||||
m.Log_CREATE(SPACE, name, mdb.TYPE, kind)
|
||||
|
||||
switch kind {
|
||||
case CHROME: // 交互节点
|
||||
m.Go(func(msg *ice.Message) {
|
||||
switch m.Option(ice.CMD) {
|
||||
case cli.PWD:
|
||||
link := kit.MergeURL(_space_domain(msg), aaa.GRANT, name)
|
||||
msg.Sleep300ms(SPACE, name, cli.PWD, name, link, msg.Cmdx(cli.QRCODE, link))
|
||||
case "sso":
|
||||
link := _space_domain(msg)
|
||||
ls := strings.Split(kit.ParseURL(link).Path, ice.PS)
|
||||
link = kit.MergeURL2(_space_domain(msg), "/chat/sso", "space", kit.Select("", ls, 3), "back", m.Option(ice.MSG_USERWEB))
|
||||
msg.Sleep300ms(SPACE, name, cli.PWD, name, link, msg.Cmdx(cli.QRCODE, link))
|
||||
default:
|
||||
msg.Sleep300ms(SPACE, name, cli.PWD, name)
|
||||
}
|
||||
})
|
||||
case WORKER: // 工作节点
|
||||
m.Event(DREAM_START, args...)
|
||||
defer m.Event(DREAM_STOP, args...)
|
||||
defer m.Cmd(DREAM, DREAM_STOP, args)
|
||||
default: // 服务节点
|
||||
m.Event(SPACE_START, args...)
|
||||
defer m.Event(SPACE_STOP, args...)
|
||||
}
|
||||
|
||||
_space_handle(m, false, c.Server().(*Frame).send, s, name)
|
||||
})
|
||||
}
|
||||
_space_fork(m)
|
||||
}},
|
||||
}})
|
||||
}
|
||||
|
1
conf.go
1
conf.go
@ -79,7 +79,6 @@ const ( // DIR
|
||||
VAR = "var"
|
||||
USR = "usr"
|
||||
|
||||
PWD = "./"
|
||||
HTML = "html"
|
||||
CSS = "css"
|
||||
JS = "js"
|
||||
|
@ -16,7 +16,7 @@ const CMD = "cmd"
|
||||
|
||||
func init() {
|
||||
Index.Merge(&ice.Context{Configs: map[string]*ice.Config{
|
||||
CMD: {Name: CMD, Help: "命令", Value: kit.Data(mdb.SHORT, "type", nfs.PATH, ice.PWD)},
|
||||
CMD: {Name: CMD, Help: "命令", Value: kit.Data(mdb.SHORT, "type", nfs.PATH, nfs.PWD)},
|
||||
}, Commands: map[string]*ice.Command{
|
||||
"/cmd/": {Name: "/cmd/", Help: "命令", Action: ice.MergeAction(map[string]*ice.Action{
|
||||
ice.CTX_INIT: {Name: "_init", Help: "初始化", Hand: func(m *ice.Message, arg ...string) {
|
||||
@ -64,7 +64,7 @@ func init() {
|
||||
} else if strings.HasSuffix(m.R.URL.Path, ice.PS) {
|
||||
m.ProcessLocation("../")
|
||||
} else {
|
||||
m.ProcessLocation(ice.PWD)
|
||||
m.ProcessLocation(nfs.PWD)
|
||||
}
|
||||
}},
|
||||
}, mdb.HashAction()), Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
|
||||
|
@ -33,13 +33,13 @@ func init() {
|
||||
}, Commands: map[string]*ice.Command{
|
||||
"/div/": {Name: "/div/", Help: "定制", Action: ice.MergeAction(ctx.CmdAction()), Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
|
||||
switch p := path.Join(arg...); kit.Ext(kit.Select("", p)) {
|
||||
case "html":
|
||||
case nfs.HTML:
|
||||
m.RenderDownload(p)
|
||||
case "css":
|
||||
case nfs.CSS:
|
||||
m.RenderResult(_div_template, m.Cmdx(nfs.CAT, p), m.Cmdx(nfs.CAT, strings.ReplaceAll(p, ".css", ".js")))
|
||||
case "js":
|
||||
case nfs.JS:
|
||||
m.RenderResult(_div_template, m.Cmdx(nfs.CAT, strings.ReplaceAll(p, ".js", ".css")), m.Cmdx(nfs.CAT, p))
|
||||
case "json":
|
||||
case nfs.JSON:
|
||||
m.RenderResult(_div_template2, kit.Format(kit.UnMarshal(m.Cmdx(nfs.CAT, p))))
|
||||
default:
|
||||
m.RenderCmd(m.PrefixKey(), p)
|
||||
|
@ -118,16 +118,19 @@ func init() {
|
||||
m.Cmd(aaa.SESS, mdb.REMOVE, ice.OptionHash(m.Option(ice.MSG_SESSID)))
|
||||
}},
|
||||
aaa.USERNICK: {Name: "usernick", Help: "用户昵称", Hand: func(m *ice.Message, arg ...string) {
|
||||
_header_users(m, aaa.USERNICK, arg...)
|
||||
_header_users(m, m.ActionKey(), arg...)
|
||||
}},
|
||||
aaa.PASSWORD: {Name: "password", Help: "修改密码", Hand: func(m *ice.Message, arg ...string) {
|
||||
_header_users(m, m.ActionKey(), arg...)
|
||||
}},
|
||||
aaa.LANGUAGE: {Name: "language", Help: "语言地区", Hand: func(m *ice.Message, arg ...string) {
|
||||
_header_users(m, aaa.LANGUAGE, arg...)
|
||||
_header_users(m, m.ActionKey(), arg...)
|
||||
}},
|
||||
aaa.BACKGROUND: {Name: "background", Help: "用户壁纸", Hand: func(m *ice.Message, arg ...string) {
|
||||
_header_users(m, aaa.BACKGROUND, arg...)
|
||||
_header_users(m, m.ActionKey(), arg...)
|
||||
}},
|
||||
aaa.AVATAR: {Name: "avatar", Help: "用户头像", Hand: func(m *ice.Message, arg ...string) {
|
||||
_header_users(m, aaa.AVATAR, arg...)
|
||||
_header_users(m, m.ActionKey(), arg...)
|
||||
}},
|
||||
|
||||
code.WEBPACK: {Name: "webpack", Help: "打包页面", Hand: func(m *ice.Message, arg ...string) {
|
||||
|
@ -27,6 +27,11 @@ func init() {
|
||||
m.RenderIndex(web.SERVE, ice.VOLCANOS)
|
||||
return // 节点首页
|
||||
}
|
||||
if arg[1] == WEBSITE {
|
||||
m.Cmdy(web.SPACE, arg[0], WEBSITE, ctx.ACTION, "show", path.Join(arg[2:]...))
|
||||
m.RenderResult()
|
||||
return
|
||||
}
|
||||
// 节点命令
|
||||
m.Cmdy("/cmd/", path.Join(arg[2:]...))
|
||||
}},
|
||||
|
@ -1,6 +1,8 @@
|
||||
package chat
|
||||
|
||||
import (
|
||||
"strings"
|
||||
|
||||
ice "shylinux.com/x/icebergs"
|
||||
"shylinux.com/x/icebergs/base/ctx"
|
||||
"shylinux.com/x/icebergs/base/mdb"
|
||||
@ -28,6 +30,7 @@ func init() {
|
||||
arg = kit.Split(arg[1], ";", ";", ";")
|
||||
}
|
||||
defer m.StatusTimeCount()
|
||||
arg[1] = strings.TrimSpace(arg[1])
|
||||
if m.Cmdy(m.Space(m.Option(ice.POD)), mdb.SEARCH, arg); arg[1] == "" {
|
||||
return
|
||||
}
|
||||
|
@ -21,7 +21,7 @@ func init() {
|
||||
Index.Merge(&ice.Context{Commands: map[string]*ice.Command{
|
||||
TRANS: {Name: "trans from to auto", Help: "传输", Action: ice.MergeAction(map[string]*ice.Action{
|
||||
SEND: {Name: "send", Help: "发送", Hand: func(m *ice.Message, arg ...string) {
|
||||
m.Cmdy(web.SPACE, m.Option(TO), web.SPIDE, ice.DEV, web.SPIDE_SAVE, kit.Select(ice.PWD, m.Option("to_path")),
|
||||
m.Cmdy(web.SPACE, m.Option(TO), web.SPIDE, ice.DEV, web.SPIDE_SAVE, kit.Select(nfs.PWD, m.Option("to_path")),
|
||||
m.MergeURL2(path.Join(web.SHARE_LOCAL, m.Option("from_path")), ice.POD, m.Option(FROM),
|
||||
web.SHARE, m.Cmdx(web.SHARE, mdb.CREATE, mdb.TYPE, web.LOGIN),
|
||||
),
|
||||
|
@ -15,12 +15,19 @@ import (
|
||||
kit "shylinux.com/x/toolkits"
|
||||
)
|
||||
|
||||
func _website_url(m *ice.Message, file string) string {
|
||||
p := path.Join(WEBSITE, file)
|
||||
if m.Option(ice.MSG_USERPOD) != "" {
|
||||
p = path.Join(ice.POD, m.Option(ice.MSG_USERPOD), WEBSITE, file)
|
||||
}
|
||||
return strings.Split(kit.MergeURL2(m.Option(ice.MSG_USERWEB), path.Join("/chat", p)), "?")[0]
|
||||
}
|
||||
func _website_parse(m *ice.Message, text string) map[string]interface{} {
|
||||
m.Option(nfs.CAT_CONTENT, text)
|
||||
river, storm, last := kit.Dict(
|
||||
"Header", kit.Dict("menus", kit.List(), "style", kit.Dict("display", "none")),
|
||||
"River", kit.Dict("menus", kit.List(), "action", kit.List()),
|
||||
"Action", kit.Dict("menus", kit.List(), "action", kit.List()),
|
||||
"Action", kit.Dict("menus", kit.List(), "action", kit.List(), "legend_event", "onclick"),
|
||||
"Footer", kit.Dict("style", kit.Dict("display", "none")),
|
||||
), kit.Dict(), kit.Dict()
|
||||
m.Cmd(lex.SPLIT, "", mdb.KEY, mdb.NAME, func(deep int, ls []string, meta map[string]interface{}) []string {
|
||||
@ -56,26 +63,23 @@ func _website_parse(m *ice.Message, text string) map[string]interface{} {
|
||||
func _website_render(m *ice.Message, w http.ResponseWriter, r *http.Request, kind, text string) bool {
|
||||
msg := m.Spawn(w, r)
|
||||
switch kind {
|
||||
case "svg":
|
||||
case nfs.SVG:
|
||||
msg.RenderResult(`<body style="background-color:cadetblue">%s</body>`, msg.Cmdx(nfs.CAT, text))
|
||||
case "shy":
|
||||
case nfs.SHY:
|
||||
if r.Method == http.MethodGet {
|
||||
msg.RenderCmd(msg.Prefix(DIV), text)
|
||||
} else {
|
||||
r.URL.Path = "/chat/cmd/web.chat.div"
|
||||
return false
|
||||
}
|
||||
case "txt":
|
||||
m.Debug("what %v", text)
|
||||
case nfs.TXT:
|
||||
res := _website_parse(msg, text)
|
||||
m.Debug("what %v", res)
|
||||
m.Debug("what %v", kit.Format(res))
|
||||
msg.RenderResult(_website_template2, kit.Format(res))
|
||||
case "json":
|
||||
case nfs.JSON:
|
||||
msg.RenderResult(_website_template2, kit.Format(kit.UnMarshal(text)))
|
||||
case "js":
|
||||
case nfs.JS:
|
||||
msg.RenderResult(_website_template, text)
|
||||
case "html":
|
||||
case nfs.HTML:
|
||||
msg.RenderResult(text)
|
||||
default:
|
||||
msg.RenderDownload(text)
|
||||
@ -113,11 +117,15 @@ func init() {
|
||||
return false
|
||||
})
|
||||
}},
|
||||
"show": {Hand: func(m *ice.Message, arg ...string) {
|
||||
res := _website_parse(m, m.Cmdx(nfs.CAT, path.Join(SRC_WEBSITE, arg[0])))
|
||||
m.Echo(_website_template2, kit.Format(res))
|
||||
}},
|
||||
mdb.RENDER: {Hand: func(m *ice.Message, arg ...string) {
|
||||
m.EchoIFrame(path.Join(CHAT_WEBSITE, strings.TrimPrefix(path.Join(arg[2], arg[1]), SRC_WEBSITE)))
|
||||
m.EchoIFrame(_website_url(m, strings.TrimPrefix(path.Join(arg[2], arg[1]), SRC_WEBSITE)))
|
||||
}},
|
||||
mdb.ENGINE: {Hand: func(m *ice.Message, arg ...string) {
|
||||
m.Echo(strings.Split(kit.MergeURL2(m.Option(ice.MSG_USERWEB), path.Join(CHAT_WEBSITE, strings.TrimPrefix(path.Join(arg[2], arg[1]), SRC_WEBSITE))), "?")[0])
|
||||
m.Echo(_website_url(m, strings.TrimPrefix(path.Join(arg[2], arg[1]), SRC_WEBSITE)))
|
||||
}},
|
||||
mdb.INPUTS: {Name: "inputs", Help: "补全", Hand: func(m *ice.Message, arg ...string) {
|
||||
switch m.Option(ctx.ACTION) {
|
||||
@ -134,7 +142,7 @@ func init() {
|
||||
mdb.IMPORT: {Name: "import path=src/website/", Help: "导入", Hand: func(m *ice.Message, arg ...string) {
|
||||
m.Cmd(nfs.DIR, kit.Dict(nfs.DIR_ROOT, m.Option(nfs.PATH)), func(p string) {
|
||||
switch name := strings.TrimPrefix(p, m.Option(nfs.PATH)); kit.Ext(p) {
|
||||
case "html", "js", "json", "txt":
|
||||
case nfs.HTML, nfs.JS, nfs.JSON, nfs.TXT:
|
||||
m.Cmd(m.PrefixKey(), mdb.CREATE, nfs.PATH, ice.PS+name,
|
||||
mdb.TYPE, kit.Ext(p), mdb.NAME, name, mdb.TEXT, m.Cmdx(nfs.CAT, p))
|
||||
default:
|
||||
@ -145,30 +153,25 @@ func init() {
|
||||
}},
|
||||
}, mdb.HashAction()), Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
|
||||
mdb.HashSelect(m, arg...).Table(func(index int, value map[string]string, head []string) {
|
||||
m.PushAnchor(strings.Split(m.MergeURL2(value[nfs.PATH]), "?")[0])
|
||||
m.PushAnchor(m.MergeLink(value[nfs.PATH]))
|
||||
})
|
||||
|
||||
if len(arg) == 0 {
|
||||
dir := SRC_WEBSITE
|
||||
m.Cmd(nfs.DIR, dir, func(f os.FileInfo, p string) {
|
||||
m.Cmd(nfs.DIR, SRC_WEBSITE, func(f os.FileInfo, p string) {
|
||||
m.Push("", kit.Dict(
|
||||
mdb.TIME, f.ModTime().Format(ice.MOD_TIME),
|
||||
nfs.PATH, ice.PS+strings.TrimPrefix(p, dir),
|
||||
mdb.TYPE, kit.Ext(p),
|
||||
mdb.NAME, path.Base(p),
|
||||
mdb.TEXT, m.Cmdx(nfs.CAT, p),
|
||||
), kit.Split(m.Config(mdb.FIELD)))
|
||||
m.PushButton("")
|
||||
m.PushAnchor(strings.Split(m.MergeURL2(path.Join(CHAT_WEBSITE, p)), "?")[0])
|
||||
})
|
||||
nfs.PATH, ice.PS+strings.TrimPrefix(p, SRC_WEBSITE),
|
||||
mdb.TYPE, kit.Ext(p), mdb.NAME, path.Base(p), mdb.TEXT, m.Cmdx(nfs.CAT, p),
|
||||
), kit.Split(m.Config(mdb.FIELD))).PushButton("")
|
||||
m.PushAnchor(m.MergeLink(path.Join(CHAT_WEBSITE, p)))
|
||||
}).Sort(nfs.PATH)
|
||||
}
|
||||
|
||||
if m.Length() == 0 && len(arg) > 0 {
|
||||
m.Push(mdb.TEXT, m.Cmdx(nfs.CAT, path.Join(SRC_WEBSITE, path.Join(arg...))))
|
||||
m.Push(nfs.PATH, path.Join(CHAT_WEBSITE, path.Join(arg...)))
|
||||
} else {
|
||||
m.Sort(nfs.PATH)
|
||||
m.PushAnchor(m.MergeLink(m.Append(nfs.PATH)))
|
||||
}
|
||||
|
||||
if m.FieldsIsDetail() {
|
||||
m.PushQRCode(mdb.SCAN, m.MergeURL2(m.Append(nfs.PATH)))
|
||||
m.EchoIFrame(m.Append(nfs.PATH))
|
||||
|
@ -195,7 +195,7 @@ func init() {
|
||||
}},
|
||||
}, Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
|
||||
if m.Option(nfs.DIR_ROOT, ice.SRC); len(arg) == 0 || strings.HasSuffix(arg[0], ice.PS) {
|
||||
m.Cmdy(nfs.DIR, kit.Select(ice.PWD, arg, 0))
|
||||
m.Cmdy(nfs.DIR, kit.Select(nfs.PWD, arg, 0))
|
||||
} else {
|
||||
m.Cmdy(nfs.CAT, arg[0])
|
||||
}
|
||||
|
@ -40,7 +40,7 @@ func _pack_dir(m *ice.Message, pack *os.File, dir string) {
|
||||
m.Option(nfs.DIR_TYPE, nfs.CAT)
|
||||
m.Option(nfs.DIR_ROOT, dir)
|
||||
|
||||
m.Cmd(nfs.DIR, ice.PWD).Sort(nfs.PATH).Table(func(index int, value map[string]string, head []string) {
|
||||
m.Cmd(nfs.DIR, nfs.PWD).Sort(nfs.PATH).Table(func(index int, value map[string]string, head []string) {
|
||||
if path.Base(value[nfs.PATH]) == "binpack.go" {
|
||||
return
|
||||
}
|
||||
|
@ -14,7 +14,7 @@ import (
|
||||
|
||||
func _c_tags(m *ice.Message, key string) {
|
||||
if _, e := os.Stat(path.Join(m.Option(cli.CMD_DIR), TAGS)); e != nil {
|
||||
m.Cmd(cli.SYSTEM, "ctags", "-R", "-f", TAGS, ice.PWD)
|
||||
m.Cmd(cli.SYSTEM, "ctags", "-R", "-f", TAGS, nfs.PWD)
|
||||
}
|
||||
_go_tags(m, key)
|
||||
}
|
||||
@ -77,7 +77,7 @@ func init() {
|
||||
m.Copy(msg)
|
||||
return
|
||||
}
|
||||
m.Echo(m.Cmd(cli.SYSTEM, ice.PWD+name).Append(cli.CMD_OUT))
|
||||
m.Echo(m.Cmd(cli.SYSTEM, nfs.PWD+name).Append(cli.CMD_OUT))
|
||||
}},
|
||||
}, PlugAction())},
|
||||
MAN: {Name: MAN, Help: "手册", Action: ice.MergeAction(map[string]*ice.Action{
|
||||
|
@ -86,14 +86,14 @@ func init() {
|
||||
"run": {Name: "run", Help: "运行", Hand: func(m *ice.Message, arg ...string) {
|
||||
// cli.Follow(m, "run", func() {
|
||||
m.Option(cli.CMD_DIR, kit.Select(path.Dir(arg[0]), arg[0], strings.HasSuffix(arg[0], "/")))
|
||||
m.Cmdy(cli.SYSTEM, "go", "test", ice.PWD, "-v", "-run="+arg[1])
|
||||
m.Cmdy(cli.SYSTEM, "go", "test", nfs.PWD, "-v", "-run="+arg[1])
|
||||
// })
|
||||
}},
|
||||
"case": {Name: "case", Help: "用例", Hand: func(m *ice.Message, arg ...string) {
|
||||
msg := m.Spawn()
|
||||
if strings.HasSuffix(arg[0], "/") {
|
||||
msg.Option(cli.CMD_DIR, arg[0])
|
||||
msg.Split(msg.Cmdx(cli.SYSTEM, "grep", "-r", "func Test.*(", ice.PWD), "file:line", ":", "\n")
|
||||
msg.Split(msg.Cmdx(cli.SYSTEM, "grep", "-r", "func Test.*(", nfs.PWD), "file:line", ":", "\n")
|
||||
msg.Table(func(index int, value map[string]string, head []string) {
|
||||
if strings.HasPrefix(strings.TrimSpace(value["line"]), "//") {
|
||||
return
|
||||
@ -111,7 +111,7 @@ func init() {
|
||||
}},
|
||||
}, Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
|
||||
if len(arg) == 0 || arg[0] == "" {
|
||||
m.Cmdy(nfs.DIR, ice.PWD)
|
||||
m.Cmdy(nfs.DIR, nfs.PWD)
|
||||
return
|
||||
}
|
||||
if len(arg) == 1 {
|
||||
@ -127,7 +127,7 @@ func init() {
|
||||
}
|
||||
|
||||
m.Option(cli.CMD_DIR, kit.Select(path.Dir(arg[0]), arg[0], strings.HasSuffix(arg[0], "/")))
|
||||
m.Cmdy(cli.SYSTEM, "go", "test", ice.PWD, "-v", "-run="+arg[1])
|
||||
m.Cmdy(cli.SYSTEM, "go", "test", nfs.PWD, "-v", "-run="+arg[1])
|
||||
}},
|
||||
}})
|
||||
}
|
||||
|
@ -16,7 +16,7 @@ import (
|
||||
|
||||
func _go_tags(m *ice.Message, key string) {
|
||||
if s, e := os.Stat(path.Join(m.Option(cli.CMD_DIR), TAGS)); os.IsNotExist(e) || s.ModTime().Before(time.Now().Add(kit.Duration("-72h"))) {
|
||||
m.Cmd(cli.SYSTEM, "gotags", "-R", "-f", TAGS, ice.PWD)
|
||||
m.Cmd(cli.SYSTEM, "gotags", "-R", "-f", TAGS, nfs.PWD)
|
||||
}
|
||||
|
||||
ls := strings.Split(key, ice.PT)
|
||||
@ -41,7 +41,7 @@ func _go_tags(m *ice.Message, key string) {
|
||||
bio := bufio.NewScanner(f)
|
||||
for i := 1; bio.Scan(); i++ {
|
||||
if i == line || bio.Text() == text {
|
||||
m.PushSearch(nfs.FILE, strings.TrimPrefix(file, ice.PWD), nfs.LINE, kit.Format(i), mdb.TEXT, bio.Text())
|
||||
m.PushSearch(nfs.FILE, strings.TrimPrefix(file, nfs.PWD), nfs.LINE, kit.Format(i), mdb.TEXT, bio.Text())
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -65,9 +65,9 @@ func _go_exec(m *ice.Message, arg ...string) {
|
||||
if key, ok := ice.Info.File[path.Join(arg[2], arg[1])]; ok && key != "" {
|
||||
m.Cmdy(cli.SYSTEM, GO, ice.RUN, ice.SRC_MAIN_GO, key)
|
||||
} else if m.Option(cli.CMD_DIR, arg[2]); strings.HasSuffix(arg[1], "_test.go") {
|
||||
m.Cmdy(cli.SYSTEM, GO, "test", "-v", ice.PWD+arg[1])
|
||||
m.Cmdy(cli.SYSTEM, GO, "test", "-v", nfs.PWD+arg[1])
|
||||
} else {
|
||||
m.Cmdy(cli.SYSTEM, GO, ice.RUN, ice.PWD+arg[1])
|
||||
m.Cmdy(cli.SYSTEM, GO, ice.RUN, nfs.PWD+arg[1])
|
||||
}
|
||||
m.SetAppend()
|
||||
}
|
||||
@ -136,7 +136,7 @@ func _mod_show(m *ice.Message, file string) {
|
||||
switch {
|
||||
case strings.HasPrefix(line, MODULE):
|
||||
require[ls[1]] = ""
|
||||
replace[ls[1]] = ice.PWD
|
||||
replace[ls[1]] = nfs.PWD
|
||||
return
|
||||
case strings.HasPrefix(line, REQUIRE+" ("):
|
||||
block = REQUIRE
|
||||
|
@ -137,14 +137,29 @@ func init() {
|
||||
_inner_make(m, m.Cmd(cli.SYSTEM, cli.MAKE, arg))
|
||||
}},
|
||||
mdb.INPUTS: {Name: "inputs", Help: "补全", Hand: func(m *ice.Message, arg ...string) {
|
||||
if m.Option(ctx.ACTION) == "website" {
|
||||
switch arg[0] {
|
||||
case nfs.FILE:
|
||||
m.Cmdy(nfs.DIR, nfs.PWD, "path,size,time", kit.Dict(nfs.DIR_ROOT, "src/website/")).ProcessAgain()
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
switch arg[0] {
|
||||
case cli.MAIN:
|
||||
m.Option(nfs.DIR_REG, "*.go")
|
||||
m.Cmdy(nfs.DIR, "src/", "path,size,time").ProcessAgain()
|
||||
case nfs.PATH:
|
||||
m.Cmdy(nfs.DIR, arg[1:], "path,size,time").ProcessAgain()
|
||||
case nfs.FILE:
|
||||
m.Cmdy(nfs.DIR, ice.PWD, "path,size,time", kit.Dict(nfs.DIR_ROOT, m.Option(nfs.PATH))).ProcessAgain()
|
||||
p := kit.Select(nfs.PWD, arg, 1)
|
||||
if !strings.HasSuffix(p, ice.FS) {
|
||||
p = path.Dir(p)
|
||||
}
|
||||
m.Cmdy(nfs.DIR, p+ice.PS, "path,size,time", kit.Dict(nfs.DIR_ROOT, m.Option(nfs.PATH))).ProcessAgain()
|
||||
case "url":
|
||||
m.Option(nfs.DIR_ROOT, "usr/volcanos/plugin/local/code/")
|
||||
m.Cmdy(nfs.DIR, ice.PWD, "path,size,time", kit.Dict(nfs.DIR_DEEP, ice.TRUE)).ProcessAgain()
|
||||
m.Cmdy(nfs.DIR, nfs.PWD, "path,size,time", kit.Dict(nfs.DIR_DEEP, ice.TRUE)).ProcessAgain()
|
||||
default:
|
||||
m.Cmdy(FAVOR, mdb.INPUTS, arg)
|
||||
}
|
||||
@ -194,7 +209,7 @@ func init() {
|
||||
PREFIX, kit.Dict("#", COMMENT),
|
||||
KEYWORD, kit.Dict("print", KEYWORD),
|
||||
),
|
||||
"html", kit.Dict(
|
||||
nfs.HTML, kit.Dict(
|
||||
SPLIT, kit.Dict(
|
||||
"space", " ",
|
||||
"operator", "<>",
|
||||
@ -204,7 +219,7 @@ func init() {
|
||||
"body", KEYWORD,
|
||||
),
|
||||
),
|
||||
"css", kit.Dict(
|
||||
nfs.CSS, kit.Dict(
|
||||
SUFFIX, kit.Dict("{", COMMENT),
|
||||
),
|
||||
"yaml", kit.Dict(
|
||||
|
@ -186,7 +186,7 @@ func init() {
|
||||
|
||||
default: // 目录列表
|
||||
m.Option(nfs.DIR_ROOT, path.Join(m.Conf(cli.DAEMON, kit.Keym(nfs.PATH)), arg[1]))
|
||||
m.Cmdy(nfs.CAT, kit.Select(ice.PWD, arg, 2))
|
||||
m.Cmdy(nfs.CAT, kit.Select(nfs.PWD, arg, 2))
|
||||
}
|
||||
}},
|
||||
}})
|
||||
|
@ -53,7 +53,7 @@ func _publish_list(m *ice.Message, arg ...string) {
|
||||
m.Option(nfs.DIR_DEEP, ice.TRUE)
|
||||
m.Option(nfs.DIR_REG, kit.Select("", arg, 0))
|
||||
m.Option(nfs.DIR_ROOT, m.Config(nfs.PATH))
|
||||
m.Cmdy(nfs.DIR, ice.PWD, kit.Select("time,size,line,path,link", arg, 1))
|
||||
m.Cmdy(nfs.DIR, nfs.PWD, kit.Select("time,size,line,path,link", arg, 1))
|
||||
}
|
||||
|
||||
const PUBLISH = "publish"
|
||||
@ -111,7 +111,7 @@ echo "hello world"
|
||||
}
|
||||
}},
|
||||
mdb.INPUTS: {Name: "inputs", Help: "补全", Hand: func(m *ice.Message, arg ...string) {
|
||||
m.Cmdy(nfs.DIR, kit.Select(ice.PWD, arg, 1))
|
||||
m.Cmdy(nfs.DIR, kit.Select(nfs.PWD, arg, 1))
|
||||
m.ProcessAgain()
|
||||
}},
|
||||
mdb.CREATE: {Name: "create file", Help: "添加", Hand: func(m *ice.Message, arg ...string) {
|
||||
|
@ -18,7 +18,7 @@ func init() {
|
||||
_wiki_save(m, m.CommandKey(), arg[0], arg[1])
|
||||
}},
|
||||
}, Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
|
||||
if !_wiki_list(m, m.CommandKey(), kit.Select(ice.PWD, arg, 0)) {
|
||||
if !_wiki_list(m, m.CommandKey(), kit.Select(nfs.PWD, arg, 0)) {
|
||||
m.CSV(m.Cmd(nfs.CAT, arg[0]).Result())
|
||||
}
|
||||
}},
|
||||
|
@ -30,7 +30,7 @@ func init() {
|
||||
_wiki_save(m, DRAW, arg[0], m.Option("content"))
|
||||
}},
|
||||
}, ctx.CmdAction()), Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
|
||||
if !_wiki_list(m, DRAW, kit.Select(ice.PWD, arg, 0)) {
|
||||
if !_wiki_list(m, DRAW, kit.Select(nfs.PWD, arg, 0)) {
|
||||
_wiki_show(m, DRAW, arg[0])
|
||||
}
|
||||
}},
|
||||
|
@ -26,7 +26,7 @@ func init() {
|
||||
os.Remove(strings.TrimPrefix(arg[0], web.SHARE_LOCAL))
|
||||
}},
|
||||
}, Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
|
||||
_wiki_list(m, m.CommandKey(), kit.Select(ice.PWD, arg, 0))
|
||||
_wiki_list(m, m.CommandKey(), kit.Select(nfs.PWD, arg, 0))
|
||||
}},
|
||||
}})
|
||||
}
|
||||
|
@ -43,12 +43,12 @@ func _wiki_list(m *ice.Message, cmd string, arg ...string) bool {
|
||||
if len(arg) == 0 || strings.HasSuffix(arg[0], ice.PS) {
|
||||
if m.Option(nfs.DIR_DEEP) != ice.TRUE { // 目录列表
|
||||
m.Option(nfs.DIR_TYPE, nfs.DIR)
|
||||
m.Cmdy(nfs.DIR, kit.Select(ice.PWD, arg, 0))
|
||||
m.Cmdy(nfs.DIR, kit.Select(nfs.PWD, arg, 0))
|
||||
}
|
||||
|
||||
// 文件列表
|
||||
m.Option(nfs.DIR_TYPE, nfs.CAT)
|
||||
m.Cmdy(nfs.DIR, kit.Select(ice.PWD, arg, 0))
|
||||
m.Cmdy(nfs.DIR, kit.Select(nfs.PWD, arg, 0))
|
||||
return true
|
||||
}
|
||||
return false
|
||||
|
3
misc.go
3
misc.go
@ -147,6 +147,9 @@ func (m *Message) AppendTrans(cb func(value string, key string, index int) strin
|
||||
}
|
||||
return m
|
||||
}
|
||||
func (m *Message) MergeLink(url string, arg ...interface{}) string {
|
||||
return strings.Split(kit.MergeURL2(m.Option(MSG_USERWEB), url, arg...), "?")[0]
|
||||
}
|
||||
func (m *Message) MergeURL2(url string, arg ...interface{}) string {
|
||||
return kit.MergeURL2(m.Option(MSG_USERWEB), url, arg...)
|
||||
}
|
||||
|
@ -19,7 +19,7 @@ func _repos_path(name string) string {
|
||||
if strings.Contains(name, ":\\") {
|
||||
return name
|
||||
}
|
||||
return kit.Select(path.Join(ice.USR, name)+ice.PS, ice.PWD, name == path.Base(kit.Pwd()))
|
||||
return kit.Select(path.Join(ice.USR, name)+ice.PS, nfs.PWD, name == path.Base(kit.Pwd()))
|
||||
}
|
||||
func _repos_insert(m *ice.Message, name string, dir string) {
|
||||
if s, e := os.Stat(m.Option(cli.CMD_DIR, path.Join(dir, ".git"))); e == nil && s.IsDir() {
|
||||
|
@ -167,7 +167,7 @@ func init() {
|
||||
}},
|
||||
}, Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
|
||||
if m.Option(nfs.DIR_ROOT, path.Join(ice.USR_LOCAL, REPOS)); len(arg) == 0 {
|
||||
m.Cmdy(nfs.DIR, ice.PWD, "time,path,size").Table(func(index int, value map[string]string, head []string) {
|
||||
m.Cmdy(nfs.DIR, nfs.PWD, "time,path,size").Table(func(index int, value map[string]string, head []string) {
|
||||
m.PushScript("git clone " + m.MergeURL2("/x/"+value[nfs.PATH]))
|
||||
})
|
||||
m.StatusTimeCount()
|
||||
|
@ -50,7 +50,7 @@ func _spide_go(m *ice.Message, file string) {
|
||||
})
|
||||
}
|
||||
func _spide_c(m *ice.Message, file string) {
|
||||
_spide_for(m.Cmdx(cli.SYSTEM, "ctags", "-f", "-", file), func(ls []string) {
|
||||
_spide_for(m.Cmdx(cli.SYSTEM, "ctags", "-f", file), func(ls []string) {
|
||||
m.Push(mdb.NAME, ls[0])
|
||||
m.Push(nfs.FILE, ls[1])
|
||||
m.Push(nfs.LINE, "1")
|
||||
|
@ -128,6 +128,15 @@ func (m *Message) StatusTimeCountTotal(arg ...interface{}) {
|
||||
func (m *Message) Confirm(text string) string {
|
||||
return m.Cmdx(SPACE, m.Option(MSG_DAEMON), "confirm", text)
|
||||
}
|
||||
func (m *Message) ToastProcess(arg ...interface{}) {
|
||||
if len(arg) == 0 {
|
||||
arg = kit.List("", "-1")
|
||||
}
|
||||
if len(arg) == 1 {
|
||||
arg = append(arg, "-1")
|
||||
}
|
||||
m.Toast(PROCESS, arg...)
|
||||
}
|
||||
func (m *Message) ToastSuccess(arg ...interface{}) {
|
||||
m.Toast(SUCCESS, arg...)
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user