mirror of
https://shylinux.com/x/icebergs
synced 2025-04-26 01:24:05 +08:00
opt some
This commit is contained in:
parent
f000c676d9
commit
735ba5c7c2
@ -148,6 +148,9 @@ func RenderTemplate(m *ice.Message, file string, arg ...ice.Any) {
|
||||
m.RenderResult(kit.Renders(kit.Format(m.Cmdx(nfs.CAT, path.Join(ice.SRC_TEMPLATE, WEB, file)), arg...), m))
|
||||
}
|
||||
|
||||
func AllowOrigin(m *ice.Message, origin string) {
|
||||
m.W.Header().Set("Access-Control-Allow-Origin", origin)
|
||||
}
|
||||
func CookieName(url string) string {
|
||||
return ice.MSG_SESSID + "_" + kit.ReplaceAll(kit.ParseURLMap(url)[tcp.PORT], ".", "_", ":", "_")
|
||||
return ice.MSG_SESSID + "_" + kit.ReplaceAll(kit.ParseURLMap(url)[tcp.HOST], ".", "_", ":", "_")
|
||||
|
@ -184,9 +184,7 @@ func init() {
|
||||
}
|
||||
ctx.ProcessField(m, "", arg, arg...)
|
||||
}},
|
||||
TOKEN: {Hand: func(m *ice.Message, arg ...string) {
|
||||
m.Echo(m.Cmdx(TOKEN, m.Cmdx(TOKEN, mdb.CREATE, aaa.USERNAME, m.Option(ice.MSG_USERNAME), TOKEN, kit.Hashs("uniq"))))
|
||||
}},
|
||||
TOKEN: {Help: "令牌", Hand: func(m *ice.Message, arg ...string) { m.Cmdy(TOKEN, cli.MAKE) }},
|
||||
}, gdb.EventAction(web.DREAM_INPUTS)), Hand: func(m *ice.Message, arg ...string) {
|
||||
if m.Option(nfs.DIR_ROOT, ice.USR_LOCAL_REPOS); len(arg) == 0 {
|
||||
m.Option(ice.MSG_USERROLE, aaa.TECH)
|
||||
|
@ -278,6 +278,10 @@ func init() {
|
||||
_git_cmd(m, "config", "--global", "url."+m.Option(nfs.TO)+".insteadof", m.Option(nfs.FROM))
|
||||
}
|
||||
}},
|
||||
"oauth": {Help: "授权", Hand: func(m *ice.Message, arg ...string) {
|
||||
m.ProcessOpen(kit.MergeURL2(kit.Select(ice.Info.Make.Remote, m.Cmdx(cli.SYSTEM, "git", "remote", "get-url", "origin")), "/chat/cmd/web.code.git.token",
|
||||
aaa.USERNAME, m.Option(ice.MSG_USERNAME), tcp.HOST, m.Option(ice.MSG_USERHOST)))
|
||||
}},
|
||||
"token": {Name: "token token", Help: "令牌", Hand: func(m *ice.Message, arg ...string) {
|
||||
list := []string{m.Option(TOKEN)}
|
||||
m.Cmd(nfs.CAT, kit.HomePath(".git-credentials"), func(line string) { list = append(list, line) })
|
||||
@ -287,11 +291,6 @@ func init() {
|
||||
"branch_switch": {Help: "切换", Hand: func(m *ice.Message, arg ...string) {
|
||||
_repos_cmd(m, m.Option(REPOS), "checkout", m.Option(BRANCH))
|
||||
}},
|
||||
"oauth": {Help: "授权", Hand: func(m *ice.Message, arg ...string) {
|
||||
m.ProcessOpen(kit.MergeURL2(kit.Select(ice.Info.Make.Remote, m.Cmdx(cli.SYSTEM, "git", "remote", "get-url", "origin")), "/chat/cmd/web.code.git.token",
|
||||
aaa.USERNAME, m.Option(ice.MSG_USERNAME),
|
||||
tcp.HOST, m.Option(ice.MSG_USERHOST)))
|
||||
}},
|
||||
nfs.TRASH: {Hand: func(m *ice.Message, arg ...string) {
|
||||
m.Assert(m.Option(REPOS) != "" && m.Option(nfs.FILE) != "")
|
||||
nfs.Trash(m, path.Join(_repos_path(m.Option(REPOS)), m.Option(nfs.FILE)))
|
||||
|
@ -5,6 +5,7 @@ import (
|
||||
|
||||
ice "shylinux.com/x/icebergs"
|
||||
"shylinux.com/x/icebergs/base/aaa"
|
||||
"shylinux.com/x/icebergs/base/cli"
|
||||
"shylinux.com/x/icebergs/base/mdb"
|
||||
"shylinux.com/x/icebergs/base/nfs"
|
||||
"shylinux.com/x/icebergs/base/tcp"
|
||||
@ -20,25 +21,30 @@ func init() {
|
||||
GET = "get"
|
||||
SID = "sid"
|
||||
)
|
||||
const LOCAL = "http://localhost:9020"
|
||||
const FILE = ".git-credentials"
|
||||
Index.MergeCommands(ice.Commands{
|
||||
TOKEN: {Name: "token username auto prunes", Actions: ice.MergeActions(ice.Actions{
|
||||
ice.CTX_INIT: {Hand: func(m *ice.Message, arg ...string) { aaa.White(m, kit.Keys(TOKEN, SID)) }},
|
||||
cli.MAKE: {Hand: func(m *ice.Message, arg ...string) {
|
||||
msg := m.Cmd("", m.Cmdx("", mdb.CREATE, aaa.USERNAME, m.Option(ice.MSG_USERNAME), TOKEN, kit.Hashs(mdb.UNIQ)))
|
||||
m.ProcessOpen(kit.MergeURL(LOCAL+m.PrefixPath(SET), TOKEN, msg.Append("url")))
|
||||
}},
|
||||
web.PP(SET): {Hand: func(m *ice.Message, arg ...string) {
|
||||
host, list := kit.Dict(), []string{m.Option(TOKEN)}
|
||||
defer web.RenderTemplate(m, "close.html")
|
||||
host, list := ice.Map{kit.ParseURL(m.Option(TOKEN)).Host: true}, []string{m.Option(TOKEN)}
|
||||
m.Cmd(nfs.CAT, kit.HomePath(FILE), func(line string) {
|
||||
kit.If(line != list[0], func() { kit.IfNoKey(host, kit.ParseURL(line).Host, func(p string) { list = append(list, line) }) })
|
||||
kit.IfNoKey(host, kit.ParseURL(line).Host, func(p string) { list = append(list, line) })
|
||||
})
|
||||
m.Cmd(nfs.SAVE, kit.HomePath(FILE), strings.Join(list, ice.NL)+ice.NL)
|
||||
web.RenderTemplate(m, "close.html")
|
||||
}},
|
||||
web.PP(GET): {Hand: func(m *ice.Message, arg ...string) {
|
||||
m.W.Header().Set("Access-Control-Allow-Origin", "*")
|
||||
web.AllowOrigin(m, "*")
|
||||
m.Cmd(nfs.CAT, kit.HomePath(FILE), func(text string) {
|
||||
if u := kit.ParseURL(text); u.Host == arg[0] {
|
||||
if p, ok := u.User.Password(); ok {
|
||||
m.Echo(u.User.Username()).Echo(p)
|
||||
m.W.Header().Set("Access-Control-Allow-Origin", u.Scheme+"://"+u.Host)
|
||||
web.AllowOrigin(m, u.Scheme+"://"+u.Host)
|
||||
}
|
||||
}
|
||||
})
|
||||
@ -51,7 +57,8 @@ func init() {
|
||||
}, mdb.HashAction(mdb.EXPIRE, mdb.MONTH, mdb.SHORT, aaa.USERNAME, mdb.FIELD, "time,username,token")), Hand: func(m *ice.Message, arg ...string) {
|
||||
if mdb.HashSelect(m, arg...); len(arg) > 0 && m.Length() > 0 {
|
||||
p := strings.Replace(m.Option(ice.MSG_USERHOST), "://", kit.Format("://%s:%s@", m.Option(ice.MSG_USERNAME), m.Append(TOKEN)), 1)
|
||||
if m.EchoScript(p).EchoScript(nfs.Template(m, "echo.sh", p)); m.Option(ice.CMD) == m.PrefixKey() {
|
||||
m.OptionDefault(tcp.HOST, LOCAL)
|
||||
if m.Push("url", p).EchoScript(p).EchoScript(nfs.Template(m, "echo.sh", p)); m.Option(ice.CMD) == m.PrefixKey() {
|
||||
m.ProcessReplace(kit.MergeURL2(m.Option(tcp.HOST), m.PrefixPath(SET), TOKEN, p))
|
||||
} else {
|
||||
m.EchoAnchor(kit.MergeURL2(m.Option(tcp.HOST), m.PrefixPath(SET), TOKEN, p))
|
||||
|
Loading…
x
Reference in New Issue
Block a user