1
0
mirror of https://shylinux.com/x/icebergs synced 2025-06-26 18:37:29 +08:00
This commit is contained in:
harveyshao 2022-11-15 10:42:31 +08:00
parent 5b3b3df314
commit a6f0a18bf4
7 changed files with 26 additions and 31 deletions

View File

@ -166,8 +166,11 @@ func RenderCmd(m *ice.Message, index string, args ...ice.Any) {
} }
m.Echo(kit.Format(_cmd_template, list)).RenderResult() m.Echo(kit.Format(_cmd_template, list)).RenderResult()
} }
func RenderMain(m *ice.Message, index string, args ...ice.Any) *ice.Message { func RenderMain(m *ice.Message, pod, index string, args ...ice.Any) *ice.Message {
return m.Echo(kit.Format(_main_template, m.Cmdx(nfs.CAT, index))).RenderResult() if script := m.Cmdx(Space(m, pod), nfs.CAT, kit.Select(ice.SRC_MAIN_JS, index)); script != "" {
return m.Echo(kit.Format(_main_template, script)).RenderResult()
}
return RenderIndex(m, ice.VOLCANOS)
} }
var _cmd_template = `<!DOCTYPE html> var _cmd_template = `<!DOCTYPE html>

View File

@ -36,13 +36,7 @@ func _serve_rewrite(m *ice.Message) {
switch r.URL.Path { switch r.URL.Path {
case ice.PS: case ice.PS:
if repos == ice.VOLCANOS { if repos == ice.VOLCANOS {
if nfs.ExistsFile(m, ice.SRC_MAIN_JS) { return Render(msg, ice.RENDER_RESULT, RenderMain(msg, "", "").Result())
RenderMain(msg, ice.SRC_MAIN_JS)
return Render(msg, ice.RENDER_RESULT, msg.Result())
}
if s := msg.Cmdx("web.chat.website", lex.PARSE, ice.INDEX_IML, "Header", "", "River", "", "Footer", ""); s != "" {
return Render(msg, ice.RENDER_RESULT, s)
}
} }
return Render(msg, ice.RENDER_DOWNLOAD, path.Join(msg.Config(kit.Keys(repos, nfs.PATH)), msg.Config(kit.Keys(repos, INDEX)))) return Render(msg, ice.RENDER_DOWNLOAD, path.Join(msg.Config(kit.Keys(repos, nfs.PATH)), msg.Config(kit.Keys(repos, INDEX))))

View File

@ -16,6 +16,7 @@ import (
"shylinux.com/x/icebergs/base/ssh" "shylinux.com/x/icebergs/base/ssh"
"shylinux.com/x/icebergs/base/tcp" "shylinux.com/x/icebergs/base/tcp"
kit "shylinux.com/x/toolkits" kit "shylinux.com/x/toolkits"
"shylinux.com/x/toolkits/logs"
"shylinux.com/x/toolkits/file" "shylinux.com/x/toolkits/file"
) )
@ -163,8 +164,9 @@ func init() {
}}, }},
PP(SHARE): {Name: "/share/", Help: "共享链", Hand: func(m *ice.Message, arg ...string) { PP(SHARE): {Name: "/share/", Help: "共享链", Hand: func(m *ice.Message, arg ...string) {
msg := m.Cmd(SHARE, m.Option(SHARE, kit.Select(m.Option(SHARE), arg, 0))) msg := m.Cmd(SHARE, m.Option(SHARE, kit.Select(m.Option(SHARE), arg, 0)))
if kit.Int(msg.Append(mdb.TIME)) < kit.Int(msg.Time()) { if m.Warn(msg.Append(mdb.TIME) < msg.Time(), ice.ErrNotValid, kit.Select(m.Option(SHARE), arg, 0), msg.Append(mdb.TIME)) {
m.RenderResult("共享超时") m.RenderResult(kit.Format("共享超时, 请联系 %s(%s), 重新分享 %s %s",
msg.Append(aaa.USERNAME), msg.Append(aaa.USERNICK), msg.Append(mdb.TYPE), msg.Append(mdb.NAME)))
return return
} }
switch msg.Append(mdb.TYPE) { switch msg.Append(mdb.TYPE) {
@ -198,3 +200,11 @@ func init() {
}}, }},
}) })
} }
func IsNotValidShare(m *ice.Message, value ice.Maps) bool {
_source := logs.FileLineMeta(logs.FileLine(2, 3))
if m.Warn(value[mdb.TIME] < m.Time(), ice.ErrNotValid, m.Option(SHARE), value[mdb.TIME], m.Time(), _source) {
return true
}
return false
}

View File

