mirror of
https://shylinux.com/x/icebergs
synced 2025-04-27 17:58:29 +08:00
add git.server
This commit is contained in:
parent
38e0594e2a
commit
a129cf2e0e
@ -34,4 +34,5 @@ field "统计量" web.code.git.total
|
|||||||
field "趋势图" web.code.git.trend args `icebergs`
|
field "趋势图" web.code.git.trend args `icebergs`
|
||||||
field "架构图" web.code.git.spide args `icebergs`
|
field "架构图" web.code.git.spide args `icebergs`
|
||||||
field "状态机" web.code.git.status
|
field "状态机" web.code.git.status
|
||||||
|
field "服务器" web.code.git.server
|
||||||
|
|
||||||
|
@ -1,11 +1,15 @@
|
|||||||
package git
|
package git
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"path"
|
||||||
|
|
||||||
"github.com/AaronO/go-git-http"
|
"github.com/AaronO/go-git-http"
|
||||||
"github.com/AaronO/go-git-http/auth"
|
"github.com/AaronO/go-git-http/auth"
|
||||||
|
|
||||||
ice "github.com/shylinux/icebergs"
|
ice "github.com/shylinux/icebergs"
|
||||||
"github.com/shylinux/icebergs/base/aaa"
|
"github.com/shylinux/icebergs/base/aaa"
|
||||||
|
"github.com/shylinux/icebergs/base/cli"
|
||||||
|
"github.com/shylinux/icebergs/base/mdb"
|
||||||
|
"github.com/shylinux/icebergs/base/nfs"
|
||||||
"github.com/shylinux/icebergs/base/web"
|
"github.com/shylinux/icebergs/base/web"
|
||||||
kit "github.com/shylinux/toolkits"
|
kit "github.com/shylinux/toolkits"
|
||||||
)
|
)
|
||||||
@ -15,12 +19,37 @@ const SERVER = "server"
|
|||||||
func init() {
|
func init() {
|
||||||
Index.Merge(&ice.Context{
|
Index.Merge(&ice.Context{
|
||||||
Configs: map[string]*ice.Config{
|
Configs: map[string]*ice.Config{
|
||||||
SERVER: {Name: SERVER, Help: "服务器", Value: kit.Data(kit.MDB_PATH, ".ish/pluged")},
|
SERVER: {Name: SERVER, Help: "服务器", Value: kit.Data(kit.MDB_PATH, "usr/local")},
|
||||||
},
|
},
|
||||||
Commands: map[string]*ice.Command{
|
Commands: map[string]*ice.Command{
|
||||||
web.WEB_LOGIN: {Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
|
web.WEB_LOGIN: {Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
|
||||||
m.Render(ice.RENDER_VOID)
|
m.Render(ice.RENDER_VOID)
|
||||||
}},
|
}},
|
||||||
|
|
||||||
|
SERVER: {Name: "server path auto create", Help: "server", Action: map[string]*ice.Action{
|
||||||
|
mdb.CREATE: {Name: "create name", Help: "添加", Hand: func(m *ice.Message, arg ...string) {
|
||||||
|
m.Option(cli.CMD_DIR, path.Join(m.Conf(SERVER, kit.META_PATH), REPOS))
|
||||||
|
m.Cmd(cli.SYSTEM, GIT, INIT, "--bare", m.Option(kit.MDB_NAME))
|
||||||
|
}},
|
||||||
|
}, Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
|
||||||
|
m.Option(nfs.DIR_ROOT, path.Join(m.Conf(SERVER, kit.META_PATH), REPOS))
|
||||||
|
m.Cmdy(nfs.DIR, "./")
|
||||||
|
m.EchoScript("git remote add origin https://shylinux.com/code/git/repos/volcanos")
|
||||||
|
}},
|
||||||
|
|
||||||
|
"/repos/": {Name: "/github.com/", Help: "/github.com/", Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
|
||||||
|
auth.Authenticator(func(info auth.AuthInfo) (bool, error) {
|
||||||
|
if !aaa.UserLogin(m, info.Username, info.Password) {
|
||||||
|
return false, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
if info.Push && aaa.UserRole(m, info.Username) == aaa.VOID {
|
||||||
|
return false, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
return true, nil
|
||||||
|
})(githttp.New(kit.Path(m.Conf(SERVER, kit.META_PATH)))).ServeHTTP(m.W, m.R)
|
||||||
|
}},
|
||||||
"/github.com/": {Name: "/github.com/", Help: "/github.com/", Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
|
"/github.com/": {Name: "/github.com/", Help: "/github.com/", Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
|
||||||
auth.Authenticator(func(info auth.AuthInfo) (bool, error) {
|
auth.Authenticator(func(info auth.AuthInfo) (bool, error) {
|
||||||
if !aaa.UserLogin(m, info.Username, info.Password) {
|
if !aaa.UserLogin(m, info.Username, info.Password) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user