")
m.Echo("
")
m.Echo("
").Echo(l).Echo("")
@@ -33,54 +33,47 @@ func _spark_show(m *ice.Message, name, text string, arg ...string) {
const (
PROMPT = "prompt"
-)
-
-const (
- SSH_SHELL = "shell"
- SSH_BREAK = "break"
+ BREAK = "break"
)
const SPARK = "spark"
func init() {
- Index.Merge(&ice.Context{
- Commands: map[string]*ice.Command{
- ice.CTX_INIT: {Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
- ice.AddRender(ice.RENDER_SCRIPT, func(m *ice.Message, cmd string, args ...interface{}) string {
- arg := kit.Simple(args...)
- if len(arg) == 1 && arg[0] != SSH_BREAK {
- arg = []string{SSH_SHELL, arg[0]}
- }
- list := []string{kit.Format(`
`, arg[0])}
- for _, l := range strings.Split(strings.Join(arg[1:], "\n"), "\n") {
- switch list = append(list, "
"); arg[0] {
- case SSH_SHELL:
- list = append(list, "")
- default:
- list = append(list, "")
- }
- list = append(list, "", l, "")
- list = append(list, "
")
- }
- list = append(list, "
")
- return strings.Join(list, "")
- })
- }},
- 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
+ Index.Merge(&ice.Context{Commands: map[string]*ice.Command{
+ ice.CTX_INIT: {Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
+ ice.AddRender(ice.RENDER_SCRIPT, func(m *ice.Message, cmd string, args ...interface{}) string {
+ arg := kit.Simple(args...)
+ if len(arg) == 1 && arg[0] != BREAK {
+ arg = []string{SHELL, arg[0]}
}
+ list := []string{kit.Format(`
`, arg[0])}
+ for _, l := range strings.Split(strings.Join(arg[1:], ice.NL), ice.NL) {
+ switch list = append(list, "
"); arg[0] {
+ case SHELL:
+ list = append(list, "")
+ default:
+ list = append(list, "")
+ }
+ list = append(list, "", l, "")
+ list = append(list, "
")
+ }
+ list = append(list, "
")
+ return strings.Join(list, "")
+ })
+ }},
+ 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], strings.TrimSpace(arg[1]), arg[2:]...)
- }},
- },
- Configs: map[string]*ice.Config{
- SPARK: {Name: SPARK, Help: "段落", Value: kit.Data(
- kit.MDB_TEMPLATE, `
{{.Option "text"}}
`,
- ssh.PROMPT, kit.Dict("shell", "$ "),
- )},
- },
- })
+ arg = _name(m, arg)
+ _spark_show(m, arg[0], strings.TrimSpace(arg[1]), arg[2:]...)
+ }},
+ }, Configs: map[string]*ice.Config{
+ SPARK: {Name: SPARK, Help: "段落", Value: kit.Data(
+ kit.MDB_TEMPLATE, `
{{.Option "text"}}
`,
+ ssh.PROMPT, kit.Dict(SHELL, "$ "),
+ )},
+ }})
}
diff --git a/core/wiki/table.go b/core/wiki/table.go
index 5fb532af..6e99b2ff 100644
--- a/core/wiki/table.go
+++ b/core/wiki/table.go
@@ -38,9 +38,9 @@ func _table_show(m *ice.Message, text string, arg ...string) {
style := []string{}
for i := 1; i < len(ls)-1; i += 2 {
switch ls[i] {
- case "bg":
+ case BG:
ls[i] = "background-color"
- case "fg":
+ case FG:
ls[i] = "color"
}
style = append(style, ls[i]+":"+ls[i+1])
@@ -60,25 +60,22 @@ func _table_show(m *ice.Message, text string, arg ...string) {
const TABLE = "table"
func init() {
- Index.Merge(&ice.Context{
- Commands: map[string]*ice.Command{
- TABLE: {Name: "table `[item item\n]...`", Help: "表格", Action: map[string]*ice.Action{
- ice.RUN: {Name: "run", Help: "执行", Hand: func(m *ice.Message, arg ...string) {
- _table_run(m, arg...)
- }},
- }, Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
- _table_show(m, arg[0], arg[1:]...)
+ Index.Merge(&ice.Context{Commands: map[string]*ice.Command{
+ TABLE: {Name: "table `[item item\n]...`", Help: "表格", Action: map[string]*ice.Action{
+ ice.RUN: {Name: "run", Help: "执行", Hand: func(m *ice.Message, arg ...string) {
+ _table_run(m, arg...)
}},
- },
- Configs: map[string]*ice.Config{
- TABLE: {Name: TABLE, Help: "表格", Value: kit.Data(
- kit.MDB_TEMPLATE, `
+ }, Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
+ _table_show(m, arg[0], arg[1:]...)
+ }},
+ }, Configs: map[string]*ice.Config{
+ TABLE: {Name: TABLE, Help: "表格", Value: kit.Data(
+ kit.MDB_TEMPLATE, `
{{range $i, $v := .Optionv "head"}}{{$v}} | {{end}}
{{range $index, $value := .Optionv "list"}}
{{range $i, $v := $value}}{{$v}} | {{end}}
{{end}}
`,
- )},
- },
- })
+ )},
+ }})
}
diff --git a/core/wiki/title.go b/core/wiki/title.go
index b38aaae1..8541a70c 100644
--- a/core/wiki/title.go
+++ b/core/wiki/title.go
@@ -36,14 +36,11 @@ func _title_parse(m *ice.Message, dir string, root map[string]interface{}, list
ls[1] = path.Join(dir, ls[1])
}
- meta := kit.Dict(
- "name", kit.Select("", ls, 0),
- "link", kit.Select("", ls, 1),
- )
+ meta := kit.Dict(kit.MDB_NAME, kit.Select("", ls, 0), kit.MDB_LINK, kit.Select("", ls, 1))
for i := 2; i < len(ls); i += 2 {
meta[ls[i]] = ls[i+1]
}
- last = kit.Dict("meta", meta, "list", kit.List())
+ last = kit.Data(meta)
kit.Value(root, "list.-2", last)
}
return len(list)
@@ -53,19 +50,19 @@ func _title_show(m *ice.Message, kind, text string, arg ...string) {
switch title, _ := m.Optionv(TITLE).(map[string]int); kind {
case NAVMENU: // 导航目录
_option(m, kind, "", text, arg...)
- data := kit.Dict("meta", kit.Dict(), "list", kit.List())
+ data := kit.Data()
_title_parse(m, path.Dir(m.Option(ice.MSG_SCRIPT)), data, strings.Split(text, ice.NL))
m.RenderTemplate(kit.Format("", kit.Format(data)))
return
case PREMENU: // 前置目录
_option(m, kind, "", "", arg...)
- m.RenderTemplate(m.Conf(TITLE, kit.Keym(kind)))
+ m.RenderTemplate(m.Config(kind))
return
case ENDMENU: // 后置目录
_option(m, kind, "", "", arg...)
- m.RenderTemplate(m.Conf(TITLE, kit.Keym(kind)))
+ m.RenderTemplate(m.Config(kind))
return
case SECTION: // 分节标题
@@ -104,7 +101,7 @@ const TITLE = "title"
func init() {
Index.Merge(&ice.Context{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) {
+ TITLE: {Name: "title [navmenu|premenu|chapter|section|endmenu] text", Help: "标题", Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
if len(arg) == 0 {
ns := kit.Split(ice.Info.NodeName, "-")
arg = append(arg, ns[len(ns)-1])
diff --git a/core/wiki/video.go b/core/wiki/video.go
index 352e4a3d..54f118f3 100644
--- a/core/wiki/video.go
+++ b/core/wiki/video.go
@@ -21,21 +21,18 @@ const (
const VIDEO = "video"
func init() {
- Index.Merge(&ice.Context{
- Commands: map[string]*ice.Command{
- VIDEO: {Name: "video url", Help: "视频", Action: map[string]*ice.Action{
- mdb.RENDER: {Name: "render", Help: "渲染", Hand: func(m *ice.Message, arg ...string) {
- _video_show(m, path.Join(arg[2], arg[1]))
- }},
- }, Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
- _video_show(m, arg[0], arg[1:]...)
+ Index.Merge(&ice.Context{Commands: map[string]*ice.Command{
+ VIDEO: {Name: "video url", Help: "视频", Action: map[string]*ice.Action{
+ mdb.RENDER: {Name: "render", Help: "渲染", Hand: func(m *ice.Message, arg ...string) {
+ _video_show(m, path.Join(arg[2], arg[1]))
}},
- },
- Configs: map[string]*ice.Config{
- VIDEO: {Name: "video", Help: "视频", Value: kit.Data(
- kit.MDB_TEMPLATE, ``,
- kit.MDB_PATH, ice.USR_LOCAL_IMAGE,
- )},
- },
- })
+ }, Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
+ _video_show(m, arg[0], arg[1:]...)
+ }},
+ }, Configs: map[string]*ice.Config{
+ VIDEO: {Name: "video", Help: "视频", Value: kit.Data(
+ kit.MDB_TEMPLATE, ``,
+ kit.MDB_PATH, ice.USR_LOCAL_IMAGE,
+ )},
+ }})
}
diff --git a/core/wiki/wiki.go b/core/wiki/wiki.go
index f9ce7e9b..39a990ee 100644
--- a/core/wiki/wiki.go
+++ b/core/wiki/wiki.go
@@ -10,18 +10,36 @@ import (
kit "shylinux.com/x/toolkits"
)
+func _name(m *ice.Message, arg []string) []string {
+ if len(arg) == 1 {
+ return []string{"", arg[0]}
+ }
+ return arg
+}
+func _option(m *ice.Message, kind, name, text string, arg ...string) {
+ m.Option(kit.MDB_TYPE, kind)
+ m.Option(kit.MDB_NAME, name)
+ m.Option(kit.MDB_TEXT, text)
+
+ extra := kit.Dict()
+ m.Optionv(kit.MDB_EXTRA, extra)
+ for i := 0; i < len(arg); i += 2 {
+ extra[arg[i]] = kit.Format(kit.Parse(nil, "", kit.Split(arg[i+1])...))
+ }
+}
+
func _wiki_path(m *ice.Message, cmd string, arg ...string) string {
- return path.Join(m.Option(ice.MSG_LOCAL), m.Conf(cmd, kit.META_PATH), path.Join(arg...))
+ return path.Join(m.Option(ice.MSG_LOCAL), m.Conf(cmd, kit.Keym(nfs.PATH)), path.Join(arg...))
}
func _wiki_link(m *ice.Message, cmd string, text string) string {
- if !strings.HasPrefix(text, "http") && !strings.HasPrefix(text, "/") {
+ if !strings.HasPrefix(text, "http") && !strings.HasPrefix(text, ice.PS) {
text = path.Join("/share/local", _wiki_path(m, cmd, text))
}
return text
}
func _wiki_list(m *ice.Message, cmd string, arg ...string) bool {
m.Option(nfs.DIR_ROOT, _wiki_path(m, cmd))
- if len(arg) == 0 || strings.HasSuffix(arg[0], "/") {
+ if len(arg) == 0 || strings.HasSuffix(arg[0], ice.PS) {
if m.Option(nfs.DIR_DEEP) != ice.TRUE { // 目录列表
m.Option(nfs.DIR_TYPE, nfs.DIR)
m.Cmdy(nfs.DIR, kit.Select("./", arg, 0))
@@ -52,20 +70,13 @@ func _wiki_template(m *ice.Message, cmd string, name, text string, arg ...string
const WIKI = "wiki"
-var Index = &ice.Context{Name: WIKI, Help: "文档中心", Commands: map[string]*ice.Command{
- ice.CTX_INIT: {Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
- m.Load()
- }},
- ice.CTX_EXIT: {Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
- m.Save()
- }},
-}}
+var Index = &ice.Context{Name: WIKI, Help: "文档中心"}
func init() {
web.Index.Register(Index, &web.Frame{},
- FEEL, WORD, DATA, DRAW,
- TITLE, BRIEF, REFER, SPARK,
- ORDER, TABLE, CHART, IMAGE, VIDEO,
+ TITLE, BRIEF, REFER, SPARK, CHART,
+ ORDER, TABLE, IMAGE, VIDEO,
FIELD, SHELL, LOCAL, PARSE,
+ FEEL, DRAW, WORD, DATA,
)
}
diff --git a/core/wiki/wiki.shy b/core/wiki/wiki.shy
index 2e152165..688713a7 100644
--- a/core/wiki/wiki.shy
+++ b/core/wiki/wiki.shy
@@ -1,29 +1,26 @@
+
title.go
brief.go
refer.go
spark.go
+chart.go
order.go
table.go
-chart.go
image.go
video.go
+poems.go
field.go
shell.go
local.go
parse.go
-data.go
-draw.go
feel.go
+draw.go
word.go
+data.go
+json.go
wiki.go
wiki.shy
-
-field "影音" web.wiki.feel
-field "数据" web.wiki.data
-field "文档" web.wiki.word
-field "绘图" web.wiki.draw
-
diff --git a/core/wiki/word.go b/core/wiki/word.go
index a67c4de5..5c651e02 100644
--- a/core/wiki/word.go
+++ b/core/wiki/word.go
@@ -1,9 +1,6 @@
package wiki
import (
- "net/http"
- "strings"
-
ice "shylinux.com/x/icebergs"
"shylinux.com/x/icebergs/base/ctx"
"shylinux.com/x/icebergs/base/nfs"
@@ -12,24 +9,6 @@ import (
kit "shylinux.com/x/toolkits"
)
-func _name(m *ice.Message, arg []string) []string {
- if len(arg) == 1 {
- return []string{"", arg[0]}
- }
- return arg
-}
-func _option(m *ice.Message, kind, name, text string, arg ...string) {
- m.Option(kit.MDB_TYPE, kind)
- m.Option(kit.MDB_NAME, name)
- m.Option(kit.MDB_TEXT, text)
-
- extra := kit.Dict()
- m.Optionv(kit.MDB_EXTRA, extra)
- for i := 0; i < len(arg); i += 2 {
- extra[arg[i]] = kit.Format(kit.Parse(nil, "", kit.Split(arg[i+1])...))
- }
-}
-
func _word_show(m *ice.Message, name string, arg ...string) {
m.Set(ice.MSG_RESULT)
m.Option(TITLE, map[string]int{})
@@ -40,11 +19,6 @@ func _word_show(m *ice.Message, name string, arg ...string) {
m.Cmdy(ssh.SOURCE, name)
}
-func _word_template(m *ice.Message, cmd string, arg ...string) {
- arg = _name(m, arg)
- _wiki_template(m, cmd, arg[0], kit.Select(arg[0], arg[1]), arg[2:]...)
-}
-
const WORD = "word"
func init() {
@@ -62,35 +36,17 @@ func init() {
)},
}, Commands: map[string]*ice.Command{
WORD: {Name: "word path=src/main.shy auto play", Help: "语言文字", Meta: kit.Dict(
- ice.Display("/plugin/local/wiki/word.js", WORD),
+ ice.Display("/plugin/local/wiki/word.js"),
), Action: ice.MergeAction(map[string]*ice.Action{
- "play": {Name: "play", Help: "演示"},
web.STORY: {Name: "story", Help: "运行", Hand: func(m *ice.Message, arg ...string) {
m.Cmdy(arg[0], ctx.ACTION, ice.RUN, arg[2:])
}},
+ "play": {Name: "play", Help: "演示"},
}, ctx.CmdAction()), 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)))
+ m.Option(nfs.DIR_REG, m.Config(kit.MDB_REGEXP))
if m.Option(nfs.DIR_DEEP, ice.TRUE); !_wiki_list(m, cmd, arg...) {
_word_show(m, arg[0])
}
}},
- "/word/": {Name: "word", Help: "文档", Meta: kit.Dict(
- ice.Display("/plugin/local/wiki/word.js", WORD),
- ), Action: ice.MergeAction(map[string]*ice.Action{
- web.STORY: {Name: "story", Help: "运行", Hand: func(m *ice.Message, arg ...string) {
- m.Cmdy(arg[0], ctx.ACTION, ice.RUN, arg[2:])
- }},
- ctx.COMMAND: {Name: "command", Help: "命令", Hand: func(m *ice.Message, arg ...string) {
- m.Cmdy(ctx.COMMAND, "web.wiki.word")
- if ls := strings.Split(m.Option("_names"), "/word/"); len(ls) > 1 {
- m.Push("args", ls[1])
- }
- }},
- }, ctx.CmdAction()), Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
- if m.R.Method == http.MethodGet {
- m.RenderIndex(web.SERVE, ice.VOLCANOS, "page/cmd.html")
- return // 目录
- }
- }},
}})
}
diff --git a/misc/git/spide.go b/misc/git/spide.go
index 435786d7..d3105558 100644
--- a/misc/git/spide.go
+++ b/misc/git/spide.go
@@ -76,7 +76,7 @@ func init() {
if arg[0] == path.Base(kit.Pwd()) {
m.Option(nfs.DIR_ROOT, path.Join(ice.SRC))
} else {
- m.Option(nfs.DIR_ROOT, path.Join(ice.USR, arg[0]))
+ m.Option(nfs.DIR_ROOT, path.Join(ice.USR, arg[0])+ice.PS)
}
if len(arg) == 1 { // 目录列表