1
0
forked from x/icebergs

add web.count

This commit is contained in:
IT 老营长 @云轩领航-创始人 2023-07-26 14:23:27 +08:00
parent dad4c73808
commit a82c81813b
6 changed files with 35 additions and 2 deletions

21
base/web/count.go Normal file
View File

@ -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")
}},
})
}

View File

@ -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)
}

View File

@ -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 {

View File

@ -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)
}

View File

@ -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 ""
}

View File

@ -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)