diff --git a/src/examples/wiki/wiki.go b/src/examples/wiki/wiki.go
index 49beb40c..2e1a71ff 100644
--- a/src/examples/wiki/wiki.go
+++ b/src/examples/wiki/wiki.go
@@ -17,6 +17,50 @@ import (
"text/template"
)
+type opt struct {
+ font_size int
+ font_color string
+ background string
+ padding int
+ margin int
+}
+
+func size(m *ctx.Message, root map[string]interface{}, depth int, width map[int]int) int {
+ text := kit.Format(kit.Chain(root, "meta.text"))
+ if len(text) > width[depth] {
+ width[depth] = len(text)
+ }
+
+ if _, ok := root["list"]; !ok {
+ kit.Chain(root, "meta.height", 1)
+ m.Log("fuck", "hi %v %d", kit.Chain(root, "meta.text"), 1)
+ return 1
+ }
+
+ height := 0
+ kit.Map(root["list"], "", func(index int, value map[string]interface{}) {
+ height += size(m, value, depth+1, width)
+ })
+ kit.Chain(root, "meta.height", height)
+ m.Log("fuck", "hi %v %d", kit.Chain(root, "meta.text"), height)
+ return height
+}
+func draw(m *ctx.Message, root map[string]interface{}, depth int, width map[int]int, x int, y int, opt *opt) {
+ m.Log("fuck", "hi %v %d", kit.Chain(root, "meta.text"), y)
+ height := kit.Int(kit.Chain(root, "meta.height"))
+ p := (height - 1) * (opt.font_size + opt.margin + opt.padding)
+
+ m.Echo(``,
+ x, y+p/2, width[depth]*opt.font_size/2+opt.padding, opt.font_size+opt.padding, opt.background)
+ m.Echo(`%v`,
+ x+width[depth]*opt.font_size/2/2+opt.padding/2, y+p/2+opt.font_size-opt.padding/2, opt.font_size, opt.font_color, kit.Chain(root, "meta.text"))
+
+ kit.Map(root["list"], "", func(index int, value map[string]interface{}) {
+ draw(m, value, depth+1, width, x+width[depth]*opt.font_size/2+opt.margin+opt.padding, y, opt)
+ y += kit.Int(kit.Chain(value, "meta.height")) * (opt.font_size + opt.margin + opt.padding)
+ })
+}
+
var Index = &ctx.Context{Name: "wiki", Help: "文档中心",
Caches: map[string]*ctx.Cache{},
Configs: map[string]*ctx.Config{
@@ -328,7 +372,46 @@ var Index = &ctx.Context{Name: "wiki", Help: "文档中心",
}},
"svg": {Name: "svg", Help: "绘图", Hand: func(m *ctx.Message, c *ctx.Context, key string, arg ...string) (e error) {
- m.Echo(arg[0])
+ data := map[string]interface{}{"meta": map[string]interface{}{"text": "chat"}, "list": []interface{}{
+ map[string]interface{}{"meta": map[string]interface{}{"text": "ocean"}},
+ map[string]interface{}{"meta": map[string]interface{}{"text": "river"}},
+ map[string]interface{}{"meta": map[string]interface{}{"text": "dream"}, "list": []interface{}{
+ map[string]interface{}{"meta": map[string]interface{}{"text": "zsh"}, "list": []interface{}{
+ map[string]interface{}{"meta": map[string]interface{}{"text": "auto.sh"}},
+ }},
+ map[string]interface{}{"meta": map[string]interface{}{"text": "tmux"}},
+ map[string]interface{}{"meta": map[string]interface{}{"text": "docker"}},
+ map[string]interface{}{"meta": map[string]interface{}{"text": "git"}},
+ map[string]interface{}{"meta": map[string]interface{}{"text": "vim"}, "list": []interface{}{
+ map[string]interface{}{"meta": map[string]interface{}{"text": "auto.vim"}},
+ }},
+ }},
+ map[string]interface{}{"meta": map[string]interface{}{"text": "storm"}},
+ map[string]interface{}{"meta": map[string]interface{}{"text": "steam"}},
+ }}
+
+ opt := &opt{
+ font_size: kit.Int(kit.Select("60", arg, 0)),
+ font_color: kit.Select("red", arg, 1),
+ background: kit.Select("green", arg, 2),
+ padding: 10,
+ margin: 20,
+ }
+ max := map[int]int{}
+ num := size(m, data, 0, max)
+ width := 0
+ for _, v := range max {
+ width += v*opt.font_size/2 + opt.margin
+ }
+
+ m.Echo(``)
+
+ // m.Echo(``)
+ // m.Echo(``)
+ // m.Echo(`SVG`)
return
}},
"xls": {Name: "xls", Help: "表格", Hand: func(m *ctx.Message, c *ctx.Context, key string, arg ...string) (e error) {
diff --git a/src/plugin/story/index.shy b/src/plugin/story/index.shy
index 67362306..1b90d3cf 100644
--- a/src/plugin/story/index.shy
+++ b/src/plugin/story/index.shy
@@ -41,15 +41,10 @@ kit xls "表格" "index.js" "index.css" private "web.wiki.xls" \
feature style "mind" \
exports xls_id id
-kit audio "" public "web.wiki.audio" \
- text "" name dream imports plugin_you \
+kit svg "" public "web.wiki.svg" \
+ select "" name type values "16 30 48 60" action auto \
+ select "" name type values "white red yellow green blue black" action auto \
+ select "" name type values "black blue green yellow red white" action auto \
+ feature display svg \
button "查看"
-kit vedio "视频" public "web.wiki.vedio" \
- text "" name dream imports plugin_you \
- button "查看"
-
-kit vedio "视频" public "web.wiki.vedio" \
- text "usr/local/vedio/5b58edd8b722c7ac7d86c5281276b7ed_wm.mp4" name file \
- feature display video \
- button "查看"
diff --git a/usr/librarys/example.js b/usr/librarys/example.js
index 5dd69044..6272f98c 100644
--- a/usr/librarys/example.js
+++ b/usr/librarys/example.js
@@ -1570,10 +1570,13 @@ function Output(plugin, type, msg, cb, target, option) {
_svg: function(width, height, src) {
kit.AppendChild(target, '')
},
+ _svg2: function(msg, width, height) {
+ target.innerHTML = msg.result.join("")
+ },
svg: function(msg, cb) {var meta = output.onimport.meta
plugin.onfigure.meta.size(function(width, height) {
- meta._svg(output.target, width, height*1.6, msg.result.join(""))
+ meta._svg2(msg, width, height*1.6)
})
},
code: function(msg, cb) {var meta = output.onimport.meta