@ -31,7 +31,7 @@ func _action_exec(m *ice.Message, river, storm, index string, arg ...string) {
} }
func _action_auth(m *ice.Message, share string) *ice.Message { func _action_auth(m *ice.Message, share string) *ice.Message {
msg := m.Cmd(web.SHARE, share) msg := m.Cmd(web.SHARE, share)
if m.Warn(msg.Append(mdb.TIME) < m.Time(), ice.ErrNotValid) { if m.Warn(msg.Append(mdb.TIME) < m.Time(), ice.ErrNotValid, share, msg.Append(mdb.TIME), m.Time()) {
msg.Append(mdb.TYPE, "") msg.Append(mdb.TYPE, "")
return msg return msg
} }
@ -77,12 +77,12 @@ const ACTION = "action"
func init() { func init() {
Index.MergeCommands(ice.Commands{ Index.MergeCommands(ice.Commands{
web.P(ACTION): {Name: "/action river storm action arg...", Help: "工作台", Actions: ice.MergeActions(ice.Actions{ web.P(ACTION): {Name: "/action", Help: "工作台", Actions: ice.MergeActions(ice.Actions{
mdb.MODIFY: {Hand: func(m *ice.Message, arg ...string) { mdb.MODIFY: {Hand: func(m *ice.Message, arg ...string) {
m.Cmdy(mdb.MODIFY, RIVER, _storm_key(m), mdb.LIST, m.OptionSimple(mdb.ID), arg) 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...) }}, web.SHARE: {Hand: func(m *ice.Message, arg ...string) { _action_share(m, arg...) }},
}, ctx.CmdAction(), aaa.WhiteAction()), Hand: func(m *ice.Message, arg ...string) { }, ctx.CmdAction(), aaa.WhiteAction(ctx.COMMAND, ice.RUN)), Hand: func(m *ice.Message, arg ...string) {
if m.Warn(m.Option(ice.MSG_USERNAME) == "", ice.ErrNotLogin, arg) { if m.Warn(m.Option(ice.MSG_USERNAME) == "", ice.ErrNotLogin, arg) {
return return
} }

View File

@ -36,15 +36,10 @@ func _header_share(m *ice.Message, arg ...string) {
func _header_check(m *ice.Message, arg ...string) bool { func _header_check(m *ice.Message, arg ...string) bool {
if m.Option(web.SHARE) != "" { if m.Option(web.SHARE) != "" {
m.Cmd(web.SHARE, m.Option(web.SHARE), ice.OptionFields(""), func(value ice.Maps) { m.Cmd(web.SHARE, m.Option(web.SHARE), ice.OptionFields(""), func(value ice.Maps) {
if m.Warn(value[mdb.TIME] < m.Time(), ice.ErrNotValid, m.Option(web.SHARE), value[mdb.TIME], m.Time()) { if web.IsNotValidShare(m, value) {
return return
} }
switch value[mdb.TYPE] { switch value[mdb.TYPE] {
case web.LOGIN:
if value[aaa.USERNAME] != m.Option(ice.MSG_USERNAME) {
web.RenderCookie(m, aaa.SessCreate(m, value[aaa.USERNAME]))
}
fallthrough
case web.STORM, web.FIELD: case web.STORM, web.FIELD:
aaa.SessAuth(m, value) aaa.SessAuth(m, value)
} }
@ -53,8 +48,8 @@ func _header_check(m *ice.Message, arg ...string) bool {
if m.Option(ice.MSG_USERNAME) != "" { if m.Option(ice.MSG_USERNAME) != "" {
return true return true
} }
if m.OptionFromConfig(web.SSO) == "" && m.Option("login.dev", m.CmdAppend(web.SPACE, ice.DEV, mdb.TEXT)) == "" { if m.OptionFromConfig(web.SSO) == "" && m.Option(ice.DEV, m.CmdAppend(web.SPACE, ice.DEV, mdb.TEXT)) == "" {
if m.Option("login.dev", m.CmdAppend(web.SPACE, ice.SHY, mdb.TEXT)) == "" { if m.Option(ice.DEV, m.CmdAppend(web.SPACE, ice.SHY, mdb.TEXT)) == "" {
m.OptionFromConfig(web.LOGIN) m.OptionFromConfig(web.LOGIN)
} }
} }

View File

@ -28,10 +28,7 @@ func init() {
if m.Cmd(web.SPACE, arg[0]).Length() == 0 && !strings.Contains(arg[0], ice.PT) { 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) web.RenderMain(aaa.UserRoot(m), arg[0], "")
if web.RenderWebsite(m, arg[0], ice.INDEX_IML, "Header", "", "River", "", "Footer", ""); m.Result() == "" {
web.RenderIndex(m, ice.VOLCANOS)
}
} else if arg[1] == CMD { } 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 { } else if arg[1] == WEBSITE {

View File

@ -38,7 +38,7 @@ const RIVER = "river"
func init() { func init() {
Index.MergeCommands(ice.Commands{ Index.MergeCommands(ice.Commands{
web.P(RIVER): {Name: "/river hash auto create", Help: "群组", Actions: ice.MergeActions(ice.Actions{ web.P(RIVER): {Name: "/river", Help: "群组", Actions: ice.MergeActions(ice.Actions{
mdb.INPUTS: {Hand: func(m *ice.Message, arg ...string) { mdb.INPUTS: {Hand: func(m *ice.Message, arg ...string) {
switch arg[0] { switch arg[0] {
case nfs.TEMPLATE: case nfs.TEMPLATE:
@ -56,10 +56,6 @@ func init() {
} }
gdb.Event(m, RIVER_CREATE, RIVER, m.Option(ice.MSG_RIVER, h), arg) gdb.Event(m, RIVER_CREATE, RIVER, m.Option(ice.MSG_RIVER, h), arg)
}}, }},
RIVER_CREATE: {Name: "river.create", Hand: func(m *ice.Message, arg ...string) {
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.WhiteAction()), 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) { if m.Warn(m.Option(ice.MSG_USERNAME) == "", ice.ErrNotLogin) {
m.RenderStatusUnauthorized() m.RenderStatusUnauthorized()