forked from x/icebergs
opt sso
This commit is contained in:
parent
cee53d8626
commit
079342ba8c
@ -71,7 +71,7 @@ const SESS = "sess"
|
|||||||
func init() {
|
func init() {
|
||||||
Index.Merge(&ice.Context{Configs: map[string]*ice.Config{
|
Index.Merge(&ice.Context{Configs: map[string]*ice.Config{
|
||||||
SESS: {Name: SESS, Help: "会话", Value: kit.Data(
|
SESS: {Name: SESS, Help: "会话", Value: kit.Data(
|
||||||
mdb.SHORT, "uniq", mdb.FIELD, "time,hash,userrole,username,ip,ua", mdb.EXPIRE, "720h",
|
mdb.SHORT, "uniq", mdb.FIELD, "time,hash,userrole,username,usernick,ip,ua", mdb.EXPIRE, "720h",
|
||||||
)},
|
)},
|
||||||
}, Commands: map[string]*ice.Command{
|
}, Commands: map[string]*ice.Command{
|
||||||
SESS: {Name: "sess hash auto prunes", Help: "会话", Action: ice.MergeAction(map[string]*ice.Action{
|
SESS: {Name: "sess hash auto prunes", Help: "会话", Action: ice.MergeAction(map[string]*ice.Action{
|
||||||
|
@ -26,6 +26,9 @@ func _user_login(m *ice.Message, name, word string) (ok bool) {
|
|||||||
return ok
|
return ok
|
||||||
}
|
}
|
||||||
func _user_create(m *ice.Message, role, name, word string) {
|
func _user_create(m *ice.Message, role, name, word string) {
|
||||||
|
if name == "" {
|
||||||
|
return
|
||||||
|
}
|
||||||
if word == "" {
|
if word == "" {
|
||||||
word = kit.Hashs()
|
word = kit.Hashs()
|
||||||
}
|
}
|
||||||
@ -52,15 +55,19 @@ func UserRole(m *ice.Message, username interface{}) (role string) {
|
|||||||
if role = VOID; username == ice.Info.UserName {
|
if role = VOID; username == ice.Info.UserName {
|
||||||
return ROOT
|
return ROOT
|
||||||
}
|
}
|
||||||
m.Richs(USER, nil, kit.Format(username), func(key string, value map[string]interface{}) {
|
if m.Richs(USER, nil, kit.Format(username), func(key string, value map[string]interface{}) {
|
||||||
role = kit.Format(kit.GetMeta(value)[USERROLE])
|
role = kit.Format(kit.GetMeta(value)[USERROLE])
|
||||||
})
|
}) == nil && kit.Format(username) == m.Option(ice.MSG_USERNAME) {
|
||||||
|
return m.Option(ice.MSG_USERROLE)
|
||||||
|
}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
func UserNick(m *ice.Message, username interface{}) (nick string) {
|
func UserNick(m *ice.Message, username interface{}) (nick string) {
|
||||||
m.Richs(USER, nil, kit.Format(username), func(key string, value map[string]interface{}) {
|
if m.Richs(USER, nil, kit.Format(username), func(key string, value map[string]interface{}) {
|
||||||
nick = kit.Format(kit.GetMeta(value)[USERNICK])
|
nick = kit.Format(kit.GetMeta(value)[USERNICK])
|
||||||
})
|
}) == nil && kit.Format(username) == m.Option(ice.MSG_USERNAME) {
|
||||||
|
return m.Option(ice.MSG_USERNICK)
|
||||||
|
}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
func UserZone(m *ice.Message, username interface{}) (zone string) {
|
func UserZone(m *ice.Message, username interface{}) (zone string) {
|
||||||
|
@ -20,9 +20,7 @@ const EVENT = "event"
|
|||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
Index.Merge(&ice.Context{Configs: map[string]*ice.Config{
|
Index.Merge(&ice.Context{Configs: map[string]*ice.Config{
|
||||||
EVENT: {Name: EVENT, Help: "事件流", Value: kit.Data(
|
EVENT: {Name: EVENT, Help: "事件流", Value: kit.Data(mdb.SHORT, EVENT, mdb.FIELD, "time,id,cmd")},
|
||||||
mdb.SHORT, EVENT, mdb.FIELD, "time,id,cmd",
|
|
||||||
)},
|
|
||||||
}, Commands: map[string]*ice.Command{
|
}, Commands: map[string]*ice.Command{
|
||||||
EVENT: {Name: "event event id auto listen", Help: "事件流", Action: ice.MergeAction(map[string]*ice.Action{
|
EVENT: {Name: "event event id auto listen", Help: "事件流", Action: ice.MergeAction(map[string]*ice.Action{
|
||||||
LISTEN: {Name: "listen event cmd", Help: "监听", Hand: func(m *ice.Message, arg ...string) {
|
LISTEN: {Name: "listen event cmd", Help: "监听", Hand: func(m *ice.Message, arg ...string) {
|
||||||
|
@ -13,9 +13,7 @@ const ROUTINE = "routine"
|
|||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
Index.Merge(&ice.Context{Configs: map[string]*ice.Config{
|
Index.Merge(&ice.Context{Configs: map[string]*ice.Config{
|
||||||
ROUTINE: {Name: ROUTINE, Help: "协程池", Value: kit.Data(
|
ROUTINE: {Name: ROUTINE, Help: "协程池", Value: kit.Data(mdb.SHORT, "time,hash,status,fileline")},
|
||||||
mdb.SHORT, "time,hash,status,fileline",
|
|
||||||
)},
|
|
||||||
}, Commands: map[string]*ice.Command{
|
}, Commands: map[string]*ice.Command{
|
||||||
ROUTINE: {Name: "routine hash auto prunes", Help: "协程池", Action: ice.MergeAction(map[string]*ice.Action{
|
ROUTINE: {Name: "routine hash auto prunes", Help: "协程池", Action: ice.MergeAction(map[string]*ice.Action{
|
||||||
mdb.CREATE: {Name: "create fileline status", Help: "创建"},
|
mdb.CREATE: {Name: "create fileline status", Help: "创建"},
|
||||||
|
@ -47,21 +47,20 @@ const SIGNAL = "signal"
|
|||||||
func init() {
|
func init() {
|
||||||
Index.Merge(&ice.Context{Configs: map[string]*ice.Config{
|
Index.Merge(&ice.Context{Configs: map[string]*ice.Config{
|
||||||
SIGNAL: {Name: SIGNAL, Help: "信号器", Value: kit.Data(
|
SIGNAL: {Name: SIGNAL, Help: "信号器", Value: kit.Data(
|
||||||
mdb.SHORT, SIGNAL, mdb.FIELD, "time,signal,name,cmd",
|
mdb.SHORT, SIGNAL, mdb.FIELD, "time,signal,name,cmd", nfs.PATH, path.Join(ice.VAR_RUN, "ice.pid"),
|
||||||
nfs.PATH, path.Join(ice.VAR_RUN, "ice.pid"),
|
|
||||||
)},
|
)},
|
||||||
}, Commands: map[string]*ice.Command{
|
}, Commands: map[string]*ice.Command{
|
||||||
ice.CTX_INIT: {Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
|
|
||||||
if log.LogDisable {
|
|
||||||
return // 禁用日志
|
|
||||||
}
|
|
||||||
m.Cmd(nfs.SAVE, kit.Select(m.Conf(SIGNAL, kit.META_PATH), m.Conf(cli.RUNTIME, kit.Keys(cli.CONF, cli.CTX_PID))),
|
|
||||||
m.Conf(cli.RUNTIME, kit.Keys(cli.HOST, cli.PID)))
|
|
||||||
|
|
||||||
m.Cmd(SIGNAL, LISTEN, SIGNAL, "3", mdb.NAME, "退出", ice.CMD, "exit 0")
|
|
||||||
m.Cmd(SIGNAL, LISTEN, SIGNAL, "2", mdb.NAME, "重启", ice.CMD, "exit 1")
|
|
||||||
}},
|
|
||||||
SIGNAL: {Name: "signal signal auto listen", Help: "信号器", Action: ice.MergeAction(map[string]*ice.Action{
|
SIGNAL: {Name: "signal signal auto listen", Help: "信号器", Action: ice.MergeAction(map[string]*ice.Action{
|
||||||
|
ice.CTX_INIT: {Hand: func(m *ice.Message, arg ...string) {
|
||||||
|
if log.LogDisable {
|
||||||
|
return // 禁用日志
|
||||||
|
}
|
||||||
|
m.Cmd(nfs.SAVE, kit.Select(m.Config(nfs.PATH), m.Conf(cli.RUNTIME, kit.Keys(cli.CONF, cli.CTX_PID))),
|
||||||
|
m.Conf(cli.RUNTIME, kit.Keys(cli.HOST, cli.PID)))
|
||||||
|
|
||||||
|
m.Cmd(SIGNAL, LISTEN, SIGNAL, "3", mdb.NAME, "退出", ice.CMD, "exit 0")
|
||||||
|
m.Cmd(SIGNAL, LISTEN, SIGNAL, "2", mdb.NAME, "重启", ice.CMD, "exit 1")
|
||||||
|
}},
|
||||||
LISTEN: {Name: "listen signal name cmd", Help: "监听", Hand: func(m *ice.Message, arg ...string) {
|
LISTEN: {Name: "listen signal name cmd", Help: "监听", Hand: func(m *ice.Message, arg ...string) {
|
||||||
_signal_listen(m, kit.Int(m.Option(SIGNAL)), arg...)
|
_signal_listen(m, kit.Int(m.Option(SIGNAL)), arg...)
|
||||||
}},
|
}},
|
||||||
|
@ -388,10 +388,10 @@ func init() {
|
|||||||
Index.Merge(&ice.Context{Configs: map[string]*ice.Config{
|
Index.Merge(&ice.Context{Configs: map[string]*ice.Config{
|
||||||
MATRIX: {Name: MATRIX, Help: "魔方矩阵", Value: kit.Data()},
|
MATRIX: {Name: MATRIX, Help: "魔方矩阵", Value: kit.Data()},
|
||||||
}, Commands: map[string]*ice.Command{
|
}, Commands: map[string]*ice.Command{
|
||||||
ice.CTX_INIT: {Hand: func(m *ice.Message, c *ice.Context, key string, arg ...string) {
|
|
||||||
// _lex_load(m.Load())
|
|
||||||
}},
|
|
||||||
MATRIX: {Name: "matrix hash npage text auto", Help: "魔方矩阵", Action: map[string]*ice.Action{
|
MATRIX: {Name: "matrix hash npage text auto", Help: "魔方矩阵", Action: map[string]*ice.Action{
|
||||||
|
ice.CTX_INIT: {Hand: func(m *ice.Message, arg ...string) {
|
||||||
|
// _lex_load(m.Load())
|
||||||
|
}},
|
||||||
mdb.CREATE: {Name: "create nlang=32 ncell=128", Help: "创建", Hand: func(m *ice.Message, arg ...string) {
|
mdb.CREATE: {Name: "create nlang=32 ncell=128", Help: "创建", Hand: func(m *ice.Message, arg ...string) {
|
||||||
mat := NewMatrix(m, kit.Int(kit.Select("32", m.Option(NLANG))), kit.Int(kit.Select("128", m.Option(NCELL))))
|
mat := NewMatrix(m, kit.Int(kit.Select("32", m.Option(NLANG))), kit.Int(kit.Select("128", m.Option(NCELL))))
|
||||||
h := m.Rich(m.Prefix(MATRIX), "", kit.Data(mdb.TIME, m.Time(), MATRIX, mat, NLANG, mat.nlang, NCELL, mat.ncell))
|
h := m.Rich(m.Prefix(MATRIX), "", kit.Data(mdb.TIME, m.Time(), MATRIX, mat, NLANG, mat.nlang, NCELL, mat.ncell))
|
||||||
|
@ -286,6 +286,11 @@ func init() {
|
|||||||
case cli.PWD:
|
case cli.PWD:
|
||||||
link := kit.MergeURL(_space_domain(msg), aaa.GRANT, name)
|
link := kit.MergeURL(_space_domain(msg), aaa.GRANT, name)
|
||||||
msg.Sleep300ms(SPACE, name, cli.PWD, name, link, msg.Cmdx(cli.QRCODE, link))
|
msg.Sleep300ms(SPACE, name, cli.PWD, name, link, msg.Cmdx(cli.QRCODE, link))
|
||||||
|
case "sso":
|
||||||
|
link := _space_domain(msg)
|
||||||
|
ls := strings.Split(kit.ParseURL(link).Path, ice.PS)
|
||||||
|
link = kit.MergeURL2(_space_domain(msg), "/chat/sso", "space", kit.Select("", ls, 3), "back", m.Option(ice.MSG_USERWEB))
|
||||||
|
msg.Sleep300ms(SPACE, name, cli.PWD, name, link, msg.Cmdx(cli.QRCODE, link))
|
||||||
default:
|
default:
|
||||||
msg.Sleep300ms(SPACE, name, cli.PWD, name)
|
msg.Sleep300ms(SPACE, name, cli.PWD, name)
|
||||||
}
|
}
|
||||||
|
@ -347,10 +347,8 @@ func init() {
|
|||||||
Index.Merge(&ice.Context{Configs: map[string]*ice.Config{
|
Index.Merge(&ice.Context{Configs: map[string]*ice.Config{
|
||||||
MATRIX: {Name: MATRIX, Help: "魔方矩阵", Value: kit.Data(mdb.SHORT, mdb.NAME)},
|
MATRIX: {Name: MATRIX, Help: "魔方矩阵", Value: kit.Data(mdb.SHORT, mdb.NAME)},
|
||||||
}, Commands: map[string]*ice.Command{
|
}, Commands: map[string]*ice.Command{
|
||||||
ice.CTX_INIT: {Hand: func(m *ice.Message, c *ice.Context, key string, arg ...string) {
|
|
||||||
_yac_load(m)
|
|
||||||
}},
|
|
||||||
MATRIX: {Name: "matrix name npage text auto", Help: "魔方矩阵", Action: map[string]*ice.Action{
|
MATRIX: {Name: "matrix name npage text auto", Help: "魔方矩阵", Action: map[string]*ice.Action{
|
||||||
|
ice.CTX_INIT: {Hand: func(m *ice.Message, arg ...string) { _yac_load(m) }},
|
||||||
mdb.CREATE: {Name: "create name=shy nlang=32 ncell=32", Help: "创建", Hand: func(m *ice.Message, arg ...string) {
|
mdb.CREATE: {Name: "create name=shy nlang=32 ncell=32", Help: "创建", Hand: func(m *ice.Message, arg ...string) {
|
||||||
mat := NewMatrix(m, kit.Int(kit.Select("32", m.Option(NLANG))), kit.Int(kit.Select("32", m.Option(NCELL))))
|
mat := NewMatrix(m, kit.Int(kit.Select("32", m.Option(NLANG))), kit.Int(kit.Select("32", m.Option(NCELL))))
|
||||||
h := m.Rich(m.Prefix(MATRIX), "", kit.Data(
|
h := m.Rich(m.Prefix(MATRIX), "", kit.Data(
|
||||||
|
@ -81,7 +81,7 @@ func init() {
|
|||||||
Index.Merge(&ice.Context{Configs: map[string]*ice.Config{
|
Index.Merge(&ice.Context{Configs: map[string]*ice.Config{
|
||||||
HEADER: {Name: HEADER, Help: "标题栏", Value: kit.Data(
|
HEADER: {Name: HEADER, Help: "标题栏", Value: kit.Data(
|
||||||
TITLE, "shylinux.com/x/contexts", MENUS, kit.List("header", kit.List("setting", "black", "white", "print", "webpack", "devpack")),
|
TITLE, "shylinux.com/x/contexts", MENUS, kit.List("header", kit.List("setting", "black", "white", "print", "webpack", "devpack")),
|
||||||
aaa.LOGIN, kit.List("登录", "扫码"),
|
aaa.LOGIN, kit.List("登录", "扫码", "授权"),
|
||||||
)},
|
)},
|
||||||
}, 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) {
|
||||||
@ -143,8 +143,9 @@ func init() {
|
|||||||
m.Cmdy(code.WEBPACK, mdb.REMOVE)
|
m.Cmdy(code.WEBPACK, mdb.REMOVE)
|
||||||
}},
|
}},
|
||||||
}, Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
|
}, Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
|
||||||
|
m.Option(aaa.USERNICK, m.Option(ice.MSG_USERNICK))
|
||||||
msg := m.Cmd(aaa.USER, m.Option(ice.MSG_USERNAME))
|
msg := m.Cmd(aaa.USER, m.Option(ice.MSG_USERNAME))
|
||||||
for _, k := range []string{aaa.USERNICK, aaa.LANGUAGE, aaa.BACKGROUND, aaa.AVATAR} {
|
for _, k := range []string{aaa.LANGUAGE, aaa.BACKGROUND, aaa.AVATAR} {
|
||||||
m.Option(k, msg.Append(k))
|
m.Option(k, msg.Append(k))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -30,21 +30,16 @@ func init() {
|
|||||||
PPROF, kit.List(GO, "tool", PPROF),
|
PPROF, kit.List(GO, "tool", PPROF),
|
||||||
)},
|
)},
|
||||||
}, Commands: map[string]*ice.Command{
|
}, Commands: map[string]*ice.Command{
|
||||||
ice.CTX_INIT: {Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
|
|
||||||
web.AddRewrite(func(w http.ResponseWriter, r *http.Request) bool {
|
|
||||||
if p := r.URL.Path; strings.HasPrefix(p, "/debug") {
|
|
||||||
r.URL.Path = strings.Replace(r.URL.Path, "/debug", "/code", -1)
|
|
||||||
m.Debug("rewrite %v -> %v", p, r.URL.Path)
|
|
||||||
}
|
|
||||||
return false
|
|
||||||
})
|
|
||||||
}},
|
|
||||||
"/pprof/": {Name: "/pprof/", Help: "性能分析", Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
|
|
||||||
defer m.Render(ice.RENDER_VOID)
|
|
||||||
m.R.URL.Path = "/debug" + m.R.URL.Path
|
|
||||||
http.DefaultServeMux.ServeHTTP(m.W, m.R)
|
|
||||||
}},
|
|
||||||
PPROF: {Name: "pprof zone id auto", Help: "性能分析", Action: ice.MergeAction(map[string]*ice.Action{
|
PPROF: {Name: "pprof zone id auto", Help: "性能分析", Action: ice.MergeAction(map[string]*ice.Action{
|
||||||
|
ice.CTX_INIT: {Hand: func(m *ice.Message, arg ...string) {
|
||||||
|
web.AddRewrite(func(w http.ResponseWriter, r *http.Request) bool {
|
||||||
|
if p := r.URL.Path; strings.HasPrefix(p, "/debug") {
|
||||||
|
r.URL.Path = strings.Replace(r.URL.Path, "/debug", "/code", -1)
|
||||||
|
m.Debug("rewrite %v -> %v", p, r.URL.Path)
|
||||||
|
}
|
||||||
|
return false
|
||||||
|
})
|
||||||
|
}},
|
||||||
mdb.INPUTS: {Name: "inputs", Help: "补全", Hand: func(m *ice.Message, arg ...string) {
|
mdb.INPUTS: {Name: "inputs", Help: "补全", Hand: func(m *ice.Message, arg ...string) {
|
||||||
switch arg[0] {
|
switch arg[0] {
|
||||||
case BINNARY:
|
case BINNARY:
|
||||||
@ -89,5 +84,10 @@ func init() {
|
|||||||
m.PushButton(web.SERVE)
|
m.PushButton(web.SERVE)
|
||||||
})
|
})
|
||||||
}},
|
}},
|
||||||
|
"/pprof/": {Name: "/pprof/", Help: "性能分析", Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
|
||||||
|
defer m.Render(ice.RENDER_VOID)
|
||||||
|
m.R.URL.Path = "/debug" + m.R.URL.Path
|
||||||
|
http.DefaultServeMux.ServeHTTP(m.W, m.R)
|
||||||
|
}},
|
||||||
}})
|
}})
|
||||||
}
|
}
|
||||||
|
@ -12,13 +12,13 @@ const SHY = "shy"
|
|||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
Index.Register(&ice.Context{Name: SHY, Help: "脚本", Commands: map[string]*ice.Command{
|
Index.Register(&ice.Context{Name: SHY, Help: "脚本", Commands: map[string]*ice.Command{
|
||||||
ice.CTX_INIT: {Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
|
|
||||||
for _, cmd := range []string{mdb.PLUGIN, mdb.RENDER, mdb.ENGINE, mdb.SEARCH} {
|
|
||||||
m.Cmd(cmd, mdb.CREATE, SHY, m.Prefix(SHY))
|
|
||||||
}
|
|
||||||
LoadPlug(m, SHY)
|
|
||||||
}},
|
|
||||||
SHY: {Name: SHY, Help: "脚本", Action: ice.MergeAction(map[string]*ice.Action{
|
SHY: {Name: SHY, Help: "脚本", Action: ice.MergeAction(map[string]*ice.Action{
|
||||||
|
ice.CTX_INIT: {Hand: func(m *ice.Message, arg ...string) {
|
||||||
|
for _, cmd := range []string{mdb.PLUGIN, mdb.RENDER, mdb.ENGINE, mdb.SEARCH} {
|
||||||
|
m.Cmd(cmd, mdb.CREATE, SHY, m.Prefix(SHY))
|
||||||
|
}
|
||||||
|
LoadPlug(m, SHY)
|
||||||
|
}},
|
||||||
mdb.ENGINE: {Hand: func(m *ice.Message, arg ...string) {
|
mdb.ENGINE: {Hand: func(m *ice.Message, arg ...string) {
|
||||||
m.Cmdy("web.wiki.word", path.Join(arg[2], arg[1]))
|
m.Cmdy("web.wiki.word", path.Join(arg[2], arg[1]))
|
||||||
}},
|
}},
|
||||||
|
@ -23,10 +23,10 @@ const IMAGE = "image"
|
|||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
Index.Merge(&ice.Context{Commands: map[string]*ice.Command{
|
Index.Merge(&ice.Context{Commands: map[string]*ice.Command{
|
||||||
ice.CTX_INIT: {Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
|
|
||||||
m.Cmd(mdb.RENDER, mdb.CREATE, PNG, m.Prefix(IMAGE))
|
|
||||||
}},
|
|
||||||
IMAGE: {Name: "image url", Help: "图片", Action: map[string]*ice.Action{
|
IMAGE: {Name: "image url", Help: "图片", Action: map[string]*ice.Action{
|
||||||
|
ice.CTX_INIT: {Hand: func(m *ice.Message, arg ...string) {
|
||||||
|
m.Cmd(mdb.RENDER, mdb.CREATE, PNG, m.PrefixKey())
|
||||||
|
}},
|
||||||
mdb.RENDER: {Name: "render", Help: "渲染", Hand: func(m *ice.Message, arg ...string) {
|
mdb.RENDER: {Name: "render", Help: "渲染", Hand: func(m *ice.Message, arg ...string) {
|
||||||
_image_show(m, path.Join(arg[2], arg[1]))
|
_image_show(m, path.Join(arg[2], arg[1]))
|
||||||
}},
|
}},
|
||||||
|
@ -45,34 +45,35 @@ const SPARK = "spark"
|
|||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
Index.Merge(&ice.Context{Commands: map[string]*ice.Command{
|
Index.Merge(&ice.Context{Commands: map[string]*ice.Command{
|
||||||
ice.CTX_INIT: {Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
|
SPARK: {Name: "spark [name] text auto field:text value:text", Help: "段落", Action: map[string]*ice.Action{
|
||||||
ice.AddRender(ice.RENDER_SCRIPT, func(m *ice.Message, cmd string, args ...interface{}) string {
|
ice.CTX_INIT: {Hand: func(m *ice.Message, arg ...string) {
|
||||||
arg := kit.Simple(args...)
|
ice.AddRender(ice.RENDER_SCRIPT, func(m *ice.Message, cmd string, args ...interface{}) string {
|
||||||
if m.IsCliUA() {
|
arg := kit.Simple(args...)
|
||||||
if len(arg) > 1 {
|
if m.IsCliUA() {
|
||||||
arg = arg[1:]
|
if len(arg) > 1 {
|
||||||
|
arg = arg[1:]
|
||||||
|
}
|
||||||
|
return strings.Join(arg, ice.NL)
|
||||||
}
|
}
|
||||||
return strings.Join(arg, ice.NL)
|
if len(arg) == 1 && arg[0] != BREAK {
|
||||||
}
|
arg = []string{SHELL, arg[0]}
|
||||||
if len(arg) == 1 && arg[0] != BREAK {
|
}
|
||||||
arg = []string{SHELL, arg[0]}
|
list := []string{kit.Format(`<div class="story" data-type="spark" data-name="%s">`, arg[0])}
|
||||||
}
|
for _, l := range strings.Split(strings.Join(arg[1:], ice.NL), ice.NL) {
|
||||||
list := []string{kit.Format(`<div class="story" data-type="spark" data-name="%s">`, arg[0])}
|
switch list = append(list, "<div>"); arg[0] {
|
||||||
for _, l := range strings.Split(strings.Join(arg[1:], ice.NL), ice.NL) {
|
case SHELL:
|
||||||
switch list = append(list, "<div>"); arg[0] {
|
list = append(list, "<label>", "$ ", "</label>")
|
||||||
case SHELL:
|
default:
|
||||||
list = append(list, "<label>", "$ ", "</label>")
|
list = append(list, "<label>", "> ", "</label>")
|
||||||
default:
|
}
|
||||||
list = append(list, "<label>", "> ", "</label>")
|
list = append(list, "<span>", l, "</span>")
|
||||||
|
list = append(list, "</div>")
|
||||||
}
|
}
|
||||||
list = append(list, "<span>", l, "</span>")
|
|
||||||
list = append(list, "</div>")
|
list = append(list, "</div>")
|
||||||
}
|
return strings.Join(list, "")
|
||||||
list = append(list, "</div>")
|
})
|
||||||
return strings.Join(list, "")
|
}},
|
||||||
})
|
}, Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
|
||||||
}},
|
|
||||||
SPARK: {Name: "spark [name] text auto field:text value:text", Help: "段落", Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
|
|
||||||
if len(arg) == 0 {
|
if len(arg) == 0 {
|
||||||
m.Echo(`<br class="story" data-type="spark">`)
|
m.Echo(`<br class="story" data-type="spark">`)
|
||||||
return
|
return
|
||||||
|
Loading…
x
Reference in New Issue
Block a user