diff --git a/base/web/spide.go b/base/web/spide.go index 923d7244..962540c3 100644 --- a/base/web/spide.go +++ b/base/web/spide.go @@ -288,6 +288,15 @@ func init() { }) } +func HostPort(m *ice.Message, host, port string, arg ...string) string { + if port == "443" { + return kit.Format("https://%s", host) + } else if port == "80" { + return kit.Format("http://%s", host) + } else { + return kit.Format("http://%s:%s", host, port) + } +} func SpideGet(m *ice.Message, arg ...ice.Any) ice.Any { return kit.UnMarshal(m.Cmdx(http.MethodGet, arg)) } diff --git a/core/code/shy.go b/core/code/shy.go index 19663791..74f8cc8b 100644 --- a/core/code/shy.go +++ b/core/code/shy.go @@ -33,7 +33,8 @@ func init() { } }}, TEMPLATE: {Hand: func(m *ice.Message, arg ...string) { - m.Echo(nfs.Template(m, "demo.shy"), path.Base(path.Dir(path.Join(arg[2], arg[1])))) + m.Option(mdb.NAME, path.Base(path.Dir(path.Join(arg[2], arg[1])))) + m.Echo(nfs.Template(m, "demo.shy")) }}, COMPLETE: {Hand: func(m *ice.Message, arg ...string) { m.Cmdy("web.wiki.word", COMPLETE, arg) }}, }, PlugAction()), Hand: func(m *ice.Message, arg ...string) { diff --git a/type.go b/type.go index dd038008..4bc8d9ba 100644 --- a/type.go +++ b/type.go @@ -283,8 +283,8 @@ func (m *Message) Start(key string, arg ...string) *Message { }) } func (m *Message) Travel(cb Any) *Message { - target := m.target - defer func() { m.target = target }() + target, cmd, key := m.target, m._cmd, m._key + defer func() { m.target, m._cmd, m._key = target, cmd, key }() list := []*Context{m.root.target} for i := 0; i < len(list); i++ { switch cb := cb.(type) { @@ -292,7 +292,10 @@ func (m *Message) Travel(cb Any) *Message { cb(list[i].context, list[i]) case func(*Context, *Context, string, *Command): m.target = list[i] - kit.For(kit.SortedKey(list[i].Commands), func(k string) { cb(list[i].context, list[i], k, list[i].Commands[k]) }) + kit.For(kit.SortedKey(list[i].Commands), func(k string) { + m._cmd, m._key = list[i].Commands[k], k + cb(list[i].context, list[i], k, list[i].Commands[k]) + }) case func(*Context, *Context, string, *Config): m.target = list[i] kit.For(kit.SortedKey(list[i].Configs), func(k string) { cb(list[i].context, list[i], k, list[i].Configs[k]) })