diff --git a/base/aaa/role.go b/base/aaa/role.go index 69f3def7..fae9dd58 100644 --- a/base/aaa/role.go +++ b/base/aaa/role.go @@ -61,6 +61,7 @@ const ( AUTH = "auth" PUBLIC = "public" PRIVATE = "private" + CONFIRM = "confirm" ) const ROLE = "role" diff --git a/base/aaa/user.go b/base/aaa/user.go index 6459725b..5f696724 100644 --- a/base/aaa/user.go +++ b/base/aaa/user.go @@ -55,11 +55,14 @@ func init() { } 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 } +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) { return UserInfo(m, username, USERNICK, ice.MSG_USERNICK) } diff --git a/base/cli/qrcode.go b/base/cli/qrcode.go index 515cc0d3..d4b8519d 100644 --- a/base/cli/qrcode.go +++ b/base/cli/qrcode.go @@ -71,7 +71,7 @@ func init() { if m.IsCliUA() { _qrcode_cli(m, kit.Select(kit.Select(ice.Info.Make.Domain, ice.Info.Domain), arg, 0)) } 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)))) } }}, diff --git a/conf.go b/conf.go index 9b38903a..9636d6f1 100644 --- a/conf.go +++ b/conf.go @@ -293,6 +293,7 @@ const ( // Err ErrNotRight = "not right: " ErrNotValid = "not valid: " ErrNotFound = "not found: " + ErrNotAllow = "not allow: " ErrNotStart = "not start: " ErrNotImplement = "not implement: " diff --git a/core/chat/grant.go b/core/chat/grant.go index 9225c7a9..6b0ac2ab 100644 --- a/core/chat/grant.go +++ b/core/chat/grant.go @@ -1,13 +1,14 @@ package chat import ( + "net/http" + ice "shylinux.com/x/icebergs" "shylinux.com/x/icebergs/base/aaa" "shylinux.com/x/icebergs/base/cli" "shylinux.com/x/icebergs/base/gdb" "shylinux.com/x/icebergs/base/lex" "shylinux.com/x/icebergs/base/mdb" - "shylinux.com/x/icebergs/base/nfs" "shylinux.com/x/icebergs/base/tcp" "shylinux.com/x/icebergs/base/web" ) @@ -15,29 +16,29 @@ import ( const GRANT = "grant" func init() { - const CONFIRM = "confirm" Index.MergeCommands(ice.Commands{ GRANT: {Name: "grant space auto", Help: "授权", Actions: ice.MergeActions(ice.Actions{ web.SPACE_LOGIN: {Hand: func(m *ice.Message, arg ...string) { m.Go(func() { 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) { - if m.Warn(m.Option(ice.MSG_USERNAME) == "", ice.ErrNotLogin) || m.Warn(m.Option(web.SPACE) == "", ice.ErrNotValid, web.SPACE) { + aaa.CONFIRM: {Help: "授权", Hand: func(m *ice.Message, arg ...string) { + if m.Warn(m.R.Method == http.MethodGet, ice.ErrNotAllow) { return - } - if msg := m.Cmd(web.SPACE, m.Option(web.SPACE)); m.Warn(msg.Append(mdb.TYPE) != aaa.LOGIN, ice.ErrNotFound, m.Option(web.SPACE)) { + } else if m.Warn(m.Option(ice.MSG_USERNAME) == "", ice.ErrNotLogin) || m.Warn(m.Option(web.SPACE) == "", ice.ErrNotValid, 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 } else { 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) { - m.Echo("请授权: %s 访问设备: %s", arg[0], ice.Info.Hostname).Echo(lex.NL).EchoButton(CONFIRM) + }, 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(aaa.CONFIRM) }}, }) } diff --git a/core/chat/header.go b/core/chat/header.go index 2b450822..7be6e724 100644 --- a/core/chat/header.go +++ b/core/chat/header.go @@ -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)) } 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) != "" { 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)) @@ -85,8 +85,11 @@ func init() { } }}, aaa.EMAIL: {Name: "email to subject content", Hand: func(m *ice.Message, arg ...string) { - m.Options("volcano", web.UserHost(m), "version", web.RenderVersion(m)) - m.Option(ice.MSG_USERWEB, kit.MergeURL(m.Option(ice.MSG_USERWEB), web.SHARE, m.Cmdx(web.SHARE, mdb.CREATE, mdb.TYPE, web.LOGIN))) + if m.Option("to") != aaa.UserEmail(m, "") && !aaa.Right(m, aaa.EMAIL, m.Option("to")) { + 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")) }}, web.SHARE: {Hand: _header_share}, @@ -94,7 +97,7 @@ func init() { "/": {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("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...) { return } diff --git a/core/chat/iframe.go b/core/chat/iframe.go index ee89bfae..edad948f 100644 --- a/core/chat/iframe.go +++ b/core/chat/iframe.go @@ -4,6 +4,7 @@ import ( ice "shylinux.com/x/icebergs" "shylinux.com/x/icebergs/base/cli" "shylinux.com/x/icebergs/base/ctx" + "shylinux.com/x/icebergs/base/log" "shylinux.com/x/icebergs/base/mdb" "shylinux.com/x/icebergs/base/web" 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) { - list := []string{m.MergePodCmd("", "web.wiki.portal")} - list = append(list, web.MergeLink(m, "/chat/portal/", ice.POD, m.Option(ice.MSG_USERPOD))) + 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), log.DEBUG, m.Option(log.DEBUG))) if mdb.HashSelect(m, arg...); len(arg) == 0 { for _, link := range list { if u := kit.ParseURL(link); u != nil { diff --git a/core/chat/macos/desktop.css b/core/chat/macos/desktop.css index 1b348f84..454cef4d 100644 --- a/core/chat/macos/desktop.css +++ b/core/chat/macos/desktop.css @@ -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 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.mobile fieldset.macos.desktop>div.output>div.desktop>fieldset>form.option>div.item.text>input { width:60px; } diff --git a/core/chat/oauth/client.go b/core/chat/oauth/client.go index ae6788eb..109208de 100644 --- a/core/chat/oauth/client.go +++ b/core/chat/oauth/client.go @@ -43,28 +43,34 @@ type Client struct { auth string `name:"auth" help:"授权"` user string `name:"user" help:"用户"` orgs string `name:"orgs" help:"组织"` - repo string `name:"repo" help:"源码"` + repo string `name:"repo" help:"资源"` list string `name:"list hash auto" help:"授权"` 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) { switch s.Hash.Inputs(m, arg...); arg[0] { case web.DOMAIN: m.Cmdy(web.SPIDE, mdb.INPUTS, arg) - m.Push(arg[0], "https://repos.shylinux.com") - case OAUTH_URL: - m.Push(arg[0], "/login/oauth/authorize") - case GRANT_URL: - 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") + default: + for _, input := range Inputs { + if value, ok := input[arg[0]]; ok { + m.Push(arg[0], value) + } + } } } 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) { 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) } diff --git a/misc/git/search.js b/misc/git/search.js index 317abcd8..7f62995f 100644 --- a/misc/git/search.js +++ b/misc/git/search.js @@ -18,7 +18,9 @@ Volcanos(chat.ONIMPORT, { {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.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) }, }, [""])