forked from x/icebergs
add some
This commit is contained in:
parent
fa158fa9ac
commit
830da6b46c
@ -1,6 +1,8 @@
|
|||||||
package aaa
|
package aaa
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"strings"
|
||||||
|
|
||||||
ice "shylinux.com/x/icebergs"
|
ice "shylinux.com/x/icebergs"
|
||||||
"shylinux.com/x/icebergs/base/mdb"
|
"shylinux.com/x/icebergs/base/mdb"
|
||||||
kit "shylinux.com/x/toolkits"
|
kit "shylinux.com/x/toolkits"
|
||||||
@ -14,12 +16,19 @@ const APPLY = "apply"
|
|||||||
const OFFER = "offer"
|
const OFFER = "offer"
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
|
const (
|
||||||
|
SUBJECT_HTML = "subject.html"
|
||||||
|
CONTENT_HTML = "content.html"
|
||||||
|
)
|
||||||
Index.MergeCommands(ice.Commands{
|
Index.MergeCommands(ice.Commands{
|
||||||
OFFER: {Help: "邀请", Role: VOID, Actions: ice.MergeActions(ice.Actions{
|
OFFER: {Help: "邀请", Role: VOID, Actions: ice.MergeActions(ice.Actions{
|
||||||
mdb.CREATE: {Name: "create email*='shy@shylinux.com' subject content", Help: "邀请", Hand: func(m *ice.Message, arg ...string) {
|
mdb.CREATE: {Name: "create email*='shy@shylinux.com' subject content", Help: "邀请", Hand: func(m *ice.Message, arg ...string) {
|
||||||
h := mdb.HashCreate(m.Spawn(), m.OptionSimple(EMAIL, SUBJECT, CONTENT), INVITE, m.Option(ice.MSG_USERNAME), mdb.STATUS, INVITE)
|
h := mdb.HashCreate(m.Spawn(), m.OptionSimple(EMAIL, SUBJECT, CONTENT), INVITE, m.Option(ice.MSG_USERNAME), mdb.STATUS, INVITE)
|
||||||
m.Cmd(EMAIL, SEND, mdb.Config(m, EMAIL), m.Option(EMAIL), "", m.OptionDefault(SUBJECT, "welcome to contexts, please continue"),
|
m.Option("link", m.Cmdx("host", "publish", m.MergePodCmd("", "", mdb.HASH, h)))
|
||||||
m.OptionDefault(CONTENT, ice.Render(m, ice.RENDER_ANCHOR, m.Cmdx("host", "publish", m.MergePodCmd("", "", mdb.HASH, h)))),
|
m.Option(ice.MSG_USERHOST, strings.Split(m.Option(ice.MSG_USERHOST), "://")[1])
|
||||||
|
m.Cmd(EMAIL, SEND, mdb.Config(m, EMAIL), m.Option(EMAIL), "",
|
||||||
|
m.OptionDefault(SUBJECT, ice.Render(m, ice.RENDER_TEMPLATE, SUBJECT_HTML)),
|
||||||
|
m.OptionDefault(CONTENT, ice.Render(m, ice.RENDER_TEMPLATE, CONTENT_HTML)),
|
||||||
)
|
)
|
||||||
}},
|
}},
|
||||||
ACCEPT: {Help: "接受", Role: VOID, Hand: func(m *ice.Message, arg ...string) {
|
ACCEPT: {Help: "接受", Role: VOID, Hand: func(m *ice.Message, arg ...string) {
|
||||||
@ -38,7 +47,8 @@ func init() {
|
|||||||
m.Echo("please add admin email")
|
m.Echo("please add admin email")
|
||||||
} else if !m.Warn(len(arg) == 0 && m.Option(ice.MSG_USERROLE) == VOID, ice.ErrNotRight) {
|
} else if !m.Warn(len(arg) == 0 && m.Option(ice.MSG_USERROLE) == VOID, ice.ErrNotRight) {
|
||||||
kit.If(mdb.HashSelect(m, arg...).FieldsIsDetail(), func() {
|
kit.If(mdb.HashSelect(m, arg...).FieldsIsDetail(), func() {
|
||||||
m.SetAppend().EchoInfoButton("welcome to contexts, please continue", ACCEPT)
|
m.Option(ice.MSG_USERHOST, strings.Split(m.Option(ice.MSG_USERHOST), "://")[1])
|
||||||
|
m.SetAppend().EchoInfoButton(ice.Render(m, ice.RENDER_TEMPLATE, SUBJECT_HTML), ACCEPT)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}},
|
}},
|
||||||
|
@ -11,7 +11,13 @@ const TEMPLATE = "template"
|
|||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
Index.MergeCommands(ice.Commands{
|
Index.MergeCommands(ice.Commands{
|
||||||
TEMPLATE: {Name: "template index path auto", Help: "模板", Actions: ice.MergeActions(ice.Actions{}), Hand: func(m *ice.Message, arg ...string) {
|
TEMPLATE: {Name: "template index path auto", Help: "模板", Actions: ice.MergeActions(ice.Actions{
|
||||||
|
ice.CTX_INIT: {Hand: func(m *ice.Message, arg ...string) {
|
||||||
|
ice.AddRender(ice.RENDER_TEMPLATE, func(m *ice.Message, args ...ice.Any) string {
|
||||||
|
return Template(m, kit.Format(args[0]), args[1:]...)
|
||||||
|
})
|
||||||
|
}},
|
||||||
|
}), Hand: func(m *ice.Message, arg ...string) {
|
||||||
if len(arg) == 0 {
|
if len(arg) == 0 {
|
||||||
m.Cmdy(ice.COMMAND).Action("filter:text").Option(ice.MSG_DISPLAY, "")
|
m.Cmdy(ice.COMMAND).Action("filter:text").Option(ice.MSG_DISPLAY, "")
|
||||||
return
|
return
|
||||||
|
@ -135,6 +135,7 @@ func _serve_handle(key string, cmd *ice.Command, m *ice.Message, w http.Response
|
|||||||
kit.If(m.Optionv(ice.MSG_CMDS) == nil, func() {
|
kit.If(m.Optionv(ice.MSG_CMDS) == nil, func() {
|
||||||
kit.If(strings.TrimPrefix(r.URL.Path, key), func(p string) { m.Optionv(ice.MSG_CMDS, strings.Split(p, nfs.PS)) })
|
kit.If(strings.TrimPrefix(r.URL.Path, key), func(p string) { m.Optionv(ice.MSG_CMDS, strings.Split(p, nfs.PS)) })
|
||||||
})
|
})
|
||||||
|
UserHost(m)
|
||||||
m.W.Header().Add(strings.ReplaceAll(ice.LOG_TRACEID, ".", "-"), m.Option(ice.LOG_TRACEID))
|
m.W.Header().Add(strings.ReplaceAll(ice.LOG_TRACEID, ".", "-"), m.Option(ice.LOG_TRACEID))
|
||||||
defer func() { Render(m, m.Option(ice.MSG_OUTPUT), kit.List(m.Optionv(ice.MSG_ARGS))...) }()
|
defer func() { Render(m, m.Option(ice.MSG_OUTPUT), kit.List(m.Optionv(ice.MSG_ARGS))...) }()
|
||||||
if cmds, ok := _serve_auth(m, key, kit.Simple(m.Optionv(ice.MSG_CMDS)), w, r); ok {
|
if cmds, ok := _serve_auth(m, key, kit.Simple(m.Optionv(ice.MSG_CMDS)), w, r); ok {
|
||||||
|
@ -27,7 +27,8 @@ func (m *Message) OptionSimple(key ...string) (res []string) {
|
|||||||
kit.If(len(key) == 0, func() {
|
kit.If(len(key) == 0, func() {
|
||||||
key = kit.Filters(kit.Split(kit.Select("type,name,text", m.Conf(m.PrefixKey(), kit.Keym(FIELD)))), TIME, HASH)
|
key = kit.Filters(kit.Split(kit.Select("type,name,text", m.Conf(m.PrefixKey(), kit.Keym(FIELD)))), TIME, HASH)
|
||||||
})
|
})
|
||||||
kit.For(kit.Filters(kit.Split(kit.Join(key)), ""), func(k string) { kit.If(m.Option(k), func(v string) { res = append(res, k, v) }) })
|
// kit.For(kit.Filters(kit.Split(kit.Join(key)), ""), func(k string) { kit.If(m.Option(k), func(v string) { res = append(res, k, v) }) })
|
||||||
|
kit.For(kit.Filters(kit.Split(kit.Join(key)), ""), func(k string) { res = append(res, k, m.Option(k)) })
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
func (m *Message) OptionSplit(key ...string) (res []string) {
|
func (m *Message) OptionSplit(key ...string) (res []string) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user