1
0
mirror of https://shylinux.com/x/icebergs synced 2025-04-26 01:24:05 +08:00
This commit is contained in:
harveyshao 2022-11-14 15:26:16 +08:00
parent ec9ce046da
commit 2f43d52c2d
15 changed files with 29 additions and 14 deletions

View File

@ -129,6 +129,7 @@ func RoleRight(m *ice.Message, userrole string, arg ...string) bool {
}
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())
m.Cmd(ROLE, BLACK, VOID, m.PrefixKey(), "action")
for _, cmd := range cmds {

View File

@ -146,7 +146,13 @@ func init() {
),
)},
}, Commands: ice.Commands{
CAT: {Name: "cat path auto", Help: "文件", Hand: func(m *ice.Message, arg ...string) {
CAT: {Name: "cat path auto", Help: "文件", Actions: ice.Actions{
ctx.CTX_INIT: {Hand: func(m *ice.Message, arg ...string) {
m.Cmd(aaa.ROLE, aaa.WHITE, aaa.VOID, ice.SRC_MAIN_SHY)
m.Cmd(aaa.ROLE, aaa.WHITE, aaa.VOID, ice.SRC_MAIN_GO)
m.Cmd(aaa.ROLE, aaa.WHITE, aaa.VOID, ice.USR_PUBLISH)
}},
}, Hand: func(m *ice.Message, arg ...string) {
if len(arg) == 0 || strings.HasSuffix(arg[0], ice.PS) {
m.Cmdy(DIR, arg)
return

View File

@ -36,6 +36,9 @@ func _serve_rewrite(m *ice.Message) {
switch r.URL.Path {
case ice.PS:
if repos == ice.VOLCANOS {
if nfs.ExistsFile(ice.SRC_MAIN_JS) {
return
}
if s := msg.Cmdx("web.chat.website", lex.PARSE, ice.INDEX_IML, "Header", "", "River", "", "Footer", ""); s != "" {
Render(msg, ice.RENDER_RESULT, s)
return true // 定制主页

View File

@ -140,6 +140,7 @@ const ( // DIR
SRC_DEBUG = "src/debug"
SRC_RELEASE = "src/release"
SRC_MAIN_GO = "src/main.go"
SRC_MAIN_GO = "src/main.js"
SRC_MAIN_SHY = "src/main.shy"
SRC_MAIN_SVG = "src/main.svg"
SRC_VERSION_GO = "src/version.go"

View File

@ -14,7 +14,7 @@ func _action_list(m *ice.Message, river, storm string) {
m.Cmdy(STORM, kit.Dict(ice.MSG_RIVER, river, ice.MSG_STORM, storm))
}
func _action_exec(m *ice.Message, river, storm, index string, arg ...string) {
m.OptionMulti(ice.MSG_RIVER, river, ice.MSG_STORM, storm)
m.Options(ice.MSG_RIVER, river, ice.MSG_STORM, storm)
if m.Warn(m.Cmd(STORM, index, func(value ice.Maps) {
if index = value[ctx.INDEX]; value[web.SPACE] != "" {
m.Option(ice.POD, value[web.SPACE])
@ -82,7 +82,7 @@ func init() {
m.Cmdy(mdb.MODIFY, RIVER, _storm_key(m), mdb.LIST, m.OptionSimple(mdb.ID), arg)
}},
web.SHARE: {Hand: func(m *ice.Message, arg ...string) { _action_share(m, arg...) }},
}, ctx.CmdAction(nfs.PATH, ice.USR_LOCAL_RIVER), aaa.RoleAction()), Hand: func(m *ice.Message, arg ...string) {
}, ctx.CmdAction(), aaa.WhiteAction()), Hand: func(m *ice.Message, arg ...string) {
if m.Warn(m.Option(ice.MSG_USERNAME) == "", ice.ErrNotLogin, arg) {
return
}

View File

@ -43,7 +43,7 @@ const CMD = "cmd"
func init() {
Index.MergeCommands(ice.Commands{
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(),
mdb.HashAction(mdb.SHORT, mdb.TYPE, nfs.PATH, nfs.PWD), ctx.CmdAction(), web.ApiAction(), aaa.WhiteAction(),
), Hand: func(m *ice.Message, arg ...string) {
if _cmd_file(m, arg...) {
return

View File

@ -17,7 +17,7 @@ const POD = "pod"
func init() {
Index.MergeCommands(ice.Commands{
web.PP(POD): {Name: "/pod/", Help: "节点", Actions: ice.MergeActions(ctx.CmdAction(), aaa.RoleAction()), Hand: func(m *ice.Message, arg ...string) {
web.PP(POD): {Name: "/pod/", Help: "节点", Actions: ice.MergeActions(ctx.CmdAction(), aaa.WhiteAction()), 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

View File

@ -24,13 +24,11 @@ func _river_list(m *ice.Message) {
return
}
}
m.Debug("what %v", m.FormatsMeta())
m.Cmd(mdb.SELECT, m.PrefixKey(), "", mdb.HASH, ice.OptionFields(mdb.HASH, mdb.NAME), func(value ice.Maps) {
if _river_right(m, value[mdb.HASH]) {
m.PushRecord(value, mdb.HASH, mdb.NAME)
}
})
m.Debug("what %v", m.FormatsMeta())
}
const (
@ -62,7 +60,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"), aaa.RoleAction()), Hand: func(m *ice.Message, arg ...string) {
}, mdb.HashAction(mdb.FIELD, "time,hash,type,name,text,template"), aaa.WhiteAction()), Hand: func(m *ice.Message, arg ...string) {
if m.Warn(m.Option(ice.MSG_USERNAME) == "", ice.ErrNotLogin) {
m.RenderStatusUnauthorized()
return

View File

@ -13,7 +13,7 @@ const SSO = "sso"
func init() {
Index.MergeCommands(ice.Commands{
web.P(SSO): {Name: "/sso", Help: "授权", Actions: aaa.RoleAction(), Hand: func(m *ice.Message, arg ...string) {
web.P(SSO): {Name: "/sso", Help: "授权", Actions: aaa.WhiteAction(), Hand: func(m *ice.Message, arg ...string) {
if m.Option(ice.MSG_USERNAME) == "" {
web.RenderIndex(m, ice.VOLCANOS)
return

View File

@ -74,7 +74,7 @@ func init() {
"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)))
}},
}, mdb.ZoneAction(mdb.FIELD, "time,id,tags,type,name,value"), aaa.RoleAction()), Hand: func(m *ice.Message, arg ...string) {
}, mdb.ZoneAction(mdb.FIELD, "time,id,tags,type,name,value"), aaa.WhiteAction()), 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)

View File

@ -231,7 +231,7 @@ 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(), aaa.RoleAction()), 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.WhiteAction()), Hand: func(m *ice.Message, arg ...string) {
mdb.HashSelect(m, arg...).Tables(func(value ice.Maps) { m.PushAnchor(web.MergePodWebSite(m, "", value[nfs.PATH])) })
}},
})

View File

@ -139,7 +139,7 @@ func init() {
}
m.Cmd(FAVOR, mdb.INSERT, mdb.ZONE, "_recent_cmd", nfs.FILE, arg[0])
}},
}, ctx.CmdAction(), aaa.RoleAction(ice.SRC_MAIN_GO)), Hand: func(m *ice.Message, arg ...string) {
}, ctx.CmdAction(), aaa.RoleAction()), 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])

View File

@ -123,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)))
}},
}, aaa.RoleAction(ice.USR_PUBLISH)), Hand: func(m *ice.Message, arg ...string) {
}, aaa.RoleAction()), 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)
}},

View File

@ -41,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(), aaa.RoleAction(ice.SRC_MAIN_SHY)), Hand: func(m *ice.Message, arg ...string) {
}, WikiAction("", nfs.SHY), ctx.CmdAction(), aaa.RoleAction()), Hand: func(m *ice.Message, arg ...string) {
if m.Option(nfs.DIR_DEEP, ice.TRUE); len(arg) == 0 {
arg = append(arg, "src/")
}

View File

@ -78,6 +78,12 @@ func (m *Message) PushDetail(value Any, arg ...string) *Message {
return m.Push(FIELDS_DETAIL, value, kit.Split(kit.Join(arg)))
}
func (m *Message) Options(arg ...Any) *Message {
for i := 0; i < len(arg); i += 2 {
m.Option(kit.Format(arg[i]), arg[i+1])
}
return m
}
func (m *Message) OptionMulti(arg ...Any) *Message {
for i := 0; i < len(arg); i += 2 {
m.Option(kit.Format(arg[i]), arg[i+1])