forked from x/icebergs
opt chat
This commit is contained in:
parent
975791294c
commit
20b60b11bf
@ -137,3 +137,12 @@ func init() {
|
||||
func RoleRight(m *ice.Message, userrole string, arg ...string) bool {
|
||||
return m.Cmdx(ROLE, RIGHT, userrole, arg) == ice.OK
|
||||
}
|
||||
func RoleAction(cmds ...string) ice.Actions {
|
||||
return ice.Actions{ice.CTX_INIT: {Hand: func(m *ice.Message, arg ...string) {
|
||||
m.Cmd(ROLE, WHITE, VOID, m.CommandKey())
|
||||
m.Cmd(ROLE, WHITE, VOID, m.PrefixKey())
|
||||
for _, cmd := range cmds {
|
||||
m.Cmd(ROLE, WHITE, VOID, cmd)
|
||||
}
|
||||
}}}
|
||||
}
|
||||
|
@ -85,6 +85,7 @@ func init() {
|
||||
func UserRoot(m *ice.Message, arg ...string) *ice.Message { // password username userrole
|
||||
username := m.Option(ice.MSG_USERNAME, kit.Select(ice.Info.UserName, arg, 1))
|
||||
userrole := m.Option(ice.MSG_USERROLE, kit.Select(ROOT, arg, 2))
|
||||
m.Option(ice.MSG_USERNICK, UserNick(m, username))
|
||||
if len(arg) > 0 {
|
||||
m.Cmd(USER, mdb.CREATE, username, kit.Select("", arg, 0), userrole)
|
||||
ice.Info.UserName = username
|
||||
|
@ -87,10 +87,8 @@ const COMMAND = "command"
|
||||
|
||||
func init() {
|
||||
Index.MergeCommands(ice.Commands{
|
||||
COMMAND: {Name: "command key auto", Help: "命令", Actions: ice.Actions{
|
||||
COMMAND: {Name: "command key auto", Help: "命令", Actions: ice.MergeActions(ice.Actions{
|
||||
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)
|
||||
TravelCmd(m, func(key, file, line string) {
|
||||
if strings.Contains(file, "icebergs") {
|
||||
AddFileCmd(file, key)
|
||||
@ -114,7 +112,7 @@ func init() {
|
||||
})
|
||||
m.Cmd("nfs.save", "tags", m.Result())
|
||||
}},
|
||||
}, Hand: func(m *ice.Message, arg ...string) {
|
||||
}, aaa.RoleAction()), Hand: func(m *ice.Message, arg ...string) {
|
||||
if len(arg) == 0 {
|
||||
arg = append(arg, "")
|
||||
}
|
||||
|
@ -53,6 +53,8 @@ func _split_list(m *ice.Message, file string, arg ...string) ice.Map {
|
||||
// 回调函数
|
||||
ls := kit.Split(text, m.Option(SPLIT_SPACE), m.Option(SPLIT_BLOCK), m.Option(SPLIT_QUOTE), m.Option(SPLIT_TRANS))
|
||||
switch cb := m.OptionCB(SPLIT).(type) {
|
||||
case func(int, []string):
|
||||
cb(deep, ls)
|
||||
case func(int, []string) []string:
|
||||
ls = cb(deep, ls)
|
||||
case func(int, []string, ice.Map, ice.List):
|
||||
|
@ -130,7 +130,7 @@ const LIST = "list"
|
||||
|
||||
func ListAction(args ...ice.Any) ice.Actions {
|
||||
return ice.Actions{ice.CTX_INIT: AutoConfig(args...),
|
||||
INPUTS: {Name: "inputs", Help: "补全", Hand: func(m *ice.Message, arg ...string) {
|
||||
INPUTS: {Hand: func(m *ice.Message, arg ...string) {
|
||||
m.Cmdy(INPUTS, m.PrefixKey(), "", LIST, ListArgs(m, arg))
|
||||
}},
|
||||
INSERT: {Name: "insert", Help: "添加", Hand: func(m *ice.Message, arg ...string) {
|
||||
|
@ -44,7 +44,7 @@ func init() {
|
||||
m.Cmd(TAIL, mdb.CREATE, kit.SimpleKV("file,name", value))
|
||||
})
|
||||
}},
|
||||
mdb.INPUTS: {Name: "inputs", Help: "补全", Hand: func(m *ice.Message, arg ...string) {
|
||||
mdb.INPUTS: {Hand: func(m *ice.Message, arg ...string) {
|
||||
switch arg[0] {
|
||||
case FILE:
|
||||
m.Cmdy(DIR, kit.Select(PWD, arg, 1), PATH).RenameAppend(PATH, FILE)
|
||||
|
@ -118,7 +118,7 @@ const DREAM = "dream"
|
||||
func init() {
|
||||
Index.MergeCommands(ice.Commands{
|
||||
DREAM: {Name: "dream name path auto create", Help: "梦想家", Actions: ice.MergeActions(ice.Actions{
|
||||
mdb.INPUTS: {Name: "inputs", Help: "补全", Hand: func(m *ice.Message, arg ...string) {
|
||||
mdb.INPUTS: {Hand: func(m *ice.Message, arg ...string) {
|
||||
switch arg[0] {
|
||||
case nfs.REPOS:
|
||||
m.Cmd("web.code.git.server", func(value ice.Maps) {
|
||||
|
@ -126,7 +126,7 @@ type Message interface {
|
||||
|
||||
func OptionAgentIs(m Message, arg ...string) bool {
|
||||
for _, k := range arg {
|
||||
if strings.HasPrefix(m.Option(ice.MSG_USERUA), k) {
|
||||
if strings.HasPrefix(strings.ToLower(m.Option(ice.MSG_USERUA)), k) {
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
@ -148,7 +148,7 @@ func init() {
|
||||
m.EchoQRCode(msg.Option(mdb.LINK))
|
||||
m.ProcessInner()
|
||||
}},
|
||||
}, mdb.HashAction(mdb.FIELD, "time,hash,userrole,username,river,storm,type,name,text", mdb.EXPIRE, "72h")), Hand: func(m *ice.Message, arg ...string) {
|
||||
}, mdb.HashAction(mdb.FIELD, "time,hash,userrole,username,usernick,river,storm,type,name,text", mdb.EXPIRE, "72h")), Hand: func(m *ice.Message, arg ...string) {
|
||||
if ctx.PodCmd(m, SHARE, arg) && m.Length() > 0 {
|
||||
return
|
||||
}
|
||||
|
@ -81,7 +81,6 @@ func init() {
|
||||
Index.MergeCommands(ice.Commands{
|
||||
web.P(ACTION): {Name: "/action river storm action arg...", Help: "工作台", Actions: ice.MergeActions(ice.Actions{
|
||||
ice.CTX_INIT: {Hand: func(m *ice.Message, arg ...string) {
|
||||
m.Cmd(aaa.ROLE, aaa.WHITE, aaa.VOID, m.CommandKey())
|
||||
m.Cmd(aaa.ROLE, aaa.BLACK, aaa.VOID, m.CommandKey(), ctx.ACTION)
|
||||
}},
|
||||
mdb.MODIFY: {Hand: func(m *ice.Message, arg ...string) {
|
||||
@ -90,7 +89,7 @@ func init() {
|
||||
web.SHARE: {Hand: func(m *ice.Message, arg ...string) {
|
||||
_action_share(m, arg...)
|
||||
}},
|
||||
}, ctx.CmdAction(nfs.PATH, ice.USR_LOCAL_RIVER)), Hand: func(m *ice.Message, arg ...string) {
|
||||
}, ctx.CmdAction(nfs.PATH, ice.USR_LOCAL_RIVER), aaa.RoleAction()), Hand: func(m *ice.Message, arg ...string) {
|
||||
if m.Warn(m.Option(ice.MSG_USERNAME) == "", ice.ErrNotLogin, arg) {
|
||||
return
|
||||
}
|
||||
|
@ -4,19 +4,18 @@ header.go
|
||||
action.go
|
||||
search.go
|
||||
footer.go
|
||||
|
||||
river.go
|
||||
storm.go
|
||||
template.go
|
||||
iframe.go
|
||||
|
||||
sso.go
|
||||
pod.go
|
||||
cmd.go
|
||||
div.go
|
||||
website.go
|
||||
topic.go
|
||||
grant.go
|
||||
sso.go
|
||||
oauth
|
||||
|
||||
room.go
|
||||
meet.go
|
||||
@ -25,8 +24,7 @@ paste.go
|
||||
media.go
|
||||
files.go
|
||||
trans.go
|
||||
|
||||
iframe.go
|
||||
keyboard.go
|
||||
location.go
|
||||
location.shy
|
||||
oauth
|
||||
|
@ -15,22 +15,17 @@ import (
|
||||
|
||||
func _cmd_file(m *ice.Message, arg ...string) bool {
|
||||
switch p := path.Join(arg...); kit.Ext(p) {
|
||||
case nfs.ZML:
|
||||
web.RenderCmd(m, CAN_PARSE, m.Cmdx(nfs.CAT, p))
|
||||
case nfs.IML:
|
||||
m.RenderRedirect(web.MergePodWebSite(m, "", strings.TrimPrefix(p, SRC_WEBSITE)))
|
||||
case nfs.SHY:
|
||||
web.RenderCmd(m, "web.wiki.word", p)
|
||||
case nfs.GO:
|
||||
web.RenderCmd(m, ctx.GetFileCmd(p))
|
||||
case nfs.JS:
|
||||
m.Display(ctx.FileURI(p))
|
||||
web.RenderCmd(m, kit.Select(ctx.CAN_PLUGIN, ctx.GetFileCmd(p)))
|
||||
|
||||
case nfs.GO:
|
||||
web.RenderCmd(m, ctx.GetFileCmd(p))
|
||||
|
||||
case nfs.SHY:
|
||||
web.RenderCmd(m, "web.wiki.word", p)
|
||||
|
||||
case nfs.IML:
|
||||
m.RenderRedirect(web.MergePodWebSite(m, "", strings.TrimPrefix(p, SRC_WEBSITE)))
|
||||
|
||||
case nfs.ZML:
|
||||
web.RenderCmd(m, "can.parse", m.Cmdx(nfs.CAT, p))
|
||||
|
||||
default:
|
||||
if p = strings.TrimPrefix(p, ice.SRC+ice.PS); nfs.ExistsFile(m, path.Join(ice.SRC, p)) {
|
||||
if msg := m.Cmd(mdb.RENDER, kit.Ext(p)); msg.Length() > 0 {
|
||||
@ -47,17 +42,9 @@ const CMD = "cmd"
|
||||
|
||||
func init() {
|
||||
Index.MergeCommands(ice.Commands{
|
||||
CMD: {Name: "cmd path auto upload up home", Help: "命令", Actions: ice.MergeActions(ice.Actions{
|
||||
ice.CTX_INIT: {Hand: func(m *ice.Message, arg ...string) {
|
||||
m.Cmd(aaa.ROLE, aaa.WHITE, aaa.VOID, CMD)
|
||||
m.Cmdy(CMD, mdb.CREATE, mdb.TYPE, nfs.SVG, mdb.NAME, "web.wiki.draw")
|
||||
m.Cmdy(CMD, mdb.CREATE, mdb.TYPE, nfs.CSV, mdb.NAME, "web.wiki.data")
|
||||
m.Cmdy(CMD, mdb.CREATE, mdb.TYPE, nfs.JSON, mdb.NAME, "web.wiki.json")
|
||||
for _, k := range []string{"mod", "sum"} {
|
||||
m.Cmdy(CMD, mdb.CREATE, mdb.TYPE, k, mdb.NAME, "web.code.inner")
|
||||
}
|
||||
}},
|
||||
}, mdb.HashAction(mdb.SHORT, mdb.TYPE, nfs.PATH, nfs.PWD), ctx.CmdAction(), web.ApiAction()), Hand: func(m *ice.Message, arg ...string) {
|
||||
CMD: {Name: "cmd path auto upload up home", Help: "命令", Actions: ice.MergeActions(
|
||||
mdb.HashAction(mdb.SHORT, mdb.TYPE, nfs.PATH, nfs.PWD), ctx.CmdAction(), web.ApiAction(), aaa.RoleAction(),
|
||||
), Hand: func(m *ice.Message, arg ...string) {
|
||||
if _cmd_file(m, arg...) {
|
||||
return
|
||||
}
|
||||
|
@ -25,13 +25,8 @@ func _div_parse(m *ice.Message, text string) string {
|
||||
const DIV = "div"
|
||||
|
||||
func init() {
|
||||
Index.Merge(&ice.Context{Configs: ice.Configs{
|
||||
DIV: {Name: "div", Help: "定制", Value: kit.Data(
|
||||
mdb.FIELD, "time,hash,type,name,text", nfs.PATH, ice.USR_PUBLISH,
|
||||
nfs.TEMPLATE, _div_template,
|
||||
)},
|
||||
}, Commands: ice.Commands{
|
||||
"/div/": {Name: "/div/", Help: "定制", Actions: ice.MergeActions(ctx.CmdAction()), Hand: func(m *ice.Message, arg ...string) {
|
||||
Index.MergeCommands(ice.Commands{
|
||||
web.PP(DIV): {Name: "/div/", Help: "定制", Actions: ice.MergeActions(ctx.CmdAction()), Hand: func(m *ice.Message, arg ...string) {
|
||||
switch p := path.Join(arg...); kit.Ext(kit.Select("", p)) {
|
||||
case nfs.HTML:
|
||||
m.RenderDownload(p)
|
||||
@ -46,10 +41,7 @@ func init() {
|
||||
}
|
||||
}},
|
||||
DIV: {Name: "div hash auto import", Help: "定制", Actions: ice.MergeActions(ice.Actions{
|
||||
lex.SPLIT: {Name: "split name=hi text", Help: "生成", Hand: func(m *ice.Message, arg ...string) {
|
||||
m.ProcessRewrite(mdb.HASH, m.Cmdx(DIV, mdb.CREATE, m.OptionSimple(mdb.NAME), mdb.TEXT, _div_parse(m, m.Option(mdb.TEXT))))
|
||||
}},
|
||||
mdb.INPUTS: {Name: "inputs", Help: "补全", Hand: func(m *ice.Message, arg ...string) {
|
||||
mdb.INPUTS: {Hand: func(m *ice.Message, arg ...string) {
|
||||
switch arg[0] {
|
||||
case nfs.PATH:
|
||||
m.Cmdy(nfs.DIR, arg[1:]).ProcessAgain()
|
||||
@ -62,16 +54,11 @@ func init() {
|
||||
m.Push(arg[0], "output")
|
||||
}
|
||||
}},
|
||||
mdb.CREATE: {Name: "create type=page name=hi text", Help: "创建"},
|
||||
mdb.IMPORT: {Name: "import path=src/", Help: "导入", Hand: func(m *ice.Message, arg ...string) {
|
||||
m.Cmd(nfs.DIR, kit.Dict(nfs.DIR_ROOT, m.Option(nfs.PATH)), func(p string) {
|
||||
switch kit.Ext(p) {
|
||||
case nfs.SHY:
|
||||
m.Cmd(m.PrefixKey(), lex.SPLIT, mdb.NAME, p, mdb.TEXT, m.Cmdx(nfs.CAT, p))
|
||||
}
|
||||
})
|
||||
mdb.CREATE: {Name: "create type=page name=hi text"},
|
||||
lex.SPLIT: {Name: "split name=hi text", Help: "生成", Hand: func(m *ice.Message, arg ...string) {
|
||||
m.ProcessRewrite(mdb.HASH, m.Cmdx(DIV, mdb.CREATE, m.OptionSimple(mdb.NAME), mdb.TEXT, _div_parse(m, m.Option(mdb.TEXT))))
|
||||
}},
|
||||
}, mdb.HashAction(), ctx.CmdAction()), Hand: func(m *ice.Message, arg ...string) {
|
||||
}, mdb.HashAction(mdb.FIELD, "time,hash,type,name,text", nfs.PATH, ice.USR_PUBLISH, nfs.TEMPLATE, _div_template), ctx.CmdAction()), Hand: func(m *ice.Message, arg ...string) {
|
||||
switch kit.Ext(kit.Select("", arg, 0)) {
|
||||
case nfs.SHY:
|
||||
m.Fields(0)
|
||||
@ -79,25 +66,25 @@ func init() {
|
||||
ctx.DisplayLocal(m, "")
|
||||
default:
|
||||
if mdb.HashSelect(m, arg...); len(arg) > 0 {
|
||||
m.Action("添加", "保存")
|
||||
m.StatusTime(mdb.LINK, web.MergeURL2(m, "/chat/div/"+arg[0])).Action("添加", "保存")
|
||||
ctx.DisplayLocal(m, "")
|
||||
m.StatusTime(mdb.LINK, web.MergeURL2(m, "/chat/div/"+arg[0]))
|
||||
} else {
|
||||
m.Action(lex.SPLIT, mdb.CREATE)
|
||||
}
|
||||
}
|
||||
}},
|
||||
}})
|
||||
})
|
||||
}
|
||||
|
||||
var _div_template = `<!DOCTYPE html>
|
||||
<head>
|
||||
<meta name="viewport" content="width=device-width,initial-scale=0.8,maximum-scale=0.8,user-scalable=no"/>
|
||||
<meta charset="utf-8">
|
||||
<title>volcanos</title>
|
||||
<link rel="shortcut icon" type="image/ico" href="/favicon.ico">
|
||||
<link rel="stylesheet" type="text/css" href="/page/cache.css">
|
||||
<link rel="stylesheet" type="text/css" href="/page/index.css">
|
||||
<style type="text/css">%s</style>
|
||||
<style type="text/css">%s</style>
|
||||
</head>
|
||||
<body>
|
||||
<script src="/proto.js"></script>
|
||||
@ -105,9 +92,9 @@ var _div_template = `<!DOCTYPE html>
|
||||
<script>%s</script>
|
||||
</body>
|
||||
`
|
||||
|
||||
var _div_template2 = `<!DOCTYPE html>
|
||||
<head>
|
||||
<meta name="viewport" content="width=device-width,initial-scale=0.8,maximum-scale=0.8,user-scalable=no"/>
|
||||
<meta charset="utf-8">
|
||||
<title>volcanos</title>
|
||||
<link rel="shortcut icon" type="image/ico" href="/favicon.ico">
|
||||
@ -117,6 +104,6 @@ var _div_template2 = `<!DOCTYPE html>
|
||||
<body>
|
||||
<script src="/proto.js"></script>
|
||||
<script src="/page/cache.js"></script>
|
||||
<script>Volcanos({name: "chat", river: JSON.parse('%s')})</script>
|
||||
<script>Volcanos({river: JSON.parse('%s')})</script>
|
||||
</body>
|
||||
`
|
||||
|
@ -8,17 +8,12 @@ import (
|
||||
"shylinux.com/x/icebergs/base/web"
|
||||
)
|
||||
|
||||
const (
|
||||
EMAIL = "email"
|
||||
)
|
||||
const FOOTER = "footer"
|
||||
|
||||
func init() {
|
||||
const EMAIL = "email"
|
||||
Index.MergeCommands(ice.Commands{
|
||||
web.P(FOOTER): {Name: "footer", Help: "状态栏", Actions: ice.MergeActions(ice.Actions{
|
||||
ice.CTX_INIT: {Hand: func(m *ice.Message, arg ...string) {
|
||||
m.Cmd(aaa.ROLE, aaa.WHITE, aaa.VOID, m.CommandKey())
|
||||
}},
|
||||
web.P(FOOTER): {Name: "/footer", Help: "状态栏", Actions: ice.MergeActions(ice.Actions{
|
||||
ice.RUN: {Hand: func(m *ice.Message, arg ...string) {
|
||||
if aaa.Right(m, arg) {
|
||||
if m.Cmdy(arg); m.IsErrNotFound() {
|
||||
@ -26,7 +21,7 @@ func init() {
|
||||
}
|
||||
}
|
||||
}},
|
||||
}, ctx.CmdAction(EMAIL, `<a href="mailto:shylinuxc@gmail.com">shylinuxc@gmail.com</a>`)), Hand: func(m *ice.Message, arg ...string) {
|
||||
}, ctx.CmdAction(EMAIL, `shylinuxc@gmail.com`), aaa.RoleAction()), Hand: func(m *ice.Message, arg ...string) {
|
||||
m.Result(m.Configv(EMAIL))
|
||||
}},
|
||||
})
|
||||
|
@ -12,7 +12,7 @@ const GRANT = "grant"
|
||||
func init() {
|
||||
Index.MergeCommands(ice.Commands{
|
||||
GRANT: {Name: "grant space id auto insert", Help: "授权", Actions: ice.MergeActions(ice.Actions{
|
||||
mdb.INPUTS: {Name: "inputs", Help: "补全", Hand: func(m *ice.Message, arg ...string) {
|
||||
mdb.INPUTS: {Hand: func(m *ice.Message, arg ...string) {
|
||||
switch arg[0] {
|
||||
case web.SPACE:
|
||||
m.Cmdy(web.SPACE).RenameAppend(mdb.NAME, web.SPACE).Cut("space,type")
|
||||
@ -24,7 +24,7 @@ func init() {
|
||||
m.Push(arg[0], m.Option(ice.MSG_USERNAME))
|
||||
}
|
||||
}},
|
||||
mdb.INSERT: {Name: "insert space grant userrole username", Help: "添加"},
|
||||
mdb.INSERT: {Name: "insert space grant userrole username"},
|
||||
}, mdb.ZoneAction(mdb.SHORT, web.SPACE, mdb.FIELD, "time,grant,userrole,username"))},
|
||||
})
|
||||
}
|
||||
|
@ -80,9 +80,6 @@ func init() {
|
||||
m.Warn(m.Option(ice.MSG_USERNAME) == "", ice.ErrNotLogin, arg)
|
||||
}},
|
||||
web.P(HEADER): {Name: "/header", Help: "标题栏", Actions: ice.MergeActions(ice.Actions{
|
||||
ice.CTX_INIT: {Hand: func(m *ice.Message, arg ...string) {
|
||||
m.Cmd(aaa.ROLE, aaa.WHITE, aaa.VOID, m.CommandKey())
|
||||
}},
|
||||
aaa.LOGIN: {Hand: func(m *ice.Message, arg ...string) {
|
||||
if aaa.UserLogin(m, arg[0], arg[1]) {
|
||||
web.RenderCookie(m, aaa.SessCreate(m, arg[0]))
|
||||
@ -95,7 +92,8 @@ func init() {
|
||||
aaa.BACKGROUND: {Hand: func(m *ice.Message, arg ...string) { _header_users(m, arg...) }},
|
||||
aaa.AVATAR: {Hand: func(m *ice.Message, arg ...string) { _header_users(m, arg...) }},
|
||||
web.SHARE: {Hand: func(m *ice.Message, arg ...string) { _header_share(m, arg...) }},
|
||||
}, ctx.ConfAction(aaa.LOGIN, kit.List("密码登录", "扫码授权"))), Hand: func(m *ice.Message, arg ...string) {
|
||||
"webpack": {Hand: func(m *ice.Message, arg ...string) { m.Cmdy("webpack", "build") }},
|
||||
}, ctx.ConfAction(aaa.LOGIN, kit.List("密码登录", "扫码授权")), aaa.RoleAction()), Hand: func(m *ice.Message, arg ...string) {
|
||||
if gdb.Event(m, HEADER_AGENT); !_header_check(m, arg...) {
|
||||
return
|
||||
}
|
||||
|
@ -16,7 +16,7 @@ func init() {
|
||||
"_refresh": {Name: "refresh", Help: "刷新", Hand: func(m *ice.Message, arg ...string) {
|
||||
m.Cmd(web.SPACE, m.Option(web.SPACE), "refresh")
|
||||
}},
|
||||
"inputs": {Name: "inputs", Help: "补全", Hand: func(m *ice.Message, arg ...string) {}},
|
||||
mdb.INPUTS: {Hand: func(m *ice.Message, arg ...string) {}},
|
||||
"input": {Name: "input", Help: "刷新", Hand: func(m *ice.Message, arg ...string) {
|
||||
m.Cmd(web.SPACE, m.Option(web.SPACE), "input", arg)
|
||||
ctx.ProcessHold(m)
|
||||
|
@ -17,33 +17,25 @@ const POD = "pod"
|
||||
|
||||
func init() {
|
||||
Index.MergeCommands(ice.Commands{
|
||||
POD: {Name: "pod", Help: "节点", Actions: ice.MergeActions(ice.Actions{
|
||||
ice.CTX_INIT: {Hand: func(m *ice.Message, arg ...string) { m.Cmd(aaa.ROLE, aaa.WHITE, aaa.VOID, POD) }},
|
||||
}, ctx.CmdAction(), web.ApiAction()), Hand: func(m *ice.Message, arg ...string) {
|
||||
if web.OptionAgentIs(m, "curl", "Wget") {
|
||||
aaa.UserRoot(m)
|
||||
m.Option(ice.POD, kit.Select("", arg, 0))
|
||||
m.Cmdy(web.SHARE_LOCAL, ice.BIN_ICE_BIN)
|
||||
return // 下载程序
|
||||
web.PP(POD): {Name: "/pod/", Help: "节点", Actions: ice.MergeActions(ctx.CmdAction(), aaa.RoleAction()), Hand: func(m *ice.Message, arg ...string) {
|
||||
if web.OptionAgentIs(m, "curl", "wget") {
|
||||
aaa.UserRoot(m).Cmdy(web.SHARE_LOCAL, ice.BIN_ICE_BIN, kit.Dict(ice.POD, kit.Select("", arg, 0)))
|
||||
return
|
||||
}
|
||||
|
||||
if len(arg) == 0 || kit.Select("", arg, 0) == "" {
|
||||
web.RenderCmd(m, web.ROUTE) // 节点列表
|
||||
|
||||
web.RenderCmd(m, web.ROUTE)
|
||||
} else if len(arg) == 1 {
|
||||
if m.Cmd(web.SPACE, arg[0]).Length() == 0 && !strings.Contains(arg[0], ice.PT) {
|
||||
m.Cmd(web.DREAM, cli.START, mdb.NAME, arg[0]) // 启动节点
|
||||
m.Cmd(web.DREAM, cli.START, mdb.NAME, arg[0])
|
||||
}
|
||||
aaa.UserRoot(m)
|
||||
if web.RenderWebsite(m, arg[0], ice.INDEX_IML, "Header", "", "River", "", "Footer", ""); m.Result() == "" {
|
||||
web.RenderIndex(m, ice.VOLCANOS) // 节点首页
|
||||
web.RenderIndex(m, ice.VOLCANOS)
|
||||
}
|
||||
|
||||
} else if arg[1] == CMD {
|
||||
m.Cmdy(web.SPACE, arg[0], m.Prefix(CMD), path.Join(arg[2:]...)) // 节点命令
|
||||
|
||||
m.Cmdy(web.SPACE, arg[0], m.Prefix(CMD), path.Join(arg[2:]...))
|
||||
} else if arg[1] == WEBSITE {
|
||||
web.RenderWebsite(m, arg[0], path.Join(arg[2:]...)) // 节点网页
|
||||
web.RenderWebsite(m, arg[0], path.Join(arg[2:]...))
|
||||
}
|
||||
}},
|
||||
})
|
||||
|
@ -41,7 +41,6 @@ func init() {
|
||||
Index.MergeCommands(ice.Commands{
|
||||
web.P(RIVER): {Name: "/river hash auto create", Help: "群组", Actions: ice.MergeActions(ice.Actions{
|
||||
ice.CTX_INIT: {Hand: func(m *ice.Message, arg ...string) {
|
||||
m.Cmd(aaa.ROLE, aaa.WHITE, aaa.VOID, m.CommandKey())
|
||||
m.Cmd(aaa.ROLE, aaa.BLACK, aaa.VOID, m.CommandKey(), ctx.ACTION)
|
||||
}},
|
||||
mdb.INPUTS: {Hand: func(m *ice.Message, arg ...string) {
|
||||
@ -65,7 +64,7 @@ func init() {
|
||||
m.Cmd(mdb.EXPORT, m.Prefix(RIVER), "", mdb.HASH)
|
||||
m.Cmd(mdb.IMPORT, m.Prefix(RIVER), "", mdb.HASH)
|
||||
}},
|
||||
}, mdb.HashAction(mdb.FIELD, "time,hash,type,name,text,template")), Hand: func(m *ice.Message, arg ...string) {
|
||||
}, mdb.HashAction(mdb.FIELD, "time,hash,type,name,text,template"), aaa.RoleAction()), Hand: func(m *ice.Message, arg ...string) {
|
||||
if m.Warn(m.Option(ice.MSG_USERNAME) == "", ice.ErrNotLogin) {
|
||||
m.RenderStatusUnauthorized()
|
||||
return
|
||||
|
@ -13,9 +13,7 @@ const SSO = "sso"
|
||||
|
||||
func init() {
|
||||
Index.MergeCommands(ice.Commands{
|
||||
web.P(SSO): {Name: "/sso", Help: "登录", Actions: ice.Actions{
|
||||
ice.CTX_INIT: {Hand: func(m *ice.Message, arg ...string) { m.Cmd(aaa.ROLE, aaa.WHITE, aaa.VOID, SSO) }},
|
||||
}, Hand: func(m *ice.Message, arg ...string) {
|
||||
web.P(SSO): {Name: "/sso", Help: "授权", Actions: aaa.RoleAction(), Hand: func(m *ice.Message, arg ...string) {
|
||||
if m.Option(ice.MSG_USERNAME) == "" {
|
||||
web.RenderIndex(m, ice.VOLCANOS)
|
||||
return
|
||||
|
@ -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/web"
|
||||
@ -15,20 +16,12 @@ const TOPIC = "topic"
|
||||
|
||||
func init() {
|
||||
form := ice.Map{
|
||||
"body.background": ice.Map{
|
||||
mdb.TYPE: "text", mdb.NAME: "background", mdb.VALUE: "black",
|
||||
},
|
||||
"header.height": ice.Map{
|
||||
"tags": "panel.Header,panel.Header>div.output",
|
||||
mdb.TYPE: "text", mdb.NAME: "height", mdb.VALUE: "31",
|
||||
},
|
||||
"body.background": ice.Map{mdb.TYPE: "text", mdb.NAME: "background", mdb.VALUE: "black"},
|
||||
"header.height": ice.Map{"tags": "panel.Header,panel.Header>div.output", mdb.TYPE: "text", mdb.NAME: "height", mdb.VALUE: "31"},
|
||||
}
|
||||
Index.MergeCommands(ice.Commands{
|
||||
TOPIC: {Name: "topic zone id auto create insert", Help: "主题", Actions: ice.MergeActions(ice.Actions{
|
||||
ice.CTX_INIT: {Hand: func(m *ice.Message, arg ...string) {
|
||||
m.Cmd(aaa.ROLE, aaa.WHITE, aaa.VOID, TOPIC)
|
||||
}},
|
||||
mdb.INPUTS: {Name: "inputs", Help: "补全", Hand: func(m *ice.Message, arg ...string) {
|
||||
mdb.INPUTS: {Hand: func(m *ice.Message, arg ...string) {
|
||||
switch arg[0] {
|
||||
case "tags":
|
||||
for k := range form {
|
||||
@ -58,11 +51,56 @@ func init() {
|
||||
}
|
||||
m.Cmdy(mdb.INPUTS, m.PrefixKey(), "", mdb.ZONE, arg)
|
||||
}},
|
||||
"create": {Name: "create topic=demo hover=gray float=lightgray color=black background=white", Hand: func(m *ice.Message, arg ...string) {
|
||||
m.Cmd(nfs.SAVE, path.Join("src/website/topic/"+m.Option("topic")+".css"), kit.Renders(_topic_template, m))
|
||||
}},
|
||||
"form": {Name: "form", Help: "表单", Hand: func(m *ice.Message, arg ...string) {
|
||||
m.Cmd(m.CommandKey(), m.Option(mdb.ZONE), func(value ice.Maps) {
|
||||
tags, _ := form[value["tags"]]
|
||||
m.Push("tags", value["tags"])
|
||||
m.Push("type", kit.Select(kit.Format(kit.Value(tags, "type")), value["type"]))
|
||||
m.Push("name", kit.Select(kit.Format(kit.Value(tags, "name")), value["name"]))
|
||||
m.Push("value", kit.Select(kit.Format(kit.Value(tags, "value")), value["value"]))
|
||||
})
|
||||
kit.Fetch(form, func(k string, v ice.Map) {
|
||||
m.Push("tags", k)
|
||||
m.Push("", v, kit.Split("type,name,value"))
|
||||
})
|
||||
m.EchoButton("submit")
|
||||
}},
|
||||
"submit": {Name: "form zone", Help: "提交", Hand: func(m *ice.Message, arg ...string) {
|
||||
m.Echo("done")
|
||||
}},
|
||||
"choose": {Name: "choose", Help: "切换", Hand: func(m *ice.Message, arg ...string) {
|
||||
m.ProcessLocation(web.MergeURL2(m, "", "topic", kit.TrimExt(m.Option(mdb.ZONE), nfs.CSS)))
|
||||
}},
|
||||
"create": {Name: "create topic=demo hover=gray float=lightgray color=black background=white", Help: "创建", Hand: func(m *ice.Message, arg ...string) {
|
||||
buf, err := kit.Render(`
|
||||
}, mdb.ZoneAction(mdb.FIELD, "time,id,tags,type,name,value"), aaa.RoleAction()), Hand: func(m *ice.Message, arg ...string) {
|
||||
if mdb.ZoneSelect(m, arg...); len(arg) == 0 {
|
||||
m.Cmd(nfs.DIR, nfs.PWD, ice.OptionFields(), kit.Dict(nfs.DIR_ROOT, "src/website/topic/")).RenameAppend(nfs.PATH, mdb.ZONE, nfs.SIZE, mdb.COUNT).Tables(func(values ice.Maps) {
|
||||
m.Push("", values)
|
||||
})
|
||||
m.PushAction("choose", "form", mdb.REMOVE)
|
||||
} else {
|
||||
if p := "src/website/topic/" + arg[0]; nfs.ExistsFile(m, p) {
|
||||
m.Cmdy(nfs.CAT, p)
|
||||
} else {
|
||||
m.Tables(func(value ice.Maps) {
|
||||
m.Echo("body.%s %s { %s:%s }\n", arg[0], value["tag"], value[mdb.NAME], value[mdb.VALUE])
|
||||
})
|
||||
}
|
||||
}
|
||||
}},
|
||||
web.PP(TOPIC): {Name: "/topic/", Help: "主题", Hand: func(m *ice.Message, arg ...string) {
|
||||
if p := "src/website/topic/" + arg[0]; nfs.ExistsFile(m, p) {
|
||||
m.RenderDownload(p)
|
||||
return
|
||||
}
|
||||
m.Cmdy("", kit.TrimExt(kit.Select(cli.BLACK, arg, 0), nfs.CSS)).RenderResult().W.Header()[web.ContentType] = kit.Simple(web.ContentCSS)
|
||||
}},
|
||||
})
|
||||
}
|
||||
|
||||
var _topic_template = `
|
||||
body.{{.Option "topic"}} { background-color:{{.Option "background" }}; color:{{.Option "color" }}; }
|
||||
body.{{.Option "topic"}} legend { background-color:{{.Option "hover" }}; color:{{.Option "color" }}; }
|
||||
body.{{.Option "topic"}} select { background-color:{{.Option "background" }}; color:{{.Option "color" }}; }
|
||||
@ -103,51 +141,4 @@ body.{{.Option "topic"}} table.content td.select { background-color:{{.Option "h
|
||||
body.{{.Option "topic"}} fieldset.plugin:hover { box-shadow:12px 12px 12px 6px {{.Option "float" }}; }
|
||||
body.{{.Option "topic"}} fieldset.story:hover { box-shadow:12px 12px 12px 6px {{.Option "float" }}; }
|
||||
body.{{.Option "topic"}} fieldset.panel.Header>div.output div:hover { background-color:{{.Option "float" }}; }
|
||||
`, m)
|
||||
m.Assert(err)
|
||||
m.Cmd(nfs.SAVE, path.Join("src/website/topic/"+m.Option("topic")+".css"), string(buf))
|
||||
}},
|
||||
"form": {Name: "form", Help: "表单", Hand: func(m *ice.Message, arg ...string) {
|
||||
m.Cmd(m.CommandKey(), m.Option(mdb.ZONE), func(value ice.Maps) {
|
||||
tags, _ := form[value["tags"]]
|
||||
m.Push("tags", value["tags"])
|
||||
m.Push("type", kit.Select(kit.Format(kit.Value(tags, "type")), value["type"]))
|
||||
m.Push("name", kit.Select(kit.Format(kit.Value(tags, "name")), value["name"]))
|
||||
m.Push("value", kit.Select(kit.Format(kit.Value(tags, "value")), value["value"]))
|
||||
})
|
||||
kit.Fetch(form, func(k string, v ice.Map) {
|
||||
m.Push("tags", k)
|
||||
m.Push("", v, kit.Split("type,name,value"))
|
||||
})
|
||||
m.EchoButton("submit")
|
||||
}},
|
||||
"submit": {Name: "form zone", Help: "提交", Hand: func(m *ice.Message, arg ...string) {
|
||||
m.Echo("dome")
|
||||
}},
|
||||
}, mdb.ZoneAction(mdb.SHORT, "zone", mdb.FIELD, "time,id,tags,type,name,value")), Hand: func(m *ice.Message, arg ...string) {
|
||||
if mdb.ZoneSelect(m, arg...); len(arg) == 0 {
|
||||
m.Cmd(nfs.DIR, nfs.PWD, ice.OptionFields(), kit.Dict(nfs.DIR_ROOT, "src/website/topic/")).RenameAppend(nfs.PATH, mdb.ZONE, nfs.SIZE, mdb.COUNT).Tables(func(values ice.Maps) {
|
||||
m.Push("", values)
|
||||
})
|
||||
m.PushAction("choose", "form", mdb.REMOVE)
|
||||
} else {
|
||||
if p := "src/website/topic/" + arg[0]; nfs.ExistsFile(m, p) {
|
||||
m.Cmdy(nfs.CAT, p)
|
||||
} else {
|
||||
m.Tables(func(value ice.Maps) {
|
||||
m.Echo("body.%s %s { %s:%s }\n", arg[0], value["tag"], value["name"], value["value"])
|
||||
})
|
||||
}
|
||||
}
|
||||
}},
|
||||
"/topic/": {Name: "/topic/", Help: "主题", Hand: func(m *ice.Message, arg ...string) {
|
||||
if p := "src/website/topic/" + arg[0]; nfs.ExistsFile(m, p) {
|
||||
m.RenderDownload(p)
|
||||
return
|
||||
}
|
||||
m.Cmdy(m.CommandKey(), kit.TrimExt(kit.Select("black", arg, 0), nfs.CSS))
|
||||
m.W.Header()[web.ContentType] = kit.Simple(web.ContentCSS)
|
||||
m.RenderResult()
|
||||
}},
|
||||
})
|
||||
}
|
||||
`
|
||||
|
@ -2,7 +2,6 @@ package chat
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
"os"
|
||||
"path"
|
||||
"strings"
|
||||
|
||||
@ -42,14 +41,14 @@ func _website_parse(m *ice.Message, text string, args ...string) (ice.Map, bool)
|
||||
), kit.Dict(), kit.Dict()
|
||||
|
||||
nriver, nstorm, prefix := 0, 0, ""
|
||||
m.Cmd(lex.SPLIT, "", mdb.KEY, mdb.NAME, kit.Dict(nfs.CAT_CONTENT, text), func(deep int, ls []string) []string {
|
||||
m.Cmd(lex.SPLIT, "", mdb.KEY, mdb.NAME, kit.Dict(nfs.CAT_CONTENT, text), func(deep int, ls []string) {
|
||||
if deep == 1 {
|
||||
switch ls[0] {
|
||||
case HEADER, RIVER, FOOTER:
|
||||
for i := 1; i < len(ls); i += 2 {
|
||||
kit.Value(river, kit.Keys(ls[0], ls[i]), ls[i+1])
|
||||
}
|
||||
return ls
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
@ -59,10 +58,10 @@ func _website_parse(m *ice.Message, text string, args ...string) (ice.Map, bool)
|
||||
ls[0], data[ctx.DISPLAY] = kit.Select(ctx.CAN_PLUGIN, ctx.GetFileCmd(ls[0])), ctx.FileURI(ls[0])
|
||||
case nfs.GO:
|
||||
ls[0] = ctx.GetFileCmd(ls[0])
|
||||
case nfs.SH:
|
||||
ls[0], data[ctx.ARGS] = "web.code.sh.sh", ls[0]
|
||||
case nfs.SHY:
|
||||
ls[0], data[ctx.ARGS] = "web.wiki.word", ls[0]
|
||||
case nfs.SH:
|
||||
ls[0], data[ctx.ARGS] = "web.code.sh.sh", ls[0]
|
||||
case nfs.PY:
|
||||
ls[0], data[ctx.ARGS] = "web.code.sh.py", ls[0]
|
||||
case "~":
|
||||
@ -72,11 +71,11 @@ func _website_parse(m *ice.Message, text string, args ...string) (ice.Map, bool)
|
||||
for _, v := range ls[1:] {
|
||||
last[mdb.LIST] = append(last[mdb.LIST].([]ice.Any), kit.Dict(mdb.INDEX, kit.Keys(prefix, v)))
|
||||
}
|
||||
return ls
|
||||
return
|
||||
}
|
||||
|
||||
if ls[0] == "" {
|
||||
return ls
|
||||
return
|
||||
} else if len(ls) == 1 && deep > 2 {
|
||||
ls = append(ls, m.Cmd(ctx.COMMAND, ls[0]).Append(mdb.HELP))
|
||||
} else if len(ls) == 1 {
|
||||
@ -115,7 +114,6 @@ func _website_parse(m *ice.Message, text string, args ...string) (ice.Map, bool)
|
||||
default:
|
||||
last[mdb.LIST] = append(last[mdb.LIST].([]ice.Any), kit.Dict(mdb.NAME, kit.Select(ls[0], data[mdb.NAME]), mdb.HELP, ls[1], mdb.INDEX, ls[0], data))
|
||||
}
|
||||
return ls
|
||||
})
|
||||
return river, true
|
||||
}
|
||||
@ -123,7 +121,7 @@ func _website_render(m *ice.Message, w http.ResponseWriter, r *http.Request, kin
|
||||
msg := m.Spawn(w, r)
|
||||
switch kind {
|
||||
case nfs.ZML:
|
||||
web.RenderCmd(msg, "can.parse", text, name)
|
||||
web.RenderCmd(msg, CAN_PARSE, text, name)
|
||||
case nfs.IML:
|
||||
res, _ := _website_parse(msg, text)
|
||||
msg.RenderResult(_website_template2, kit.Format(res))
|
||||
@ -134,10 +132,10 @@ func _website_render(m *ice.Message, w http.ResponseWriter, r *http.Request, kin
|
||||
r.URL.Path = "/chat/cmd/web.chat.div"
|
||||
return false
|
||||
}
|
||||
case nfs.JSON:
|
||||
msg.RenderResult(_website_template2, kit.Format(kit.UnMarshal(text)))
|
||||
case nfs.JS:
|
||||
msg.RenderResult(_website_template, text)
|
||||
case nfs.JSON:
|
||||
msg.RenderResult(_website_template2, kit.Format(kit.UnMarshal(text)))
|
||||
case nfs.HTML:
|
||||
msg.RenderResult(text)
|
||||
case nfs.SVG:
|
||||
@ -148,13 +146,9 @@ func _website_render(m *ice.Message, w http.ResponseWriter, r *http.Request, kin
|
||||
web.Render(msg, msg.Option(ice.MSG_OUTPUT), msg.Optionv(ice.MSG_ARGS).([]ice.Any)...)
|
||||
return true
|
||||
}
|
||||
func _website_search(m *ice.Message, kind, name, text string, arg ...string) {
|
||||
m.Cmd(m.PrefixKey(), ice.OptionFields(""), func(value ice.Maps) {
|
||||
m.PushSearch(value, mdb.TEXT, web.MergePodWebSite(m, "", value[nfs.PATH]))
|
||||
})
|
||||
}
|
||||
|
||||
const (
|
||||
CAN_PARSE = "can.parse"
|
||||
SRC_WEBSITE = "src/website/"
|
||||
CHAT_WEBSITE = "/chat/website/"
|
||||
)
|
||||
@ -164,17 +158,14 @@ func init() {
|
||||
Index.MergeCommands(ice.Commands{
|
||||
WEBSITE: {Name: "website path auto create import", Help: "网站", Actions: ice.MergeActions(ice.Actions{
|
||||
ice.CTX_INIT: {Hand: func(m *ice.Message, arg ...string) {
|
||||
m.Cmd(mdb.RENDER, mdb.CREATE, nfs.TXT, m.PrefixKey())
|
||||
m.Cmd(mdb.ENGINE, mdb.CREATE, nfs.TXT, m.PrefixKey())
|
||||
m.Cmd(mdb.RENDER, mdb.CREATE, nfs.IML, m.PrefixKey())
|
||||
m.Cmd(mdb.ENGINE, mdb.CREATE, nfs.IML, m.PrefixKey())
|
||||
m.Cmd(aaa.ROLE, aaa.WHITE, WEBSITE)
|
||||
|
||||
web.AddRewrite(func(w http.ResponseWriter, r *http.Request) bool {
|
||||
if r.Method != http.MethodGet {
|
||||
return false
|
||||
}
|
||||
if strings.HasSuffix(r.URL.Path, "/") {
|
||||
if strings.HasSuffix(r.URL.Path, ice.PS) {
|
||||
return false
|
||||
}
|
||||
if !strings.HasPrefix(r.Header.Get(web.UserAgent), "Mozilla") {
|
||||
@ -194,15 +185,13 @@ func init() {
|
||||
}},
|
||||
lex.PARSE: {Hand: func(m *ice.Message, arg ...string) {
|
||||
switch kit.Ext(arg[0]) {
|
||||
case nfs.ZML: // 前端解析
|
||||
web.RenderCmd(m, "can.parse", m.Cmdx(nfs.CAT, path.Join(SRC_WEBSITE, arg[0])))
|
||||
|
||||
case nfs.IML: // 文件解析
|
||||
case nfs.ZML:
|
||||
web.RenderCmd(m, CAN_PARSE, m.Cmdx(nfs.CAT, path.Join(SRC_WEBSITE, arg[0])))
|
||||
case nfs.IML:
|
||||
if res, ok := _website_parse(m, m.Cmdx(nfs.CAT, path.Join(SRC_WEBSITE, arg[0])), arg[1:]...); ok {
|
||||
m.Echo(_website_template2, kit.Format(res))
|
||||
}
|
||||
|
||||
default: // 缓存解析
|
||||
default:
|
||||
if text := m.CmdAppend("", path.Join(ice.PS, arg[0]), mdb.TEXT); text != "" {
|
||||
if res, ok := _website_parse(m, text, arg[1:]...); ok {
|
||||
m.Echo(_website_template2, kit.Format(res))
|
||||
@ -210,7 +199,7 @@ func init() {
|
||||
}
|
||||
}
|
||||
}},
|
||||
mdb.INPUTS: {Name: "inputs", Help: "补全", Hand: func(m *ice.Message, arg ...string) {
|
||||
mdb.INPUTS: {Hand: func(m *ice.Message, arg ...string) {
|
||||
switch m.Option(ctx.ACTION) {
|
||||
case mdb.CREATE:
|
||||
mdb.HashInputs(m, arg)
|
||||
@ -221,8 +210,8 @@ func init() {
|
||||
m.Cmdy(nfs.DIR, arg[1:]).ProcessAgain()
|
||||
}
|
||||
}},
|
||||
mdb.CREATE: {Name: "create path type=iml,zml,json,js,html name text", Help: "创建"},
|
||||
mdb.IMPORT: {Name: "import path=src/website/", Help: "导入", Hand: func(m *ice.Message, arg ...string) {
|
||||
mdb.CREATE: {Name: "create path type=zml,iml,json,js,html name text"},
|
||||
mdb.IMPORT: {Name: "import path=src/website/", Hand: func(m *ice.Message, arg ...string) {
|
||||
m.Cmd(nfs.DIR, kit.Dict(nfs.DIR_ROOT, m.Option(nfs.PATH)), func(p string) {
|
||||
switch name := strings.TrimPrefix(p, m.Option(nfs.PATH)); kit.Ext(p) {
|
||||
case nfs.HTML, nfs.JS, nfs.JSON, nfs.ZML, nfs.IML, nfs.TXT:
|
||||
@ -242,29 +231,8 @@ func init() {
|
||||
m.Echo(_website_url(m, strings.TrimPrefix(path.Join(arg[2], arg[1]), SRC_WEBSITE)))
|
||||
}
|
||||
}},
|
||||
}, mdb.HashAction(mdb.SHORT, nfs.PATH, mdb.FIELD, "time,path,type,name,text"), ctx.CmdAction(), web.ApiAction()), Hand: func(m *ice.Message, arg ...string) {
|
||||
}, mdb.HashAction(mdb.SHORT, nfs.PATH, mdb.FIELD, "time,path,type,name,text"), ctx.CmdAction(), web.ApiAction(), aaa.RoleAction()), Hand: func(m *ice.Message, arg ...string) {
|
||||
mdb.HashSelect(m, arg...).Tables(func(value ice.Maps) { m.PushAnchor(web.MergePodWebSite(m, "", value[nfs.PATH])) })
|
||||
if len(arg) == 0 { // 文件列表
|
||||
m.Cmd(nfs.DIR, SRC_WEBSITE, func(f os.FileInfo, p string) {
|
||||
m.Push("", kit.Dict(
|
||||
mdb.TIME, f.ModTime().Format(ice.MOD_TIME),
|
||||
nfs.PATH, ice.PS+strings.TrimPrefix(p, SRC_WEBSITE),
|
||||
mdb.TYPE, kit.Ext(p), mdb.NAME, path.Base(p), mdb.TEXT, m.Cmdx(nfs.CAT, p),
|
||||
), kit.Split(m.Config(mdb.FIELD))).PushButton("")
|
||||
m.PushAnchor(web.MergeURL2(m, path.Join(CHAT_WEBSITE, strings.TrimPrefix(p, SRC_WEBSITE))))
|
||||
}).Sort(nfs.PATH)
|
||||
}
|
||||
p := path.Join(SRC_WEBSITE, path.Join(arg...))
|
||||
if m.Length() == 0 && len(arg) > 0 && !strings.HasSuffix(arg[0], ice.PS) && nfs.ExistsFile(m, p) { // 文件详情
|
||||
m.Push(mdb.TYPE, kit.Ext(p))
|
||||
m.Push(mdb.TEXT, m.Cmdx(nfs.CAT, p))
|
||||
m.Push(nfs.PATH, path.Join(CHAT_WEBSITE, path.Join(arg...)))
|
||||
m.PushAnchor(web.MergeLink(m, m.Append(nfs.PATH)))
|
||||
}
|
||||
if m.Length() > 0 && len(arg) > 0 { // 文件预览
|
||||
m.PushQRCode(mdb.SCAN, web.MergeURL2(m, m.Append(nfs.PATH)))
|
||||
m.EchoIFrame(m.Append(nfs.PATH))
|
||||
}
|
||||
}},
|
||||
})
|
||||
}
|
||||
@ -284,7 +252,6 @@ var _website_template = `<!DOCTYPE html>
|
||||
<script>%s</script>
|
||||
</body>
|
||||
`
|
||||
|
||||
var _website_template2 = `<!DOCTYPE html>
|
||||
<head>
|
||||
<meta name="viewport" content="width=device-width,initial-scale=0.8,maximum-scale=0.8,user-scalable=no"/>
|
||||
|
@ -165,7 +165,7 @@ const AUTOGEN = "autogen"
|
||||
func init() {
|
||||
Index.MergeCommands(ice.Commands{
|
||||
AUTOGEN: {Name: "autogen path auto create binpack script relay", Help: "生成", Actions: ice.Actions{
|
||||
mdb.INPUTS: {Name: "inputs", Help: "补全", Hand: func(m *ice.Message, arg ...string) {
|
||||
mdb.INPUTS: {Hand: func(m *ice.Message, arg ...string) {
|
||||
switch arg[0] {
|
||||
case cli.MAIN:
|
||||
m.Option(nfs.DIR_ROOT, m.Option(nfs.PATH))
|
||||
|
@ -94,10 +94,6 @@ const INNER = "inner"
|
||||
func init() {
|
||||
Index.MergeCommands(ice.Commands{
|
||||
INNER: {Name: "inner path=src/@key file=main.go@key line=1 auto", Help: "源代码", Actions: ice.MergeActions(ice.Actions{
|
||||
ice.CTX_INIT: {Hand: func(m *ice.Message, arg ...string) {
|
||||
m.Cmd(aaa.ROLE, aaa.WHITE, aaa.VOID, m.PrefixKey())
|
||||
m.Cmd(aaa.ROLE, aaa.WHITE, aaa.VOID, ice.SRC_MAIN_GO)
|
||||
}},
|
||||
mdb.INPUTS: {Hand: func(m *ice.Message, arg ...string) {
|
||||
switch arg[0] {
|
||||
case nfs.PATH:
|
||||
@ -143,7 +139,7 @@ func init() {
|
||||
}
|
||||
m.Cmd(FAVOR, mdb.INSERT, mdb.ZONE, "_recent_cmd", nfs.FILE, arg[0])
|
||||
}},
|
||||
}, ctx.CmdAction()), Hand: func(m *ice.Message, arg ...string) {
|
||||
}, ctx.CmdAction(), aaa.RoleAction(ice.SRC_MAIN_GO)), Hand: func(m *ice.Message, arg ...string) {
|
||||
if arg[0] = strings.Split(arg[0], ice.FS)[0]; !strings.HasSuffix(arg[0], ice.PS) && len(arg) == 1 {
|
||||
arg[1] = kit.Slice(strings.Split(arg[0], ice.PS), -1)[0]
|
||||
arg[0] = strings.TrimSuffix(arg[0], arg[1])
|
||||
|
@ -32,7 +32,7 @@ func init() {
|
||||
ctx.CONFIG: {Name: "config client_id client_secret redirect_uri", Help: "配置", Hand: func(m *ice.Message, arg ...string) {
|
||||
ctx.ConfigFromOption(m, CLIENT_ID, CLIENT_SECRET, REDIRECT_URI)
|
||||
}},
|
||||
mdb.INPUTS: {Name: "inputs", Help: "补全", Hand: func(m *ice.Message, arg ...string) {
|
||||
mdb.INPUTS: {Hand: func(m *ice.Message, arg ...string) {
|
||||
if arg[0] == mdb.HASH {
|
||||
m.Cmdy(aaa.RSA).Cut("hash,title,public")
|
||||
return
|
||||
|
@ -35,7 +35,7 @@ func init() {
|
||||
return false
|
||||
})
|
||||
}},
|
||||
mdb.INPUTS: {Name: "inputs", Help: "补全", Hand: func(m *ice.Message, arg ...string) {
|
||||
mdb.INPUTS: {Hand: func(m *ice.Message, arg ...string) {
|
||||
switch arg[0] {
|
||||
case BINNARY:
|
||||
m.Cmdy(nfs.DIR, ice.BIN, nfs.DIR_CLI_FIELDS).RenameAppend(nfs.PATH, BINNARY)
|
||||
|
@ -91,9 +91,8 @@ const PUBLISH = "publish"
|
||||
|
||||
func init() {
|
||||
Index.Merge(&ice.Context{Commands: ice.Commands{
|
||||
PUBLISH: {Name: "publish path auto create volcanos icebergs intshell", Help: "发布", Actions: ice.Actions{
|
||||
PUBLISH: {Name: "publish path auto create volcanos icebergs intshell", Help: "发布", Actions: ice.MergeActions(ice.Actions{
|
||||
ice.CTX_INIT: {Hand: func(m *ice.Message, arg ...string) {
|
||||
m.Cmd(aaa.ROLE, aaa.WHITE, aaa.VOID, ice.USR_PUBLISH)
|
||||
m.Config(ice.CONTEXTS, _contexts)
|
||||
}},
|
||||
web.SERVE_START: {Name: "serve.start", Help: "服务启动", Hand: func(m *ice.Message, arg ...string) {
|
||||
@ -115,7 +114,7 @@ func init() {
|
||||
ice.CONTEXTS: {Name: "contexts", Help: "环境", Hand: func(m *ice.Message, arg ...string) {
|
||||
_publish_contexts(m, arg...)
|
||||
}},
|
||||
mdb.INPUTS: {Name: "inputs", Help: "补全", Hand: func(m *ice.Message, arg ...string) {
|
||||
mdb.INPUTS: {Hand: func(m *ice.Message, arg ...string) {
|
||||
m.Cmdy(nfs.DIR, kit.Select(nfs.PWD, arg, 1)).ProcessAgain()
|
||||
}},
|
||||
mdb.CREATE: {Name: "create file", Help: "添加", Hand: func(m *ice.Message, arg ...string) {
|
||||
@ -124,7 +123,7 @@ func init() {
|
||||
nfs.TRASH: {Name: "trash", Help: "删除", Hand: func(m *ice.Message, arg ...string) {
|
||||
m.Cmd(nfs.TRASH, path.Join(ice.USR_PUBLISH, m.Option(nfs.PATH)))
|
||||
}},
|
||||
}, Hand: func(m *ice.Message, arg ...string) {
|
||||
}, aaa.RoleAction(ice.USR_PUBLISH)), Hand: func(m *ice.Message, arg ...string) {
|
||||
m.Option(nfs.DIR_ROOT, ice.USR_PUBLISH)
|
||||
m.Cmdy(nfs.DIR, kit.Select("", arg, 0), nfs.DIR_WEB_FIELDS)
|
||||
}},
|
||||
|
@ -77,7 +77,7 @@ func init() {
|
||||
}
|
||||
ctx.ProcessField(m, "", arg, arg...)
|
||||
}},
|
||||
mdb.INPUTS: {Name: "inputs", Help: "补全", Hand: func(m *ice.Message, arg ...string) {
|
||||
mdb.INPUTS: {Hand: func(m *ice.Message, arg ...string) {
|
||||
switch mdb.HashInputs(m, arg).Cmdy(FAVOR, "_system_term", ice.OptionFields(arg[0])).Cut(arg[0]); arg[0] {
|
||||
case mdb.TYPE:
|
||||
if m.Option(nfs.LINE) != "" && m.Option(nfs.FILE) != "" {
|
||||
|
@ -22,8 +22,6 @@ func init() {
|
||||
Index.MergeCommands(ice.Commands{
|
||||
WORD: {Name: "word path=src/main.shy@key list play", Help: "笔记文档", Actions: ice.MergeActions(ice.Actions{
|
||||
ice.CTX_INIT: {Hand: func(m *ice.Message, arg ...string) {
|
||||
m.Cmd(aaa.ROLE, aaa.WHITE, aaa.VOID, m.PrefixKey())
|
||||
m.Cmd(aaa.ROLE, aaa.WHITE, aaa.VOID, ice.SRC_MAIN_SHY)
|
||||
WordAlias(m, NAVMENU, TITLE, NAVMENU)
|
||||
WordAlias(m, PREMENU, TITLE, PREMENU)
|
||||
WordAlias(m, CHAPTER, TITLE, CHAPTER)
|
||||
@ -43,7 +41,7 @@ func init() {
|
||||
})
|
||||
}}, "play": {Name: "play", Help: "演示"},
|
||||
ice.STORY: {Hand: func(m *ice.Message, arg ...string) { m.Cmdy(arg[0], ice.RUN, arg[2:]) }},
|
||||
}, WikiAction("", nfs.SHY), ctx.CmdAction()), Hand: func(m *ice.Message, arg ...string) {
|
||||
}, WikiAction("", nfs.SHY), ctx.CmdAction(), aaa.RoleAction(ice.SRC_MAIN_SHY)), Hand: func(m *ice.Message, arg ...string) {
|
||||
if m.Option(nfs.DIR_DEEP, ice.TRUE); len(arg) == 0 {
|
||||
arg = append(arg, "src/")
|
||||
}
|
||||
|
@ -32,7 +32,7 @@ func init() {
|
||||
ctx.ProcessCommand(m, cli.SYSTEM, kit.Split(m.Option(mdb.TEXT)), arg...)
|
||||
ctx.ProcessCommandOpt(m, arg, cli.PWD)
|
||||
}},
|
||||
mdb.INPUTS: {Name: "inputs", Help: "补全", Hand: func(m *ice.Message, arg ...string) {
|
||||
mdb.INPUTS: {Hand: func(m *ice.Message, arg ...string) {
|
||||
m.Cmdy(FAVOR, mdb.INPUTS, arg)
|
||||
}},
|
||||
FAVOR: {Name: "favor zone=some@key type name text pwd", Help: "收藏", Hand: func(m *ice.Message, arg ...string) {
|
||||
|
@ -201,7 +201,7 @@ const STATUS = "status"
|
||||
func init() {
|
||||
Index.MergeCommands(ice.Commands{
|
||||
STATUS: {Name: "status repos auto", Help: "状态机", Actions: ice.Actions{
|
||||
mdb.INPUTS: {Name: "inputs", Help: "补全", Hand: func(m *ice.Message, arg ...string) {
|
||||
mdb.INPUTS: {Hand: func(m *ice.Message, arg ...string) {
|
||||
switch arg[0] {
|
||||
case mdb.NAME, REPOS:
|
||||
m.Cmdy(REPOS).Cut(REPOS)
|
||||
|
@ -13,7 +13,7 @@ const TREND = "trend"
|
||||
func init() {
|
||||
Index.MergeCommands(ice.Commands{
|
||||
TREND: {Name: "trend repos@key begin_time@date auto", Help: "趋势图", Actions: ice.MergeActions(ice.Actions{
|
||||
mdb.INPUTS: {Name: "inputs", Help: "补全", Hand: func(m *ice.Message, arg ...string) {
|
||||
mdb.INPUTS: {Hand: func(m *ice.Message, arg ...string) {
|
||||
m.Cmdy(REPOS, ice.OptionFields("name,time"))
|
||||
}}, code.INNER: {Name: "web.code.inner"},
|
||||
}, ctx.CmdAction()), Hand: func(m *ice.Message, arg ...string) {
|
||||
|
@ -88,7 +88,7 @@ func init() {
|
||||
m.Cmd("", mdb.CREATE)
|
||||
}
|
||||
}},
|
||||
mdb.INPUTS: {Name: "inputs", Help: "补全", Hand: func(m *ice.Message, arg ...string) {
|
||||
mdb.INPUTS: {Hand: func(m *ice.Message, arg ...string) {
|
||||
if m.Option(ctx.ACTION) == SCRIPT {
|
||||
m.Cmdy(SCRIPT, mdb.INPUTS, arg)
|
||||
return
|
||||
|
@ -31,7 +31,7 @@ func init() {
|
||||
p := path.Join(m.Option(cli.PWD), m.Option(BUF))
|
||||
ctx.ProcessCommand(m, code.INNER, []string{path.Dir(p) + ice.PS, path.Base(p), m.Option(ROW)}, arg...)
|
||||
}},
|
||||
mdb.INPUTS: {Name: "inputs", Help: "补全", Hand: func(m *ice.Message, arg ...string) {
|
||||
mdb.INPUTS: {Hand: func(m *ice.Message, arg ...string) {
|
||||
m.Cmdy(FAVOR, mdb.INPUTS, arg)
|
||||
}},
|
||||
FAVOR: {Name: "favor zone=some@key type name text buf row pwd", Help: "收藏", Hand: func(m *ice.Message, arg ...string) {
|
||||
|
@ -146,7 +146,7 @@ func init() {
|
||||
code.INNER: {Name: "inner", Help: "源码", Hand: func(m *ice.Message, arg ...string) {
|
||||
ctx.ProcessCommand(m, code.INNER, m.OptionSplit("path,file,line"), arg...)
|
||||
}},
|
||||
INPUT: {Name: "input name text", Help: "补全", Hand: func(m *ice.Message, arg ...string) {
|
||||
INPUT: {Name: "input name text", Hand: func(m *ice.Message, arg ...string) {
|
||||
if kit.Ext(m.Option(BUF)) == nfs.SHY && arg[1] == "" {
|
||||
for _, k := range []string{
|
||||
"field",
|
||||
|
Loading…
x
Reference in New Issue
Block a user