diff --git a/base/aaa/offer.go b/base/aaa/offer.go index 0c790d9a..df9db3e6 100644 --- a/base/aaa/offer.go +++ b/base/aaa/offer.go @@ -29,6 +29,7 @@ func init() { mdb.CREATE: {Name: "create from*=admin email*='shy@shylinux.com' subject content", Help: "邀请", Hand: func(m *ice.Message, arg ...string) { h := mdb.HashCreate(m.Spawn(), m.OptionSimple(EMAIL, SUBJECT, CONTENT), INVITER, m.Option(ice.MSG_USERNAME), mdb.STATUS, INVITE) SendEmail(m.Options("link", m.Cmdx("host", "publish", m.MergePodCmd("", "", mdb.HASH, h))), m.Option(FROM), "", "") + m.Cmd("count", mdb.CREATE, OFFER, m.Option(FROM), kit.Dict(ice.LOG_DISABLE, ice.TRUE)) }}, ACCEPT: {Help: "接受", Role: VOID, Hand: func(m *ice.Message, arg ...string) { if m.Warn(m.Option(mdb.HASH) == "", ice.ErrNotValid, mdb.HASH) { diff --git a/base/tcp/host.go b/base/tcp/host.go index 66760905..63b5d45e 100644 --- a/base/tcp/host.go +++ b/base/tcp/host.go @@ -92,10 +92,11 @@ func init() { } }}, PUBLISH: {Hand: func(m *ice.Message, arg ...string) { - if strings.Contains(arg[0], LOCALHOST) { - arg[0] = strings.Replace(arg[0], LOCALHOST, _host_domain(m), 1) - } else if strings.Contains(arg[0], "127.0.0.1") { - arg[0] = strings.Replace(arg[0], "127.0.0.1", _host_domain(m), 1) + for _, p := range []string{LOCALHOST, "127.0.0.1", strings.ToLower(ice.Info.Hostname)} { + if strings.Contains(arg[0], p) { + arg[0] = strings.Replace(arg[0], p, _host_domain(m), 1) + break + } } m.Echo(arg[0]) }}, diff --git a/base/web/broad.go b/base/web/broad.go index a0798a67..59ebb9ef 100644 --- a/base/web/broad.go +++ b/base/web/broad.go @@ -60,11 +60,15 @@ func init() { ADMIN: {Hand: func(m *ice.Message, arg ...string) { broadOpen(m) }}, DREAM: {Hand: func(m *ice.Message, arg ...string) { broadOpen(m) }}, VIMER: {Hand: func(m *ice.Message, arg ...string) { broadOpen(m) }}, - OPEN: {Hand: func(m *ice.Message, arg ...string) { m.ProcessOpen(Domain(m.Option(mdb.NAME), m.Option(tcp.PORT))) }}, - tcp.SEND: {Hand: func(m *ice.Message, arg ...string) { _broad_send(m, "", "", "", "", arg...) }}, + SPIDE: {Name: "spide name type=repos", Hand: func(m *ice.Message, arg ...string) { + m.Cmd(SPIDE, mdb.CREATE, + m.OptionSimple(mdb.NAME), ORIGIN, "http://"+m.Option(mdb.NAME)+":"+m.Option(tcp.PORT)) + }}, + OPEN: {Hand: func(m *ice.Message, arg ...string) { m.ProcessOpen(Domain(m.Option(mdb.NAME), m.Option(tcp.PORT))) }}, + tcp.SEND: {Hand: func(m *ice.Message, arg ...string) { _broad_send(m, "", "", "", "", arg...) }}, }, gdb.EventsAction(SERVE_START), mdb.HashAction(mdb.SHORT, "host,port", mdb.FIELD, "time,hash,type,name,host,port,module,version,commitTime,compileTime,bootTime,kernel,arch", - mdb.ACTION, "admin,dream,vimer,open", mdb.SORT, "type,name,host,port"), mdb.ClearOnExitHashAction())}, + mdb.ACTION, "admin,dream,vimer,spide,open", mdb.SORT, "type,name,host,port"), mdb.ClearOnExitHashAction())}, }) } func broadOpen(m *ice.Message) { diff --git a/base/web/count.go b/base/web/count.go index 9df9c170..14538eba 100644 --- a/base/web/count.go +++ b/base/web/count.go @@ -5,6 +5,7 @@ import ( ice "shylinux.com/x/icebergs" "shylinux.com/x/icebergs/base/aaa" + "shylinux.com/x/icebergs/base/ctx" "shylinux.com/x/icebergs/base/mdb" "shylinux.com/x/icebergs/base/web/html" kit "shylinux.com/x/toolkits" @@ -106,6 +107,8 @@ func init() { } func Count(m *ice.Message, arg ...string) *ice.Message { + kit.If(len(arg) > 0 && arg[0] == "", func() { arg[0] = ctx.ShortCmd(m.PrefixKey()) }) + kit.If(len(arg) > 1 && arg[1] == "", func() { arg[1] = m.ActionKey() }) m.Cmd(COUNT, mdb.CREATE, arg, kit.Dict(ice.LOG_DISABLE, ice.TRUE)) return m } diff --git a/base/web/option.go b/base/web/option.go index 72902df9..1113cad7 100644 --- a/base/web/option.go +++ b/base/web/option.go @@ -26,7 +26,7 @@ func UserWeb(m Message) *url.URL { func UserHost(m *ice.Message) string { if p := m.Option(ice.MSG_USERHOST); p != "" { return p - } else if u := UserWeb(m); strings.Contains(u.Host, tcp.LOCALHOST) { + } else if u := UserWeb(m); kit.HasSuffix(u.Hostname(), tcp.LOCALHOST, ".local") { return m.Option(ice.MSG_USERHOST, tcp.PublishLocalhost(m, u.Scheme+"://"+u.Host)) } else { return m.Option(ice.MSG_USERHOST, u.Scheme+"://"+u.Host) diff --git a/base/web/serve.go b/base/web/serve.go index 1981d6b3..099266af 100644 --- a/base/web/serve.go +++ b/base/web/serve.go @@ -231,6 +231,7 @@ func init() { cli.SYSTEM: {Help: "系统", Hand: func(m *ice.Message, arg ...string) { cli.Opens(m, "System Settings.app") }}, cli.START: {Name: "start dev proto host port=9020 nodename username usernick", Hand: func(m *ice.Message, arg ...string) { _serve_start(m) }}, SERVE_START: {Hand: func(m *ice.Message, arg ...string) { + Count(m, m.ActionKey(), m.Option(tcp.PORT)) kit.If(m.Option(ice.DEMO) == ice.TRUE, func() { m.Cmd(CHAT_HEADER, ice.DEMO) }) switch cb := m.Optionv(SERVE_START).(type) { case func(): diff --git a/base/web/share.go b/base/web/share.go index 8243d4b9..f52cc212 100644 --- a/base/web/share.go +++ b/base/web/share.go @@ -77,6 +77,7 @@ func init() { kit.If(m.Option(mdb.TYPE) == LOGIN && m.Option(mdb.TEXT) == "", func() { arg = append(arg, mdb.TEXT, tcp.PublishLocalhost(m, m.Option(ice.MSG_USERWEB))) }) mdb.HashCreate(m, m.OptionSimple(mdb.TEXT), arg, SPACE, m.Option(ice.MSG_USERPOD), aaa.USERNICK, m.Option(ice.MSG_USERNICK), aaa.USERNAME, m.Option(ice.MSG_USERNAME), aaa.USERROLE, m.Option(ice.MSG_USERROLE)) m.Option(mdb.LINK, tcp.PublishLocalhost(m, m.MergeLink(P(SHARE, m.Result())))) + Count(m, "", m.Option(mdb.TYPE)) }}, LOGIN: {Help: "登录", Hand: func(m *ice.Message, arg ...string) { m.EchoQRCode(m.Cmd(SHARE, mdb.CREATE, mdb.TYPE, LOGIN).Option(mdb.LINK)).ProcessInner() diff --git a/core/chat/sso.go b/core/chat/sso.go index 5f69d676..8d13214b 100644 --- a/core/chat/sso.go +++ b/core/chat/sso.go @@ -24,6 +24,7 @@ func init() { } m.Cmdx(web.SPACE, m.Option(web.SPACE), aaa.USER, mdb.CREATE, m.Cmd(aaa.USER, m.Option(ice.MSG_USERNAME)).AppendSimple(aaa.USERNICK, aaa.USERNAME, aaa.USERROLE, aaa.USERZONE, aaa.AVATAR, aaa.AVATAR_URL, aaa.BACKGROUND, aaa.LANGUAGE)) m.RenderRedirect(kit.MergeURL2(m.Option(cli.BACK), web.P(web.SHARE, m.Cmdx(web.SPACE, m.Option(web.SPACE), web.SHARE, mdb.CREATE, mdb.TYPE, web.LOGIN, mdb.TEXT, m.Option(cli.BACK))))) + web.Count(m, SSO, m.Option(web.SPACE)) }}, }) } diff --git a/core/code/compile.go b/core/code/compile.go index 80bf5ece..81220d06 100644 --- a/core/code/compile.go +++ b/core/code/compile.go @@ -124,6 +124,7 @@ func init() { m.Logs(nfs.SAVE, nfs.TARGET, file, nfs.SOURCE, main) m.Cmdy(nfs.DIR, file, "time,path,size,hash,link") kit.If(!m.IsCliUA() && strings.Contains(file, ice.ICE), func() { m.Cmdy(PUBLISH, ice.CONTEXTS, ice.APP) }) + web.Count(m, "", file) } }}, }) diff --git a/core/code/publish.go b/core/code/publish.go index f5a6dc1b..c81d5caa 100644 --- a/core/code/publish.go +++ b/core/code/publish.go @@ -78,6 +78,7 @@ const PUBLISH = "publish" func init() { web.Index.MergeCommands(ice.Commands{ web.PP(ice.PUBLISH): {Role: aaa.VOID, Hand: func(m *ice.Message, arg ...string) { + web.Count(m, PUBLISH, path.Join(arg...)) web.ShareLocalFile(m, ice.USR_PUBLISH, path.Join(arg...)) }}, }) diff --git a/core/wiki/portal.go b/core/wiki/portal.go index 825de0f5..d26ed599 100644 --- a/core/wiki/portal.go +++ b/core/wiki/portal.go @@ -88,6 +88,7 @@ func init() { kit.If(path.Join(arg...) == "commands", func() { _portal_commands(m, arg...) }) m.Push(NAV, m.Cmdx(WORD, path.Join(nfs.USR_LEARNING_PORTAL, path.Join(arg...), INDEX_SHY))) } + web.Count(m, "", path.Join(arg...)) m.Display("") }}, }) diff --git a/data.go b/data.go index 76507261..8d02d6c6 100644 --- a/data.go +++ b/data.go @@ -8,7 +8,13 @@ import ( "shylinux.com/x/toolkits/task" ) -func (m *Message) ActionKey() string { return strings.TrimPrefix(strings.TrimSuffix(m._sub, PS), PS) } +func (m *Message) ActionKey() string { + if action := strings.TrimPrefix(strings.TrimSuffix(m._sub, PS), PS); kit.IsIn(action, LIST, SELECT) { + return "" + } else { + return action + } +} func (m *Message) CommandKey() string { return strings.TrimPrefix(strings.TrimSuffix(m._key, PS), PS) } func (m *Message) PrefixKey() string { return m.Prefix(m.CommandKey()) } func (m *Message) Prefix(arg ...string) string { return m.Target().Prefix(arg...) } diff --git a/misc/git/service.go b/misc/git/service.go index 4f360e42..3aa40bce 100644 --- a/misc/git/service.go +++ b/misc/git/service.go @@ -52,6 +52,7 @@ func _service_repos(m *ice.Message, arg ...string) error { } else { web.RenderType(m.W, "", kit.Format("application/x-git-%s-result", service)) } + web.Count(m, service, repos) if mdb.Conf(m, web.CODE_GIT_SERVICE, kit.Keym(ice.CMD)) == GIT { return _service_repos0(m, arg...) }