diff --git a/base/ctx/command.go b/base/ctx/command.go
index b48b38fa..fa64a9cd 100644
--- a/base/ctx/command.go
+++ b/base/ctx/command.go
@@ -47,6 +47,9 @@ func _command_search(m *ice.Message, kind, name, text string) {
})
}
+const (
+ ACTION = "action"
+)
const COMMAND = "command"
func init() {
diff --git a/base/ssh/scripts.go b/base/ssh/scripts.go
index 9646b545..931d419e 100644
--- a/base/ssh/scripts.go
+++ b/base/ssh/scripts.go
@@ -225,7 +225,7 @@ func (f *Frame) parse(m *ice.Message, line string) string {
msg.Cmdy(ls[0], ls[1:])
}
- if strings.HasPrefix(msg.Result(), ice.ErrWarn) && m.Option("render") == "raw" {
+ if strings.HasPrefix(msg.Result(), ice.ErrWarn) && m.Option(ice.MSG_RENDER) == ice.RENDER_RAW {
fmt.Fprintf(msg.O, line)
continue
}
diff --git a/conf.go b/conf.go
index 0e974076..b1668063 100644
--- a/conf.go
+++ b/conf.go
@@ -87,6 +87,7 @@ const ( // MSG
MSG_SOURCE = "_source"
MSG_TARGET = "_target"
MSG_HANDLE = "_handle"
+ MSG_RENDER = "_render"
MSG_OUTPUT = "_output"
MSG_ARGS = "_args"
@@ -122,6 +123,7 @@ const ( // MSG
MSG_TOAST = "sess.toast"
)
const ( // RENDER
+ RENDER_RAW = "_raw"
RENDER_VOID = "_void"
RENDER_RESULT = "_result"
RENDER_ANCHOR = "_anchor"
diff --git a/core/chat/meet.go b/core/chat/meet.go
index 2d847383..2ec9796f 100644
--- a/core/chat/meet.go
+++ b/core/chat/meet.go
@@ -27,7 +27,7 @@ func init() {
ice.CTX_EXIT: {Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) { m.Save() }},
MEDIA: {Name: "media name auto open snapshot", Help: "视频会议", Meta: kit.Dict(
- "display", "/plugin/local/chat/media.js",
+ ice.Display("/plugin/local/chat/media.js"),
), Action: map[string]*ice.Action{
tcp.OPEN: {Name: "open", Help: "打开摄相头", Hand: func(m *ice.Message, arg ...string) {
m.Cmdy(mdb.IMPORT, m.Prefix(MISS), "", mdb.HASH)
diff --git a/core/team/count.go b/core/team/count.go
index 1a131c9c..1fa53d77 100644
--- a/core/team/count.go
+++ b/core/team/count.go
@@ -13,7 +13,9 @@ const COUNT = "count"
func init() {
Index.Merge(&ice.Context{Commands: map[string]*ice.Command{
- COUNT: {Name: "count begin_time@date end_time@date auto insert", Help: "倒计时", Meta: kit.Dict(kit.MDB_DISPLAY, COUNT), Action: map[string]*ice.Action{
+ COUNT: {Name: "count begin_time@date end_time@date auto insert", Help: "倒计时", Meta: kit.Dict(
+ ice.Display(COUNT),
+ ), Action: map[string]*ice.Action{
mdb.INSERT: {Name: "insert zone type=once,step,week name text begin_time@date close_time@date", Help: "添加", Hand: func(m *ice.Message, arg ...string) {
m.Cmdy(TASK, mdb.INSERT, arg)
}},
diff --git a/core/team/plan.go b/core/team/plan.go
index bd80538d..1749572a 100644
--- a/core/team/plan.go
+++ b/core/team/plan.go
@@ -36,7 +36,7 @@ func init() {
Index.Merge(&ice.Context{
Commands: map[string]*ice.Command{
PLAN: {Name: "plan scale=day,week,month,year,long begin_time@date auto insert export import", Help: "计划", Meta: kit.Dict(
- kit.MDB_DISPLAY, "/plugin/local/team/plan.js", kit.MDB_STYLE, PLAN,
+ ice.Display("/plugin/local/team/plan.js", PLAN),
), Action: map[string]*ice.Action{
mdb.INSERT: {Name: "insert zone type=once,step,week name text begin_time@date close_time@date", Help: "添加", Hand: func(m *ice.Message, arg ...string) {
_task_create(m, arg[1])
diff --git a/core/wiki/baidu.go b/core/wiki/baidu.go
deleted file mode 100644
index 3438be0d..00000000
--- a/core/wiki/baidu.go
+++ /dev/null
@@ -1,39 +0,0 @@
-package wiki
-
-import (
- ice "github.com/shylinux/icebergs"
- "github.com/shylinux/icebergs/base/mdb"
- kit "github.com/shylinux/toolkits"
-)
-
-func _baidu_show(m *ice.Message, name, text string, arg ...string) {
- _option(m, BAIDU, name, text, arg...)
- // m.Cmdy(mdb.RENDER, web.RENDER.Frame, kit.Format("https://baidu.com/s?wd=%s", text))
-}
-func _baidu_search(m *ice.Message, kind, name, text string) {
- if kit.Contains(kind, "*") || kit.Contains(kind, "baidu") {
- m.PushSearchWeb(BAIDU, name)
- }
-}
-
-const BAIDU = "baidu"
-
-func init() {
- Index.Merge(&ice.Context{
- Configs: map[string]*ice.Config{
- BAIDU: {Name: "baidu", Help: "百度", Value: kit.Data(kit.MDB_SHORT, kit.MDB_TEXT)},
- },
- Commands: map[string]*ice.Command{
- BAIDU: {Name: "baidu [name] word", Help: "百度", Action: map[string]*ice.Action{
- mdb.SEARCH: {Name: "search type name text", Help: "搜索", Hand: func(m *ice.Message, arg ...string) {
- _baidu_search(m, arg[0], arg[1], arg[2])
- }},
- mdb.CREATE: {Name: "create type name text", Help: "创建", Hand: func(m *ice.Message, arg ...string) {
- m.Cmd(mdb.INSERT, m.Prefix(BAIDU), "", mdb.HASH, arg)
- }},
- }, Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
- arg = _name(m, arg)
- _baidu_show(m, arg[0], kit.Select(arg[0], arg[1]), arg[2:]...)
- }},
- }})
-}
diff --git a/core/wiki/chart.go b/core/wiki/chart.go
index 6b6e9658..c242b17e 100644
--- a/core/wiki/chart.go
+++ b/core/wiki/chart.go
@@ -356,3 +356,82 @@ func Stack(m *ice.Message, name string, level int, data interface{}) {
})
m.Echo("")
}
+
+func _chart_show(m *ice.Message, kind, name, text string, arg ...string) {
+ var chart Chart
+ switch kind {
+ case LABEL: // 标签
+ chart = &Label{}
+ case CHAIN: // 链接
+ chart = &Chain{}
+ }
+
+ // 基本参数
+ m.Option(kit.MDB_TYPE, strings.TrimSpace(kind))
+ m.Option(kit.MDB_NAME, strings.TrimSpace(name))
+ m.Option(kit.MDB_TEXT, strings.TrimSpace(text))
+
+ // 扩展参数
+ m.Option("font-size", "24")
+ m.Option("stroke", "blue")
+ m.Option("fill", "yellow")
+ // 扩展参数
+ m.Option("style", "")
+ m.Option("stroke-width", "2")
+ m.Option("font-family", "monospace")
+ // 扩展参数
+ m.Option("compact", "false")
+ m.Option("padding", "10")
+ m.Option("marginx", "10")
+ m.Option("marginy", "10")
+ // m.Option("font-family", kit.Select("", "monospace", len(text) == len([]rune(text))))
+
+ for i := 0; i < len(arg)-1; i++ {
+ m.Option(arg[i], arg[i+1])
+ }
+ if m.Option("bg") != "" {
+ m.Option("fill", m.Option("bg"))
+ }
+ if m.Option("fg") != "" {
+ m.Option("stroke", m.Option("fg"))
+ }
+
+ // 计算尺寸
+ chart.Init(m, m.Option(kit.MDB_TEXT))
+ m.Option("height", chart.GetHeight())
+ m.Option("width", chart.GetWidth())
+
+ // 渲染引擎
+ m.RenderTemplate(m.Conf(CHART, kit.Keym(kit.MDB_TEMPLATE)))
+ defer m.RenderTemplate(m.Conf(CHART, kit.Keym("suffix")))
+ chart.Draw(m, 0, 0)
+}
+
+const (
+ LABEL = "label"
+ CHAIN = "chain"
+)
+const CHART = "chart"
+
+func init() {
+ Index.Merge(&ice.Context{
+ Commands: map[string]*ice.Command{
+ CHART: {Name: "chart label|chain [name] text", Help: "图表", Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
+ if len(arg) == 2 {
+ arg = []string{arg[0], "", arg[1]}
+ }
+ _chart_show(m, arg[0], arg[1], arg[2], arg[3:]...)
+ }},
+ },
+ Configs: map[string]*ice.Config{
+ CHART: {Name: CHART, Help: "图表", Value: kit.Data(
+ kit.MDB_TEMPLATE, ``,
+ )},
+ },
+ })
+}
diff --git a/core/wiki/data.go b/core/wiki/data.go
index cb736da5..764c3ede 100644
--- a/core/wiki/data.go
+++ b/core/wiki/data.go
@@ -6,27 +6,25 @@ import (
kit "github.com/shylinux/toolkits"
)
-func _data_show(m *ice.Message, name string, arg ...string) {
- m.CSV(m.Cmd(nfs.CAT, name).Result())
-}
-
const DATA = "data"
func init() {
Index.Merge(&ice.Context{
Configs: map[string]*ice.Config{
- DATA: {Name: DATA, Help: "数据表格", Value: kit.Data(kit.MDB_PATH, "usr/local/export", kit.MDB_REGEXP, ".*\\.csv")},
+ DATA: {Name: DATA, Help: "数据表格", Value: kit.Data(
+ kit.MDB_PATH, "usr/local/export", kit.MDB_REGEXP, ".*\\.csv",
+ )},
},
Commands: map[string]*ice.Command{
DATA: {Name: "data path auto", Help: "数据表格", Meta: kit.Dict(
- "display", "/plugin/local/wiki/data.js",
+ ice.Display("/plugin/local/wiki/data.js"),
), Action: map[string]*ice.Action{
nfs.SAVE: {Name: "save path text", Help: "保存", Hand: func(m *ice.Message, arg ...string) {
_wiki_save(m, DATA, arg[0], arg[1])
}},
}, Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
if !_wiki_list(m, DATA, kit.Select("./", arg, 0)) {
- _data_show(m, arg[0])
+ m.CSV(m.Cmd(nfs.CAT, arg[0]).Result())
}
}},
},
diff --git a/core/wiki/draw.go b/core/wiki/draw.go
index 93c7a5bb..790949a1 100644
--- a/core/wiki/draw.go
+++ b/core/wiki/draw.go
@@ -1,11 +1,11 @@
package wiki
import (
+ "path"
+
ice "github.com/shylinux/icebergs"
"github.com/shylinux/icebergs/base/nfs"
kit "github.com/shylinux/toolkits"
-
- "path"
)
const DRAW = "draw"
@@ -13,13 +13,15 @@ const DRAW = "draw"
func init() {
Index.Merge(&ice.Context{
Configs: map[string]*ice.Config{
- DRAW: {Name: DRAW, Help: "思维导图", Value: kit.Data(kit.MDB_PATH, "", kit.MDB_REGEXP, ".*\\.svg")},
+ DRAW: {Name: DRAW, Help: "思维导图", Value: kit.Data(
+ kit.MDB_PATH, "", kit.MDB_REGEXP, ".*\\.svg",
+ )},
},
Commands: map[string]*ice.Command{
DRAW: {Name: "draw path=src/ file=main.svg 刷新:button=auto 编辑 save 项目 参数", Help: "思维导图", Meta: kit.Dict(
- "display", "/plugin/local/wiki/draw.js",
+ ice.Display("/plugin/local/wiki/draw.js"),
), Action: map[string]*ice.Action{
- nfs.SAVE: {Name: "save", Help: "保存", Hand: func(m *ice.Message, arg ...string) {
+ nfs.SAVE: {Name: "save path", Help: "保存", Hand: func(m *ice.Message, arg ...string) {
_wiki_save(m, DRAW, path.Join(arg...), m.Option("content"))
}},
}, Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
diff --git a/core/wiki/feel.go b/core/wiki/feel.go
index 8c37d69a..8efcdd17 100644
--- a/core/wiki/feel.go
+++ b/core/wiki/feel.go
@@ -17,7 +17,7 @@ func init() {
},
Commands: map[string]*ice.Command{
FEEL: {Name: "feel path auto upload 上一页 下一页 参数", Help: "影音媒体", Meta: kit.Dict(
- kit.MDB_DISPLAY, "/plugin/local/wiki/feel.js",
+ ice.Display("/plugin/local/wiki/feel.js"),
), Action: map[string]*ice.Action{
web.UPLOAD: {Name: "upload", Help: "上传", Hand: func(m *ice.Message, arg ...string) {
_wiki_upload(m, FEEL, m.Option(kit.MDB_PATH))
diff --git a/core/wiki/image.go b/core/wiki/image.go
index eb9ca2c7..7aec5930 100644
--- a/core/wiki/image.go
+++ b/core/wiki/image.go
@@ -9,18 +9,13 @@ import (
kit "github.com/shylinux/toolkits"
)
-var image = `
`
-
func _image_show(m *ice.Message, name, text string, arg ...string) {
if !strings.HasPrefix(text, "http") && !strings.HasPrefix(text, "/") {
text = path.Join("/share/local", _wiki_path(m, FEEL, text))
}
_option(m, IMAGE, name, text, arg...)
- m.Render(ice.RENDER_TEMPLATE, m.Conf(IMAGE, kit.Keym(kit.MDB_TEMPLATE)))
+ m.RenderTemplate(m.Conf(IMAGE, kit.Keym(kit.MDB_TEMPLATE)))
}
const (
@@ -32,10 +27,10 @@ const IMAGE = "image"
func init() {
Index.Merge(&ice.Context{
- Configs: map[string]*ice.Config{
- IMAGE: {Name: IMAGE, Help: "图片", Value: kit.Data(kit.MDB_TEMPLATE, image)},
- },
Commands: map[string]*ice.Command{
+ ice.CTX_INIT: {Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
+ m.Cmd(mdb.RENDER, mdb.CREATE, PNG, m.Prefix(IMAGE))
+ }},
IMAGE: {Name: "image [name] url", Help: "图片", Action: map[string]*ice.Action{
mdb.RENDER: {Name: "render", Help: "渲染", Hand: func(m *ice.Message, arg ...string) {
_image_show(m, arg[1], path.Join(arg[2], arg[1]))
@@ -45,5 +40,13 @@ func init() {
_image_show(m, arg[0], arg[1], arg[2:]...)
}},
},
+ Configs: map[string]*ice.Config{
+ IMAGE: {Name: IMAGE, Help: "图片", Value: kit.Data(
+ kit.MDB_TEMPLATE, `
`,
+ )},
+ },
})
}
diff --git a/core/wiki/template.go b/core/wiki/template.go
index d0517a70..3e1ef4c3 100644
--- a/core/wiki/template.go
+++ b/core/wiki/template.go
@@ -1,59 +1 @@
package wiki
-
-var premenu = `
`
-var endmenu = `{{$menu := .Optionv "menu"}}{{range $index, $value := Value $menu "list"}}
-- {{Value $value "prefix"}} {{Value $value "content"}}
{{end}}
-
`
-
-var title = `<{{.Option "level"}} class="story"
-{{range $k, $v := .Optionv "extra"}}data-{{$k}}='{{$v}}'{{end}}
-data-type="{{.Option "type"}}"
->{{.Option "prefix"}} {{.Option "content"}}{{.Option "level"}}>`
-var brief = `{{.Option "text"}}
`
-var refer = `
-{{range $index, $value := .Optionv "list"}}- {{index $value 0}}: {{index $value 1}}
{{end}}
`
-var spark = `{{.Option "text"}}
`
-
-var order = `
-{{range $index, $value := .Optionv "list"}}- {{$value}}
{{end}}
`
-var table = `
-{{range $i, $v := .Optionv "head"}}{{$v}} | {{end}}
-{{range $index, $value := .Optionv "list"}}
-{{range $i, $v := $value}}{{$v}} | {{end}}
-{{end}}
-
`
-var shell = `$ {{.Option "input"}} # {{.Option "name"}}
-{{.Option "output"}}
`
-var local = `{{range $index, $value := .Optionv "input"}}{{$value}}{{end}}
`
-
-var chart = ``)},
- FIELD: {Name: FIELD, Help: "插件", Value: kit.Data(kit.MDB_TEMPLATE, field)},
- OTHER: {Name: FIELD, Help: "网页", Value: kit.Data(kit.MDB_TEMPLATE, other)},
-
WORD: {Name: WORD, Help: "语言文字", Value: kit.Data(
- kit.MDB_PATH, "", kit.MDB_REGEXP, ".*\\.shy", "alias", map[string]interface{}{
- PREMENU: []interface{}{TITLE, PREMENU},
- CHAPTER: []interface{}{TITLE, CHAPTER},
- SECTION: []interface{}{TITLE, SECTION},
- ENDMENU: []interface{}{TITLE, ENDMENU},
- LABEL: []interface{}{CHART, LABEL},
- CHAIN: []interface{}{CHART, CHAIN},
- },
+ kit.MDB_PATH, "", kit.MDB_REGEXP, ".*\\.shy", "alias", kit.Dict(
+ PREMENU, []interface{}{TITLE, PREMENU},
+ CHAPTER, []interface{}{TITLE, CHAPTER},
+ SECTION, []interface{}{TITLE, SECTION},
+ ENDMENU, []interface{}{TITLE, ENDMENU},
+ LABEL, []interface{}{CHART, LABEL},
+ CHAIN, []interface{}{CHART, CHAIN},
+ ),
)},
},
Commands: map[string]*ice.Command{
- TITLE: {Name: "title [premenu|chapter|section|endmenu] text", Help: "标题", Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
- if len(arg) == 0 {
- ns := strings.Split(ice.Info.NodeName, "-")
- arg = append(arg, kit.Select(ns[len(ns)-1], ""))
- }
-
- if len(arg) == 1 {
- arg = append(arg, "")
- }
- _title_show(m, arg[0], kit.Select(arg[0], arg[1]), arg[2:]...)
- }},
- BRIEF: {Name: "brief [name] text", Help: "摘要", Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
- arg = _name(m, arg)
- _brief_show(m, arg[0], kit.Select(arg[0], arg[1]), arg[2:]...)
- }},
- REFER: {Name: "refer [name] `[name url]...`", Help: "参考", Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
- arg = _name(m, arg)
- _refer_show(m, arg[0], arg[1], arg[2:]...)
- }},
- SPARK: {Name: "spark [name] text", Help: "段落", Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
- if len(arg) == 0 {
- m.Echo(`
`)
- return
- }
-
- arg = _name(m, arg)
- _spark_show(m, arg[0], kit.Select(arg[0], arg[1]), arg[2:]...)
- }},
-
- ORDER: {Name: "order [name] `[item \n]...`", Help: "列表", Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
- arg = _name(m, arg)
- _order_show(m, arg[0], kit.Select(arg[0], arg[1]), arg[2:]...)
- }},
- TABLE: {Name: "table [name] `[item item\n]...`", Help: "表格", Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
- arg = _name(m, arg)
- _table_show(m, arg[0], kit.Select(arg[0], arg[1]), arg[2:]...)
- }},
- SHELL: {Name: "shell [name] cmd", Help: "命令", Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
- arg = _name(m, arg)
- _shell_show(m, arg[0], kit.Select(arg[0], arg[1]), arg[2:]...)
- }},
- LOCAL: {Name: "local [name] file", Help: "文件", Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
- arg = _name(m, arg)
- _local_show(m, arg[0], kit.Select(arg[0], arg[1]), arg[2:]...)
- }},
-
- CHART: {Name: "chart label|chain [name] text", Help: "图表", Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
- if len(arg) == 2 {
- arg = []string{arg[0], "", arg[1]}
- }
- _chart_show(m, arg[0], arg[1], arg[2], arg[3:]...)
- }},
- FIELD: {Name: "field [name] cmd", Help: "插件", Action: map[string]*ice.Action{
- "run": {Name: "run", Help: "运行", Hand: func(m *ice.Message, arg ...string) {
- if !m.Warn(!m.Right(arg[1:]), ice.ErrNotRight, arg[1:]) {
- m.Cmdy(arg[1:])
- }
- }},
- }, Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
- arg = _name(m, arg)
- _field_show(m, strings.ReplaceAll(kit.Select(path.Base(arg[1]), arg[0]), " ", "_"), arg[1], arg[2:]...)
- }},
- OTHER: {Name: "other [name] url", Help: "网页", Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
- arg = _name(m, arg)
- _other_show(m, arg[0], kit.Select(arg[0], arg[1]), arg[2:]...)
- }},
-
- PARSE: {Name: "parse type=auto,json,http,form,list auto text:textarea", Help: "解析", Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
- if len(arg) < 2 {
- return
- }
- if arg[0] == "auto" && (strings.HasPrefix(arg[1], "{") || strings.HasPrefix(arg[1], "[")) {
- arg[0] = "json"
- } else if strings.HasPrefix(arg[1], "http") {
- arg[0] = "http"
- } else if strings.Contains(arg[1], "=") {
- arg[0] = "form"
- } else {
- arg[0] = "list"
- }
-
- m.Option(mdb.FIELDS, mdb.DETAIL)
- switch arg[0] {
- case "json":
- m.Echo(kit.Formats(kit.UnMarshal(arg[1])))
- case "http":
- u, _ := url.Parse(arg[1])
- for k, v := range u.Query() {
- for _, v := range v {
- m.Push(k, v)
- }
- }
- m.EchoQRCode(arg[1])
-
- case "form":
- for _, v := range kit.Split(arg[1], "&", "&", "&") {
- ls := kit.Split(v, "=", "=", "=")
- key, _ := url.QueryUnescape(ls[0])
- value, _ := url.QueryUnescape(kit.Select("", ls, 1))
- m.Push(key, value)
- }
- case "list":
- for i, v := range kit.Split(arg[1]) {
- m.Push(kit.Format(i), v)
- }
- }
- }},
-
WORD: {Name: "word path=src/main.shy auto 演示", Help: "语言文字", Meta: kit.Dict(
- kit.MDB_DISPLAY, "/plugin/local/wiki/word.js", kit.MDB_STYLE, WORD,
+ ice.Display("/plugin/local/wiki/word.js", WORD),
), Action: map[string]*ice.Action{
web.STORY: {Name: "story", Help: "运行", Hand: func(m *ice.Message, arg ...string) {
- m.Cmdy(arg[0], kit.MDB_ACTION, "run", arg[1:])
+ m.Cmdy(arg[0], ctx.ACTION, cli.RUN, arg[1:])
}},
}, Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
m.Option(nfs.DIR_REG, m.Conf(WORD, kit.Keym(kit.MDB_REGEXP)))
- if m.Option(nfs.DIR_DEEP, "true"); _wiki_list(m, cmd, arg...) {
- return
+ if m.Option(nfs.DIR_DEEP, ice.TRUE); !_wiki_list(m, cmd, arg...) {
+ _word_show(m, arg[0])
}
- _word_show(m, arg[0])
}},
},
})
diff --git a/misc.go b/misc.go
index 1e6381e7..6482fe1c 100644
--- a/misc.go
+++ b/misc.go
@@ -544,7 +544,8 @@ func Display(file string, arg ...string) map[string]string {
file = kit.Select(file+".js", file, strings.HasSuffix(file, ".js"))
file = path.Join("/require/github.com/shylinux", path.Dir(ls[len(ls)-1]), file)
}
- return map[string]string{kit.MDB_DISPLAY: file, kit.MDB_STYLE: kit.Select("", arg, 0)}
+ // return map[string]string{kit.MDB_DISPLAY: file, kit.MDB_STYLE: kit.Select("", arg, 0)}
+ return map[string]string{"display": file, kit.MDB_STYLE: kit.Select("", arg, 0)}
}
func (m *Message) OptionSplit(fields ...string) (res []string) {
for _, k := range strings.Split(strings.Join(fields, ","), ",") {
@@ -552,3 +553,22 @@ func (m *Message) OptionSplit(fields ...string) (res []string) {
}
return res
}
+func (m *Message) OptionTemplate() string {
+ res := []string{`class="story"`}
+ for _, key := range kit.Split("style") {
+ if m.Option(key) != "" {
+ res = append(res, kit.Format(`s="%s"`, key, m.Option(key)))
+ }
+ }
+ for _, key := range kit.Split("type,name,text") {
+ if m.Option(key) != "" {
+ res = append(res, kit.Format(`data-%s="%s"`, key, m.Option(key)))
+ }
+ }
+ kit.Fetch(m.Optionv("extra"), func(key string, value string) {
+ if value != "" {
+ res = append(res, kit.Format(`data-%s="%s"`, key, value))
+ }
+ })
+ return strings.Join(res, " ")
+}
diff --git a/misc/git/spide.go b/misc/git/spide.go
index b47439f4..040efff7 100644
--- a/misc/git/spide.go
+++ b/misc/git/spide.go
@@ -62,7 +62,7 @@ const SPIDE = "spide"
func init() {
Index.Merge(&ice.Context{Commands: map[string]*ice.Command{
SPIDE: {Name: "spide name@key auto", Help: "构架图", Meta: kit.Dict(
- kit.MDB_DISPLAY, "/plugin/story/spide.js",
+ ice.Display("/plugin/story/spide.js"),
), Action: map[string]*ice.Action{
mdb.INPUTS: {Name: "inputs", Help: "补全", Hand: func(m *ice.Message, arg ...string) {
m.Cmdy(REPOS)
diff --git a/misc/git/trend.go b/misc/git/trend.go
index 052e8241..6409a169 100644
--- a/misc/git/trend.go
+++ b/misc/git/trend.go
@@ -13,7 +13,7 @@ const TREND = "trend"
func init() {
Index.Merge(&ice.Context{Commands: map[string]*ice.Command{
TREND: {Name: "trend name@key begin_time@date auto", Help: "趋势图", Meta: kit.Dict(
- kit.MDB_DISPLAY, "/plugin/story/trend.js",
+ ice.Display("/plugin/story/trend.js"),
), Action: map[string]*ice.Action{
mdb.INPUTS: {Name: "inputs", Help: "补全", Hand: func(m *ice.Message, arg ...string) {
m.Cmdy(REPOS, ice.OptionFields("name,time"))
diff --git a/misc/trash/md/md.go b/misc/trash/md/md.go
index b1f505f0..6ee6b2a1 100644
--- a/misc/trash/md/md.go
+++ b/misc/trash/md/md.go
@@ -1,14 +1,15 @@
package md
import (
- "github.com/shylinux/icebergs"
+ ice "github.com/shylinux/icebergs"
"github.com/shylinux/icebergs/core/wiki"
- "github.com/shylinux/toolkits"
+ kit "github.com/shylinux/toolkits"
- "github.com/gomarkdown/markdown"
"io/ioutil"
"path"
"strings"
+
+ "github.com/gomarkdown/markdown"
)
/*
@@ -42,7 +43,9 @@ var Index = &ice.Context{Name: "md", Help: "md",
m.Echo("hello world")
}},
- "note": {Name: "note file", Help: "文档", Meta: kit.Dict("display", "inner"), List: kit.List(
+ "note": {Name: "note file", Help: "文档", Meta: kit.Dict(
+ ice.Display("inner"),
+ ), List: kit.List(
kit.MDB_INPUT, "text", "name", "path", "value", "README.md", "action", "auto",
kit.MDB_INPUT, "button", "name", "执行", "action", "auto",
kit.MDB_INPUT, "button", "name", "返回", "cb", "Last",
diff --git a/misc/trash/web/_favor.go b/misc/trash/web/_favor.go
index 76fecf68..460cf61d 100644
--- a/misc/trash/web/_favor.go
+++ b/misc/trash/web/_favor.go
@@ -2,6 +2,7 @@ package web
import (
ice "github.com/shylinux/icebergs"
+ "github.com/shylinux/icebergs/base/aaa"
"github.com/shylinux/icebergs/base/mdb"
kit "github.com/shylinux/toolkits"
@@ -394,7 +395,7 @@ func init() {
m.Option(kit.MDB_TYPE, value[kit.MDB_TYPE])
m.Option(kit.MDB_NAME, value[kit.MDB_NAME])
m.Option(kit.MDB_TEXT, value[kit.MDB_TEXT])
- m.Render(ice.RENDER_TEMPLATE, m.Conf(SHARE, "meta.template.simple"))
+ m.RenderTemplate(m.Conf(SHARE, "meta.template.simple"))
m.Option(ice.MSG_OUTPUT, ice.RENDER_RESULT)
}
})
diff --git a/type.go b/type.go
index 8b52396d..ae777512 100644
--- a/type.go
+++ b/type.go
@@ -5,7 +5,6 @@ import (
"fmt"
"io"
"net/http"
- "path"
"reflect"
"runtime"
"sort"
@@ -188,11 +187,6 @@ func (c *Context) Merge(s *Context) *Context {
v.Meta = kit.Dict()
}
- if p := kit.Format(v.Meta[kit.MDB_DISPLAY]); p != "" && !strings.HasPrefix(p, "/") {
- ls := strings.Split(kit.FileLine(2, 100), "usr")
- p = kit.Select(p+".js", p, strings.HasSuffix(p, ".js"))
- v.Meta[kit.MDB_DISPLAY] = path.Join("/require/github.com/shylinux", path.Dir(ls[len(ls)-1]), p)
- }
if p := kit.Format(v.Meta[kit.MDB_STYLE]); p == "" {
v.Meta[kit.MDB_STYLE] = k
}