forked from x/icebergs
add some
This commit is contained in:
parent
2b4b3e16b2
commit
b3024262ca
19
meta.go
19
meta.go
@ -367,7 +367,9 @@ func (m *Message) Options(arg ...Any) *Message {
|
|||||||
return m
|
return m
|
||||||
}
|
}
|
||||||
func (m *Message) Optionv(key string, arg ...Any) Any {
|
func (m *Message) Optionv(key string, arg ...Any) Any {
|
||||||
|
var unlock func()
|
||||||
if len(arg) > 0 {
|
if len(arg) > 0 {
|
||||||
|
unlock = m.lock.Lock()
|
||||||
kit.If(kit.IndexOf(m.meta[MSG_OPTION], key) == -1, func() { m.meta[MSG_OPTION] = append(m.meta[MSG_OPTION], key) })
|
kit.If(kit.IndexOf(m.meta[MSG_OPTION], key) == -1, func() { m.meta[MSG_OPTION] = append(m.meta[MSG_OPTION], key) })
|
||||||
switch delete(m.data, key); v := arg[0].(type) {
|
switch delete(m.data, key); v := arg[0].(type) {
|
||||||
case nil:
|
case nil:
|
||||||
@ -379,17 +381,24 @@ func (m *Message) Optionv(key string, arg ...Any) Any {
|
|||||||
default:
|
default:
|
||||||
m.data[key] = v
|
m.data[key] = v
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
unlock = m.lock.RLock()
|
||||||
}
|
}
|
||||||
for msg := m; msg != nil; msg = msg.message {
|
if v, ok := m.data[key]; ok {
|
||||||
if v, ok := msg.data[key]; ok {
|
unlock()
|
||||||
return v
|
return v
|
||||||
}
|
} else if v, ok := m.meta[key]; ok {
|
||||||
if v, ok := msg.meta[key]; ok {
|
unlock()
|
||||||
return v
|
return v
|
||||||
|
} else {
|
||||||
|
unlock()
|
||||||
}
|
}
|
||||||
}
|
if m.message != nil {
|
||||||
|
return m.message.Optionv(key)
|
||||||
|
} else {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
}
|
||||||
func (m *Message) Option(key string, arg ...Any) string {
|
func (m *Message) Option(key string, arg ...Any) string {
|
||||||
return kit.Select("", kit.Simple(m.Optionv(key, arg...)), 0)
|
return kit.Select("", kit.Simple(m.Optionv(key, arg...)), 0)
|
||||||
}
|
}
|
||||||
|
@ -45,9 +45,9 @@ field "状态机" web.code.git.status
|
|||||||
field "配置键" web.code.git.configs
|
field "配置键" web.code.git.configs
|
||||||
field "服务器" web.code.git.service
|
field "服务器" web.code.git.service
|
||||||
field "代码源" web.code.git.search args `repos`
|
field "代码源" web.code.git.search args `repos`
|
||||||
return
|
|
||||||
field "架构图" web.code.git.spide args `icebergs`
|
field "架构图" web.code.git.spide args `icebergs`
|
||||||
field "趋势图" web.code.git.trend args `icebergs`
|
field "趋势图" web.code.git.trend args `icebergs`
|
||||||
|
return
|
||||||
field "代码行" web.code.git.count
|
field "代码行" web.code.git.count
|
||||||
field "统计量" web.code.git.total
|
field "统计量" web.code.git.total
|
||||||
|
|
||||||
@ -58,7 +58,6 @@ service.go
|
|||||||
search.go
|
search.go
|
||||||
search.js
|
search.js
|
||||||
search.css
|
search.css
|
||||||
search.shy
|
|
||||||
|
|
||||||
spide.go
|
spide.go
|
||||||
trend.go
|
trend.go
|
||||||
|
@ -2,11 +2,8 @@ package git
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
ice "shylinux.com/x/icebergs"
|
ice "shylinux.com/x/icebergs"
|
||||||
"shylinux.com/x/icebergs/base/aaa"
|
|
||||||
"shylinux.com/x/icebergs/base/ctx"
|
"shylinux.com/x/icebergs/base/ctx"
|
||||||
"shylinux.com/x/icebergs/base/mdb"
|
|
||||||
"shylinux.com/x/icebergs/base/nfs"
|
"shylinux.com/x/icebergs/base/nfs"
|
||||||
kit "shylinux.com/x/toolkits"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
const SPIDE = "spide"
|
const SPIDE = "spide"
|
||||||
@ -14,12 +11,11 @@ const SPIDE = "spide"
|
|||||||
func init() {
|
func init() {
|
||||||
Index.MergeCommands(ice.Commands{
|
Index.MergeCommands(ice.Commands{
|
||||||
SPIDE: {Name: "spide repos auto", Help: "构架图", Hand: func(m *ice.Message, arg ...string) {
|
SPIDE: {Name: "spide repos auto", Help: "构架图", Hand: func(m *ice.Message, arg ...string) {
|
||||||
if len(kit.Slice(arg, 0, 1)) == 0 {
|
if len(arg) == 0 {
|
||||||
m.Cmdy(REPOS)
|
m.Cmdy(REPOS)
|
||||||
} else if len(arg) == 1 {
|
} else if p := _repos_path(m, arg[0]); len(arg) == 1 {
|
||||||
nfs.DirDeepAll(m, _repos_path(m, arg[0]), "", func(value ice.Maps) { m.Push("", value, []string{nfs.PATH}) }, nfs.PATH)
|
nfs.DirDeepAll(m, p, "", nil, nfs.PATH).Options(nfs.DIR_ROOT, p+nfs.PS)
|
||||||
m.Options(nfs.DIR_ROOT, _repos_path(m, arg[0])+nfs.PS).StatusTimeCount()
|
ctx.DisplayStory(m, "")
|
||||||
ctx.DisplayStory(m, "", mdb.FIELD, nfs.PATH, aaa.ROOT, arg[0])
|
|
||||||
}
|
}
|
||||||
}},
|
}},
|
||||||
})
|
})
|
||||||
|
@ -29,7 +29,7 @@ func init() {
|
|||||||
REST = "rest"
|
REST = "rest"
|
||||||
)
|
)
|
||||||
Index.MergeCommands(ice.Commands{
|
Index.MergeCommands(ice.Commands{
|
||||||
TOTAL: {Name: "total repos auto pie", Help: "统计量", Actions: ice.MergeActions(ice.Actions{
|
TOTAL: {Name: "total repos auto pie", Help: "统计量", Actions: ice.Actions{
|
||||||
"pie": {Help: "饼图", Hand: func(m *ice.Message, arg ...string) {
|
"pie": {Help: "饼图", Hand: func(m *ice.Message, arg ...string) {
|
||||||
defer ctx.DisplayStory(m, "pie.js")
|
defer ctx.DisplayStory(m, "pie.js")
|
||||||
m.Cmd("", func(value ice.Maps) {
|
m.Cmd("", func(value ice.Maps) {
|
||||||
@ -38,9 +38,9 @@ func init() {
|
|||||||
})
|
})
|
||||||
})
|
})
|
||||||
}},
|
}},
|
||||||
}, ctx.ConfAction("skip", kit.DictList("go-git", "go-qrcode", "websocket", "webview", "word-dict"))), Hand: func(m *ice.Message, arg ...string) {
|
}, Hand: func(m *ice.Message, arg ...string) {
|
||||||
if len(arg) > 0 {
|
if len(arg) > 0 {
|
||||||
ReposList(m).Table(func(value ice.Maps) {
|
ReposList(m.Spawn()).Table(func(value ice.Maps) {
|
||||||
kit.If(value[REPOS] == arg[0], func() { m.Cmdy("_sum", value[nfs.PATH], arg[1:]) })
|
kit.If(value[REPOS] == arg[0], func() { m.Cmdy("_sum", value[nfs.PATH], arg[1:]) })
|
||||||
})
|
})
|
||||||
m.StatusTimeCount(m.AppendSimple(FROM))
|
m.StatusTimeCount(m.AppendSimple(FROM))
|
||||||
@ -48,9 +48,6 @@ func init() {
|
|||||||
}
|
}
|
||||||
from, days, commit, adds, dels, rest := "", 0, 0, 0, 0, 0
|
from, days, commit, adds, dels, rest := "", 0, 0, 0, 0, 0
|
||||||
TableGo(ReposList(m), func(value ice.Maps, lock *task.Lock) {
|
TableGo(ReposList(m), func(value ice.Maps, lock *task.Lock) {
|
||||||
if mdb.Config(m, kit.Keys("skip", value[REPOS])) == ice.TRUE {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
msg := m.Cmd("_sum", value[nfs.PATH], mdb.TOTAL, "10000")
|
msg := m.Cmd("_sum", value[nfs.PATH], mdb.TOTAL, "10000")
|
||||||
defer lock.Lock()()
|
defer lock.Lock()()
|
||||||
msg.Table(func(value ice.Maps) {
|
msg.Table(func(value ice.Maps) {
|
||||||
@ -66,6 +63,8 @@ func init() {
|
|||||||
m.SortIntR(REST).StatusTimeCount()
|
m.SortIntR(REST).StatusTimeCount()
|
||||||
}},
|
}},
|
||||||
"_sum": {Name: "_sum [path] [total] [count|date] args...", Help: "统计量", Hand: func(m *ice.Message, arg ...string) {
|
"_sum": {Name: "_sum [path] [total] [count|date] args...", Help: "统计量", Hand: func(m *ice.Message, arg ...string) {
|
||||||
|
m.Options(nfs.CAT_CONTENT, "")
|
||||||
|
m.Options(nfs.DIR_ROOT, "")
|
||||||
if len(arg) > 0 {
|
if len(arg) > 0 {
|
||||||
if nfs.Exists(m, _git_dir(arg[0])) || nfs.Exists(m, path.Join(arg[0], "refs/heads/")) {
|
if nfs.Exists(m, _git_dir(arg[0])) || nfs.Exists(m, path.Join(arg[0], "refs/heads/")) {
|
||||||
m.Option(cli.CMD_DIR, arg[0])
|
m.Option(cli.CMD_DIR, arg[0])
|
||||||
|
@ -5,6 +5,7 @@ import (
|
|||||||
"shylinux.com/x/icebergs/base/ctx"
|
"shylinux.com/x/icebergs/base/ctx"
|
||||||
"shylinux.com/x/icebergs/base/mdb"
|
"shylinux.com/x/icebergs/base/mdb"
|
||||||
"shylinux.com/x/icebergs/base/nfs"
|
"shylinux.com/x/icebergs/base/nfs"
|
||||||
|
"shylinux.com/x/icebergs/base/web/html"
|
||||||
"shylinux.com/x/icebergs/core/code"
|
"shylinux.com/x/icebergs/core/code"
|
||||||
kit "shylinux.com/x/toolkits"
|
kit "shylinux.com/x/toolkits"
|
||||||
)
|
)
|
||||||
@ -13,14 +14,13 @@ const TREND = "trend"
|
|||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
Index.MergeCommands(ice.Commands{
|
Index.MergeCommands(ice.Commands{
|
||||||
TREND: {Name: "trend repos@key begin_time@date auto", Help: "趋势图", Actions: ice.Actions{
|
TREND: {Name: "trend repos begin_time@date auto", Help: "趋势图", Actions: ice.Actions{
|
||||||
mdb.INPUTS: {Hand: func(m *ice.Message, arg ...string) { m.Cmdy(REPOS, ice.OptionFields("repos,time")) }},
|
|
||||||
mdb.DETAIL: {Hand: func(m *ice.Message, arg ...string) {
|
mdb.DETAIL: {Hand: func(m *ice.Message, arg ...string) {
|
||||||
m.Cmdy("", code.INNER, m.Option(REPOS), MASTER, m.Option(mdb.HASH), m.Cmdv(REPOS, m.Option(REPOS), MASTER, m.Option(mdb.HASH), nfs.FILE))
|
m.Cmdy("", code.INNER, m.Option(REPOS), MASTER, m.Option(mdb.HASH), m.Cmdv(REPOS, m.Option(REPOS), MASTER, m.Option(mdb.HASH), nfs.FILE))
|
||||||
}},
|
}},
|
||||||
code.INNER: {Hand: func(m *ice.Message, arg ...string) {
|
code.INNER: {Hand: func(m *ice.Message, arg ...string) {
|
||||||
m.Cmdy(REPOS, code.INNER, arg)
|
m.Cmdy(REPOS, code.INNER, arg)
|
||||||
ctx.DisplayLocal(m, "code/inner.js", "style", "float")
|
ctx.DisplayLocal(m, "code/inner.js", ctx.STYLE, html.FLOAT)
|
||||||
}},
|
}},
|
||||||
}, Hand: func(m *ice.Message, arg ...string) {
|
}, Hand: func(m *ice.Message, arg ...string) {
|
||||||
if len(arg) == 0 {
|
if len(arg) == 0 {
|
||||||
|
2
type.go
2
type.go
@ -10,6 +10,7 @@ import (
|
|||||||
|
|
||||||
kit "shylinux.com/x/toolkits"
|
kit "shylinux.com/x/toolkits"
|
||||||
"shylinux.com/x/toolkits/logs"
|
"shylinux.com/x/toolkits/logs"
|
||||||
|
"shylinux.com/x/toolkits/task"
|
||||||
)
|
)
|
||||||
|
|
||||||
type Any = interface{}
|
type Any = interface{}
|
||||||
@ -212,6 +213,7 @@ type Message struct {
|
|||||||
|
|
||||||
data Map
|
data Map
|
||||||
meta map[string][]string
|
meta map[string][]string
|
||||||
|
lock task.Lock
|
||||||
|
|
||||||
root *Message
|
root *Message
|
||||||
message *Message
|
message *Message
|
||||||
|
Loading…
x
Reference in New Issue
Block a user