1
0
mirror of https://shylinux.com/x/icebergs synced 2025-04-25 17:18:05 +08:00

add oauth

This commit is contained in:
harveyshao 2022-04-30 15:15:11 +08:00
parent c9ad3cdcc9
commit bdc21c1207
21 changed files with 135 additions and 30 deletions

View File

@ -21,7 +21,7 @@ func _role_list(m *ice.Message, userrole string) {
}) })
} }
func _role_chain(arg ...string) string { func _role_chain(arg ...string) string {
return kit.ReplaceAll(kit.Keys(arg), ice.PS, ice.PT) return kit.ReplaceAll(kit.ReplaceAll(kit.Keys(arg), ice.PS, ice.PT), "..", ".")
} }
func _role_black(m *ice.Message, userrole, chain string) { func _role_black(m *ice.Message, userrole, chain string) {
m.Richs(ROLE, nil, userrole, func(key string, value map[string]interface{}) { m.Richs(ROLE, nil, userrole, func(key string, value map[string]interface{}) {

View File

@ -52,6 +52,7 @@ func UserRoot(m *ice.Message, arg ...string) *ice.Message { // password username
userrole := m.Option(ice.MSG_USERROLE, kit.Select(ROOT, arg, 2)) userrole := m.Option(ice.MSG_USERROLE, kit.Select(ROOT, arg, 2))
if len(arg) > 0 { if len(arg) > 0 {
_user_create(m, userrole, username, kit.Select("", arg, 0)) _user_create(m, userrole, username, kit.Select("", arg, 0))
ice.Info.UserName = username
} }
return m return m
} }

View File

@ -118,12 +118,15 @@ const (
CTX_DEV = "ctx_dev" CTX_DEV = "ctx_dev"
CTX_OPS = "ctx_ops" CTX_OPS = "ctx_ops"
CTX_ARG = "ctx_arg" CTX_ARG = "ctx_arg"
CTX_POD = "ctx_pod"
CTX_PID = "ctx_pid" CTX_PID = "ctx_pid"
CTX_LOG = "ctx_log" CTX_LOG = "ctx_log"
CTX_USER = "ctx_user" CTX_USER = "ctx_user"
CTX_SHARE = "ctx_share" CTX_SHARE = "ctx_share"
CTX_RIVER = "ctx_river" CTX_RIVER = "ctx_river"
MAKE_DOMAIN = "make.domain"
) )
const ( const (
HOSTNAME = "hostname" HOSTNAME = "hostname"
@ -204,11 +207,11 @@ func init() {
} }
m.Sort(nfs.PATH) m.Sort(nfs.PATH)
}}, }},
"make.domain": {Name: "make.domain", Help: "接口命令", Hand: func(m *ice.Message, arg ...string) { MAKE_DOMAIN: {Name: "make.domain", Help: "编译主机", Hand: func(m *ice.Message, arg ...string) {
if os.Getenv("ctx_dev") == "" || os.Getenv("ctx_pod") == "" { if os.Getenv(CTX_DEV) == "" || os.Getenv(CTX_POD) == "" {
m.Echo(m.Conf(RUNTIME, "make.domain")) m.Echo(m.Conf(RUNTIME, MAKE_DOMAIN))
} else { } else {
m.Echo(kit.MergePOD(os.Getenv("ctx_dev"), os.Getenv("ctx_pod"))) m.Echo(kit.MergePOD(os.Getenv(CTX_DEV), os.Getenv(CTX_POD)))
} }
}}, }},
}, Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) { }, Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {

View File

@ -4,6 +4,7 @@ import (
"strings" "strings"
ice "shylinux.com/x/icebergs" ice "shylinux.com/x/icebergs"
"shylinux.com/x/icebergs/base/aaa"
"shylinux.com/x/icebergs/base/mdb" "shylinux.com/x/icebergs/base/mdb"
kit "shylinux.com/x/toolkits" kit "shylinux.com/x/toolkits"
) )
@ -80,6 +81,10 @@ const COMMAND = "command"
func init() { func init() {
Index.Merge(&ice.Context{Commands: map[string]*ice.Command{ Index.Merge(&ice.Context{Commands: map[string]*ice.Command{
COMMAND: {Name: "command key auto", Help: "命令", Action: map[string]*ice.Action{ COMMAND: {Name: "command key auto", Help: "命令", Action: map[string]*ice.Action{
ice.CTX_INIT: {Hand: func(m *ice.Message, arg ...string) {
m.Cmd(aaa.ROLE, aaa.WHITE, aaa.VOID, m.Prefix(COMMAND))
m.Cmd(aaa.ROLE, aaa.WHITE, aaa.VOID, COMMAND)
}},
mdb.SEARCH: {Name: "search type name text", Help: "搜索", Hand: func(m *ice.Message, arg ...string) { mdb.SEARCH: {Name: "search type name text", Help: "搜索", Hand: func(m *ice.Message, arg ...string) {
if arg[0] == m.CommandKey() || len(arg) > 1 && arg[1] != "" { if arg[0] == m.CommandKey() || len(arg) > 1 && arg[1] != "" {
_command_search(m, arg[0], kit.Select("", arg, 1), kit.Select("", arg, 2)) _command_search(m, arg[0], kit.Select("", arg, 1), kit.Select("", arg, 2))

View File

@ -151,10 +151,10 @@ func AutoConfig(args ...interface{}) *ice.Action {
} }
func HashAction(args ...interface{}) map[string]*ice.Action { func HashAction(args ...interface{}) map[string]*ice.Action {
_key := func(m *ice.Message) string { _key := func(m *ice.Message) string {
if m.Config(HASH) == "uniq" { if m.Config(HASH) == UNIQ {
return HASH return HASH
} }
if m.Config(SHORT) == "uniq" { if m.Config(SHORT) == UNIQ {
return HASH return HASH
} }
return kit.Select(HASH, m.Config(SHORT)) return kit.Select(HASH, m.Config(SHORT))
@ -198,6 +198,9 @@ func HashActionStatus(args ...interface{}) map[string]*ice.Action {
}} }}
return list return list
} }
func HashCreate(m *ice.Message, arg ...interface{}) *ice.Message {
return m.Cmd(INSERT, m.PrefixKey(), "", HASH, kit.Simple(arg...))
}
func HashSelect(m *ice.Message, arg ...string) *ice.Message { func HashSelect(m *ice.Message, arg ...string) *ice.Message {
m.Fields(len(arg), m.Config(FIELD)) m.Fields(len(arg), m.Config(FIELD))
m.Cmdy(SELECT, m.PrefixKey(), "", HASH, m.Config(SHORT), arg) m.Cmdy(SELECT, m.PrefixKey(), "", HASH, m.Config(SHORT), arg)
@ -207,7 +210,7 @@ func HashSelect(m *ice.Message, arg ...string) *ice.Message {
} }
func HashPrunes(m *ice.Message, cb func(map[string]string) bool) *ice.Message { func HashPrunes(m *ice.Message, cb func(map[string]string) bool) *ice.Message {
_key := func(m *ice.Message) string { _key := func(m *ice.Message) string {
if m.Config(HASH) == "uniq" { if m.Config(HASH) == UNIQ {
return HASH return HASH
} }
return kit.Select(HASH, m.Config(SHORT)) return kit.Select(HASH, m.Config(SHORT))

View File

@ -62,6 +62,8 @@ const (
FOREACH = "*" FOREACH = "*"
RANDOMS = "%" RANDOMS = "%"
UNIQ = kit.MDB_UNIQ
) )
const ( const (
DETAIL = "detail" DETAIL = "detail"

View File

@ -80,7 +80,7 @@ func _cache_upload(m *ice.Message, r *http.Request) (kind, name, file, size stri
func _cache_download(m *ice.Message, r *http.Response) (file, size string) { func _cache_download(m *ice.Message, r *http.Response) (file, size string) {
defer r.Body.Close() defer r.Body.Close()
if f, p, e := kit.Create(path.Join(ice.VAR_TMP, kit.Hashs("uniq"))); m.Assert(e) { if f, p, e := kit.Create(path.Join(ice.VAR_TMP, kit.Hashs(mdb.UNIQ))); m.Assert(e) {
step, total := 0, kit.Int(kit.Select("1", r.Header.Get(ContentLength))) step, total := 0, kit.Int(kit.Select("1", r.Header.Get(ContentLength)))
size, buf := 0, make([]byte, ice.MOD_BUFS) size, buf := 0, make([]byte, ice.MOD_BUFS)

View File

@ -303,6 +303,7 @@ func init() {
} }
return false return false
}) })
m.Cmd(aaa.ROLE, aaa.WHITE, aaa.VOID, nfs.CAT, "usr/publish/order.js")
}}, }},
ice.CTX_EXIT: {Hand: func(m *ice.Message, arg ...string) { ice.CTX_EXIT: {Hand: func(m *ice.Message, arg ...string) {
m.Cmd(SERVE).Table(func(index int, value map[string]string, head []string) { m.Cmd(SERVE).Table(func(index int, value map[string]string, head []string) {

View File

@ -92,8 +92,12 @@ func _space_handle(m *ice.Message, safe bool, send map[string]*ice.Message, c *w
msg.Log("recv", "%v->%v %s %v", source, target, msg.Detailv(), msg.FormatMeta()) msg.Log("recv", "%v->%v %s %v", source, target, msg.Detailv(), msg.FormatMeta())
if len(target) == 0 { if len(target) == 0 {
msg.Log_AUTH(aaa.USERROLE, kit.Select(msg.Option(ice.MSG_USERROLE), m.Cmd(aaa.USER, msg.Option(ice.MSG_USERNAME)).Append(aaa.USERROLE)), aaa.USERNAME, msg.Option(ice.MSG_USERNAME))
if msg.Optionv(ice.MSG_HANDLE, ice.TRUE); safe { // 下行命令 if msg.Optionv(ice.MSG_HANDLE, ice.TRUE); safe { // 下行命令
msg.Option(ice.MSG_USERROLE, kit.Select(msg.Option(ice.MSG_USERROLE), msg.Cmd(aaa.USER, msg.Option(ice.MSG_USERNAME)).Append(aaa.USERROLE)))
if msg.Option(ice.MSG_USERROLE) == aaa.VOID && ice.Info.UserName == "demo" {
msg.Option(ice.MSG_USERROLE, aaa.TECH)
}
msg.Log_AUTH(aaa.USERROLE, msg.Option(ice.MSG_USERROLE), aaa.USERNAME, msg.Option(ice.MSG_USERNAME))
msg.Go(func() { _space_exec(msg, source, target, c, name) }) msg.Go(func() { _space_exec(msg, source, target, c, name) })
} else { // 上行请求 } else { // 上行请求
msg.Push(mdb.LINK, kit.MergePOD(_space_domain(msg), name)) msg.Push(mdb.LINK, kit.MergePOD(_space_domain(msg), name))

View File

@ -317,6 +317,7 @@ const (
Authorization = "Authorization" Authorization = "Authorization"
ContentType = "Content-Type" ContentType = "Content-Type"
ContentLength = "Content-Length" ContentLength = "Content-Length"
UserAgent = "User-Agent"
ContentFORM = "application/x-www-form-urlencoded" ContentFORM = "application/x-www-form-urlencoded"
ContentJSON = "application/json" ContentJSON = "application/json"

View File

@ -220,6 +220,8 @@ const ( // RENDER
) )
const ( // PROCESS const ( // PROCESS
PROCESS_LOCATION = "_location" PROCESS_LOCATION = "_location"
PROCESS_REPLACE = "_replace"
PROCESS_HISTORY = "_history"
PROCESS_REFRESH = "_refresh" PROCESS_REFRESH = "_refresh"
PROCESS_REWRITE = "_rewrite" PROCESS_REWRITE = "_rewrite"
PROCESS_DISPLAY = "_display" PROCESS_DISPLAY = "_display"

View File

@ -39,7 +39,7 @@ func _action_exec(m *ice.Message, river, storm, index string, arg ...string) {
if cmds = kit.Simple(kit.Keys(value[ice.CTX], value[ice.CMD])); kit.Format(value[ice.POD]) != "" { if cmds = kit.Simple(kit.Keys(value[ice.CTX], value[ice.CMD])); kit.Format(value[ice.POD]) != "" {
m.Option(ice.POD, value[ice.POD]) // 远程节点 m.Option(ice.POD, value[ice.POD]) // 远程节点
} }
}) == nil && !m.Right(cmds) { }) == nil && m.Option(ice.MSG_USERPOD) == "" && !m.Right(cmds) {
return // 没有授权 return // 没有授权
} }
@ -189,7 +189,7 @@ func init() {
if m.Warn(m.Option(ice.MSG_USERNAME) == "", ice.ErrNotLogin, arg) { if m.Warn(m.Option(ice.MSG_USERNAME) == "", ice.ErrNotLogin, arg) {
return // 没有登录 return // 没有登录
} }
if m.Warn(!_action_right(m, arg[0], arg[1]), ice.ErrNotRight, arg) { if m.Option(ice.MSG_USERPOD) == "" && m.Warn(!_action_right(m, arg[0], arg[1]), ice.ErrNotRight, arg) {
return // 没有授权 return // 没有授权
} }

View File

@ -42,8 +42,10 @@ func init() {
return // 插件 return // 插件
} }
if m.PodCmd(ctx.COMMAND, arg[0]) && m.Length() > 0 { if m.PodCmd(ctx.COMMAND, arg[0]) {
m.RenderCmd(arg[0], arg[1:]) // 远程命令 if !m.IsErr() {
m.RenderCmd(arg[0], arg[1:]) // 远程命令
}
} else if m.Cmdy(ctx.COMMAND, arg[0]); m.Length() > 0 { } else if m.Cmdy(ctx.COMMAND, arg[0]); m.Length() > 0 {
m.RenderCmd(arg[0], arg[1:]) // 本地命令 m.RenderCmd(arg[0], arg[1:]) // 本地命令
} else { } else {

View File

@ -8,8 +8,6 @@ import (
"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/mdb" "shylinux.com/x/icebergs/base/mdb"
"shylinux.com/x/icebergs/base/nfs"
"shylinux.com/x/icebergs/base/ssh"
"shylinux.com/x/icebergs/base/tcp" "shylinux.com/x/icebergs/base/tcp"
"shylinux.com/x/icebergs/base/web" "shylinux.com/x/icebergs/base/web"
"shylinux.com/x/icebergs/core/code" "shylinux.com/x/icebergs/core/code"
@ -125,10 +123,8 @@ func init() {
_header_users(m, m.ActionKey(), arg...) _header_users(m, m.ActionKey(), arg...)
}}, }},
ctx.CONFIG: {Name: "config file", Help: "配置", Hand: func(m *ice.Message, arg ...string) { ctx.CONFIG: {Name: "config scope", Help: "配置", Hand: func(m *ice.Message, arg ...string) {
pod := strings.Split(m.Cmdx(web.SPACE, m.Option(ice.MSG_USERPOD), cli.RUNTIME, "make.domain"), "/chat/pod/")[1] m.Cmdy(web.SPACE, m.Option(ice.MSG_USERPOD), m.Prefix(OAUTH), CHECK, arg)
m.Cmd(web.SPACE, m.Option(ice.MSG_USERPOD), nfs.SAVE, m.Option(nfs.FILE), m.Cmdx(web.SPACE, pod, nfs.CAT, m.Option(nfs.FILE)))
m.Cmd(web.SPACE, m.Option(ice.MSG_USERPOD), ssh.SOURCE, m.Option(nfs.FILE))
}}, }},
code.WEBPACK: {Name: "webpack", Help: "打包页面", Hand: func(m *ice.Message, arg ...string) { code.WEBPACK: {Name: "webpack", Help: "打包页面", Hand: func(m *ice.Message, arg ...string) {
m.Cmdy(code.WEBPACK, cli.BUILD, m.OptionSimple(mdb.NAME)) m.Cmdy(code.WEBPACK, cli.BUILD, m.OptionSimple(mdb.NAME))

66
core/chat/oauth.go Normal file
View File

@ -0,0 +1,66 @@
package chat
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/ssh"
"shylinux.com/x/icebergs/base/web"
kit "shylinux.com/x/toolkits"
)
const OAUTH = "oauth"
func init() {
const (
CHECK = "check"
APPLY = "apply"
REPLY = "reply"
OFFER = "offer"
OAUTH_APPLY = "/oauth/apply"
OAUTH_REPLY = "/oauth/reply"
OAUTH_OFFER = "/oauth/offer"
)
const (
SCOPE = "scope"
REDIRECT_URI = "redirect_uri"
ACCESS_TOKEN = "access_token"
EXPIRES = "expires"
)
Index.Merge(&ice.Context{Commands: map[string]*ice.Command{
OAUTH: {Name: "oauth hash auto prunes", Help: "授权", Action: ice.MergeAction(map[string]*ice.Action{
ice.CTX_INIT: {Hand: func(m *ice.Message, arg ...string) {
m.Cmd(aaa.ROLE, aaa.WHITE, aaa.VOID, m.Prefix(OAUTH_APPLY))
m.Cmd(aaa.ROLE, aaa.WHITE, aaa.VOID, m.Prefix(OAUTH_OFFER))
}},
CHECK: {Name: "check scope", Help: "检查", Hand: func(m *ice.Message, arg ...string) {
m.Echo(kit.MergeURL(m.Cmdx(cli.RUNTIME, cli.MAKE_DOMAIN)+OAUTH_APPLY, m.OptionSimple(SCOPE), REDIRECT_URI, m.MergePodURL(OAUTH_REPLY)))
}},
APPLY: {Name: "apply redirect_uri", Help: "申请", Hand: func(m *ice.Message, arg ...string) {
if m.Right(m.Option(SCOPE)) {
token := mdb.HashCreate(m, mdb.TIME, m.Time(m.Config(EXPIRES)), aaa.USERNAME, m.Option(ice.MSG_USERNAME), m.OptionSimple(SCOPE, REDIRECT_URI)).Result()
m.ProcessReplace(kit.MergeURL(m.Option(REDIRECT_URI), OFFER, m.MergePodURL(OAUTH_OFFER, ACCESS_TOKEN, token)))
}
}},
REPLY: {Name: "reply offer", Help: "通过", Hand: func(m *ice.Message, arg ...string) {
m.Option(web.SPIDE_HEADER, web.UserAgent, m.PrefixKey())
m.Cmd(ssh.SOURCE, ice.ETC_LOCAL_SHY, kit.Dict(nfs.CAT_CONTENT, m.Cmdx(web.SPIDE, ice.DEV, web.SPIDE_GET, m.Option(OFFER))))
m.ProcessHistory()
}},
}, mdb.HashAction(mdb.SHORT, mdb.UNIQ, EXPIRES, "720h"))},
OAUTH_APPLY: {Name: "/oauth/apply", Help: "授权申请", Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
m.RenderCmd(m.Prefix(OAUTH), APPLY)
}},
OAUTH_REPLY: {Name: "/oauth/reply", Help: "授权通过", Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
m.RenderCmd(m.Prefix(OAUTH), REPLY)
}},
OAUTH_OFFER: {Name: "/oauth/offer", Help: "授权资源", Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
if msg := m.Cmd(OAUTH, m.Option(ACCESS_TOKEN), ice.OptionFields("time,scope")); kit.Time(msg.Time()) < kit.Time(msg.Append(mdb.TIME)) {
aaa.UserRoot(m).Cmdy(nfs.CAT, msg.Append(SCOPE)).RenderResult()
}
}},
}})
}

View File

@ -2,6 +2,7 @@ package chat
import ( import (
"path" "path"
"strings"
ice "shylinux.com/x/icebergs" ice "shylinux.com/x/icebergs"
"shylinux.com/x/icebergs/base/aaa" "shylinux.com/x/icebergs/base/aaa"
@ -20,7 +21,7 @@ func init() {
ice.CTX_INIT: {Name: "_init", Help: "初始化", Hand: func(m *ice.Message, arg ...string) { ice.CTX_INIT: {Name: "_init", Help: "初始化", Hand: func(m *ice.Message, arg ...string) {
}}, }},
}, ctx.CmdAction()), Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) { }, ctx.CmdAction()), Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
if m.IsCliUA() { if strings.HasPrefix(m.R.Header.Get("User-Agent"), "curl") || strings.HasPrefix(m.R.Header.Get("User-Agent"), "Wget") {
m.Option(ice.MSG_USERNAME, "root") m.Option(ice.MSG_USERNAME, "root")
m.Option(ice.MSG_USERROLE, "root") m.Option(ice.MSG_USERROLE, "root")
m.Option(ice.POD, kit.Select("", arg, 0)) m.Option(ice.POD, kit.Select("", arg, 0))
@ -40,8 +41,10 @@ func init() {
} else if arg[1] == WEBSITE { // 节点网页 } else if arg[1] == WEBSITE { // 节点网页
m.RenderWebsite(arg[0], path.Join(arg[2:]...)) m.RenderWebsite(arg[0], path.Join(arg[2:]...))
} else { // 节点命令 } else if arg[1] == "cmd" { // 节点命令
m.Cmdy("/cmd/", path.Join(arg[2:]...)) m.Cmdy("/cmd/", path.Join(arg[2:]...))
} else {
m.Cmdy(web.SPACE, m.Option(ice.MSG_USERPOD), "web.chat."+ice.PS+path.Join(arg[1:]...))
} }
}}, }},
}}) }})

View File

@ -40,6 +40,9 @@ func _field_show(m *ice.Message, name, text string, arg ...string) {
name = cmd.Help name = cmd.Help
} }
}) })
if !m.Spawn().Right(cmds[0]) {
return
}
name = strings.ReplaceAll(name, ice.SP, "_") name = strings.ReplaceAll(name, ice.SP, "_")
meta[mdb.NAME], meta[mdb.INDEX] = name, text meta[mdb.NAME], meta[mdb.INDEX] = name, text

View File

@ -2,6 +2,7 @@ package wiki
import ( import (
ice "shylinux.com/x/icebergs" ice "shylinux.com/x/icebergs"
"shylinux.com/x/icebergs/base/aaa"
"shylinux.com/x/icebergs/base/ctx" "shylinux.com/x/icebergs/base/ctx"
"shylinux.com/x/icebergs/base/lex" "shylinux.com/x/icebergs/base/lex"
"shylinux.com/x/icebergs/base/mdb" "shylinux.com/x/icebergs/base/mdb"
@ -38,6 +39,9 @@ func init() {
)}, )},
}, Commands: map[string]*ice.Command{ }, Commands: map[string]*ice.Command{
WORD: {Name: "word path=src/main.shy@key auto play", Help: "语言文字", Meta: kit.Dict(ice.DisplayLocal("")), Action: ice.MergeAction(map[string]*ice.Action{ WORD: {Name: "word path=src/main.shy@key auto play", Help: "语言文字", Meta: kit.Dict(ice.DisplayLocal("")), Action: ice.MergeAction(map[string]*ice.Action{
ice.CTX_INIT: {Hand: func(m *ice.Message, arg ...string) {
m.Cmd(aaa.ROLE, aaa.WHITE, aaa.VOID, m.PrefixKey("src/main.shy"))
}},
mdb.SEARCH: {Name: "search", Help: "搜索", Hand: func(m *ice.Message, arg ...string) { mdb.SEARCH: {Name: "search", Help: "搜索", Hand: func(m *ice.Message, arg ...string) {
if arg[0] == mdb.FOREACH && arg[1] == "" { if arg[0] == mdb.FOREACH && arg[1] == "" {
m.PushSearch(mdb.TYPE, "shy", mdb.NAME, "src/main.shy", mdb.TEXT, m.MergeCmd("")) m.PushSearch(mdb.TYPE, "shy", mdb.NAME, "src/main.shy", mdb.TEXT, m.MergeCmd(""))

2
go.sum
View File

@ -1,4 +1,6 @@
shylinux.com/x/go-qrcode v0.0.1 h1:/eOGqMj1qtgs9Ymd12zTUa1gcJZs9S92kj2lb0QzKsE=
shylinux.com/x/go-qrcode v0.0.1/go.mod h1:KAbtU+KwiiABMZ/CJ0zh9PI2AX82Uf9rRYcQ4ODm4po= shylinux.com/x/go-qrcode v0.0.1/go.mod h1:KAbtU+KwiiABMZ/CJ0zh9PI2AX82Uf9rRYcQ4ODm4po=
shylinux.com/x/toolkits v0.5.8 h1:8MhHLmglPTPiXAdUgAJXx+gOxJoQzmpNeC7QzsZcjJw= shylinux.com/x/toolkits v0.5.8 h1:8MhHLmglPTPiXAdUgAJXx+gOxJoQzmpNeC7QzsZcjJw=
shylinux.com/x/toolkits v0.5.8/go.mod h1:8LbYHe7oxBIqb6s4MSOD+4d28QvPdvkyCVtwB/JW7AA= shylinux.com/x/toolkits v0.5.8/go.mod h1:8LbYHe7oxBIqb6s4MSOD+4d28QvPdvkyCVtwB/JW7AA=
shylinux.com/x/websocket v0.0.1 h1:OBc21DxqsGlQ2+Pz76xqLyDNo1LV+PUUqfWi+1PZPDE=
shylinux.com/x/websocket v0.0.1/go.mod h1:AaSpMToOxbMULKQytzczeHPuqb708vK1vrAzCxLo/XE= shylinux.com/x/websocket v0.0.1/go.mod h1:AaSpMToOxbMULKQytzczeHPuqb708vK1vrAzCxLo/XE=

View File

@ -217,6 +217,12 @@ func (m *Message) Process(action string, arg ...interface{}) {
func (m *Message) ProcessLocation(arg ...interface{}) { func (m *Message) ProcessLocation(arg ...interface{}) {
m.Process(PROCESS_LOCATION, arg...) m.Process(PROCESS_LOCATION, arg...)
} }
func (m *Message) ProcessReplace(arg ...interface{}) {
m.Process(PROCESS_REPLACE, arg...)
}
func (m *Message) ProcessHistory(arg ...interface{}) {
m.Process(PROCESS_HISTORY, arg...)
}
func (m *Message) ProcessRewrite(arg ...interface{}) { func (m *Message) ProcessRewrite(arg ...interface{}) {
m.Process(PROCESS_REWRITE, arg...) m.Process(PROCESS_REWRITE, arg...)
} }
@ -264,11 +270,14 @@ func (m *Message) ProcessBack() { m.Process(PROCESS_BACK) }
func (m *Message) OptionUserWeb() *url.URL { func (m *Message) OptionUserWeb() *url.URL {
return kit.ParseURL(m.Option(MSG_USERWEB)) return kit.ParseURL(m.Option(MSG_USERWEB))
} }
func (m *Message) MergeURL2(url string, arg ...interface{}) string {
return kit.MergeURL2(m.Option(MSG_USERWEB), url, arg...)
}
func (m *Message) MergeLink(url string, arg ...interface{}) string { func (m *Message) MergeLink(url string, arg ...interface{}) string {
return strings.Split(m.MergeURL2(url, arg...), "?")[0] return strings.Split(m.MergeURL2(url, arg...), "?")[0]
} }
func (m *Message) MergeURL2(url string, arg ...interface{}) string { func (m *Message) MergePodURL(url string, arg ...interface{}) string {
return kit.MergeURL2(m.Option(MSG_USERWEB), url, arg...) return kit.MergeURL(m.MergeLink(path.Join("/chat/pod/", m.Option(MSG_USERPOD), url)), arg...)
} }
func (m *Message) MergePod(pod string, arg ...interface{}) string { func (m *Message) MergePod(pod string, arg ...interface{}) string {
return kit.MergePOD(kit.Select(Info.Domain, m.Option(MSG_USERWEB)), pod, arg...) return kit.MergePOD(kit.Select(Info.Domain, m.Option(MSG_USERWEB)), pod, arg...)

View File

@ -87,13 +87,11 @@ func (m *Message) RenderCmd(index string, args ...interface{}) {
if index != "" { if index != "" {
msg := m.Cmd(COMMAND, index) msg := m.Cmd(COMMAND, index)
list = kit.Format(kit.List(kit.Dict( list = kit.Format(kit.List(kit.Dict(
INDEX, index, ARGS, kit.Simple(args), INDEX, index, ARGS, kit.Simple(args), msg.AppendSimple(NAME, HELP),
msg.AppendSimple(NAME, HELP), INPUTS, kit.UnMarshal(msg.Append(LIST)), FEATURE, kit.UnMarshal(msg.Append(META)),
FEATURE, kit.UnMarshal(msg.Append(META)),
INPUTS, kit.UnMarshal(msg.Append(LIST)),
))) )))
} }
m.RenderResult(kit.Format(`<!DOCTYPE html> m.Echo(kit.Format(`<!DOCTYPE html>
<head> <head>
<meta charset="utf-8"> <meta charset="utf-8">
<meta name="viewport" content="width=device-width,initial-scale=0.8,user-scalable=no"> <meta name="viewport" content="width=device-width,initial-scale=0.8,user-scalable=no">
@ -103,7 +101,7 @@ func (m *Message) RenderCmd(index string, args ...interface{}) {
<script src="/page/can.js"></script> <script src="/page/can.js"></script>
<script>can(%s)</script> <script>can(%s)</script>
</body> </body>
`, list)) `, list)).RenderResult()
} }
func (m *Message) IsCliUA() bool { func (m *Message) IsCliUA() bool {