diff --git a/base/web/web.go b/base/web/web.go
index c75aa47b..b951af66 100644
--- a/base/web/web.go
+++ b/base/web/web.go
@@ -896,7 +896,7 @@ var Index = &ice.Context{Name: "web", Help: "网络模块",
m.Push("favor", kit.Value(value, "meta.name"))
m.Push("count", kit.Value(value, "meta.count"))
})
- m.Sort("time", "time_r")
+ m.Sort("favor")
return
}
diff --git a/core/code/auto.vim b/core/code/auto.vim
index 2f57e90e..68e62887 100644
--- a/core/code/auto.vim
+++ b/core/code/auto.vim
@@ -83,7 +83,7 @@ endfun
fun! ShyGrep(word)
if !exists("g:grep_dir") | let g:grep_dir = "./" | endif
let g:grep_dir = input("dir: ", g:grep_dir, "file")
- execute "grep -rn --exclude tags --exclude '*.tags' " . a:word . " " . g:grep_dir
+ execute "grep -rn --exclude tags --exclude '*.tags' '\<" . a:word . "\>' " . g:grep_dir
endfun
fun! ShyTag(word)
execute "tag " . a:word
diff --git a/core/code/code.go b/core/code/code.go
index 864af01b..2073ab62 100644
--- a/core/code/code.go
+++ b/core/code/code.go
@@ -49,6 +49,14 @@ var Index = &ice.Context{Name: "code", Help: "编程中心",
m.Cmd(ice.CTX_CONFIG, "load", "code.json")
m.Watch(ice.SYSTEM_INIT, "compile", "linux")
m.Watch(ice.SYSTEM_INIT, "publish", "bin/ice.sh")
+
+ if m.Richs(ice.WEB_FAVOR, nil, "auto.init", nil) == nil {
+ m.Cmd(ice.WEB_FAVOR, "auto.init", ice.TYPE_SHELL, "下载脚本", `curl -s "$ctx_dev/publish/auto.sh" -o auto.sh`)
+ m.Cmd(ice.WEB_FAVOR, "auto.init", ice.TYPE_SHELL, "加载脚本", `source auto.sh`)
+ }
+ if m.Richs(ice.WEB_FAVOR, nil, "ice.init", nil) == nil {
+ m.Cmd(ice.WEB_FAVOR, "ice.init", ice.TYPE_SHELL, "一键启动", `curl -s "$ctx_dev/publish/ice.sh" |sh`)
+ }
}},
ice.ICE_EXIT: {Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
m.Cmd(ice.CTX_CONFIG, "save", "code.json", "web.code.login")
@@ -71,6 +79,7 @@ var Index = &ice.Context{Name: "code", Help: "编程中心",
m.Add("option", "cmd_env", "GOCACHE", os.Getenv("GOCACHE"))
m.Add("option", "cmd_env", "GOARCH", arch, "GOOS", goos)
m.Add("option", "cmd_env", "HOME", os.Getenv("HOME"))
+ m.Add("option", "cmd_env", "CGO_ENABLED", "0")
m.Cmd("cli.system", "go", "build", "-o", file, main)
// 编译记录
diff --git a/core/wiki/chart.go b/core/wiki/chart.go
index 61378945..08de4114 100644
--- a/core/wiki/chart.go
+++ b/core/wiki/chart.go
@@ -273,3 +273,30 @@ func (b *Table) Draw(m *ice.Message, x, y int) Chart {
}
return b
}
+
+func stack(m *ice.Message, name string, level int, data interface{}) {
+ l, ok := kit.Value(data, "list").([]interface{})
+ style := []string{}
+ kit.Fetch(kit.Value(data, "meta"), func(key string, value string) {
+ switch key {
+ case "bg":
+ style = append(style, "background:"+value)
+ case "fg":
+ style = append(style, "color:"+value)
+ }
+ })
+ if !ok || len(l) == 0 {
+ m.Echo(`
o %s
`, name, strings.Join(style, ";"), kit.Value(data, "meta.text"))
+ return
+ }
+ m.Echo(`%s %s
`,
+ kit.Select("span", "fold", level > 2), name, strings.Join(style, ";"), kit.Select("v", ">", level > 2), kit.Value(data, "meta.text"))
+
+ m.Echo("", name, kit.Select("", `style="display:none"`, level > 2))
+ kit.Fetch(kit.Value(data, "list"), func(index int, value map[string]interface{}) {
+ m.Echo("- ")
+ stack(m, name, level+1, value)
+ m.Echo("
")
+ })
+ m.Echo("
")
+}
diff --git a/core/wiki/template.go b/core/wiki/template.go
index 7d167bd5..5802160b 100644
--- a/core/wiki/template.go
+++ b/core/wiki/template.go
@@ -8,7 +8,8 @@ data-type="{{.Option "type"}}" data-name="{{.Option "name"}}" data-text="{{.Opti
var spark = `{{.}}
`
var shell = `$ {{.Option "input"}}
-{{.Option "output"}}
`
+{{.Option "output"}}
+`
var order = `
diff --git a/core/wiki/wiki.go b/core/wiki/wiki.go
index bc3993bf..95e39c09 100644
--- a/core/wiki/wiki.go
+++ b/core/wiki/wiki.go
@@ -51,11 +51,9 @@ var Index = &ice.Context{Name: "wiki", Help: "文档中心",
var chart Chart
switch arg[0] {
case "block":
- chart = &Block{}
+ chart = &Table{}
case "chain":
chart = &Chain{}
- case "table":
- chart = &Table{}
}
arg[1] = strings.TrimSpace(arg[1])
arg[2] = strings.TrimSpace(arg[2])
@@ -73,6 +71,11 @@ var Index = &ice.Context{Name: "wiki", Help: "文档中心",
chart.Draw(m, 0, 0)
m.Render(m.Conf("chart", ice.Meta("suffix")))
}},
+ "stack": {Name: "stack name text", Help: "堆栈", Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
+ chain := &Chain{}
+ m.Render(m.Conf("spark", ice.Meta("template")), arg[0])
+ stack(m, "stack", 0, kit.Parse(nil, "", chain.show(m, arg[1])...))
+ }},
"table": {Name: "table name text", Help: "表格", Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
m.Option("type", "table")
m.Option("name", arg[0])
@@ -101,13 +104,17 @@ var Index = &ice.Context{Name: "wiki", Help: "文档中心",
m.Option("name", arg[0])
m.Option("cmd_dir", arg[1])
+ input, output := "", ""
switch arg = arg[2:]; arg[0] {
case "install", "compile":
- m.Option("input", html.EscapeString(strings.Join(arg[1:], " ")))
+ input = strings.Join(arg[1:], " ")
default:
- m.Option("input", html.EscapeString(strings.Join(arg, " ")))
- m.Option("output", html.EscapeString(m.Cmdx("cli.system", "sh", "-c", strings.Join(arg, " "))))
+ input = strings.Join(arg, " ")
+ output = m.Cmdx("cli.system", "sh", "-c", strings.Join(arg, " "))
}
+
+ m.Option("input", html.EscapeString(input))
+ m.Option("output", html.EscapeString(output))
m.Render(m.Conf("spark", ice.Meta("template")), m.Option("name"))
m.Render(m.Conf("shell", ice.Meta("template")))
}},
diff --git a/misc/docker/docker.go b/misc/docker/docker.go
index 751fc3f0..d462caed 100644
--- a/misc/docker/docker.go
+++ b/misc/docker/docker.go
@@ -13,7 +13,13 @@ var Index = &ice.Context{Name: "docker", Help: "容器管理",
"docker": {Name: "docker", Help: "docker", Value: kit.Data(kit.MDB_SHORT, "name")},
},
Commands: map[string]*ice.Command{
- ice.ICE_INIT: {Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {}},
+ ice.ICE_INIT: {Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
+ if m.Richs(ice.WEB_FAVOR, nil, "alpine.init", nil) == nil {
+ m.Cmd(ice.WEB_FAVOR, "alpine.init", ice.TYPE_SHELL, "镜像源", `sed -i 's/dl-cdn.alpinelinux.org/mirrors.aliyun.com/g' /etc/apk/repositories`)
+ m.Cmd(ice.WEB_FAVOR, "alpine.init", ice.TYPE_SHELL, "软件包", `apk add bash`)
+ m.Cmd(ice.WEB_FAVOR, "alpine.init", ice.TYPE_SHELL, "软件包", `apk add curl`)
+ }
+ }},
ice.ICE_EXIT: {Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {}},
"image": {Name: "image", Help: "镜像管理", Meta: kit.Dict("detail", []string{"运行", "清理", "删除"}), Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
@@ -48,8 +54,12 @@ var Index = &ice.Context{Name: "docker", Help: "容器管理",
if len(arg) > 2 {
switch arg[1] {
case "进入":
- m.Cmdy(ice.CLI_SYSTEM, "tmux", "new-window", "-t", "", "-n", m.Option("NAMES"),
- "-PF", "#{session_name}:#{window_name}.1", "docker exec -it "+m.Option("NAMES")+" sh").Set("append")
+ m.Cmd("cli.tmux.session").Table(func(index int, value map[string]string, head []string) {
+ if value["tag"] == "1" {
+ m.Cmdy(ice.CLI_SYSTEM, "tmux", "new-window", "-t", value["session"], "-n", m.Option("NAMES"),
+ "-PF", "#{session_name}:#{window_name}.1", "docker exec -it "+m.Option("NAMES")+" sh").Set("append")
+ }
+ })
return
case "停止":
m.Cmd(prefix, "stop", m.Option("CONTAINER_ID"))
diff --git a/misc/git/git.go b/misc/git/git.go
index e5eb9bc3..9341a9fd 100644
--- a/misc/git/git.go
+++ b/misc/git/git.go
@@ -4,6 +4,7 @@ import (
"github.com/shylinux/icebergs"
"github.com/shylinux/icebergs/base/cli"
"github.com/shylinux/toolkits"
+
"os"
"path"
"strings"
@@ -44,8 +45,7 @@ var Index = &ice.Context{Name: "git", Help: "代码管理",
})
m.Watch(ice.SYSTEM_INIT, "cli.git.check", "volcanos")
}},
- ice.ICE_EXIT: {Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
- }},
+ ice.ICE_EXIT: {Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {}},
"repos": {Name: "repos", Help: "仓库", Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
m.Richs("repos", nil, "*", func(key string, value map[string]interface{}) {
m.Push(key, value["meta"], []string{"time", "name", "branch", "path", "remote"})
@@ -62,6 +62,7 @@ var Index = &ice.Context{Name: "git", Help: "代码管理",
m.Push("tags", v[:2])
vs := strings.SplitN(strings.TrimSpace(v[2:]), " ", 2)
m.Push("branch", vs[0])
+ m.Push("last", m.Cmdx(ice.CLI_SYSTEM, "git", "log", "-n", "1", "--pretty=%ad", "--date=short"))
vs = strings.SplitN(strings.TrimSpace(vs[1]), " ", 2)
m.Push("hash", vs[0])
m.Push("note", strings.TrimSpace(vs[1]))
@@ -87,7 +88,7 @@ var Index = &ice.Context{Name: "git", Help: "代码管理",
commit, adds, dels, rest := 0, 0, 0, 0
m.Richs("repos", nil, kit.Select("*", arg, 0), func(key string, value map[string]interface{}) {
m.Push("repos", kit.Value(value, "meta.name"))
- m.Copy(m.Cmd("sum", "total", kit.Value(value, "meta.path"), "10000").Table(func(index int, value map[string]string, head []string) {
+ m.Copy(m.Cmd("sum", kit.Value(value, "meta.path"), "total", "10000").Table(func(index int, value map[string]string, head []string) {
if kit.Int(value["days"]) > days {
days = kit.Int(value["days"])
}
@@ -103,7 +104,7 @@ var Index = &ice.Context{Name: "git", Help: "代码管理",
m.Push("adds", adds)
m.Push("dels", dels)
m.Push("rest", rest)
- m.Sort("commit", "int_r")
+ m.Sort("adds", "int_r")
}},
"check": {Name: "check", Help: "检查", Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
m.Richs("repos", nil, arg[0], func(key string, value map[string]interface{}) {
@@ -113,19 +114,20 @@ var Index = &ice.Context{Name: "git", Help: "代码管理",
}
})
}},
- "sum": {Name: "sum", 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 s, e := os.Stat(arg[0] + "/.git"); e == nil && s.IsDir() {
+ m.Option("cmd_dir", arg[0])
+ arg = arg[1:]
+ }
+ }
+
total := false
if len(arg) > 0 && arg[0] == "total" {
total, arg = true, arg[1:]
}
args := []string{}
- if len(arg) > 0 {
- if s, e := os.Stat(arg[0] + "/.git"); e == nil && s.IsDir() {
- args, arg = append(args, "-C", arg[0]), arg[1:]
- }
- }
-
args = append(args, "log", "--shortstat", "--pretty=commit: %ad %n%s", "--date=iso", "--reverse")
if len(arg) > 0 {
args = append(args, kit.Select("-n", "--since", strings.Contains(arg[0], "-")))
diff --git a/misc/tmux/tmux.go b/misc/tmux/tmux.go
index cdaa03e7..cb3caa1c 100644
--- a/misc/tmux/tmux.go
+++ b/misc/tmux/tmux.go
@@ -69,14 +69,6 @@ var Index = &ice.Context{Name: "tmux", Help: "终端管理",
}
}
}
-
- if m.Richs(ice.WEB_FAVOR, nil, "tmux.auto", nil) == nil {
- m.Cmd(ice.WEB_FAVOR, "tmux.auto", ice.TYPE_SHELL, "下载脚本", `curl -s "$ctx_dev/publish/auto.sh" -o auto.sh`)
- m.Cmd(ice.WEB_FAVOR, "tmux.auto", ice.TYPE_SHELL, "加载脚本", `source auto.sh`)
- }
- if m.Richs(ice.WEB_FAVOR, nil, "tmux.init", nil) == nil {
- m.Cmd(ice.WEB_FAVOR, "tmux.init", ice.TYPE_SHELL, "一键启动", `curl -s "$ctx_dev/publish/ice.sh" |sh`)
- }
}},
"buffer": {Name: "buffer", Help: "终端",
diff --git a/miss/Makefile b/miss/Makefile
index 2787cdf8..d714c987 100644
--- a/miss/Makefile
+++ b/miss/Makefile
@@ -1,4 +1,6 @@
all:
@echo && date
+ export CGO_ENABLED=0
export GOPRIVATE=github.com
+ export GOPROXY=https://goproxy.cn
go build -o bin/ice.bin src/main.go && chmod u+x bin/ice.bin && ./bin/ice.sh restart
diff --git a/template.sh b/template.sh
index 711baeb5..7b6a1453 100755
--- a/template.sh
+++ b/template.sh
@@ -34,6 +34,7 @@ END
[ -f Makefile ] || cat >> Makefile <