mirror of
https://shylinux.com/x/icebergs
synced 2025-04-26 09:34:05 +08:00
Compare commits
3 Commits
Author | SHA1 | Date | |
---|---|---|---|
b0c7feb56e | |||
7e5cff6b81 | |||
6c0e3a0a58 |
@ -5,6 +5,7 @@ import (
|
|||||||
"net/http"
|
"net/http"
|
||||||
"os"
|
"os"
|
||||||
"path"
|
"path"
|
||||||
|
"strings"
|
||||||
|
|
||||||
ice "shylinux.com/x/icebergs"
|
ice "shylinux.com/x/icebergs"
|
||||||
"shylinux.com/x/icebergs/base/aaa"
|
"shylinux.com/x/icebergs/base/aaa"
|
||||||
@ -189,6 +190,12 @@ func init() {
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
func UploadSave(m *ice.Message, p string) string {
|
||||||
|
up := kit.Simple(m.Optionv(ice.MSG_UPLOAD))
|
||||||
|
kit.If(strings.HasSuffix(p, nfs.PS), func() { p = path.Join(p, up[1]) })
|
||||||
|
m.Cmd(CACHE, WATCH, up[0], p)
|
||||||
|
return p
|
||||||
|
}
|
||||||
func Upload(m *ice.Message) []string {
|
func Upload(m *ice.Message) []string {
|
||||||
if up := kit.Simple(m.Optionv(ice.MSG_UPLOAD)); len(up) == 1 {
|
if up := kit.Simple(m.Optionv(ice.MSG_UPLOAD)); len(up) == 1 {
|
||||||
msg := m.Cmd(CACHE, UPLOAD)
|
msg := m.Cmd(CACHE, UPLOAD)
|
||||||
|
@ -84,6 +84,7 @@ func Render(m *ice.Message, cmd string, args ...ice.Any) bool {
|
|||||||
"$output", fieldset+">div.output",
|
"$output", fieldset+">div.output",
|
||||||
"$status", fieldset+">div.status",
|
"$status", fieldset+">div.status",
|
||||||
"$fieldset", fieldset,
|
"$fieldset", fieldset,
|
||||||
|
"$body", "body.cmd."+m.Option(ctx.INDEX),
|
||||||
"$index", m.Option(ctx.INDEX),
|
"$index", m.Option(ctx.INDEX),
|
||||||
"$input", "body>div.input.float."+m.Option(ctx.INDEX),
|
"$input", "body>div.input.float."+m.Option(ctx.INDEX),
|
||||||
)))
|
)))
|
||||||
@ -171,7 +172,7 @@ func RenderPodCmd(m *ice.Message, pod, cmd string, arg ...ice.Any) {
|
|||||||
m.Option(mdb.ICONS, msg.Option(ice.MSG_NODEICON))
|
m.Option(mdb.ICONS, msg.Option(ice.MSG_NODEICON))
|
||||||
}
|
}
|
||||||
m.OptionDefault(mdb.ICONS, m.Resource(kit.Select(ice.Info.NodeIcon, msg.Option(ice.MSG_NODEICON), msg.Append(mdb.ICONS))))
|
m.OptionDefault(mdb.ICONS, m.Resource(kit.Select(ice.Info.NodeIcon, msg.Option(ice.MSG_NODEICON), msg.Append(mdb.ICONS))))
|
||||||
serve := kit.Select("localhost:9020", UserWeb(m).Host)
|
serve := strings.Split(UserHost(m), "://")[1]
|
||||||
pod = kit.Select(pod, msg.Option(ice.MSG_NODENAME), m.Option(ice.MSG_USERPOD) != "")
|
pod = kit.Select(pod, msg.Option(ice.MSG_NODENAME), m.Option(ice.MSG_USERPOD) != "")
|
||||||
m.OptionDefault(TITLE, kit.Select(cmd, msg.Append(mdb.HELP), !m.IsEnglish())+" "+kit.Select(serve, pod))
|
m.OptionDefault(TITLE, kit.Select(cmd, msg.Append(mdb.HELP), !m.IsEnglish())+" "+kit.Select(serve, pod))
|
||||||
RenderCmds(m, kit.Dict(msg.AppendSimple(), ctx.ARGS, kit.Simple(arg), ctx.DISPLAY, m.Option(ice.MSG_DISPLAY)))
|
RenderCmds(m, kit.Dict(msg.AppendSimple(), ctx.ARGS, kit.Simple(arg), ctx.DISPLAY, m.Option(ice.MSG_DISPLAY)))
|
||||||
|
@ -431,8 +431,17 @@ func init() {
|
|||||||
return kit.Format(mdb.Cache(ice.Pulse, p, func() ice.Any { return m.Cmdx(SPIDE, ice.OPS, SPIDE_RAW, http.MethodGet, p) }))
|
return kit.Format(mdb.Cache(ice.Pulse, p, func() ice.Any { return m.Cmdx(SPIDE, ice.OPS, SPIDE_RAW, http.MethodGet, p) }))
|
||||||
} else if p == "" {
|
} else if p == "" {
|
||||||
return ""
|
return ""
|
||||||
} else {
|
} else if nfs.Exists(m, p) {
|
||||||
return m.Cmdx(nfs.CAT, p)
|
return m.Cmdx(nfs.CAT, p)
|
||||||
|
} else if strings.Contains(p, "/pkg/mod/") {
|
||||||
|
ls := strings.Split(p, "/pkg/mod/")
|
||||||
|
return kit.Format(mdb.Cache(ice.Pulse, p, func() ice.Any { return m.Cmdx(SPIDE, ice.OPS, SPIDE_RAW, http.MethodGet, nfs.REQUIRE+ls[1]) }))
|
||||||
|
} else if strings.Contains(p, "/usr/local/work/") {
|
||||||
|
ls := strings.Split(strings.Split(p, "/usr/local/work/")[1], "/src/")
|
||||||
|
pp := kit.MergeURL2(ice.Info.Make.Domain, "/p/src/"+ls[1]+"?pod="+ls[0])
|
||||||
|
return kit.Format(mdb.Cache(ice.Pulse, p, func() ice.Any { return m.Cmdx(SPIDE, ice.OPS, SPIDE_RAW, http.MethodGet, pp) }))
|
||||||
|
} else {
|
||||||
|
return ""
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
nfs.TemplatePath = func(m *ice.Message, arg ...string) string {
|
nfs.TemplatePath = func(m *ice.Message, arg ...string) string {
|
||||||
|
@ -136,6 +136,9 @@ func init() {
|
|||||||
nfs.TRASH: {Hand: func(m *ice.Message, arg ...string) {
|
nfs.TRASH: {Hand: func(m *ice.Message, arg ...string) {
|
||||||
nfs.Trash(m, arg[0])
|
nfs.Trash(m, arg[0])
|
||||||
}},
|
}},
|
||||||
|
web.UPLOAD: {Hand: func(m *ice.Message, arg ...string) {
|
||||||
|
web.UploadSave(m, path.Dir(path.Join(m.Option(nfs.PATH), m.Option(nfs.FILE)))+nfs.PS)
|
||||||
|
}},
|
||||||
nfs.SAVE: {Hand: func(m *ice.Message, arg ...string) {
|
nfs.SAVE: {Hand: func(m *ice.Message, arg ...string) {
|
||||||
kit.If(m.Option(nfs.CONTENT) == "", func() { m.Option(nfs.CONTENT, m.Cmdx("", TEMPLATE)) })
|
kit.If(m.Option(nfs.CONTENT) == "", func() { m.Option(nfs.CONTENT, m.Cmdx("", TEMPLATE)) })
|
||||||
m.Cmd(nfs.SAVE, path.Join(m.Option(nfs.PATH), m.Option(nfs.FILE)))
|
m.Cmd(nfs.SAVE, path.Join(m.Option(nfs.PATH), m.Option(nfs.FILE)))
|
||||||
|
Loading…
x
Reference in New Issue
Block a user