mirror of
https://shylinux.com/x/icebergs
synced 2025-04-27 01:48:27 +08:00
add some
This commit is contained in:
parent
f9f4324bce
commit
fd1a1613a5
@ -61,6 +61,7 @@ const (
|
|||||||
AUTH = "auth"
|
AUTH = "auth"
|
||||||
PUBLIC = "public"
|
PUBLIC = "public"
|
||||||
PRIVATE = "private"
|
PRIVATE = "private"
|
||||||
|
CONFIRM = "confirm"
|
||||||
)
|
)
|
||||||
const ROLE = "role"
|
const ROLE = "role"
|
||||||
|
|
||||||
|
@ -55,11 +55,14 @@ func init() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func UserInfo(m *ice.Message, name ice.Any, key, meta string) (value string) {
|
func UserInfo(m *ice.Message, name ice.Any, key, meta string) (value string) {
|
||||||
if m.Cmd(USER, name, func(val ice.Maps) { value = val[key] }).Length() == 0 && kit.Format(name) == m.Option(ice.MSG_USERNAME) {
|
if m.Cmd(USER, kit.Select(m.Option(ice.MSG_USERNAME), name), func(val ice.Maps) { value = val[key] }).Length() == 0 && kit.Format(name) == m.Option(ice.MSG_USERNAME) {
|
||||||
return m.Option(meta)
|
return m.Option(meta)
|
||||||
}
|
}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
func UserEmail(m *ice.Message, username ice.Any) (nick string) {
|
||||||
|
return UserInfo(m, username, EMAIL, EMAIL)
|
||||||
|
}
|
||||||
func UserNick(m *ice.Message, username ice.Any) (nick string) {
|
func UserNick(m *ice.Message, username ice.Any) (nick string) {
|
||||||
return UserInfo(m, username, USERNICK, ice.MSG_USERNICK)
|
return UserInfo(m, username, USERNICK, ice.MSG_USERNICK)
|
||||||
}
|
}
|
||||||
|
@ -71,7 +71,7 @@ func init() {
|
|||||||
if m.IsCliUA() {
|
if m.IsCliUA() {
|
||||||
_qrcode_cli(m, kit.Select(kit.Select(ice.Info.Make.Domain, ice.Info.Domain), arg, 0))
|
_qrcode_cli(m, kit.Select(kit.Select(ice.Info.Make.Domain, ice.Info.Domain), arg, 0))
|
||||||
} else {
|
} else {
|
||||||
m.OptionDefault(SIZE, "480")
|
m.OptionDefault(SIZE, "360")
|
||||||
m.StatusTime(mdb.LINK, _qrcode_web(m, tcp.PublishLocalhost(m, kit.Select(m.Option(ice.MSG_USERWEB), arg, 0))))
|
m.StatusTime(mdb.LINK, _qrcode_web(m, tcp.PublishLocalhost(m, kit.Select(m.Option(ice.MSG_USERWEB), arg, 0))))
|
||||||
}
|
}
|
||||||
}},
|
}},
|
||||||
|
1
conf.go
1
conf.go
@ -293,6 +293,7 @@ const ( // Err
|
|||||||
ErrNotRight = "not right: "
|
ErrNotRight = "not right: "
|
||||||
ErrNotValid = "not valid: "
|
ErrNotValid = "not valid: "
|
||||||
ErrNotFound = "not found: "
|
ErrNotFound = "not found: "
|
||||||
|
ErrNotAllow = "not allow: "
|
||||||
ErrNotStart = "not start: "
|
ErrNotStart = "not start: "
|
||||||
|
|
||||||
ErrNotImplement = "not implement: "
|
ErrNotImplement = "not implement: "
|
||||||
|
@ -1,13 +1,14 @@
|
|||||||
package chat
|
package chat
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"net/http"
|
||||||
|
|
||||||
ice "shylinux.com/x/icebergs"
|
ice "shylinux.com/x/icebergs"
|
||||||
"shylinux.com/x/icebergs/base/aaa"
|
"shylinux.com/x/icebergs/base/aaa"
|
||||||
"shylinux.com/x/icebergs/base/cli"
|
"shylinux.com/x/icebergs/base/cli"
|
||||||
"shylinux.com/x/icebergs/base/gdb"
|
"shylinux.com/x/icebergs/base/gdb"
|
||||||
"shylinux.com/x/icebergs/base/lex"
|
"shylinux.com/x/icebergs/base/lex"
|
||||||
"shylinux.com/x/icebergs/base/mdb"
|
"shylinux.com/x/icebergs/base/mdb"
|
||||||
"shylinux.com/x/icebergs/base/nfs"
|
|
||||||
"shylinux.com/x/icebergs/base/tcp"
|
"shylinux.com/x/icebergs/base/tcp"
|
||||||
"shylinux.com/x/icebergs/base/web"
|
"shylinux.com/x/icebergs/base/web"
|
||||||
)
|
)
|
||||||
@ -15,29 +16,29 @@ import (
|
|||||||
const GRANT = "grant"
|
const GRANT = "grant"
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
const CONFIRM = "confirm"
|
|
||||||
Index.MergeCommands(ice.Commands{
|
Index.MergeCommands(ice.Commands{
|
||||||
GRANT: {Name: "grant space auto", Help: "授权", Actions: ice.MergeActions(ice.Actions{
|
GRANT: {Name: "grant space auto", Help: "授权", Actions: ice.MergeActions(ice.Actions{
|
||||||
web.SPACE_LOGIN: {Hand: func(m *ice.Message, arg ...string) {
|
web.SPACE_LOGIN: {Hand: func(m *ice.Message, arg ...string) {
|
||||||
m.Go(func() {
|
m.Go(func() {
|
||||||
link := tcp.PublishLocalhost(m, m.MergePodCmd("", "", web.SPACE, m.Option(mdb.NAME)))
|
link := tcp.PublishLocalhost(m, m.MergePodCmd("", "", web.SPACE, m.Option(mdb.NAME)))
|
||||||
m.Sleep300ms(web.SPACE, m.Option(mdb.NAME), cli.PWD, m.Option(mdb.NAME), link, m.Cmdx(cli.QRCODE, link))
|
m.Sleep30ms(web.SPACE, m.Option(mdb.NAME), cli.PWD, m.Option(mdb.NAME), link, m.Cmdx(cli.QRCODE, link))
|
||||||
})
|
})
|
||||||
}},
|
}},
|
||||||
CONFIRM: {Help: "授权", Hand: func(m *ice.Message, arg ...string) {
|
aaa.CONFIRM: {Help: "授权", Hand: func(m *ice.Message, arg ...string) {
|
||||||
if m.Warn(m.Option(ice.MSG_USERNAME) == "", ice.ErrNotLogin) || m.Warn(m.Option(web.SPACE) == "", ice.ErrNotValid, web.SPACE) {
|
if m.Warn(m.R.Method == http.MethodGet, ice.ErrNotAllow) {
|
||||||
return
|
return
|
||||||
}
|
} else if m.Warn(m.Option(ice.MSG_USERNAME) == "", ice.ErrNotLogin) || m.Warn(m.Option(web.SPACE) == "", ice.ErrNotValid, web.SPACE) {
|
||||||
if msg := m.Cmd(web.SPACE, m.Option(web.SPACE)); m.Warn(msg.Append(mdb.TYPE) != aaa.LOGIN, ice.ErrNotFound, m.Option(web.SPACE)) {
|
return
|
||||||
|
} else if msg := m.Cmd(web.SPACE, m.Option(web.SPACE)); m.Warn(msg.Append(mdb.TYPE) != aaa.LOGIN, ice.ErrNotFound, m.Option(web.SPACE)) {
|
||||||
return
|
return
|
||||||
} else {
|
} else {
|
||||||
m.Option(ice.MSG_USERUA, msg.Append(ice.MSG_USERUA))
|
m.Option(ice.MSG_USERUA, msg.Append(ice.MSG_USERUA))
|
||||||
|
m.Cmd(web.SPACE, m.Option(web.SPACE), ice.MSG_SESSID, aaa.SessCreate(m, m.Option(ice.MSG_USERNAME)))
|
||||||
|
m.ProcessLocation(web.MergeURL2(m, msg.Append(mdb.TEXT)))
|
||||||
}
|
}
|
||||||
m.Cmd(web.SPACE, m.Option(web.SPACE), ice.MSG_SESSID, aaa.SessCreate(m, m.Option(ice.MSG_USERNAME)))
|
|
||||||
m.ProcessLocation(web.MergeURL2(m, nfs.PS))
|
|
||||||
}},
|
}},
|
||||||
}, gdb.EventAction(web.SPACE_LOGIN), aaa.RoleAction(CONFIRM)), Hand: func(m *ice.Message, arg ...string) {
|
}, aaa.RoleAction(aaa.CONFIRM), gdb.EventAction(web.SPACE_LOGIN)), Hand: func(m *ice.Message, arg ...string) {
|
||||||
m.Echo("请授权: %s 访问设备: %s", arg[0], ice.Info.Hostname).Echo(lex.NL).EchoButton(CONFIRM)
|
m.Echo("请授权: %s 访问设备: %s", arg[0], ice.Info.Hostname).Echo(lex.NL).EchoButton(aaa.CONFIRM)
|
||||||
}},
|
}},
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -35,7 +35,7 @@ func _header_share(m *ice.Message, arg ...string) {
|
|||||||
m.Push(mdb.NAME, m.Option(mdb.LINK)).PushQRCode(mdb.TEXT, m.Option(mdb.LINK))
|
m.Push(mdb.NAME, m.Option(mdb.LINK)).PushQRCode(mdb.TEXT, m.Option(mdb.LINK))
|
||||||
}
|
}
|
||||||
func _header_check(m *ice.Message, arg ...string) bool {
|
func _header_check(m *ice.Message, arg ...string) bool {
|
||||||
m.Option(ice.MAIN, mdb.Conf(m, "web.serve", "meta.main"))
|
m.Option(ice.MAIN, mdb.Conf(m, "web.serve", kit.Keym(ice.MAIN)))
|
||||||
if m.Option(ice.CMD) == aaa.OFFER && m.Option(mdb.HASH) != "" {
|
if m.Option(ice.CMD) == aaa.OFFER && m.Option(mdb.HASH) != "" {
|
||||||
m.Cmd(aaa.OFFER, m.Option(mdb.HASH), func(value ice.Maps) {
|
m.Cmd(aaa.OFFER, m.Option(mdb.HASH), func(value ice.Maps) {
|
||||||
aaa.SessAuth(m, kit.Dict(aaa.USERNAME, value[aaa.EMAIL], aaa.USERROLE, aaa.VOID))
|
aaa.SessAuth(m, kit.Dict(aaa.USERNAME, value[aaa.EMAIL], aaa.USERROLE, aaa.VOID))
|
||||||
@ -85,8 +85,11 @@ func init() {
|
|||||||
}
|
}
|
||||||
}},
|
}},
|
||||||
aaa.EMAIL: {Name: "email to subject content", Hand: func(m *ice.Message, arg ...string) {
|
aaa.EMAIL: {Name: "email to subject content", Hand: func(m *ice.Message, arg ...string) {
|
||||||
m.Options("volcano", web.UserHost(m), "version", web.RenderVersion(m))
|
if m.Option("to") != aaa.UserEmail(m, "") && !aaa.Right(m, aaa.EMAIL, m.Option("to")) {
|
||||||
m.Option(ice.MSG_USERWEB, kit.MergeURL(m.Option(ice.MSG_USERWEB), web.SHARE, m.Cmdx(web.SHARE, mdb.CREATE, mdb.TYPE, web.LOGIN)))
|
return
|
||||||
|
}
|
||||||
|
m.Options("volcano", web.UserHost(m), nfs.VERSION, web.RenderVersion(m))
|
||||||
|
m.Options(ice.MSG_USERWEB, kit.MergeURL(m.Option(ice.MSG_USERWEB), web.SHARE, m.Cmdx(web.SHARE, mdb.CREATE, mdb.TYPE, web.LOGIN)))
|
||||||
m.Cmdy(aaa.EMAIL, aaa.SEND, arg, aaa.CONTENT, nfs.Template(m, "email.html"))
|
m.Cmdy(aaa.EMAIL, aaa.SEND, arg, aaa.CONTENT, nfs.Template(m, "email.html"))
|
||||||
}},
|
}},
|
||||||
web.SHARE: {Hand: _header_share},
|
web.SHARE: {Hand: _header_share},
|
||||||
@ -94,7 +97,7 @@ func init() {
|
|||||||
"/": {Hand: func(m *ice.Message, arg ...string) {
|
"/": {Hand: func(m *ice.Message, arg ...string) {
|
||||||
m.Option("language.list", m.Cmd(nfs.DIR, path.Join(ice.SRC_TEMPLATE, m.PrefixKey(), aaa.LANGUAGE), nfs.FILE).Appendv(nfs.FILE))
|
m.Option("language.list", m.Cmd(nfs.DIR, path.Join(ice.SRC_TEMPLATE, m.PrefixKey(), aaa.LANGUAGE), nfs.FILE).Appendv(nfs.FILE))
|
||||||
m.Option("theme.list", m.Cmd(nfs.DIR, path.Join(ice.SRC_TEMPLATE, m.PrefixKey(), aaa.THEME), nfs.FILE).Appendv(nfs.FILE))
|
m.Option("theme.list", m.Cmd(nfs.DIR, path.Join(ice.SRC_TEMPLATE, m.PrefixKey(), aaa.THEME), nfs.FILE).Appendv(nfs.FILE))
|
||||||
m.Option("spide.hub", m.Cmdv(web.SPIDE, ice.HUB, web.CLIENT_URL))
|
m.Option(nfs.REPOS, m.Cmdv(web.SPIDE, ice.HUB, web.CLIENT_URL))
|
||||||
if gdb.Event(m, HEADER_AGENT); !_header_check(m, arg...) {
|
if gdb.Event(m, HEADER_AGENT); !_header_check(m, arg...) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -4,6 +4,7 @@ import (
|
|||||||
ice "shylinux.com/x/icebergs"
|
ice "shylinux.com/x/icebergs"
|
||||||
"shylinux.com/x/icebergs/base/cli"
|
"shylinux.com/x/icebergs/base/cli"
|
||||||
"shylinux.com/x/icebergs/base/ctx"
|
"shylinux.com/x/icebergs/base/ctx"
|
||||||
|
"shylinux.com/x/icebergs/base/log"
|
||||||
"shylinux.com/x/icebergs/base/mdb"
|
"shylinux.com/x/icebergs/base/mdb"
|
||||||
"shylinux.com/x/icebergs/base/web"
|
"shylinux.com/x/icebergs/base/web"
|
||||||
kit "shylinux.com/x/toolkits"
|
kit "shylinux.com/x/toolkits"
|
||||||
@ -82,8 +83,8 @@ func init() {
|
|||||||
}
|
}
|
||||||
}},
|
}},
|
||||||
}, mdb.HashAction(mdb.SHORT, web.LINK, mdb.FIELD, "time,hash,type,name,link"), FavorAction()), Hand: func(m *ice.Message, arg ...string) {
|
}, mdb.HashAction(mdb.SHORT, web.LINK, mdb.FIELD, "time,hash,type,name,link"), FavorAction()), Hand: func(m *ice.Message, arg ...string) {
|
||||||
list := []string{m.MergePodCmd("", "web.wiki.portal")}
|
list := []string{m.MergePodCmd("", "web.wiki.portal", log.DEBUG, m.Option(log.DEBUG))}
|
||||||
list = append(list, web.MergeLink(m, "/chat/portal/", ice.POD, m.Option(ice.MSG_USERPOD)))
|
list = append(list, web.MergeLink(m, "/chat/portal/", ice.POD, m.Option(ice.MSG_USERPOD), log.DEBUG, m.Option(log.DEBUG)))
|
||||||
if mdb.HashSelect(m, arg...); len(arg) == 0 {
|
if mdb.HashSelect(m, arg...); len(arg) == 0 {
|
||||||
for _, link := range list {
|
for _, link := range list {
|
||||||
if u := kit.ParseURL(link); u != nil {
|
if u := kit.ParseURL(link); u != nil {
|
||||||
|
@ -63,3 +63,4 @@ body:not(.mobile) fieldset.macos.dock>div.output { overflow:visible; }
|
|||||||
body:not(.mobile) fieldset.macos.dock>div.output>div.item:hover { background-color:unset; margin-top:-80px; transition:margin-top 0.3s; }
|
body:not(.mobile) fieldset.macos.dock>div.output>div.item:hover { background-color:unset; margin-top:-80px; transition:margin-top 0.3s; }
|
||||||
body:not(.mobile) fieldset.macos.dock>div.output>div.item img:hover { width:160px; transition:width 0.3s; }
|
body:not(.mobile) fieldset.macos.dock>div.output>div.item img:hover { width:160px; transition:width 0.3s; }
|
||||||
body:not(.mobile) fieldset.macos.desktop>div.output>fieldset.macos.dock:hover { margin-left:-40px; transition:margin-left 0.3s; }
|
body:not(.mobile) fieldset.macos.desktop>div.output>fieldset.macos.dock:hover { margin-left:-40px; transition:margin-left 0.3s; }
|
||||||
|
body.mobile fieldset.macos.desktop>div.output>div.desktop>fieldset>form.option>div.item.text>input { width:60px; }
|
||||||
|
@ -43,28 +43,34 @@ type Client struct {
|
|||||||
auth string `name:"auth" help:"授权"`
|
auth string `name:"auth" help:"授权"`
|
||||||
user string `name:"user" help:"用户"`
|
user string `name:"user" help:"用户"`
|
||||||
orgs string `name:"orgs" help:"组织"`
|
orgs string `name:"orgs" help:"组织"`
|
||||||
repo string `name:"repo" help:"源码"`
|
repo string `name:"repo" help:"资源"`
|
||||||
list string `name:"list hash auto" help:"授权"`
|
list string `name:"list hash auto" help:"授权"`
|
||||||
login string `name:"login" role:"void"`
|
login string `name:"login" role:"void"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var Inputs = []map[string]string{}
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
Inputs = append(Inputs, map[string]string{
|
||||||
|
OAUTH_URL: "/login/oauth/authorize",
|
||||||
|
GRANT_URL: "/login/oauth/access_token",
|
||||||
|
TOKEN_URL: "/login/oauth/access_token",
|
||||||
|
USERS_URL: "/api/v1/user",
|
||||||
|
API_PREFIX: "/api/v1/",
|
||||||
|
TOKEN_PREFIX: "token",
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
func (s Client) Inputs(m *ice.Message, arg ...string) {
|
func (s Client) Inputs(m *ice.Message, arg ...string) {
|
||||||
switch s.Hash.Inputs(m, arg...); arg[0] {
|
switch s.Hash.Inputs(m, arg...); arg[0] {
|
||||||
case web.DOMAIN:
|
case web.DOMAIN:
|
||||||
m.Cmdy(web.SPIDE, mdb.INPUTS, arg)
|
m.Cmdy(web.SPIDE, mdb.INPUTS, arg)
|
||||||
m.Push(arg[0], "https://repos.shylinux.com")
|
default:
|
||||||
case OAUTH_URL:
|
for _, input := range Inputs {
|
||||||
m.Push(arg[0], "/login/oauth/authorize")
|
if value, ok := input[arg[0]]; ok {
|
||||||
case GRANT_URL:
|
m.Push(arg[0], value)
|
||||||
m.Push(arg[0], "/login/oauth/access_token")
|
}
|
||||||
case TOKEN_URL:
|
}
|
||||||
m.Push(arg[0], "/login/oauth/access_token")
|
|
||||||
case USERS_URL:
|
|
||||||
m.Push(arg[0], "/api/v1/user")
|
|
||||||
case API_PREFIX:
|
|
||||||
m.Push(arg[0], "/api/v1/")
|
|
||||||
case TOKEN_PREFIX:
|
|
||||||
m.Push(arg[0], "token")
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
func (s Client) Sso(m *ice.Message, arg ...string) {
|
func (s Client) Sso(m *ice.Message, arg ...string) {
|
||||||
@ -128,6 +134,7 @@ func (s Client) request(m *ice.Message, hash, api string, arg ...string) []strin
|
|||||||
kit.If(msg.Append(ACCESS_TOKEN), func(p string) {
|
kit.If(msg.Append(ACCESS_TOKEN), func(p string) {
|
||||||
m.Options(web.SPIDE_HEADER, ice.Maps{web.Authorization: msg.Append(TOKEN_PREFIX) + lex.SP + p})
|
m.Options(web.SPIDE_HEADER, ice.Maps{web.Authorization: msg.Append(TOKEN_PREFIX) + lex.SP + p})
|
||||||
})
|
})
|
||||||
kit.If(api == "", func() { api = path.Join(msg.Append(API_PREFIX), strings.ToLower(kit.FuncName(6))) })
|
kit.If(api == "", func() { api = path.Join(msg.Append(API_PREFIX), m.ActionKey()) })
|
||||||
|
// kit.If(api == "", func() { api = path.Join(msg.Append(API_PREFIX), strings.ToLower(kit.FuncName(6))) })
|
||||||
return kit.Simple(kit.MergeURL2(msg.Append(web.DOMAIN), api), arg)
|
return kit.Simple(kit.MergeURL2(msg.Append(web.DOMAIN), api), arg)
|
||||||
}
|
}
|
||||||
|
@ -18,7 +18,9 @@ Volcanos(chat.ONIMPORT, {
|
|||||||
{view: html.ACTION, inner: value.action, _init: function(target) { can.onappend.mores(can, target, value, 5) }},
|
{view: html.ACTION, inner: value.action, _init: function(target) { can.onappend.mores(can, target, value, 5) }},
|
||||||
]}
|
]}
|
||||||
})), can.onappend.board(can, msg), can.onimport.layout(can)
|
})), can.onappend.board(can, msg), can.onimport.layout(can)
|
||||||
can.onappend.scroll(can, can._output)
|
can.user.isWindows && can.onappend.scroll(can, can._output)
|
||||||
|
},
|
||||||
|
layout: function(can) {
|
||||||
|
can.onlayout.expand(can, can._output, can.user.isMobile && !can.user.isLandscape()? can.ConfWidth(): 380)
|
||||||
},
|
},
|
||||||
layout: function(can) { can.onlayout.expand(can, can._output, 380) },
|
|
||||||
}, [""])
|
}, [""])
|
||||||
|
Loading…
x
Reference in New Issue
Block a user