forked from x/icebergs
61 lines
1.8 KiB
Go
61 lines
1.8 KiB
Go
package wx
|
|
|
|
import (
|
|
ice "shylinux.com/x/icebergs"
|
|
"shylinux.com/x/icebergs/base/mdb"
|
|
"shylinux.com/x/icebergs/base/web"
|
|
"shylinux.com/x/icebergs/core/wiki"
|
|
kit "shylinux.com/x/toolkits"
|
|
)
|
|
|
|
func _wx_action(m *ice.Message) {
|
|
m.Set(ice.MSG_RESULT).RenderResult()
|
|
|
|
m.Echo(`<xml>
|
|
<FromUserName><![CDATA[%s]]></FromUserName>
|
|
<ToUserName><![CDATA[%s]]></ToUserName>
|
|
<CreateTime>%s</CreateTime>
|
|
<MsgType><![CDATA[%s]]></MsgType>
|
|
`, m.Option("ToUserName"), m.Option("FromUserName"), m.Option("CreateTime"), "news")
|
|
|
|
count := 0
|
|
m.Table(func(index int, value map[string]string, head []string) { count++ })
|
|
m.Echo(`<ArticleCount>%d</ArticleCount>`, count)
|
|
|
|
share := m.Cmdx(web.SHARE, mdb.CREATE, kit.MDB_TYPE, web.LOGIN)
|
|
|
|
m.Echo(`<Articles>`)
|
|
m.Table(func(index int, value map[string]string, head []string) {
|
|
m.Echo(`<item>
|
|
<Title><![CDATA[%s]]></Title>
|
|
<Description><![CDATA[%s]]></Description>
|
|
<PicUrl><![CDATA[%s]]></PicUrl>
|
|
<Url><![CDATA[%s]]></Url>
|
|
</item>
|
|
`, value[wiki.TITLE], value[wiki.SPARK], value[wiki.IMAGE],
|
|
kit.MergeURL(kit.Format(value[wiki.REFER]), web.SHARE, share))
|
|
})
|
|
m.Echo(`</Articles>`)
|
|
m.Echo(`</xml>`)
|
|
|
|
m.Debug("echo: %v", m.Result())
|
|
}
|
|
|
|
const MENU = "menu"
|
|
|
|
func init() {
|
|
Index.Merge(&ice.Context{Configs: map[string]*ice.Config{
|
|
MENU: {Name: MENU, Help: "菜单", Value: kit.Data(
|
|
kit.MDB_SHORT, kit.MDB_ZONE, kit.MDB_FIELD, "time,id,title,refer,image",
|
|
)},
|
|
}, Commands: map[string]*ice.Command{
|
|
MENU: {Name: "menu zone id auto insert", Help: "菜单", Action: ice.MergeAction(map[string]*ice.Action{
|
|
mdb.INSERT: {Name: "insert zone=home title=hi refer=hello image", Help: "添加"},
|
|
}, mdb.ZoneAction()), Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
|
|
if mdb.ZoneSelect(m, arg...); len(arg) > 0 {
|
|
_wx_action(m)
|
|
}
|
|
}},
|
|
}})
|
|
}
|