forked from x/icebergs
opt count
This commit is contained in:
parent
39908a29b1
commit
1a75e9a77e
@ -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) {
|
||||
|
@ -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])
|
||||
}},
|
||||
|
@ -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) {
|
||||
|
@ -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
|
||||
}
|
||||
|
@ -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)
|
||||
|
@ -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():
|
||||
|
@ -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()
|
||||
|
@ -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))
|
||||
}},
|
||||
})
|
||||
}
|
||||
|
@ -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)
|
||||
}
|
||||
}},
|
||||
})
|
||||
|
@ -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...))
|
||||
}},
|
||||
})
|
||||
|
@ -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("")
|
||||
}},
|
||||
})
|
||||
|
8
data.go
8
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...) }
|
||||
|
@ -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...)
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user