diff --git a/base/aaa/role.go b/base/aaa/role.go index e106409a..d5cc6ec3 100644 --- a/base/aaa/role.go +++ b/base/aaa/role.go @@ -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 { diff --git a/base/nfs/cat.go b/base/nfs/cat.go index 8af95fe2..6b605b8e 100644 --- a/base/nfs/cat.go +++ b/base/nfs/cat.go @@ -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 diff --git a/base/web/serve.go b/base/web/serve.go index 775e49c8..b890f34a 100644 --- a/base/web/serve.go +++ b/base/web/serve.go @@ -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 // 定制主页 diff --git a/conf.go b/conf.go index 9d9bc524..ea33aafc 100644 --- a/conf.go +++ b/conf.go @@ -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" diff --git a/core/chat/action.go b/core/chat/action.go index 71844c9c..c7e7900e 100644 --- a/core/chat/action.go +++ b/core/chat/action.go @@ -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 } diff --git a/core/chat/cmd.go b/core/chat/cmd.go index c190c444..1ff44f82 100644 --- a/core/chat/cmd.go +++ b/core/chat/cmd.go @@ -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 diff --git a/core/chat/pod.go b/core/chat/pod.go index 325851ad..22d71479 100644 --- a/core/chat/pod.go +++ b/core/chat/pod.go @@ -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 diff --git a/core/chat/river.go b/core/chat/river.go index 21049b43..2570ad8e 100644 --- a/core/chat/river.go +++ b/core/chat/river.go @@ -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 diff --git a/core/chat/sso.go b/core/chat/sso.go index 32b58990..06c6a41e 100644 --- a/core/chat/sso.go +++ b/core/chat/sso.go @@ -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 diff --git a/core/chat/topic.go b/core/chat/topic.go index 443565a8..7462d0a1 100644 --- a/core/chat/topic.go +++ b/core/chat/topic.go @@ -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) diff --git a/core/chat/website.go b/core/chat/website.go index e5eae6dd..4f038a18 100644 --- a/core/chat/website.go +++ b/core/chat/website.go @@ -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])) }) }}, }) diff --git a/core/code/inner.go b/core/code/inner.go index d9cff323..d113052b 100644 --- a/core/code/inner.go +++ b/core/code/inner.go @@ -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]) diff --git a/core/code/publish.go b/core/code/publish.go index 45b9e0e2..667023b5 100644 --- a/core/code/publish.go +++ b/core/code/publish.go @@ -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) }}, diff --git a/core/wiki/word.go b/core/wiki/word.go index 0e99befe..3057900d 100644 --- a/core/wiki/word.go +++ b/core/wiki/word.go @@ -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/") } diff --git a/misc.go b/misc.go index 34a35d47..39033288 100644 --- a/misc.go +++ b/misc.go @@ -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])