`, arg[0], kit.JoinKV(":", ";", kit.TransArgKey(arg[1:], transKey)...))
} else {
- m.Echo(`
`, "story", arg[0])
+ m.Echo(`
`, arg[0])
}
}
}},
diff --git a/core/wiki/table.go b/core/wiki/table.go
index a3139688..2e740f8e 100644
--- a/core/wiki/table.go
+++ b/core/wiki/table.go
@@ -1,51 +1,44 @@
package wiki
import (
- "strings"
-
ice "shylinux.com/x/icebergs"
"shylinux.com/x/icebergs/base/ctx"
+ "shylinux.com/x/icebergs/base/nfs"
+ "shylinux.com/x/icebergs/base/web/html"
kit "shylinux.com/x/toolkits"
)
func _table_run(m *ice.Message, arg ...string) {
list := [][]string{}
m.Cmd(arg).Table(func(index int, value ice.Maps, head []string) {
- kit.If(index == 0, func() { m.Optionv("head", head) })
- line := []string{}
- kit.For(head, func(h string) { line = append(line, value[h]) })
- list = append(list, line)
+ ls := []string{}
+ kit.If(index == 0, func() { m.Options(HEAD, head) })
+ kit.For(head, func(h string) { ls = append(ls, value[h]) })
+ list = append(list, ls)
})
- _wiki_template(m.Options("list", list), "", "", "")
+ _wiki_template(m.Options(LIST, list), "", "", "")
}
func _table_show(m *ice.Message, text string, arg ...string) {
head, list := []string{}, [][]string{}
- for i, line := range kit.SplitLine(text) {
- if line = strings.Replace(line, "%", "%%", -1); i == 0 {
- head = kit.SplitWord(line)
- continue
+ m.Cmd(nfs.CAT, "", kit.Dict(nfs.CAT_CONTENT, text), func(ls []string) {
+ if len(head) == 0 {
+ head = ls
+ return
}
- list = append(list, kit.Simple(kit.SplitWord(line), func(value string) string {
+ list = append(list, kit.Simple(ls, func(value string) string {
if ls := kit.SplitWord(value); len(ls) > 1 {
return kit.Format(`%s`, kit.JoinKV(":", ";", transArgKey(ls[1:])...), ls[0])
}
return value
}))
- }
- _wiki_template(m.Options("head", head, "list", list), "", "", text, arg...)
-}
-func transArgKey(arg []string) []string {
- for i := 0; i < len(arg)-1; i += 2 {
- switch arg[i] {
- case BG:
- arg[i] = "background-color"
- case FG:
- arg[i] = "color"
- }
- }
- return arg
+ })
+ _wiki_template(m.Options(HEAD, head, LIST, list), "", "", text, arg...)
}
+const (
+ HEAD = "head"
+ LIST = "list"
+)
const TABLE = "table"
func init() {
@@ -55,3 +48,15 @@ func init() {
}), Hand: func(m *ice.Message, arg ...string) { _table_show(m, arg[0], arg[1:]...) }},
})
}
+
+func transArgKey(arg []string) []string {
+ for i := 0; i < len(arg)-1; i += 2 {
+ switch arg[i] {
+ case BG:
+ arg[i] = html.BACKGROUND_COLOR
+ case FG:
+ arg[i] = html.COLOR
+ }
+ }
+ return arg
+}
diff --git a/core/wiki/title.go b/core/wiki/title.go
index fed68731..63ed1ca2 100644
--- a/core/wiki/title.go
+++ b/core/wiki/title.go
@@ -9,6 +9,7 @@ import (
"shylinux.com/x/icebergs/base/mdb"
"shylinux.com/x/icebergs/base/nfs"
"shylinux.com/x/icebergs/base/web"
+ "shylinux.com/x/icebergs/base/web/html"
kit "shylinux.com/x/toolkits"
)
@@ -16,16 +17,14 @@ func _title_parse(m *ice.Message, text string) string {
deep, list := []int{}, []string{}
return m.Cmdx(lex.SPLIT, "", "name,link", kit.Dict(nfs.CAT_CONTENT, text), func(indent int, ls []string) []string {
for len(deep) > 0 && indent <= deep[len(deep)-1] {
- deep = deep[:len(deep)-1]
- list = list[:len(list)-1]
+ deep, list = deep[:len(deep)-1], list[:len(list)-1]
}
if len(ls) > 1 {
kit.If(!kit.HasPrefix(ls[1], nfs.PS, web.HTTP, nfs.SRC, nfs.USR), func() {
ls[1] = path.Join(kit.Select(path.Dir(m.Option(ice.MSG_SCRIPT)), list, -1), ls[1]) + kit.Select("", nfs.PS, strings.HasSuffix(ls[1], nfs.PS))
})
}
- deep = append(deep, indent)
- list = append(list, kit.Select("", ls, 1))
+ deep, list = append(deep, indent), append(list, kit.Select("", ls, 1))
return ls
})
}
@@ -34,16 +33,16 @@ func _title_menu(m *ice.Message, name, text string, arg ...string) *ice.Message
return _wiki_template(m, name, name, text, arg...)
}
func _title_show(m *ice.Message, name, text string, arg ...string) *ice.Message {
- switch title, _ := m.Optionv(TITLE).(map[string]int); name {
+ switch title := m.Optionv(TITLE).(map[string]int); name {
case SECTION:
title[SECTION]++
- m.Options(LEVEL, "h3", PREFIX, kit.Format("%d.%d ", title[CHAPTER], title[SECTION]))
+ m.Options(LEVEL, html.H3, PREFIX, kit.Format("%d.%d ", title[CHAPTER], title[SECTION]))
case CHAPTER:
title[CHAPTER]++
title[SECTION] = 0
- m.Options(LEVEL, "h2", PREFIX, kit.Format("%d ", title[CHAPTER]))
+ m.Options(LEVEL, html.H2, PREFIX, kit.Format("%d ", title[CHAPTER]))
default:
- m.Options(LEVEL, "h1", PREFIX, "")
+ m.Options(LEVEL, html.H1, PREFIX, "")
}
return _wiki_template(m, "", name, text, arg...)
}
diff --git a/core/wiki/video.go b/core/wiki/video.go
index 3ec3b527..bd2ea862 100644
--- a/core/wiki/video.go
+++ b/core/wiki/video.go
@@ -2,21 +2,15 @@ package wiki
import (
ice "shylinux.com/x/icebergs"
- "shylinux.com/x/icebergs/base/ctx"
- "shylinux.com/x/icebergs/base/nfs"
)
-const (
- m4v = "m4v"
- mp4 = "mp4"
- MOV = "mov"
-)
const VIDEO = "video"
func init() {
Index.MergeCommands(ice.Commands{
- VIDEO: {Name: "video url run", Help: "视频", Actions: ice.MergeActions(ctx.ConfAction(nfs.PATH, ice.USR_LOCAL_IMAGE)), Hand: func(m *ice.Message, arg ...string) {
- _image_show(m, arg[0], arg[1:]...)
+ VIDEO: {Name: "video path", Help: "视频", Hand: func(m *ice.Message, arg ...string) {
+ arg = _name(m, arg)
+ _image_show(m, arg[0], arg[1], arg[2:]...)
}},
})
}
diff --git a/core/wiki/wiki.go b/core/wiki/wiki.go
index bba36575..8b1485e3 100644
--- a/core/wiki/wiki.go
+++ b/core/wiki/wiki.go
@@ -6,6 +6,7 @@ import (
"strings"
ice "shylinux.com/x/icebergs"
+ "shylinux.com/x/icebergs/base/cli"
"shylinux.com/x/icebergs/base/ctx"
"shylinux.com/x/icebergs/base/lex"
"shylinux.com/x/icebergs/base/mdb"
@@ -21,8 +22,8 @@ func _name(m *ice.Message, arg []string) []string {
func _option(m *ice.Message, kind, name, text string, arg ...string) *ice.Message {
extra := kit.Dict()
kit.For(arg, func(k, v string) {
- kit.If(k == "fg", func() { k = "style.color" })
- kit.If(k == "bg", func() { k = "style.background" })
+ kit.If(k == cli.FG, func() { k = "style.color" })
+ kit.If(k == cli.BG, func() { k = "style.background" })
kit.Value(extra, k, kit.Format(kit.Parse(nil, "", kit.Split(v)...)))
})
m.OptionDefault(mdb.META, kit.Format(extra))
@@ -40,12 +41,6 @@ func _wiki_list(m *ice.Message, arg ...string) bool {
m.Copy(m.Cmd(nfs.DIR, kit.Slice(arg, 0, 1), kit.Dict(nfs.DIR_TYPE, nfs.CAT, nfs.DIR_REG, mdb.Config(m, lex.REGEXP))).SortStr(nfs.PATH))
return true
} else {
- p := ctx.GetCmdFile(m, m.PrefixKey())
- m.Debug("what %v", p)
- p = nfs.Relative(m, p)
- m.Debug("what %v", p)
- p = ctx.FileURI(p)
- m.Debug("what %v", p)
ctx.Display(m, ctx.FileURI(nfs.Relative(m, ctx.GetCmdFile(m, m.PrefixKey()))))
// ctx.DisplayLocal(m, path.Join(kit.PathName(2), kit.Keys(kit.FileName(2), nfs.JS)))
return false
@@ -71,9 +66,9 @@ var Index = &ice.Context{Name: WIKI, Help: "文档中心"}
func init() {
web.Index.Register(Index, &web.Frame{},
- TITLE, BRIEF, REFER, SPARK, PARSE, FIELD,
+ FEEL, DRAW, DATA, WORD, PORTAL, STYLE,
+ TITLE, BRIEF, REFER, SPARK, FIELD,
ORDER, TABLE, CHART, IMAGE, VIDEO, AUDIO,
- WORD, DATA, DRAW, FEEL, STYLE, PORTAL,
)
}
func Prefix(arg ...string) string { return web.Prefix(WIKI, kit.Keys(arg)) }
diff --git a/core/wiki/wiki.shy b/core/wiki/wiki.shy
index 54ccbcec..832ca209 100644
--- a/core/wiki/wiki.shy
+++ b/core/wiki/wiki.shy
@@ -7,10 +7,9 @@ data.go
word.go
title.go
-refer.go
brief.go
+refer.go
spark.go
-parse.go
field.go
order.go
@@ -19,9 +18,9 @@ chart.go
image.go
video.go
audio.go
+iframe.go
style.go
-iframe.go
portal.go
portal.js
portal.css
diff --git a/core/wiki/word.go b/core/wiki/word.go
index e0bb48ae..21437e5e 100644
--- a/core/wiki/word.go
+++ b/core/wiki/word.go
@@ -2,7 +2,7 @@ package wiki
import (
"net/http"
- "strings"
+ "path"
ice "shylinux.com/x/icebergs"
"shylinux.com/x/icebergs/base/aaa"
@@ -16,10 +16,8 @@ import (
)
func _word_show(m *ice.Message, name string, arg ...string) {
- if strings.HasPrefix(name, "/require/") {
- m.Option(nfs.CAT_CONTENT, m.Cmdx(web.SPIDE, ice.OPS, web.SPIDE_RAW, http.MethodGet, name))
- }
- m.Options(ice.MSG_ALIAS, mdb.Configv(m, mdb.ALIAS), TITLE, map[string]int{})
+ kit.If(kit.HasPrefix(name, nfs.PS, web.HTTP), func() { m.Option(nfs.CAT_CONTENT, m.Cmdx(web.SPIDE, ice.OPS, web.SPIDE_RAW, http.MethodGet, name)) })
+ m.Options(ice.SSH_TARGET, m.Target(), ice.SSH_ALIAS, mdb.Configv(m, mdb.ALIAS), TITLE, map[string]int{})
m.Cmdy(ssh.SOURCE, name, kit.Dict(nfs.DIR_ROOT, _wiki_path(m)))
}
@@ -44,19 +42,17 @@ func init() {
if m.Option(nfs.DIR_DEEP, ice.TRUE); kit.Path(value[nfs.PATH]) == kit.Path("") {
_wiki_list(m, nfs.SRC)
} else {
- _wiki_list(m, value[nfs.PATH])
+ _wiki_list(m, path.Join(value[nfs.PATH], nfs.SRC))
}
})
m.Cut("path,size,time")
- }}, "play": {Help: "演示"},
+ }},
code.COMPLETE: {Hand: func(m *ice.Message, arg ...string) {
- ls := kit.Split(m.Option(mdb.TEXT))
- kit.If(kit.IsIn(ls[0], IMAGE, VIDEO, AUDIO), func() { m.Cmdy(FEEL).CutTo(nfs.PATH, mdb.NAME) })
+ kit.If(kit.IsIn(kit.Split(m.Option(mdb.TEXT))[0], IMAGE, VIDEO, AUDIO), func() { m.Cmdy(FEEL).CutTo(nfs.PATH, mdb.NAME) })
}},
}, aaa.RoleAction(), WikiAction("", nfs.SHY)), Hand: func(m *ice.Message, arg ...string) {
- if m.Option(nfs.DIR_DEEP, ice.TRUE); len(arg) == 0 {
- arg = append(arg, nfs.SRC)
- }
+ m.Option(nfs.DIR_DEEP, ice.TRUE)
+ kit.If(len(arg) == 0, func() { arg = append(arg, nfs.SRC) })
kit.If(!_wiki_list(m, arg...), func() { _word_show(m, arg[0]) })
}},
})
diff --git a/misc/chrome/spide.go b/misc/chrome/spide.go
index 43812c64..1ad04a93 100644
--- a/misc/chrome/spide.go
+++ b/misc/chrome/spide.go
@@ -29,7 +29,7 @@ func (s spide) List(m *ice.Message, arg ...string) {
m.PushAudios(mdb.SHOW, value[mdb.LINK])
case wiki.VIDEO:
m.PushVideos(mdb.SHOW, value[mdb.LINK])
- case wiki.IMG:
+ case "img":
m.PushImages(mdb.SHOW, value[mdb.LINK])
default:
m.Push(mdb.SHOW, "")