forked from x/icebergs
opt git
This commit is contained in:
parent
515ec07559
commit
ebc9a99756
@ -80,7 +80,7 @@ func init() {
|
|||||||
}
|
}
|
||||||
_inner_list(m, _inner_ext(arg[1]), arg[1], arg[0])
|
_inner_list(m, _inner_ext(arg[1]), arg[1], arg[0])
|
||||||
}},
|
}},
|
||||||
VIMER: {Name: "vimer path=usr/demo file=hi.sh line=1 刷新:button=auto 编辑:button 保存:button 运行:button 项目:button", Help: "编辑器", Meta: kit.Dict(
|
VIMER: {Name: "vimer path=usr/demo file=hi.sh line=1 刷新:button=auto 保存:button 运行:button 项目:button", Help: "编辑器", Meta: kit.Dict(
|
||||||
"display", "/plugin/local/code/vimer.js", "style", "editor",
|
"display", "/plugin/local/code/vimer.js", "style", "editor",
|
||||||
), Action: map[string]*ice.Action{
|
), Action: map[string]*ice.Action{
|
||||||
web.UPLOAD: {Name: "upload path name", Help: "上传", Hand: func(m *ice.Message, arg ...string) {
|
web.UPLOAD: {Name: "upload path name", Help: "上传", Hand: func(m *ice.Message, arg ...string) {
|
||||||
|
@ -19,7 +19,7 @@ var refer = `<ul class="story"
|
|||||||
{{range $k, $v := .Optionv "extra"}}data-{{$k}}='{{$v}}'{{end}}
|
{{range $k, $v := .Optionv "extra"}}data-{{$k}}='{{$v}}'{{end}}
|
||||||
data-type="{{.Option "type"}}" data-name="{{.Option "name"}}" data-text="{{.Option "text"}}">
|
data-type="{{.Option "type"}}" data-name="{{.Option "name"}}" data-text="{{.Option "text"}}">
|
||||||
{{range $index, $value := .Optionv "list"}}<li>{{index $value 0}}: <a href="{{index $value 1}}" target="_blank">{{index $value 1}}</a></li>{{end}}</ul>`
|
{{range $index, $value := .Optionv "list"}}<li>{{index $value 0}}: <a href="{{index $value 1}}" target="_blank">{{index $value 1}}</a></li>{{end}}</ul>`
|
||||||
var spark = `<p class="story" {{range $k, $v := .Optionv "extra"}}data-{{$k}}='{{$v}}'{{end}} data-type="{{.Option "type"}}" data-name="{{.Option "name"}}" data-text="{{.Option "text"}}">{{.Option "text"}}</p>`
|
var spark = `<p class="story {{.Option "style"}}" {{range $k, $v := .Optionv "extra"}}data-{{$k}}='{{$v}}'{{end}} data-type="{{.Option "type"}}" data-name="{{.Option "name"}}" data-text="{{.Option "text"}}">{{.Option "text"}}</p>`
|
||||||
|
|
||||||
var chart = `<svg class="story" vertion="1.1" xmlns="http://www.w3.org/2000/svg" dominant-baseline="middle" text-anchor="middle"
|
var chart = `<svg class="story" vertion="1.1" xmlns="http://www.w3.org/2000/svg" dominant-baseline="middle" text-anchor="middle"
|
||||||
data-type="{{.Option "type"}}" data-name="{{.Option "name"}}" data-text="{{.Option "text"}}"
|
data-type="{{.Option "type"}}" data-name="{{.Option "name"}}" data-text="{{.Option "text"}}"
|
||||||
|
@ -85,6 +85,7 @@ func _refer_show(m *ice.Message, name, text string, arg ...string) {
|
|||||||
m.Render(ice.RENDER_TEMPLATE, m.Conf(REFER, "meta.template"))
|
m.Render(ice.RENDER_TEMPLATE, m.Conf(REFER, "meta.template"))
|
||||||
}
|
}
|
||||||
func _spark_show(m *ice.Message, name, text string, arg ...string) {
|
func _spark_show(m *ice.Message, name, text string, arg ...string) {
|
||||||
|
m.Option("style", kit.Select("", name))
|
||||||
text = strings.TrimSpace(text)
|
text = strings.TrimSpace(text)
|
||||||
m.Optionv("list", kit.Split(text, "\n"))
|
m.Optionv("list", kit.Split(text, "\n"))
|
||||||
|
|
||||||
@ -290,6 +291,7 @@ const (
|
|||||||
|
|
||||||
BAIDU = "baidu"
|
BAIDU = "baidu"
|
||||||
OTHER = "other"
|
OTHER = "other"
|
||||||
|
SNIPPET = "snippet"
|
||||||
|
|
||||||
PREMENU = "premenu"
|
PREMENU = "premenu"
|
||||||
CHAPTER = "chapter"
|
CHAPTER = "chapter"
|
||||||
|
2
go.sum
2
go.sum
@ -11,6 +11,8 @@ github.com/nareix/joy4 v0.0.0-20200507095837-05a4ffbb5369 h1:Yp0zFEufLz0H7jzffb4
|
|||||||
github.com/nareix/joy4 v0.0.0-20200507095837-05a4ffbb5369/go.mod h1:aFJ1ZwLjvHN4yEzE5Bkz8rD8/d8Vlj3UIuvz2yfET7I=
|
github.com/nareix/joy4 v0.0.0-20200507095837-05a4ffbb5369/go.mod h1:aFJ1ZwLjvHN4yEzE5Bkz8rD8/d8Vlj3UIuvz2yfET7I=
|
||||||
github.com/shylinux/toolkits v0.1.6 h1:x+Bs+oijuS11TWGAsdCEgwDbCS35uJvnP4jYDETJqig=
|
github.com/shylinux/toolkits v0.1.6 h1:x+Bs+oijuS11TWGAsdCEgwDbCS35uJvnP4jYDETJqig=
|
||||||
github.com/shylinux/toolkits v0.1.6/go.mod h1:Y68Ot6xOmo1bun67YvqC3chDGeU2gDxtsUnvVDGJm4g=
|
github.com/shylinux/toolkits v0.1.6/go.mod h1:Y68Ot6xOmo1bun67YvqC3chDGeU2gDxtsUnvVDGJm4g=
|
||||||
|
github.com/shylinux/toolkits v0.1.7 h1:RDUpZNTgnob6vaKJvJgNVaDE2UZRURjLG4StpSaAWF8=
|
||||||
|
github.com/shylinux/toolkits v0.1.7/go.mod h1:Y68Ot6xOmo1bun67YvqC3chDGeU2gDxtsUnvVDGJm4g=
|
||||||
github.com/skip2/go-qrcode v0.0.0-20200617195104-da1b6568686e h1:MRM5ITcdelLK2j1vwZ3Je0FKVCfqOLp5zO6trqMLYs0=
|
github.com/skip2/go-qrcode v0.0.0-20200617195104-da1b6568686e h1:MRM5ITcdelLK2j1vwZ3Je0FKVCfqOLp5zO6trqMLYs0=
|
||||||
github.com/skip2/go-qrcode v0.0.0-20200617195104-da1b6568686e/go.mod h1:XV66xRDqSt+GTGFMVlhk3ULuV0y9ZmzeVGR4mloJI3M=
|
github.com/skip2/go-qrcode v0.0.0-20200617195104-da1b6568686e/go.mod h1:XV66xRDqSt+GTGFMVlhk3ULuV0y9ZmzeVGR4mloJI3M=
|
||||||
github.com/tuotoo/qrcode v0.0.0-20190222102259-ac9c44189bf2 h1:BWVtt2VBY+lmVDu9MGKqLGKl04B+iRHcrW1Ptyi/8tg=
|
github.com/tuotoo/qrcode v0.0.0-20190222102259-ac9c44189bf2 h1:BWVtt2VBY+lmVDu9MGKqLGKl04B+iRHcrW1Ptyi/8tg=
|
||||||
|
235
misc/git/git.go
235
misc/git/git.go
@ -17,11 +17,11 @@ import (
|
|||||||
"time"
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
func add(m *ice.Message, n string, p string) {
|
func _repos_insert(m *ice.Message, name string, dir string) {
|
||||||
if s, e := os.Stat(m.Option("cmd_dir", path.Join(p, ".git"))); e == nil && s.IsDir() {
|
if s, e := os.Stat(m.Option(cli.CMD_DIR, path.Join(dir, ".git"))); e == nil && s.IsDir() {
|
||||||
ls := strings.SplitN(strings.Trim(m.Cmdx(cli.SYSTEM, "git", "log", "-n1", `--pretty=format:"%ad %s"`, "--date=iso"), "\""), " ", 4)
|
ls := strings.SplitN(strings.Trim(m.Cmdx(cli.SYSTEM, "git", "log", "-n1", `--pretty=format:"%ad %s"`, "--date=iso"), "\""), " ", 4)
|
||||||
m.Rich("repos", nil, kit.Data(
|
m.Rich(REPOS, nil, kit.Data(
|
||||||
"name", n, "path", p,
|
"name", name, "path", dir,
|
||||||
"last", kit.Select("", ls, 3), "time", strings.Join(ls[:2], " "),
|
"last", kit.Select("", ls, 3), "time", strings.Join(ls[:2], " "),
|
||||||
"branch", strings.TrimSpace(m.Cmdx(cli.SYSTEM, "git", "branch")),
|
"branch", strings.TrimSpace(m.Cmdx(cli.SYSTEM, "git", "branch")),
|
||||||
"remote", strings.TrimSpace(m.Cmdx(cli.SYSTEM, "git", "remote", "-v")),
|
"remote", strings.TrimSpace(m.Cmdx(cli.SYSTEM, "git", "remote", "-v")),
|
||||||
@ -29,10 +29,17 @@ func add(m *ice.Message, n string, p string) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var Index = &ice.Context{Name: "git", Help: "代码库",
|
const (
|
||||||
Caches: map[string]*ice.Cache{},
|
GIT = "git"
|
||||||
|
REPOS = "repos"
|
||||||
|
TOTAL = "total"
|
||||||
|
TREND = "trend"
|
||||||
|
SPIDE = "spide"
|
||||||
|
)
|
||||||
|
|
||||||
|
var Index = &ice.Context{Name: GIT, Help: "代码库",
|
||||||
Configs: map[string]*ice.Config{
|
Configs: map[string]*ice.Config{
|
||||||
"git": {Name: "git", Help: "代码库", Value: kit.Data(
|
GIT: {Name: GIT, Help: "代码库", Value: kit.Data(
|
||||||
"source", "https://github.com/git/git.git", "config", kit.Dict(
|
"source", "https://github.com/git/git.git", "config", kit.Dict(
|
||||||
"alias", kit.Dict("s", "status", "b", "branch"),
|
"alias", kit.Dict("s", "status", "b", "branch"),
|
||||||
"color", kit.Dict("ui", "true"),
|
"color", kit.Dict("ui", "true"),
|
||||||
@ -40,89 +47,59 @@ var Index = &ice.Context{Name: "git", Help: "代码库",
|
|||||||
"credential", kit.Dict("helper", "store"),
|
"credential", kit.Dict("helper", "store"),
|
||||||
),
|
),
|
||||||
)},
|
)},
|
||||||
|
REPOS: {Name: REPOS, Help: "仓库", Value: kit.Data(
|
||||||
"repos": {Name: "repos", Help: "仓库", Value: kit.Data(kit.MDB_SHORT, "name", "owner", "https://github.com/shylinux")},
|
kit.MDB_SHORT, kit.MDB_NAME, "owner", "https://github.com/shylinux",
|
||||||
"total": {Name: "total", Help: "统计", Value: kit.Data(kit.MDB_SHORT, "name", "skip", kit.Dict("wubi-dict", "true", "word-dict", "true"))},
|
)},
|
||||||
|
TOTAL: {Name: TOTAL, Help: "统计", Value: kit.Data(
|
||||||
|
kit.MDB_SHORT, kit.MDB_NAME, "skip", kit.Dict(
|
||||||
|
"wubi-dict", "true", "word-dict", "true",
|
||||||
|
),
|
||||||
|
)},
|
||||||
},
|
},
|
||||||
Commands: map[string]*ice.Command{
|
Commands: map[string]*ice.Command{
|
||||||
ice.CTX_INIT: {Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
|
ice.CTX_INIT: {Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
|
||||||
m.Watch(gdb.SYSTEM_INIT, m.AddCmd(&ice.Command{Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
|
m.Watch(gdb.SYSTEM_INIT, m.AddCmd(&ice.Command{Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
|
||||||
m.Cmd("repos", "volcanos", "usr/volcanos")
|
m.Cmd(REPOS, "volcanos", "usr/volcanos")
|
||||||
|
|
||||||
}}))
|
}}))
|
||||||
}},
|
}},
|
||||||
web.LOGIN: {Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
|
|
||||||
}},
|
|
||||||
|
|
||||||
code.INSTALL: {Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
|
|
||||||
m.Option("cmd_dir", m.Conf("install", "meta.path"))
|
|
||||||
m.Cmd(cli.SYSTEM, "git", "clone", m.Conf("git", "meta.source"))
|
|
||||||
|
|
||||||
m.Option("cmd_dir", path.Join(m.Conf("install", "meta.path"), "git"))
|
|
||||||
m.Cmd(cli.SYSTEM, "make", "configure")
|
|
||||||
m.Cmd(cli.SYSTEM, "./configure", "--prefix="+kit.Path("usr/local"))
|
|
||||||
|
|
||||||
m.Cmd(cli.SYSTEM, "make", "-j4")
|
|
||||||
m.Cmd(cli.SYSTEM, "make", "install")
|
|
||||||
}},
|
|
||||||
code.PREPARE: {Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
|
|
||||||
kit.Fetch(m.Confv("git", "meta.config"), func(conf string, value interface{}) {
|
|
||||||
kit.Fetch(value, func(key string, value string) {
|
|
||||||
m.Cmd(cli.SYSTEM, "git", "config", "--global", conf+"."+key, value)
|
|
||||||
})
|
|
||||||
})
|
|
||||||
}},
|
|
||||||
code.PROJECT: {Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
|
|
||||||
}},
|
|
||||||
|
|
||||||
"init": {Name: "init", Help: "初始化", Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
|
"init": {Name: "init", Help: "初始化", Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
|
||||||
// 系统项目
|
// 系统项目
|
||||||
wd, _ := os.Getwd()
|
wd, _ := os.Getwd()
|
||||||
add(m, path.Base(wd), wd)
|
_repos_insert(m, path.Base(wd), wd)
|
||||||
|
|
||||||
// 官方项目
|
// 官方项目
|
||||||
m.Cmd("nfs.dir", "usr", "name path").Table(func(index int, value map[string]string, head []string) {
|
m.Cmd(nfs.DIR, "usr", "name path").Table(func(index int, value map[string]string, head []string) {
|
||||||
add(m, value["name"], value["path"])
|
_repos_insert(m, value["name"], value["path"])
|
||||||
})
|
|
||||||
|
|
||||||
// 应用项目
|
|
||||||
m.Cmd("nfs.dir", m.Conf(web.DREAM, "meta.path"), "name path").Table(func(index int, value map[string]string, head []string) {
|
|
||||||
// add(m, value["name"], value["path"])
|
|
||||||
})
|
})
|
||||||
}},
|
}},
|
||||||
"auto": {Name: "auto", Help: "自动化", Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
|
REPOS: {Name: "repos [name=auto [path [remote [branch]]]] auto", Help: "代码仓库", Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
|
||||||
}},
|
|
||||||
"load": {Name: "load", Help: "序列化", Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
|
|
||||||
}},
|
|
||||||
|
|
||||||
"repos": {Name: "repos [name=auto [path [remote [branch]]]] auto", Help: "代码仓库", Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
|
|
||||||
if len(arg) > 1 {
|
if len(arg) > 1 {
|
||||||
if _, e := os.Stat(path.Join(arg[1], ".git")); e != nil && os.IsNotExist(e) {
|
if _, e := os.Stat(path.Join(arg[1], ".git")); e != nil && os.IsNotExist(e) {
|
||||||
// 下载仓库
|
// 下载仓库
|
||||||
m.Cmd(cli.SYSTEM, "git", "clone", "-b", kit.Select("master", arg, 3),
|
m.Cmd(cli.SYSTEM, GIT, "clone", "-b", kit.Select("master", arg, 3),
|
||||||
kit.Select(m.Conf("repos", "meta.owner")+"/"+arg[0], arg, 2), arg[1])
|
kit.Select(m.Conf(REPOS, "meta.owner")+"/"+arg[0], arg, 2), arg[1])
|
||||||
add(m, arg[0], arg[1])
|
_repos_insert(m, arg[0], arg[1])
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if len(arg) > 0 {
|
if len(arg) > 0 {
|
||||||
// 仓库详情
|
// 仓库详情
|
||||||
m.Richs("repos", nil, arg[0], func(key string, value map[string]interface{}) {
|
m.Richs(REPOS, nil, arg[0], func(key string, value map[string]interface{}) {
|
||||||
m.Push("detail", value["meta"])
|
m.Push("detail", value[kit.MDB_META])
|
||||||
})
|
})
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
// 仓库列表
|
// 仓库列表
|
||||||
m.Richs("repos", nil, "*", func(key string, value map[string]interface{}) {
|
m.Richs(REPOS, nil, kit.MDB_FOREACH, func(key string, value map[string]interface{}) {
|
||||||
m.Push(key, value["meta"], []string{"time", "name", "branch", "last"})
|
m.Push(key, value[kit.MDB_META], []string{kit.MDB_TIME, kit.MDB_NAME, "branch", "last"})
|
||||||
})
|
})
|
||||||
m.Sort("name")
|
m.Sort(kit.MDB_NAME)
|
||||||
}},
|
}},
|
||||||
"total": {Name: "total name=auto auto", Help: "提交统计", Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
|
TOTAL: {Name: "total name=auto auto", Help: "提交统计", Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
|
||||||
if len(arg) > 0 {
|
if len(arg) > 0 {
|
||||||
// 提交详情
|
// 提交详情
|
||||||
m.Richs("repos", nil, arg[0], func(key string, value map[string]interface{}) {
|
m.Richs(REPOS, nil, arg[0], func(key string, value map[string]interface{}) {
|
||||||
m.Cmdy("_sum", kit.Value(value, "meta.path"), arg[1:])
|
m.Cmdy("_sum", kit.Value(value, "meta.path"), arg[1:])
|
||||||
})
|
})
|
||||||
return
|
return
|
||||||
@ -132,8 +109,8 @@ var Index = &ice.Context{Name: "git", Help: "代码库",
|
|||||||
days := 0
|
days := 0
|
||||||
commit, adds, dels, rest := 0, 0, 0, 0
|
commit, adds, dels, rest := 0, 0, 0, 0
|
||||||
wg := &sync.WaitGroup{}
|
wg := &sync.WaitGroup{}
|
||||||
m.Richs("repos", nil, "*", func(key string, value map[string]interface{}) {
|
m.Richs(REPOS, nil, kit.MDB_FOREACH, func(key string, value map[string]interface{}) {
|
||||||
if m.Conf("total", kit.Keys("meta.skip", kit.Value(value, "meta.name"))) == "true" {
|
if m.Conf(TOTAL, kit.Keys("meta.skip", kit.Value(value, "meta.name"))) == "true" {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
wg.Add(1)
|
wg.Add(1)
|
||||||
@ -161,52 +138,10 @@ var Index = &ice.Context{Name: "git", Help: "代码库",
|
|||||||
m.Push("rest", rest)
|
m.Push("rest", rest)
|
||||||
m.Sort("rest", "int_r")
|
m.Sort("rest", "int_r")
|
||||||
}},
|
}},
|
||||||
"status": {Name: "status name=auto auto", Help: "文件状态", Meta: kit.Dict(
|
|
||||||
"detail", []interface{}{"add", "reset", "remove", kit.Dict("name", "commit", "args", kit.List(
|
|
||||||
kit.MDB_INPUT, "select", "name", "type", "values", []string{"add", "opt"},
|
|
||||||
kit.MDB_INPUT, "text", "name", "name", "value", "some",
|
|
||||||
))},
|
|
||||||
), Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
|
|
||||||
prefix := []string{cli.SYSTEM, "git"}
|
|
||||||
|
|
||||||
if len(arg) > 1 && arg[0] == "action" {
|
|
||||||
m.Richs("repos", nil, m.Option("name"), func(key string, value map[string]interface{}) {
|
|
||||||
m.Option("cmd_dir", kit.Value(value, "meta.path"))
|
|
||||||
switch arg[1] {
|
|
||||||
case "add":
|
|
||||||
m.Cmdy(prefix, arg[1], m.Option("file"))
|
|
||||||
case "reset":
|
|
||||||
m.Cmdy(prefix, arg[1], m.Option("file"))
|
|
||||||
case "checkout":
|
|
||||||
m.Cmdy(prefix, arg[1], m.Option("file"))
|
|
||||||
case "commit":
|
|
||||||
m.Cmdy(prefix, arg[1], "-m", m.Option("comment"))
|
|
||||||
}
|
|
||||||
})
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
m.Richs("repos", nil, kit.Select("*", arg, 0), func(key string, value map[string]interface{}) {
|
|
||||||
if m.Option("cmd_dir", kit.Value(value, "meta.path")); len(arg) > 0 {
|
|
||||||
// 更改详情
|
|
||||||
m.Echo(m.Cmdx(prefix, "diff"))
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
// 更改列表
|
|
||||||
for _, v := range strings.Split(strings.TrimSpace(m.Cmdx(prefix, "status", "-sb")), "\n") {
|
|
||||||
vs := strings.SplitN(strings.TrimSpace(v), " ", 2)
|
|
||||||
m.Push("name", kit.Value(value, "meta.name"))
|
|
||||||
m.Push("tags", vs[0])
|
|
||||||
m.Push("file", vs[1])
|
|
||||||
}
|
|
||||||
})
|
|
||||||
}},
|
|
||||||
|
|
||||||
"_sum": {Name: "_sum [path] [total] [count|date] args...", Help: "统计", Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
|
"_sum": {Name: "_sum [path] [total] [count|date] args...", Help: "统计", Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
|
||||||
if len(arg) > 0 {
|
if len(arg) > 0 {
|
||||||
if s, e := os.Stat(arg[0] + "/.git"); e == nil && s.IsDir() {
|
if s, e := os.Stat(arg[0] + "/.git"); e == nil && s.IsDir() {
|
||||||
m.Option("cmd_dir", arg[0])
|
m.Option(cli.CMD_DIR, arg[0])
|
||||||
arg = arg[1:]
|
arg = arg[1:]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -278,42 +213,42 @@ var Index = &ice.Context{Name: "git", Help: "代码库",
|
|||||||
m.Push("rest", count_add-count_del)
|
m.Push("rest", count_add-count_del)
|
||||||
}
|
}
|
||||||
}},
|
}},
|
||||||
|
TREND: {Name: "trend name=auto begin_time=@date auto", Help: "趋势图", Meta: kit.Dict(
|
||||||
"trend": {Name: "trend name=auto begin_time=@date auto", Help: "趋势图", Meta: kit.Dict(
|
|
||||||
"display", "/plugin/story/trend.js",
|
"display", "/plugin/story/trend.js",
|
||||||
), Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
|
), Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
|
||||||
if len(arg) == 0 {
|
if len(arg) == 0 {
|
||||||
m.Option("_display", "table")
|
m.Option("_display", "table")
|
||||||
}
|
}
|
||||||
m.Cmdy("total", arg)
|
m.Cmdy(TOTAL, arg)
|
||||||
}},
|
}},
|
||||||
|
SPIDE: {Name: "spide path=auto file=auto auto", Help: "结构图", Meta: kit.Dict(
|
||||||
"spide": {Name: "spide path=auto file=auto auto", Help: "结构图", Meta: kit.Dict(
|
|
||||||
"display", "/plugin/story/spide.js",
|
"display", "/plugin/story/spide.js",
|
||||||
), Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
|
), Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
|
||||||
if len(arg) > 0 && arg[0] == "inner" {
|
|
||||||
arg[1] = path.Join("usr", arg[1])
|
|
||||||
m.Cmdy("web.code.inner", arg[1:])
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
if len(arg) == 0 {
|
if len(arg) == 0 {
|
||||||
|
// 仓库列表
|
||||||
m.Option("_display", "table")
|
m.Option("_display", "table")
|
||||||
m.Cmdy("total", arg)
|
m.Cmdy(TOTAL, arg)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if len(arg) == 1 {
|
if len(arg) == 1 {
|
||||||
|
// 目录列表
|
||||||
m.Option(nfs.DIR_DEEP, "true")
|
m.Option(nfs.DIR_DEEP, "true")
|
||||||
m.Cmdy(nfs.DIR, mdb.RENDER, nfs.DIR, "", path.Join("usr", arg[0]))
|
m.Cmdy(nfs.DIR, mdb.RENDER, nfs.DIR, "", path.Join("usr", arg[0]))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if len(arg) > 1 && arg[0] == "inner" {
|
||||||
|
// 代码详情
|
||||||
|
arg[1] = path.Join("usr", arg[1])
|
||||||
|
m.Cmdy("web.code.inner", arg[1:])
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
tags := ""
|
tags := ""
|
||||||
m.Option(cli.CMD_DIR, path.Join("usr", arg[0]))
|
m.Option(cli.CMD_DIR, path.Join("usr", arg[0]))
|
||||||
if strings.HasSuffix(arg[1], ".go") {
|
if strings.HasSuffix(arg[1], ".go") {
|
||||||
tags = m.Cmdx(cli.SYSTEM, "gotags", arg[1])
|
tags = m.Cmdx(cli.SYSTEM, "gotags", arg[1])
|
||||||
for _, line := range strings.Split(tags, "\n") {
|
for _, line := range strings.Split(tags, "\n") {
|
||||||
m.Debug("line: %v", line)
|
|
||||||
if len(line) == 0 || strings.HasPrefix(line, "!_") {
|
if len(line) == 0 || strings.HasPrefix(line, "!_") {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
@ -353,9 +288,71 @@ var Index = &ice.Context{Name: "git", Help: "代码库",
|
|||||||
m.Push("line", "1")
|
m.Push("line", "1")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
m.Sort("line", "int")
|
m.Sort("line", "int")
|
||||||
}},
|
}},
|
||||||
|
|
||||||
|
"status": {Name: "status name=auto auto 提交:button", Help: "文件状态", Meta: kit.Dict(
|
||||||
|
"提交", kit.List("_input", "text", "name", "text"),
|
||||||
|
), Action: map[string]*ice.Action{
|
||||||
|
"submit": {Name: "submit", Help: "提交", Hand: func(m *ice.Message, arg ...string) {
|
||||||
|
m.Cmdy(cli.SYSTEM, "commit", "-am", arg[0])
|
||||||
|
}},
|
||||||
|
}, Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
|
||||||
|
prefix := []string{cli.SYSTEM, "git"}
|
||||||
|
if len(arg) > 1 && arg[0] == "action" {
|
||||||
|
m.Richs("repos", nil, m.Option("name"), func(key string, value map[string]interface{}) {
|
||||||
|
m.Option("cmd_dir", kit.Value(value, "meta.path"))
|
||||||
|
switch arg[1] {
|
||||||
|
case "add":
|
||||||
|
m.Cmdy(prefix, arg[1], m.Option("file"))
|
||||||
|
case "reset":
|
||||||
|
m.Cmdy(prefix, arg[1], m.Option("file"))
|
||||||
|
case "checkout":
|
||||||
|
m.Cmdy(prefix, arg[1], m.Option("file"))
|
||||||
|
case "commit":
|
||||||
|
m.Cmdy(prefix, arg[1], "-m", m.Option("comment"))
|
||||||
|
}
|
||||||
|
})
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
m.Richs("repos", nil, kit.Select("*", arg, 0), func(key string, value map[string]interface{}) {
|
||||||
|
if m.Option("cmd_dir", kit.Value(value, "meta.path")); len(arg) > 0 {
|
||||||
|
// 更改详情
|
||||||
|
m.Echo(m.Cmdx(prefix, "diff"))
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// 更改列表
|
||||||
|
for _, v := range strings.Split(strings.TrimSpace(m.Cmdx(prefix, "status", "-sb")), "\n") {
|
||||||
|
vs := strings.SplitN(strings.TrimSpace(v), " ", 2)
|
||||||
|
m.Push("name", kit.Value(value, "meta.name"))
|
||||||
|
m.Push("tags", vs[0])
|
||||||
|
m.Push("file", vs[1])
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}},
|
||||||
|
|
||||||
|
code.INSTALL: {Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
|
||||||
|
m.Option("cmd_dir", m.Conf("install", "meta.path"))
|
||||||
|
m.Cmd(cli.SYSTEM, "git", "clone", m.Conf("git", "meta.source"))
|
||||||
|
|
||||||
|
m.Option("cmd_dir", path.Join(m.Conf("install", "meta.path"), "git"))
|
||||||
|
m.Cmd(cli.SYSTEM, "make", "configure")
|
||||||
|
m.Cmd(cli.SYSTEM, "./configure", "--prefix="+kit.Path("usr/local"))
|
||||||
|
|
||||||
|
m.Cmd(cli.SYSTEM, "make", "-j4")
|
||||||
|
m.Cmd(cli.SYSTEM, "make", "install")
|
||||||
|
}},
|
||||||
|
code.PREPARE: {Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
|
||||||
|
kit.Fetch(m.Confv("git", "meta.config"), func(conf string, value interface{}) {
|
||||||
|
kit.Fetch(value, func(key string, value string) {
|
||||||
|
m.Cmd(cli.SYSTEM, "git", "config", "--global", conf+"."+key, value)
|
||||||
|
})
|
||||||
|
})
|
||||||
|
}},
|
||||||
|
code.PROJECT: {Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
|
||||||
|
}},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -7,5 +7,11 @@ refer "官网" `
|
|||||||
`
|
`
|
||||||
|
|
||||||
chapter "应用"
|
chapter "应用"
|
||||||
|
field "代码统计" web.code.git.total
|
||||||
|
field "提交趋势" web.code.git.trend args icebergs
|
||||||
|
field "代码结构" web.code.git.spide args icebergs
|
||||||
|
|
||||||
field status web.code.git.status
|
field status web.code.git.status
|
||||||
field total web.code.git.total
|
|
||||||
|
chapter "项目"
|
||||||
|
field icebergs web.code.inner args `[ usr/icebergs misc/git/git.go ]`
|
||||||
|
Loading…
x
Reference in New Issue
Block a user