forked from x/icebergs
add some
This commit is contained in:
parent
fa44a6d370
commit
5f6cb250a1
@ -256,10 +256,11 @@ func init() {
|
||||
_dream_start(m, m.Option(mdb.NAME))
|
||||
}},
|
||||
cli.STOP: {Hand: func(m *ice.Message, arg ...string) {
|
||||
defer ToastProcess(m)()
|
||||
defer m.Sleep3s()
|
||||
gdb.Event(m, DREAM_STOP, arg)
|
||||
m.Cmd(SPACE, mdb.MODIFY, m.OptionSimple(mdb.NAME), mdb.STATUS, cli.STOP)
|
||||
m.Cmd(SPACE, m.Option(mdb.NAME), ice.EXIT)
|
||||
m.Sleep300ms()
|
||||
}},
|
||||
nfs.TRASH: {Hand: func(m *ice.Message, arg ...string) {
|
||||
gdb.Event(m, DREAM_TRASH, arg)
|
||||
|
@ -12,6 +12,7 @@ import (
|
||||
"shylinux.com/x/icebergs/base/lex"
|
||||
"shylinux.com/x/icebergs/base/log"
|
||||
"shylinux.com/x/icebergs/base/mdb"
|
||||
"shylinux.com/x/icebergs/base/nfs"
|
||||
"shylinux.com/x/icebergs/base/tcp"
|
||||
kit "shylinux.com/x/toolkits"
|
||||
"shylinux.com/x/toolkits/file"
|
||||
@ -51,6 +52,18 @@ func MergeLink(m *ice.Message, url string, arg ...ice.Any) string {
|
||||
kit.If(m.Option(log.DEBUG) == ice.TRUE, func() { arg = append(arg, log.DEBUG, ice.TRUE) })
|
||||
return kit.MergeURL(strings.Split(MergeURL2(m, url), QS)[0], arg...)
|
||||
}
|
||||
func ParseLink(m *ice.Message, url string) ice.Maps {
|
||||
list := ice.Maps{}
|
||||
u := kit.ParseURL(url)
|
||||
switch arg := strings.Split(strings.TrimPrefix(u.Path, nfs.PS), nfs.PS); arg[0] {
|
||||
case CHAT:
|
||||
kit.For(arg[1:], func(k, v string) { list[k] = v })
|
||||
case SHARE:
|
||||
list[arg[0]] = arg[1]
|
||||
}
|
||||
kit.For(u.Query(), func(k string, v []string) { list[k] = v[0] })
|
||||
return list
|
||||
}
|
||||
func ProcessPodCmd(m *ice.Message, pod, cmd string, arg ...ice.Any) {
|
||||
m.ProcessOpen(m.MergePodCmd(pod, cmd, arg...))
|
||||
}
|
||||
|
@ -42,7 +42,7 @@ func Render(m *ice.Message, cmd string, args ...ice.Any) bool {
|
||||
case COOKIE: // value [name [path [expire]]]
|
||||
RenderCookie(m, arg[0], arg[1:]...)
|
||||
case STATUS, ice.RENDER_STATUS: // [code [text]]
|
||||
RenderStatus(m.W, kit.Int(kit.Select("200", arg, 0)), strings.Join(kit.Slice(arg, 1), " "))
|
||||
RenderStatus(m.W, kit.Int(kit.Select("200", arg, 0)), kit.Select(m.Result(), strings.Join(kit.Slice(arg, 1), " ")))
|
||||
case ice.RENDER_REDIRECT: // url [arg...]
|
||||
http.Redirect(m.W, m.R, kit.MergeURL(arg[0], arg[1:]), http.StatusTemporaryRedirect)
|
||||
case ice.RENDER_DOWNLOAD: // file [type [name]]
|
||||
@ -124,11 +124,11 @@ func RenderMain(m *ice.Message) *ice.Message {
|
||||
if m.IsCliUA() {
|
||||
return m.RenderDownload(path.Join(ice.USR_INTSHELL, ice.INDEX_SH))
|
||||
}
|
||||
m.OptionDefault(nfs.VERSION, RenderVersion(m)+kit.Select("", "&pod="+m.Option(ice.MSG_USERPOD), m.Option(ice.MSG_USERPOD) != ""))
|
||||
m.Option(nfs.VERSION, RenderVersion(m)+kit.Select("", "&pod="+m.Option(ice.MSG_USERPOD), m.Option(ice.MSG_USERPOD) != ""))
|
||||
return RenderTemplate(m, "main.html")
|
||||
}
|
||||
func RenderCmds(m *ice.Message, list ...ice.Any) {
|
||||
m.OptionDefault(nfs.VERSION, RenderVersion(m)+kit.Select("", "&pod="+m.Option(ice.MSG_USERPOD), m.Option(ice.MSG_USERPOD) != ""))
|
||||
m.Option(nfs.VERSION, RenderVersion(m)+kit.Select("", "&pod="+m.Option(ice.MSG_USERPOD), m.Option(ice.MSG_USERPOD) != ""))
|
||||
RenderTemplate(m.Options(mdb.LIST, kit.Format(list)), "cmds.html")
|
||||
}
|
||||
func RenderPodCmd(m *ice.Message, pod, cmd string, arg ...ice.Any) {
|
||||
|
@ -58,7 +58,7 @@ func _serve_main(m *ice.Message, w http.ResponseWriter, r *http.Request) bool {
|
||||
} else {
|
||||
r.Header.Set(ice.MSG_USERIP, strings.Split(r.RemoteAddr, nfs.DF)[0])
|
||||
}
|
||||
if !kit.HasPrefix(r.URL.String(), VOLCANOS, REQUIRE_SRC, REQUIRE_MODULES, INTSHELL) {
|
||||
if !kit.HasPrefix(r.URL.String(), VOLCANOS, REQUIRE_MODULES, INTSHELL) {
|
||||
r.Header.Set(ice.LOG_TRACEID, log.Traceid())
|
||||
m.Logs(r.Header.Get(ice.MSG_USERIP), r.Method, r.URL.String(), logs.TraceidMeta(r.Header.Get(ice.LOG_TRACEID)))
|
||||
}
|
||||
@ -66,7 +66,8 @@ func _serve_main(m *ice.Message, w http.ResponseWriter, r *http.Request) bool {
|
||||
r.URL.Path = kit.Select(nfs.PS, mdb.Config(m, ice.MAIN))
|
||||
}
|
||||
if r.Method == http.MethodGet {
|
||||
msg := m.Spawn(w, r).Options(ice.MSG_USERUA, r.UserAgent(), ice.LOG_TRACEID, r.Header.Get(ice.LOG_TRACEID))
|
||||
msg := m.Spawn(w, r).Options(ice.MSG_USERUA, r.UserAgent(), ice.LOG_TRACEID, r.Header.Get(ice.LOG_TRACEID),
|
||||
ParseLink(m, kit.Select(r.URL.String(), r.Referer())))
|
||||
if path.Join(r.URL.Path) == nfs.PS {
|
||||
if Render(RenderMain(msg), msg.Option(ice.MSG_OUTPUT), kit.List(msg.Optionv(ice.MSG_ARGS))...) {
|
||||
return false
|
||||
|
@ -205,6 +205,9 @@ func init() {
|
||||
m.Cmd(SPACE, pod, SPIDE, ice.DEV, CACHE, SHARE_CACHE+ls[0])
|
||||
}
|
||||
m.Options(key, []string{}, ice.MSG_USERPOD, pod).Cmdy(append(kit.List(ice.SPACE, pod), arg...)...)
|
||||
if m.IsErr() {
|
||||
m.Warn(m.IsErr(), kit.Select("", m.Resultv(), 1), kit.Slice(m.Resultv(), 2))
|
||||
}
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
@ -30,7 +30,7 @@ func init() {
|
||||
m.Cmd(web.DREAM, cli.START, kit.Dict(mdb.NAME, arg[0]))
|
||||
}
|
||||
if len(arg) == 1 {
|
||||
m.Cmdy(web.SPACE, arg[0], web.SPACE, ice.MAIN, kit.Dict(nfs.VERSION, web.RenderVersion(m), ice.MSG_USERPOD, arg[0]))
|
||||
m.Cmdy(web.SPACE, arg[0], web.SPACE, ice.MAIN, kit.Dict(ice.MSG_USERPOD, arg[0]))
|
||||
} else if arg[1] == CMD {
|
||||
web.RenderPodCmd(m, arg[0], arg[2], arg[3:])
|
||||
}
|
||||
|
2
logs.go
2
logs.go
@ -119,7 +119,7 @@ func (m *Message) Warn(err Any, arg ...Any) bool {
|
||||
return false
|
||||
}
|
||||
str, meta := m.join(arg...)
|
||||
if m.log(LOG_WARN, str, meta...); !m.IsErr() && len(arg) > 0 {
|
||||
if m.log(LOG_WARN, str, meta...); len(arg) > 0 {
|
||||
m.error(arg...)
|
||||
kit.If(map[string]int{
|
||||
ErrNotLogin: http.StatusUnauthorized,
|
||||
|
Loading…
x
Reference in New Issue
Block a user