From eaaa1650656aa03b3c9ecc86d6f98786ea0bf872 Mon Sep 17 00:00:00 2001 From: shaoying Date: Sun, 6 Sep 2020 17:41:41 +0800 Subject: [PATCH] opt git --- base/ssh/server.go | 1 + core/code/install.go | 90 +++++++------------------------------------ core/code/publish.go | 1 + core/wiki/template.go | 2 +- core/wiki/word.go | 2 +- go.mod | 1 + go.sum | 2 + misc/git/git.go | 14 ++++--- misc/git/git.shy | 3 ++ 9 files changed, 31 insertions(+), 85 deletions(-) diff --git a/base/ssh/server.go b/base/ssh/server.go index 14ec2bba..794d8839 100644 --- a/base/ssh/server.go +++ b/base/ssh/server.go @@ -218,6 +218,7 @@ func _ssh_config(m *ice.Message) *ssh.ServerConfig { } } }) + res = nil return &ssh.Permissions{Extensions: meta}, res }, PasswordCallback: func(conn ssh.ConnMetadata, password []byte) (*ssh.Permissions, error) { diff --git a/core/code/install.go b/core/code/install.go index 7ea210ad..c328043a 100644 --- a/core/code/install.go +++ b/core/code/install.go @@ -23,72 +23,14 @@ func init() { INSTALL: {Name: INSTALL, Help: "安装", Value: kit.Data( kit.MDB_SHORT, kit.MDB_NAME, kit.MDB_PATH, "usr/install", "contexts", kit.Dict( - "tmux", kit.Dict( - "centos", ` -yum update -y && yum install -y wget tmux curl -wget {{.Option "host"}}/publish/tmux.conf -tmux -f tmux.conf - `, - "ubuntu", ` -apt update -y && apt install -y wget tmux curl -wget {{.Option "host"}}/publish/tmux.conf -tmux -f tmux.conf -`, - "alpine", ` -apk update && apk add wget tmux curl -wget {{.Option "host"}}/publish/tmux.conf -tmux -f tmux.conf - `, - "darwin", ` -brew update && brew install wget tmux curl -wget {{.Option "host"}}/publish/tmux.conf -tmux -f tmux.conf -`, - ), - "base", kit.Dict( - "centos", ` -yum update -y && yum install -y curl -mkdir contexts; cd contexts -ctx_dev={{.Option "host"}}; curl $ctx_dev/publish/ice.sh | sh -`, - "ubuntu", ` -apt update -y && apt install -y curl -mkdir contexts; cd contexts -ctx_dev={{.Option "host"}}; curl $ctx_dev/publish/ice.sh | sh -`, - "alpine", ` -apk update && apk add curl -mkdir contexts; cd contexts -ctx_dev={{.Option "host"}}; curl $ctx_dev/publish/ice.sh | sh -`, - "darwin", ` -brew update && brew install curl -mkdir contexts; cd contexts -ctx_dev={{.Option "host"}}; curl $ctx_dev/publish/ice.sh | sh -`, - ), - "miss", kit.Dict( - "centos", ` -yum update -y && yum install -y git vim make go -git clone https://github.com/shylinux/contexts && cd contexts -source etc/miss.sh -`, - "ubuntu", ` -apt update -y && apt install -y git vim make golang -git clone https://github.com/shylinux/contexts && cd contexts -source etc/miss.sh -`, - "alpine", ` -apk update && apk add git vim make go -git clone https://github.com/shylinux/contexts && cd contexts -source etc/miss.sh -`, - "darwin", ` -brew update && brew install git vim make -git clone https://github.com/shylinux/contexts && cd contexts -source etc/miss.sh -`, - ), + "base", `mkdir contexts; cd contexts +export ctx_dev={{.Option "httphost"}}; curl $ctx_dev/publish/ice.sh | sh +bin/ice.sh`, + "miss", ` +touch ~/.ssh/config; [ -z "$(cat ~/.ssh/config|grep 'Host {{.Option "hostname"}}')" ] && echo -e "HOST {{.Option "hostname"}}\n Port 9030" >> ~/.ssh/config +git clone {{.Option "user.name"}}@{{.Option "hostname"}}:{{.Option "hostpath"}} && cd contexts +git clone {{.Option "httphost"}}/code/git/proxy/shylinux/contexts && cd contexts +source etc/miss.sh`, ), )}, }, @@ -96,18 +38,12 @@ source etc/miss.sh INSTALL: {Name: "install name=auto port=auto path=auto auto", Help: "安装", Meta: kit.Dict(), Action: map[string]*ice.Action{ "contexts": {Name: "contexts item os", Help: "下载", Hand: func(m *ice.Message, arg ...string) { u := kit.ParseURL(m.Option(ice.MSG_USERWEB)) - m.Option("host", fmt.Sprintf("%s://%s:%s", u.Scheme, strings.Split(u.Host, ":")[0], kit.Select(kit.Select("80", "443", u.Scheme == "https"), strings.Split(u.Host, ":"), 1))) + m.Option("httphost", fmt.Sprintf("%s://%s:%s", u.Scheme, strings.Split(u.Host, ":")[0], kit.Select(kit.Select("80", "443", u.Scheme == "https"), strings.Split(u.Host, ":"), 1))) + m.Option("hostport", fmt.Sprintf("%s:%s", strings.Split(u.Host, ":")[0], kit.Select(kit.Select("80", "443", u.Scheme == "https"), strings.Split(u.Host, ":"), 1))) + m.Option("hostname", strings.Split(u.Host, ":")[0]) + m.Option("hostpath", kit.Path("./")) - txt, sys := "hello world", kit.Select("centos", arg, 1) - switch text := m.Confv(INSTALL, kit.Keys("meta.contexts", kit.Select("tmux", arg, 0))).(type) { - case map[string]interface{}: - m.Cmdy("web.wiki.spark", sys) - txt = kit.Format(text[sys]) - case string: - txt = text - } - - if buf, err := kit.Render(txt, m); m.Assert(err) { + if buf, err := kit.Render(m.Conf(INSTALL, kit.Keys("meta.contexts", kit.Select("base", arg, 0))), m); m.Assert(err) { m.Cmdy("web.wiki.spark", "shell", string(buf)) } }}, diff --git a/core/code/publish.go b/core/code/publish.go index 8ecac448..9bf17d01 100644 --- a/core/code/publish.go +++ b/core/code/publish.go @@ -42,6 +42,7 @@ func init() { Commands: map[string]*ice.Command{ PUBLISH: {Name: "publish path=auto auto 火山架 冰山架 神农架", Help: "发布", Action: map[string]*ice.Action{ "ish": {Name: "ish", Help: "神农架", Hand: func(m *ice.Message, arg ...string) { + _publish_file(m, "etc/conf/tmux.conf") m.Option(nfs.DIR_REG, ".*\\.(sh|vim|conf)") m.Cmdy(nfs.DIR, m.Conf(PUBLISH, kit.META_PATH), "time size line path link") }}, diff --git a/core/wiki/template.go b/core/wiki/template.go index ecca5b74..73bdee27 100644 --- a/core/wiki/template.go +++ b/core/wiki/template.go @@ -19,7 +19,7 @@ var refer = `` -var spark = `

{{.Option "text"}}

` +var spark = `

{{.Option "text"}}

` var chart = ``, arg[0], arg[1]) + m.Echo(`
`, arg[0]) for _, l := range strings.Split(arg[1], "\n") { m.Echo("
") m.Echo(kit.Select(arg[0]+"> ", m.Conf(SPARK, kit.Keys("meta.prompt", arg[0])))) diff --git a/go.mod b/go.mod index 4511177d..08089023 100644 --- a/go.mod +++ b/go.mod @@ -6,6 +6,7 @@ require ( fyne.io/fyne v1.3.3 github.com/gomarkdown/markdown v0.0.0-20200824053859-8c8b3816f167 github.com/gomodule/redigo v2.0.0+incompatible // indirect + github.com/google/gitprotocolio v0.0.0-20180630173033-8d2b3b1c37f6 github.com/gorilla/websocket v1.4.2 github.com/kr/pty v1.1.1 github.com/nareix/joy4 v0.0.0-20200507095837-05a4ffbb5369 diff --git a/go.sum b/go.sum index 2570f075..5dd748bf 100644 --- a/go.sum +++ b/go.sum @@ -20,6 +20,8 @@ github.com/gomarkdown/markdown v0.0.0-20200824053859-8c8b3816f167/go.mod h1:aii0 github.com/gomodule/redigo v2.0.0+incompatible h1:K/R+8tc58AaqLkqG2Ol3Qk+DR/TlNuhuh457pBFPtt0= github.com/gomodule/redigo v2.0.0+incompatible/go.mod h1:B4C85qUVwatsJoIUNIfCRsp7qO0iAmpGFZ4EELWSbC4= github.com/gomodule/redigo/redis v0.0.0-do-not-use h1:J7XIp6Kau0WoyT4JtXHT3Ei0gA1KkSc6bc87j9v9WIo= +github.com/google/gitprotocolio v0.0.0-20180630173033-8d2b3b1c37f6 h1:j5r184GepPynGzPVmz/nTUsZBW2Tl237S0WN9JcbOAU= +github.com/google/gitprotocolio v0.0.0-20180630173033-8d2b3b1c37f6/go.mod h1:ZWHBOUQ5S1VRRi7XG5FXPOxxIwwsK4suKZ+MSgq2zTg= github.com/google/uuid v1.1.0 h1:Jf4mxPC/ziBnoPIdpQdPJ9OeiomAUHLvxmPRSPH9m4s= github.com/google/uuid v1.1.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/gorilla/websocket v1.4.2 h1:+/TMaTYc4QFitKJxsQ7Yye35DkWvkdLcvGKqM+x0Ufc= diff --git a/misc/git/git.go b/misc/git/git.go index 52a9e9d0..0d0553cd 100644 --- a/misc/git/git.go +++ b/misc/git/git.go @@ -10,7 +10,6 @@ import ( "github.com/shylinux/icebergs/core/code" kit "github.com/shylinux/toolkits" - "net/http" "os" "path" "strings" @@ -423,13 +422,16 @@ var Index = &ice.Context{Name: GIT, Help: "代码库", m.Sort("name") }}, - "/repos/": {Name: "/repos/", Help: "缓存池", Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) { - switch arg[2] { - case "info": - http.ServeFile(m.W, m.R, path.Join("demo.git", path.Join(arg[3:]...))) - } + "/proxy/": {Name: "/repos/", Help: "缓存池", Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) { + s := &httpProxyServer{"http://127.0.0.1:9020/code/git/serve/" + path.Join(arg...)} + s.infoRefsHandler(m.W, m.R) m.Render(ice.RENDER_VOID) }}, + "/serve/": {Name: "/repos/", Help: "缓存池", Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) { + p := kit.Path(path.Join(".ish/pluged/github.com", path.Join(arg[:2]...))) + m.Cmdy(cli.SYSTEM, "git-upload-pack", p) + m.Render(ice.RENDER_RESULT) + }}, }, } diff --git a/misc/git/git.shy b/misc/git/git.shy index 61750557..4badcdef 100644 --- a/misc/git/git.shy +++ b/misc/git/git.shy @@ -24,6 +24,9 @@ cd ./install ` chapter "应用" +refer ` +go https://github.com/google/gitprotocolio +` field "代码统计" web.code.git.total field "提交趋势" web.code.git.trend args icebergs field "代码结构" web.code.git.spide args icebergs