diff --git a/base/web/count.go b/base/web/count.go new file mode 100644 index 00000000..8012fb7e --- /dev/null +++ b/base/web/count.go @@ -0,0 +1,21 @@ +package web + +import ( + ice "shylinux.com/x/icebergs" + "shylinux.com/x/icebergs/base/mdb" + kit "shylinux.com/x/toolkits" +) + +const COUNT = "count" + +func init() { + Index.MergeCommands(ice.Commands{ + COUNT: &ice.Command{Name: "count hash auto", Help: "计数", Actions: ice.MergeActions(ice.Actions{ + mdb.CREATE: {Name: "create type name text", Hand: func(m *ice.Message, arg ...string) { + mdb.HashSelectUpdate(m, mdb.HashCreate(m), func(value ice.Map) { value[mdb.COUNT] = kit.Int(value[mdb.COUNT]) + 1 }) + }}, + }, mdb.HashAction(mdb.SHORT, "type,name", mdb.FIELD, "time,hash,count,type,name,text")), Hand: func(m *ice.Message, arg ...string) { + mdb.HashSelect(m, arg...).Sort("type,name,text", "str", "str", "str") + }}, + }) +} diff --git a/base/web/serve.go b/base/web/serve.go index 65f8c855..872f1d1d 100644 --- a/base/web/serve.go +++ b/base/web/serve.go @@ -155,6 +155,8 @@ func _serve_auth(m *ice.Message, key string, cmds []string, w http.ResponseWrite m.Auth(aaa.USERNICK, m.Option(ice.MSG_USERNICK, ls[1]), aaa.USERNAME, m.Option(ice.MSG_USERNAME, ls[2]), aaa.USERROLE, m.Option(ice.MSG_USERROLE, ls[3]), CACHE, ls[0]) } } + m.Cmd(COUNT, mdb.CREATE, aaa.IP, m.Option(ice.MSG_USERIP), m.Option(ice.MSG_USERUA)) + m.Cmd(COUNT, mdb.CREATE, m.R.Method, m.R.URL.Path, kit.Join(kit.Simple(m.Optionv(ice.MSG_CMDS)), " ")) return cmds, aaa.Right(m, key, cmds) } diff --git a/base/web/web.go b/base/web/web.go index 8c0019c0..b78c910e 100644 --- a/base/web/web.go +++ b/base/web/web.go @@ -79,7 +79,9 @@ const WEB = "web" var Index = &ice.Context{Name: WEB, Help: "网络模块"} -func init() { ice.Index.Register(Index, &Frame{}, BROAD, SERVE, SPACE, DREAM, CACHE, SPIDE, SHARE) } +func init() { + ice.Index.Register(Index, &Frame{}, COUNT, BROAD, SERVE, SPACE, DREAM, CACHE, SPIDE, SHARE) +} func ApiAction(arg ...string) ice.Actions { return ice.Actions{kit.Select(nfs.PS, arg, 0): {}} } func Prefix(arg ...string) string { diff --git a/core/chat/action.go b/core/chat/action.go index b21d12b0..0ccbd0e7 100644 --- a/core/chat/action.go +++ b/core/chat/action.go @@ -21,6 +21,7 @@ func _action_exec(m *ice.Message, river, storm, index string, arg ...string) { }).Length() == 0, ice.ErrNotRight, index, arg) { return } + m.Cmd(web.COUNT, mdb.CREATE, ACTION, index, kit.Join(arg)) if !ctx.PodCmd(m, index, arg) { m.Cmdy(index, arg) } diff --git a/logs.go b/logs.go index 3f247d1c..16f113ab 100644 --- a/logs.go +++ b/logs.go @@ -200,6 +200,9 @@ func (m *Message) FormatChain() string { ms = append(ms, msg) } show := func(msg *Message, key string, arg ...string) string { + if _, ok := msg.data[key]; ok { + return kit.Format("%s%s:%s %v", kit.Select("", arg, 0), key, kit.Select("", arg, 1), msg.data[key]) + } if len(msg.meta[key]) == 0 || len(msg.meta[key]) == 1 && msg.meta[key][0] == "" { return "" } diff --git a/misc/git/service.go b/misc/git/service.go index 0f96b585..5aa89e80 100644 --- a/misc/git/service.go +++ b/misc/git/service.go @@ -55,10 +55,11 @@ func _service_param(m *ice.Message, arg ...string) (string, string) { return _service_path(m, repos), strings.TrimPrefix(service, "git-") } func _service_repos(m *ice.Message, arg ...string) error { + repos, service := _service_param(m, arg...) + m.Cmd(web.COUNT, mdb.CREATE, service, strings.TrimPrefix(repos, kit.Path(ice.USR_LOCAL_REPOS)+nfs.PS), m.Option(ice.MSG_USERUA)) if mdb.Conf(m, "web.code.git.service", "meta.cmd") == "git" { return _service_repos0(m, arg...) } - repos, service := _service_param(m, arg...) m.Logs(m.R.Method, service, repos) info := false if m.Option(cli.CMD_DIR, repos); strings.HasSuffix(path.Join(arg...), INFO_REFS) { @@ -132,6 +133,9 @@ func init() { m.RenderRedirect(kit.MergeURL(ice.Info.Make.Remote+"/info/refs", m.OptionSimple(SERVICE))) }}}) web.Index.MergeCommands(ice.Commands{"/x/": {Actions: aaa.WhiteAction(), Hand: func(m *ice.Message, arg ...string) { + if len(arg) == 0 { + return + } if arg[0] == ice.LIST { m.Cmd(Prefix(SERVICE), func(value ice.Maps) { m.Push(nfs.REPOS, web.MergeLink(m, "/x/"+kit.Keys(value[nfs.REPOS], GIT))) }) m.Sort(nfs.REPOS)