1
0
forked from x/icebergs
This commit is contained in:
harveyshao 2021-12-01 17:37:59 +08:00
parent 3ea5de2480
commit 10c34585c2
2 changed files with 81 additions and 10 deletions

View File

@ -1,6 +1,7 @@
package chat
import (
"encoding/json"
"path"
"strings"
@ -28,10 +29,25 @@ func init() {
Index.Merge(&ice.Context{Configs: map[string]*ice.Config{
DIV: {Name: "div", Help: "定制", Value: kit.Data(
kit.MDB_FIELD, "time,hash,type,name,text", kit.MDB_PATH, ice.USR_PUBLISH,
kit.MDB_TEMPLATE, _div_template,
)},
}, Commands: map[string]*ice.Command{
"/div/": {Name: "/div/", Help: "定制", Action: ice.MergeAction(ctx.CmdAction()), Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
m.RenderCmd(m.PrefixKey(), path.Join(arg...))
switch p := path.Join(arg...); kit.Ext(kit.Select("", p)) {
case "html":
m.RenderDownload(p)
case "css":
m.RenderResult(_div_template, m.Cmdx(nfs.CAT, p), m.Cmdx(nfs.CAT, strings.ReplaceAll(p, ".css", ".js")))
case "js":
m.RenderResult(_div_template, m.Cmdx(nfs.CAT, strings.ReplaceAll(p, ".js", ".css")), m.Cmdx(nfs.CAT, p))
case "json":
var res interface{}
err := json.Unmarshal([]byte(m.Cmdx(nfs.CAT, p)), &res)
m.Assert(err)
m.RenderResult(_div_template2, kit.Format(res))
default:
m.RenderCmd(m.PrefixKey(), p)
}
}},
DIV: {Name: "div hash auto", Help: "定制", Action: ice.MergeAction(map[string]*ice.Action{
lex.SPLIT: {Name: "split name=hi text", Help: "生成", Hand: func(m *ice.Message, arg ...string) {
@ -40,18 +56,73 @@ func init() {
}},
mdb.CREATE: {Name: "create type=page name=hi text", Help: "创建"},
}, mdb.HashAction(), ctx.CmdAction()), Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
if len(arg) > 0 && strings.HasSuffix(arg[0], ".shy") {
switch kit.Ext(kit.Select("", arg, 0)) {
case "shy":
m.Fields(0)
m.Option(ice.MSG_DISPLAY, "/plugin/local/chat/div.js")
m.Push(kit.MDB_TEXT, _div_parse(m, m.Cmdx(nfs.CAT, arg[0])))
return
}
if mdb.HashSelect(m, arg...); len(arg) > 0 {
m.Option(ice.MSG_DISPLAY, "/plugin/local/chat/div.js")
m.Action("添加", "保存", "预览")
} else {
m.Action(lex.SPLIT, mdb.CREATE)
default:
if mdb.HashSelect(m, arg...); len(arg) > 0 {
m.Option(ice.MSG_DISPLAY, "/plugin/local/chat/div.js")
m.Action("添加", "保存", "预览")
} else {
m.Action(lex.SPLIT, mdb.CREATE)
}
}
}},
}})
}
var _div_template = `<!DOCTYPE html>
<head>
<meta charset="utf-8">
<title>volcanos</title>
<link rel="shortcut icon" type="image/ico" href="/favicon.ico">
<link rel="stylesheet" type="text/css" href="/page/cache.css">
<link rel="stylesheet" type="text/css" href="/page/index.css">
<style type="text/css">%s</style>
</head>
<body>
<script src="/proto.js"></script>
<script src="/page/cache.js"></script>
<script>%s</script>
</body>
`
var _div_template2 = `<!DOCTYPE html>
<head>
<meta charset="utf-8">
<title>volcanos</title>
<link rel="shortcut icon" type="image/ico" href="/favicon.ico">
<link rel="stylesheet" type="text/css" href="/page/cache.css">
<link rel="stylesheet" type="text/css" href="/page/index.css">
</head>
<body>
<script src="/proto.js"></script>
<script src="/page/cache.js"></script>
<script>
Volcanos({name: "chat", panels: [
{name: "Header", help: "标题栏", pos: chat.HEAD, state: ["time", "usernick", "avatar"]},
{name: "River", help: "群聊组", pos: chat.LEFT, action: ["create", "refresh"]},
{name: "Action", help: "工作台", pos: chat.MAIN},
{name: "Search", help: "搜索框", pos: chat.AUTO},
{name: "Footer", help: "状态条", pos: chat.FOOT, state: ["ncmd"]},
], main: {name: "Header", list: ["/publish/order.js"]}, plugin: [
"/plugin/state.js",
"/plugin/input.js",
"/plugin/table.js",
"/plugin/input/key.js",
"/plugin/input/date.js",
"/plugin/story/spide.js",
"/plugin/story/trend.js",
"/plugin/local/code/inner.js",
"/plugin/local/code/vimer.js",
"/plugin/local/wiki/draw/path.js",
"/plugin/local/wiki/draw.js",
"/plugin/local/wiki/word.js",
"/plugin/local/chat/div.js",
"/plugin/local/team/plan.js",
"/plugin/input/province.js",
], river: JSON.parse('%s')})
</script>
</body>
`

View File

@ -18,7 +18,7 @@ func init() {
kit.MDB_PATH, ice.USR_LOCAL_IMAGE, kit.MDB_REGEXP, ".*.(png|PNG|jpg|JPG|jpeg|mp4|m4v|MOV)",
)},
}, Commands: map[string]*ice.Command{
FEEL: {Name: "feel path auto upload 上一页 下一页 参数", Help: "影音媒体", Meta: kit.Dict(
FEEL: {Name: "feel path auto upload 上一页 下一页 actions", Help: "影音媒体", Meta: kit.Dict(
ice.Display("/plugin/local/wiki/feel.js"),
), Action: map[string]*ice.Action{
web.UPLOAD: {Name: "upload", Help: "上传", Hand: func(m *ice.Message, arg ...string) {