mirror of
https://shylinux.com/x/icebergs
synced 2025-04-28 18:22:02 +08:00
add web.count
This commit is contained in:
parent
dad4c73808
commit
a82c81813b
21
base/web/count.go
Normal file
21
base/web/count.go
Normal 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")
|
||||||
|
}},
|
||||||
|
})
|
||||||
|
}
|
@ -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.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)
|
return cmds, aaa.Right(m, key, cmds)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -79,7 +79,9 @@ const WEB = "web"
|
|||||||
|
|
||||||
var Index = &ice.Context{Name: WEB, Help: "网络模块"}
|
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 ApiAction(arg ...string) ice.Actions { return ice.Actions{kit.Select(nfs.PS, arg, 0): {}} }
|
||||||
func Prefix(arg ...string) string {
|
func Prefix(arg ...string) string {
|
||||||
|
@ -21,6 +21,7 @@ func _action_exec(m *ice.Message, river, storm, index string, arg ...string) {
|
|||||||
}).Length() == 0, ice.ErrNotRight, index, arg) {
|
}).Length() == 0, ice.ErrNotRight, index, arg) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
m.Cmd(web.COUNT, mdb.CREATE, ACTION, index, kit.Join(arg))
|
||||||
if !ctx.PodCmd(m, index, arg) {
|
if !ctx.PodCmd(m, index, arg) {
|
||||||
m.Cmdy(index, arg)
|
m.Cmdy(index, arg)
|
||||||
}
|
}
|
||||||
|
3
logs.go
3
logs.go
@ -200,6 +200,9 @@ func (m *Message) FormatChain() string {
|
|||||||
ms = append(ms, msg)
|
ms = append(ms, msg)
|
||||||
}
|
}
|
||||||
show := func(msg *Message, key string, arg ...string) string {
|
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] == "" {
|
if len(msg.meta[key]) == 0 || len(msg.meta[key]) == 1 && msg.meta[key][0] == "" {
|
||||||
return ""
|
return ""
|
||||||
}
|
}
|
||||||
|
@ -55,10 +55,11 @@ func _service_param(m *ice.Message, arg ...string) (string, string) {
|
|||||||
return _service_path(m, repos), strings.TrimPrefix(service, "git-")
|
return _service_path(m, repos), strings.TrimPrefix(service, "git-")
|
||||||
}
|
}
|
||||||
func _service_repos(m *ice.Message, arg ...string) error {
|
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" {
|
if mdb.Conf(m, "web.code.git.service", "meta.cmd") == "git" {
|
||||||
return _service_repos0(m, arg...)
|
return _service_repos0(m, arg...)
|
||||||
}
|
}
|
||||||
repos, service := _service_param(m, arg...)
|
|
||||||
m.Logs(m.R.Method, service, repos)
|
m.Logs(m.R.Method, service, repos)
|
||||||
info := false
|
info := false
|
||||||
if m.Option(cli.CMD_DIR, repos); strings.HasSuffix(path.Join(arg...), INFO_REFS) {
|
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)))
|
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) {
|
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 {
|
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.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)
|
m.Sort(nfs.REPOS)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user