mirror of
https://shylinux.com/x/icebergs
synced 2025-05-02 03:29:25 +08:00
opt wiki
This commit is contained in:
parent
d582280b0a
commit
40d48142b6
@ -11,7 +11,10 @@ func init() { Index.MergeCommands(ice.Commands{RENDER: {Help: "渲染", Actions:
|
|||||||
|
|
||||||
func RenderAction(arg ...ice.Any) ice.Actions {
|
func RenderAction(arg ...ice.Any) ice.Actions {
|
||||||
return ice.MergeActions(ice.Actions{ice.CTX_INIT: AutoConfig(SHORT, TYPE, FIELD, "time,type,name,text", arg),
|
return ice.MergeActions(ice.Actions{ice.CTX_INIT: AutoConfig(SHORT, TYPE, FIELD, "time,type,name,text", arg),
|
||||||
CREATE: {Name: "create type name text", Hand: func(m *ice.Message, arg ...string) { HashCreate(m) }},
|
CREATE: {Name: "create type name text", Hand: func(m *ice.Message, arg ...string) {
|
||||||
|
Config(m, SHORT, TYPE)
|
||||||
|
HashCreate(m)
|
||||||
|
}},
|
||||||
SELECT: {Name: "select type name text auto create", Hand: func(m *ice.Message, arg ...string) {
|
SELECT: {Name: "select type name text auto create", Hand: func(m *ice.Message, arg ...string) {
|
||||||
if len(arg) < 2 || arg[0] == "" {
|
if len(arg) < 2 || arg[0] == "" {
|
||||||
HashSelect(m, arg...)
|
HashSelect(m, arg...)
|
||||||
|
@ -131,7 +131,7 @@ func Template(m templateMessage, p string, arg ...ice.Any) string {
|
|||||||
return kit.Renders(kit.Format(TemplateText(m, p), arg...), m)
|
return kit.Renders(kit.Format(TemplateText(m, p), arg...), m)
|
||||||
}
|
}
|
||||||
func TemplateText(m templateMessage, p string) string {
|
func TemplateText(m templateMessage, p string) string {
|
||||||
return m.Cmdx(CAT, path.Join(m.PrefixKey(), path.Base(p)), kit.Dict(DIR_ROOT, ice.SRC_TEMPLATE))
|
return strings.TrimSpace(m.Cmdx(CAT, path.Join(m.PrefixKey(), path.Base(p)), kit.Dict(DIR_ROOT, ice.SRC_TEMPLATE)))
|
||||||
}
|
}
|
||||||
func IsSourceFile(m *ice.Message, ext string) bool {
|
func IsSourceFile(m *ice.Message, ext string) bool {
|
||||||
return mdb.Conf(m, Prefix(CAT), kit.Keym(SOURCE, ext)) == ice.TRUE
|
return mdb.Conf(m, Prefix(CAT), kit.Keym(SOURCE, ext)) == ice.TRUE
|
||||||
|
@ -96,11 +96,11 @@ func _space_handle(m *ice.Message, safe bool, name string, c *websocket.Conn) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
func _space_domain(m *ice.Message) (link string) {
|
func _space_domain(m *ice.Message) (link string) {
|
||||||
// m.Options(ice.MSG_OPTION, ice.MSG_USERNAME, ice.MSG_OPTS, ice.MSG_USERNAME)
|
|
||||||
return kit.GetValid(
|
return kit.GetValid(
|
||||||
func() string { return ice.Info.Domain },
|
func() string { return ice.Info.Domain },
|
||||||
func() string {
|
func() string {
|
||||||
if dev := kit.Select(ice.DEV, ice.OPS, ice.Info.NodeType == WORKER); mdb.HashSelectDetail(m, dev, nil) {
|
if dev := kit.Select(ice.DEV, ice.OPS, ice.Info.NodeType == WORKER); mdb.HashSelectDetail(m, dev, nil) {
|
||||||
|
m.Options(ice.MSG_OPTION, ice.MSG_USERNAME, ice.MSG_OPTS, ice.MSG_USERNAME)
|
||||||
return m.Cmdv(SPACE, dev, cli.PWD, mdb.LINK)
|
return m.Cmdv(SPACE, dev, cli.PWD, mdb.LINK)
|
||||||
}
|
}
|
||||||
return ""
|
return ""
|
||||||
@ -111,7 +111,7 @@ func _space_domain(m *ice.Message) (link string) {
|
|||||||
func _space_exec(m *ice.Message, source, target []string, c *websocket.Conn) {
|
func _space_exec(m *ice.Message, source, target []string, c *websocket.Conn) {
|
||||||
switch kit.Select(cli.PWD, m.Detailv(), 0) {
|
switch kit.Select(cli.PWD, m.Detailv(), 0) {
|
||||||
case cli.PWD:
|
case cli.PWD:
|
||||||
m.Push(mdb.LINK, m.MergePod(_space_domain(m), kit.Select("", source, -1)))
|
m.Push(mdb.LINK, m.MergePod(kit.Select("", source, -1)))
|
||||||
default:
|
default:
|
||||||
kit.If(aaa.Right(m, m.Detailv()), func() { m = m.Cmd() })
|
kit.If(aaa.Right(m, m.Detailv()), func() { m = m.Cmd() })
|
||||||
}
|
}
|
||||||
|
@ -66,7 +66,7 @@ func _autogen_version(m *ice.Message) string {
|
|||||||
func _autogen_gits(m *ice.Message, arg ...string) string {
|
func _autogen_gits(m *ice.Message, arg ...string) string {
|
||||||
res := []string{}
|
res := []string{}
|
||||||
kit.For(_autogen_git(m, arg...), func(k, v string) {
|
kit.For(_autogen_git(m, arg...), func(k, v string) {
|
||||||
res = append(res, kit.Format(` %s: "%s",`, kit.LowerCapital(k), strings.TrimSpace(v)))
|
res = append(res, kit.Format(` %s: "%s",`, kit.Capital(k), strings.TrimSpace(v)))
|
||||||
})
|
})
|
||||||
return kit.Join(res, ice.NL)
|
return kit.Join(res, ice.NL)
|
||||||
}
|
}
|
||||||
|
@ -133,7 +133,7 @@ func init() {
|
|||||||
func PlugAction() ice.Actions {
|
func PlugAction() ice.Actions {
|
||||||
return ice.Actions{
|
return ice.Actions{
|
||||||
ice.CTX_INIT: {Hand: func(m *ice.Message, arg ...string) {
|
ice.CTX_INIT: {Hand: func(m *ice.Message, arg ...string) {
|
||||||
kit.For([]string{mdb.PLUGIN, mdb.RENDER, mdb.ENGINE}, func(cmd string) { m.Cmd(cmd, mdb.CREATE, m.CommandKey(), m.PrefixKey()) })
|
kit.For([]string{mdb.PLUGIN, mdb.RENDER, mdb.ENGINE, TEMPLATE, COMPLETE}, func(cmd string) { m.Cmd(cmd, mdb.CREATE, m.CommandKey(), m.PrefixKey()) })
|
||||||
LoadPlug(m, m.CommandKey())
|
LoadPlug(m, m.CommandKey())
|
||||||
}},
|
}},
|
||||||
mdb.PLUGIN: {Hand: func(m *ice.Message, arg ...string) { m.Echo(mdb.Config(m, PLUG)) }},
|
mdb.PLUGIN: {Hand: func(m *ice.Message, arg ...string) { m.Echo(mdb.Config(m, PLUG)) }},
|
||||||
|
@ -19,17 +19,13 @@ func init() {
|
|||||||
Index.MergeCommands(ice.Commands{
|
Index.MergeCommands(ice.Commands{
|
||||||
SHY: {Name: "shy path auto", Help: "笔记", Actions: ice.MergeActions(ice.Actions{
|
SHY: {Name: "shy path auto", Help: "笔记", Actions: ice.MergeActions(ice.Actions{
|
||||||
mdb.RENDER: {Hand: func(m *ice.Message, arg ...string) {
|
mdb.RENDER: {Hand: func(m *ice.Message, arg ...string) {
|
||||||
// ctx.ProcessCommand(m, web.WIKI_WORD, kit.Simple(path.Join(arg[2], arg[1])))
|
ctx.ProcessCommand(m, web.WIKI_WORD, kit.Simple(path.Join(arg[2], arg[1])))
|
||||||
// ctx.ProcessCommand(m, yac.STACK, kit.Simple(arg[1]))
|
return
|
||||||
// if ls := kit.Split(arg[1], ice.PS); ls[0] == nfs.SCRIPT {
|
|
||||||
// m.Search(ls[1], func(key string, cmd *ice.Command) { yac.StackHandler(m) })
|
|
||||||
// ctx.ProcessCommand(m, ls[1], kit.Simple())
|
|
||||||
// } else {
|
|
||||||
// ctx.ProcessCommand(m, kit.TrimExt(arg[1], SHY), kit.Simple())
|
|
||||||
// }
|
|
||||||
ctx.ProcessCommand(m, yac.STACK, kit.Simple(path.Join(arg[2], arg[1])))
|
ctx.ProcessCommand(m, yac.STACK, kit.Simple(path.Join(arg[2], arg[1])))
|
||||||
}},
|
}},
|
||||||
mdb.ENGINE: {Hand: func(m *ice.Message, arg ...string) {
|
mdb.ENGINE: {Hand: func(m *ice.Message, arg ...string) {
|
||||||
|
ctx.ProcessCommand(m, web.WIKI_WORD, kit.Simple(path.Join(arg[2], arg[1])))
|
||||||
|
return
|
||||||
if msg := m.Cmd(yac.STACK, path.Join(arg[2], arg[1])); msg.Option("__index") != "" {
|
if msg := m.Cmd(yac.STACK, path.Join(arg[2], arg[1])); msg.Option("__index") != "" {
|
||||||
ctx.ProcessCommand(m, msg.Option("__index"), kit.Simple())
|
ctx.ProcessCommand(m, msg.Option("__index"), kit.Simple())
|
||||||
} else {
|
} else {
|
||||||
@ -39,6 +35,7 @@ func init() {
|
|||||||
TEMPLATE: {Hand: func(m *ice.Message, arg ...string) {
|
TEMPLATE: {Hand: func(m *ice.Message, arg ...string) {
|
||||||
m.Echo(nfs.Template(m, "demo.shy"), path.Base(path.Dir(path.Join(arg[2], arg[1]))))
|
m.Echo(nfs.Template(m, "demo.shy"), path.Base(path.Dir(path.Join(arg[2], arg[1]))))
|
||||||
}},
|
}},
|
||||||
|
COMPLETE: {Hand: func(m *ice.Message, arg ...string) { m.Cmdy("web.wiki.word", COMPLETE, arg) }},
|
||||||
}, PlugAction()), Hand: func(m *ice.Message, arg ...string) {
|
}, PlugAction()), Hand: func(m *ice.Message, arg ...string) {
|
||||||
if len(arg) > 0 && kit.Ext(arg[0]) == m.CommandKey() {
|
if len(arg) > 0 && kit.Ext(arg[0]) == m.CommandKey() {
|
||||||
m.Cmdy(web.WIKI_WORD, path.Join(ice.SRC, strings.TrimPrefix(arg[0], nfs.SRC)))
|
m.Cmdy(web.WIKI_WORD, path.Join(ice.SRC, strings.TrimPrefix(arg[0], nfs.SRC)))
|
||||||
|
@ -2,6 +2,7 @@ package wiki
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
ice "shylinux.com/x/icebergs"
|
ice "shylinux.com/x/icebergs"
|
||||||
|
"shylinux.com/x/icebergs/base/ctx"
|
||||||
"shylinux.com/x/icebergs/base/nfs"
|
"shylinux.com/x/icebergs/base/nfs"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -12,8 +13,8 @@ const AUDIO = "audio"
|
|||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
Index.MergeCommands(ice.Commands{
|
Index.MergeCommands(ice.Commands{
|
||||||
AUDIO: {Name: "audio url", Help: "音频", Actions: WordAction(
|
AUDIO: {Name: "audio url", Help: "音频", Actions: ctx.ConfAction(nfs.PATH, ice.USR_LOCAL_IMAGE), Hand: func(m *ice.Message, arg ...string) {
|
||||||
`<audio {{.OptionTemplate}} src="{{.Option "text"}}" controls></audio>`, nfs.PATH, ice.USR_LOCAL_IMAGE,
|
_image_show(m, arg[0], arg[1:]...)
|
||||||
), Hand: func(m *ice.Message, arg ...string) { _image_show(m, arg[0], arg[1:]...) }},
|
}},
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -8,8 +8,8 @@ const BRIEF = "brief"
|
|||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
Index.MergeCommands(ice.Commands{
|
Index.MergeCommands(ice.Commands{
|
||||||
BRIEF: {Name: "brief text", Help: "摘要", Actions: WordAction(
|
BRIEF: {Name: "brief text", Help: "摘要", Hand: func(m *ice.Message, arg ...string) {
|
||||||
`<p {{.OptionTemplate}}>{{.Option "text"}}</p>`,
|
_wiki_template(m, "", "", arg[0], arg[1:]...)
|
||||||
), Hand: func(m *ice.Message, arg ...string) { _wiki_template(m, "", arg[0], arg[1:]...) }},
|
}},
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -124,7 +124,7 @@ func _chart_show(m *ice.Message, kind, text string, arg ...string) {
|
|||||||
m.Option(WIDTH, chart.GetWidth())
|
m.Option(WIDTH, chart.GetWidth())
|
||||||
m.Option(HEIGHT, chart.GetHeight())
|
m.Option(HEIGHT, chart.GetHeight())
|
||||||
|
|
||||||
_wiki_template(m, "", text, arg...)
|
_wiki_template(m, "", "", text, arg...)
|
||||||
defer m.Echo("</svg>")
|
defer m.Echo("</svg>")
|
||||||
defer m.RenderResult()
|
defer m.RenderResult()
|
||||||
chart.Draw(m, 0, 0)
|
chart.Draw(m, 0, 0)
|
||||||
@ -156,10 +156,8 @@ const CHART = "chart"
|
|||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
Index.MergeCommands(ice.Commands{
|
Index.MergeCommands(ice.Commands{
|
||||||
CHART: {Name: "chart type=label,chain,sequence run text", Help: "图表", Actions: WordAction(
|
CHART: {Name: "chart type=label,chain,sequence auto text", Help: "图表", Hand: func(m *ice.Message, arg ...string) {
|
||||||
`<svg xmlns="http://www.w3.org/2000/svg" vertion="1.1"
|
_chart_show(m, arg[0], strings.TrimSpace(arg[1]), arg[2:]...)
|
||||||
{{.OptionTemplate}} {{.OptionKV "height,width,font-size,font-family,stroke-width,stroke,fill"}}
|
}},
|
||||||
text-anchor="middle" dominant-baseline="middle">`,
|
|
||||||
), Hand: func(m *ice.Message, arg ...string) { _chart_show(m, arg[0], strings.TrimSpace(arg[1]), arg[2:]...) }},
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -29,25 +29,19 @@ func init() {
|
|||||||
m.Cmd(nfs.PUSH, path.Join(mdb.Config(m, nfs.PATH), arg[0]), kit.Join(arg[1:], ice.FS)+ice.NL)
|
m.Cmd(nfs.PUSH, path.Join(mdb.Config(m, nfs.PATH), arg[0]), kit.Join(arg[1:], ice.FS)+ice.NL)
|
||||||
}}, "draw": {Help: "绘图"},
|
}}, "draw": {Help: "绘图"},
|
||||||
}, WikiAction(ice.USR_LOCAL_EXPORT, nfs.CSV)), Hand: func(m *ice.Message, arg ...string) {
|
}, WikiAction(ice.USR_LOCAL_EXPORT, nfs.CSV)), Hand: func(m *ice.Message, arg ...string) {
|
||||||
if !_wiki_list(m, arg...) {
|
kit.If(!_wiki_list(m, arg...), func() { CSV(m, m.Cmdx(nfs.CAT, arg[0])).StatusTimeCount() })
|
||||||
CSV(m, m.Cmdx(nfs.CAT, arg[0])).StatusTimeCount()
|
|
||||||
}
|
|
||||||
}},
|
}},
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
func CSV(m *ice.Message, text string, head ...string) *ice.Message {
|
func CSV(m *ice.Message, text string, head ...string) *ice.Message {
|
||||||
r := csv.NewReader(bytes.NewBufferString(text))
|
r := csv.NewReader(bytes.NewBufferString(text))
|
||||||
if len(head) == 0 {
|
kit.If(len(head) == 0, func() { head, _ = r.Read() })
|
||||||
head, _ = r.Read()
|
|
||||||
}
|
|
||||||
for {
|
for {
|
||||||
line, e := r.Read()
|
line, e := r.Read()
|
||||||
if e != nil {
|
if e != nil {
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
for i, k := range head {
|
kit.For(head, func(i int, k string) { m.Push(k, kit.Select("", line, i)) })
|
||||||
m.Push(k, kit.Select("", line, i))
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return m
|
return m
|
||||||
}
|
}
|
||||||
|
@ -7,6 +7,7 @@ import (
|
|||||||
"shylinux.com/x/icebergs/base/ctx"
|
"shylinux.com/x/icebergs/base/ctx"
|
||||||
"shylinux.com/x/icebergs/base/mdb"
|
"shylinux.com/x/icebergs/base/mdb"
|
||||||
"shylinux.com/x/icebergs/base/nfs"
|
"shylinux.com/x/icebergs/base/nfs"
|
||||||
|
kit "shylinux.com/x/toolkits"
|
||||||
)
|
)
|
||||||
|
|
||||||
const DRAW = "draw"
|
const DRAW = "draw"
|
||||||
@ -22,9 +23,7 @@ func init() {
|
|||||||
m.Cmdy(nfs.CAT, path.Join(arg[2], arg[1]))
|
m.Cmdy(nfs.CAT, path.Join(arg[2], arg[1]))
|
||||||
}},
|
}},
|
||||||
}, WikiAction("", nfs.SVG), ctx.CmdAction()), Hand: func(m *ice.Message, arg ...string) {
|
}, WikiAction("", nfs.SVG), ctx.CmdAction()), Hand: func(m *ice.Message, arg ...string) {
|
||||||
if !_wiki_list(m, arg...) {
|
kit.If(!_wiki_list(m, arg...), func() { _wiki_show(m, arg[0]) })
|
||||||
_wiki_show(m, arg[0])
|
|
||||||
}
|
|
||||||
}},
|
}},
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -10,10 +10,9 @@ const FEEL = "feel"
|
|||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
Index.MergeCommands(ice.Commands{
|
Index.MergeCommands(ice.Commands{
|
||||||
FEEL: {Name: "feel path auto record1 record2 upload prev next actions", Help: "影音媒体", Actions: ice.MergeActions(ice.Actions{
|
FEEL: {Name: "feel path auto prev next record1 record2 upload actions", Help: "影音媒体", Actions: ice.MergeActions(ice.Actions{
|
||||||
"record1": {Name: "record1", Help: "截图"},
|
"record1": {Help: "截图"}, "record2": {Help: "录屏"},
|
||||||
"record2": {Name: "record2", Help: "录屏"},
|
}, WikiAction(ice.USR_LOCAL_IMAGE, "png|PNG|jpg|JPG|jpeg|mp4|m4v|mov|MOV|webm")), Hand: func(m *ice.Message, arg ...string) {
|
||||||
}, WikiAction(ice.USR_LOCAL_IMAGE, "png|PNG|jpg|JPG|jpeg|mp4|m4v|MOV|webm")), Hand: func(m *ice.Message, arg ...string) {
|
|
||||||
_wiki_list(m, kit.Slice(arg, 0, 1)...)
|
_wiki_list(m, kit.Slice(arg, 0, 1)...)
|
||||||
ctx.DisplayLocal(m, "")
|
ctx.DisplayLocal(m, "")
|
||||||
}},
|
}},
|
||||||
|
@ -1,121 +1,41 @@
|
|||||||
package wiki
|
package wiki
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"path"
|
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
ice "shylinux.com/x/icebergs"
|
ice "shylinux.com/x/icebergs"
|
||||||
"shylinux.com/x/icebergs/base/aaa"
|
"shylinux.com/x/icebergs/base/aaa"
|
||||||
"shylinux.com/x/icebergs/base/ctx"
|
"shylinux.com/x/icebergs/base/ctx"
|
||||||
"shylinux.com/x/icebergs/base/mdb"
|
"shylinux.com/x/icebergs/base/mdb"
|
||||||
"shylinux.com/x/icebergs/base/nfs"
|
|
||||||
kit "shylinux.com/x/toolkits"
|
kit "shylinux.com/x/toolkits"
|
||||||
)
|
)
|
||||||
|
|
||||||
func Parse(m *ice.Message, meta string, key string, arg ...string) (data ice.Any) {
|
|
||||||
list := []string{}
|
|
||||||
for _, line := range kit.SplitLine(strings.Join(arg, ice.SP)) {
|
|
||||||
if strings.HasPrefix(strings.TrimSpace(line), "# ") {
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
list = append(list, kit.SplitWord(line)...)
|
|
||||||
}
|
|
||||||
switch data = kit.Parse(nil, "", list...); meta {
|
|
||||||
case ice.MSG_OPTION:
|
|
||||||
m.Option(key, data)
|
|
||||||
case ice.MSG_APPEND:
|
|
||||||
m.Append(key, data)
|
|
||||||
}
|
|
||||||
return data
|
|
||||||
}
|
|
||||||
func _field_show(m *ice.Message, name, text string, arg ...string) {
|
func _field_show(m *ice.Message, name, text string, arg ...string) {
|
||||||
meta, cmds := kit.Dict(), kit.Split(text)
|
meta := kit.Dict()
|
||||||
m.Search(cmds[0], func(p *ice.Context, s *ice.Context, key string, cmd *ice.Command) {
|
m.Search(text, func(key string, cmd *ice.Command) {
|
||||||
if meta[FEATURE], meta[INPUTS] = kit.Dict(cmd.Meta), cmd.List; name == "" {
|
meta[mdb.META], meta[mdb.LIST], name = kit.Dict(cmd.Meta), cmd.List, kit.Select(cmd.Help, name)
|
||||||
name = cmd.Help
|
|
||||||
}
|
|
||||||
})
|
})
|
||||||
if len(meta) == 0 || !aaa.Right(m.Spawn(), cmds[0]) {
|
if m.Warn(len(meta) == 0, ice.ErrNotFound, text) || !aaa.Right(m.Spawn(), text) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
name = strings.Replace(name, ice.SP, "_", -1)
|
kit.For(arg, func(k, v string) {
|
||||||
meta[mdb.NAME], meta[mdb.INDEX] = name, text
|
if k == ctx.ARGS {
|
||||||
msg := m.Spawn()
|
kit.Value(meta, k, kit.Split(strings.TrimSuffix(strings.TrimPrefix(v, "["), "]")))
|
||||||
for i := 0; i < len(arg)-1; i += 2 {
|
|
||||||
if strings.HasPrefix(arg[i], "args.") {
|
|
||||||
kit.Value(meta, arg[i], m.Option(arg[i], strings.TrimSpace(arg[i+1])))
|
|
||||||
} else if strings.HasPrefix(arg[i], ARGS) {
|
|
||||||
kit.Value(meta, arg[i], m.Optionv(arg[i], kit.Split(strings.TrimSuffix(strings.TrimPrefix(arg[i+1], "["), "]"))))
|
|
||||||
} else {
|
} else {
|
||||||
kit.Value(meta, arg[i], Parse(m, ice.MSG_OPTION, arg[i], arg[i+1]))
|
kit.Value(meta, k, v)
|
||||||
}
|
}
|
||||||
|
})
|
||||||
switch arg[i] {
|
meta[mdb.NAME], meta[mdb.INDEX] = name, text
|
||||||
case ARGS:
|
_wiki_template(m.Options(mdb.META, kit.Format(meta)), "", name, text)
|
||||||
count := 0
|
|
||||||
kit.For(meta[INPUTS], func(index int, value ice.Map) {
|
|
||||||
if value[mdb.TYPE] != "button" {
|
|
||||||
count++
|
|
||||||
}
|
|
||||||
})
|
|
||||||
if args := kit.Simple(m.Optionv(arg[i])); len(args) > count {
|
|
||||||
list := meta[INPUTS].([]ice.Any)
|
|
||||||
for i := count; i < len(args); i++ {
|
|
||||||
list = append(list, kit.Dict(mdb.TYPE, "text", mdb.NAME, ARGS, mdb.VALUE, args[i]))
|
|
||||||
}
|
|
||||||
meta[INPUTS] = list
|
|
||||||
}
|
|
||||||
case TABLE:
|
|
||||||
ls := kit.SplitLine(arg[i+1])
|
|
||||||
head := kit.SplitWord(ls[0])
|
|
||||||
for _, l := range ls[1:] {
|
|
||||||
for i, v := range kit.SplitWord(l) {
|
|
||||||
msg.Push(head[i], v)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
kit.Value(meta, "msg", msg.FormatMeta(), kit.Keys(FEATURE, "mode"), "simple")
|
|
||||||
case SPARK:
|
|
||||||
if arg[i+1][0] == '@' && nfs.Exists(m, arg[i+1][1:]) {
|
|
||||||
msg.Cmdy(nfs.CAT, arg[i+1][1:])
|
|
||||||
} else {
|
|
||||||
msg.Echo(strings.TrimSpace(arg[i+1]))
|
|
||||||
}
|
|
||||||
kit.Value(meta, "msg", msg.FormatMeta(), kit.Keys(FEATURE, "mode"), "simple")
|
|
||||||
if text == "web.code.inner" {
|
|
||||||
kit.Value(meta, kit.Keys(FEATURE, ctx.DISPLAY), "/plugin/local/code/inner.js")
|
|
||||||
kit.Value(meta, "plug", kit.UnMarshal(m.Cmdx(mdb.PLUGIN, kit.Ext(name))))
|
|
||||||
kit.Value(meta, ARGS, kit.List(path.Dir(name)+ice.PS, path.Base(name)))
|
|
||||||
}
|
|
||||||
default:
|
|
||||||
kit.Value(meta, kit.Keys(FEATURE, arg[i]), msg.Optionv(arg[i], arg[i+1]))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
m.Option(mdb.META, meta)
|
|
||||||
_wiki_template(m, name, text)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const (
|
|
||||||
FEATURE = "feature"
|
|
||||||
INPUTS = "inputs"
|
|
||||||
ARGS = "args"
|
|
||||||
)
|
|
||||||
const FIELD = "field"
|
const FIELD = "field"
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
Index.MergeCommands(ice.Commands{
|
Index.MergeCommands(ice.Commands{
|
||||||
FIELD: {Name: "field [name] cmd", Help: "插件", Actions: ice.MergeActions(WordAction(`<fieldset {{.OptionTemplate}}" data-meta='{{.Optionv "meta"|Format}}'>
|
FIELD: {Name: "field name cmd", Help: "插件", Actions: ctx.CmdAction(), Hand: func(m *ice.Message, arg ...string) {
|
||||||
<legend>{{.Option "name"}}</legend>
|
kit.If(kit.Select("", arg, 1) == ctx.ARGS, func() { arg = kit.Simple("", arg) })
|
||||||
<form class="option"></form>
|
arg = _name(m, arg)
|
||||||
<div class="action"></div>
|
|
||||||
<div class="output"></div>
|
|
||||||
<div class="status"></div>
|
|
||||||
</fieldset>`), ctx.CmdAction()), Hand: func(m *ice.Message, arg ...string) {
|
|
||||||
if kit.Select("", arg, 1) == ctx.ARGS {
|
|
||||||
arg = kit.Simple("", arg)
|
|
||||||
}
|
|
||||||
if arg = _name(m, arg); strings.Contains(arg[1], ice.NL) {
|
|
||||||
arg = kit.Simple(arg[0], "web.chat.div", "auto.cmd", "split", "opts.text", arg[1], arg[2:])
|
|
||||||
}
|
|
||||||
_field_show(m, arg[0], arg[1], arg[2:]...)
|
_field_show(m, arg[0], arg[1], arg[2:]...)
|
||||||
}},
|
}},
|
||||||
})
|
})
|
||||||
|
@ -2,11 +2,12 @@ package wiki
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
ice "shylinux.com/x/icebergs"
|
ice "shylinux.com/x/icebergs"
|
||||||
|
"shylinux.com/x/icebergs/base/ctx"
|
||||||
"shylinux.com/x/icebergs/base/nfs"
|
"shylinux.com/x/icebergs/base/nfs"
|
||||||
)
|
)
|
||||||
|
|
||||||
func _image_show(m *ice.Message, text string, arg ...string) {
|
func _image_show(m *ice.Message, text string, arg ...string) {
|
||||||
_wiki_template(m, "", _wiki_link(m, text), arg...)
|
_wiki_template(m, "", "", _wiki_link(m, text), arg...)
|
||||||
}
|
}
|
||||||
|
|
||||||
const (
|
const (
|
||||||
@ -19,8 +20,8 @@ const IMAGE = "image"
|
|||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
Index.MergeCommands(ice.Commands{
|
Index.MergeCommands(ice.Commands{
|
||||||
IMAGE: {Name: "image url run", Help: "图片", Actions: WordAction(
|
IMAGE: {Name: "image path auto", Help: "图片", Actions: ice.MergeActions(ctx.ConfAction(nfs.PATH, ice.USR_LOCAL_IMAGE)), Hand: func(m *ice.Message, arg ...string) {
|
||||||
`<img {{.OptionTemplate}} title="{{.Option "text"}}" src="{{.Option "text"}}">`, nfs.PATH, ice.USR_LOCAL_IMAGE,
|
_image_show(m, arg[0], arg[1:]...)
|
||||||
), Hand: func(m *ice.Message, arg ...string) { _image_show(m, arg[0], arg[1:]...) }},
|
}},
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -7,16 +7,15 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func _order_show(m *ice.Message, text string, arg ...string) {
|
func _order_show(m *ice.Message, text string, arg ...string) {
|
||||||
m.Optionv(mdb.LIST, kit.SplitLine(text))
|
_wiki_template(m.Options(mdb.LIST, kit.SplitLine(text)), "", "", text, arg...)
|
||||||
_wiki_template(m, "", text, arg...)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const ORDER = "order"
|
const ORDER = "order"
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
Index.MergeCommands(ice.Commands{
|
Index.MergeCommands(ice.Commands{
|
||||||
ORDER: {Name: "order text", Help: "列表", Actions: WordAction(
|
ORDER: {Name: "order text", Help: "列表", Hand: func(m *ice.Message, arg ...string) {
|
||||||
`<ul {{.OptionTemplate}}>{{range $index, $value := .Optionv "list"}}<li>{{$value}}</li>{{end}}</ul>`,
|
_order_show(m, arg[0], arg[1:]...)
|
||||||
), Hand: func(m *ice.Message, arg ...string) { _order_show(m, arg[0], arg[1:]...) }},
|
}},
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -3,7 +3,6 @@ package wiki
|
|||||||
import (
|
import (
|
||||||
"encoding/base64"
|
"encoding/base64"
|
||||||
"encoding/hex"
|
"encoding/hex"
|
||||||
"net/url"
|
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
@ -39,36 +38,27 @@ func init() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
switch m.OptionFields(mdb.DETAIL); arg[0] {
|
switch m.OptionFields(mdb.DETAIL); arg[0] {
|
||||||
case "base64":
|
|
||||||
if buf, err := base64.StdEncoding.DecodeString(arg[1]); err == nil {
|
|
||||||
m.Echo(hex.EncodeToString(buf))
|
|
||||||
}
|
|
||||||
case nfs.JSON:
|
case nfs.JSON:
|
||||||
m.Echo(kit.Formats(kit.UnMarshal(arg[1])))
|
m.Echo(kit.Formats(kit.UnMarshal(arg[1])))
|
||||||
ctx.DisplayStoryJSON(m)
|
ctx.DisplayStoryJSON(m)
|
||||||
case web.HTTP:
|
case web.HTTP:
|
||||||
u, _ := url.Parse(arg[1])
|
u := kit.ParseURL(arg[1])
|
||||||
m.Push(tcp.PROTO, u.Scheme)
|
m.Push(tcp.PROTO, u.Scheme).Push(tcp.HOST, u.Host).Push(nfs.PATH, u.Path)
|
||||||
m.Push(tcp.HOST, u.Host)
|
kit.For(u, func(k string, v []string) { m.Push(k, v) })
|
||||||
m.Push(nfs.PATH, u.Path)
|
|
||||||
for k, v := range u.Query() {
|
|
||||||
for _, v := range v {
|
|
||||||
m.Push(k, v)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
m.EchoQRCode(arg[1])
|
m.EchoQRCode(arg[1])
|
||||||
case web.FORM:
|
case web.FORM:
|
||||||
for _, v := range strings.Split(arg[1], "&") {
|
kit.SplitKV("=", "&", arg[1], func(k string, v []string) {
|
||||||
ls := strings.Split(v, ice.EQ)
|
kit.For(v, func(v string) { m.Push(kit.QueryUnescape(k), kit.QueryUnescape(v)) })
|
||||||
m.Push(kit.QueryUnescape(ls[0]), kit.QueryUnescape(kit.Select("", ls, 1)))
|
})
|
||||||
}
|
|
||||||
case mdb.TIME:
|
case mdb.TIME:
|
||||||
if i, e := strconv.ParseInt(arg[1], 10, 64); e == nil {
|
if i, e := strconv.ParseInt(arg[1], 10, 64); e == nil {
|
||||||
m.Echo(time.Unix(i, 0).Format(ice.MOD_TIME))
|
m.Echo(time.Unix(i, 0).Format(ice.MOD_TIME))
|
||||||
}
|
}
|
||||||
case mdb.LIST:
|
case mdb.LIST:
|
||||||
for i, v := range kit.Split(arg[1]) {
|
kit.For(kit.Split(arg[1]), func(i int, v string) { m.Push(kit.Format(i), v) })
|
||||||
m.Push(kit.Format(i), v)
|
case "base64":
|
||||||
|
if buf, err := base64.StdEncoding.DecodeString(arg[1]); err == nil {
|
||||||
|
m.Echo(hex.EncodeToString(buf))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}},
|
}},
|
||||||
|
@ -2,6 +2,7 @@ package wiki
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"path"
|
"path"
|
||||||
|
"strings"
|
||||||
|
|
||||||
ice "shylinux.com/x/icebergs"
|
ice "shylinux.com/x/icebergs"
|
||||||
"shylinux.com/x/icebergs/base/mdb"
|
"shylinux.com/x/icebergs/base/mdb"
|
||||||
@ -13,25 +14,20 @@ func _refer_show(m *ice.Message, text string, arg ...string) {
|
|||||||
for _, v := range kit.SplitLine(text) {
|
for _, v := range kit.SplitLine(text) {
|
||||||
if ls := kit.SplitWord(v); len(ls) == 1 {
|
if ls := kit.SplitWord(v); len(ls) == 1 {
|
||||||
p := kit.QueryUnescape(ls[0])
|
p := kit.QueryUnescape(ls[0])
|
||||||
list = append(list, []string{kit.Select(ls[0], path.Base(p)), ls[0], p})
|
list = append(list, []string{kit.Select(ls[0], path.Base(strings.Split(p, ice.QS)[0])), ls[0], p})
|
||||||
} else {
|
} else {
|
||||||
list = append(list, append(ls, kit.QueryUnescape(ls[1])))
|
list = append(list, append(ls, kit.QueryUnescape(ls[1])))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
m.Optionv(mdb.LIST, list)
|
_wiki_template(m.Options(mdb.LIST, list), "", "", text, arg...)
|
||||||
_wiki_template(m, "", text, arg...)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const REFER = "refer"
|
const REFER = "refer"
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
Index.MergeCommands(ice.Commands{
|
Index.MergeCommands(ice.Commands{
|
||||||
REFER: {Name: "refer text", Help: "参考", Actions: WordAction(
|
REFER: {Name: "refer text", Help: "参考", Hand: func(m *ice.Message, arg ...string) {
|
||||||
`<ul {{.OptionTemplate}}>{{range $index, $value := .Optionv "list"}}<li>{{index $value 0}}: <a href="{{index $value 1}}" data-name="{{index $value 0}}" target="_blank">{{index $value 2}}</a></li>{{end}}</ul>`,
|
_refer_show(m, arg[0], arg[1:]...)
|
||||||
), Hand: func(m *ice.Message, arg ...string) {
|
|
||||||
if len(arg) > 1 {
|
|
||||||
_refer_show(m, arg[0], arg[1:]...)
|
|
||||||
}
|
|
||||||
}},
|
}},
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -6,104 +6,63 @@ import (
|
|||||||
ice "shylinux.com/x/icebergs"
|
ice "shylinux.com/x/icebergs"
|
||||||
"shylinux.com/x/icebergs/base/mdb"
|
"shylinux.com/x/icebergs/base/mdb"
|
||||||
"shylinux.com/x/icebergs/base/nfs"
|
"shylinux.com/x/icebergs/base/nfs"
|
||||||
"shylinux.com/x/icebergs/base/ssh"
|
|
||||||
kit "shylinux.com/x/toolkits"
|
kit "shylinux.com/x/toolkits"
|
||||||
)
|
)
|
||||||
|
|
||||||
func _spark_show(m *ice.Message, name, text string, arg ...string) *ice.Message {
|
func _spark_md(m *ice.Message, arg ...string) *ice.Message {
|
||||||
if _option(m, m.CommandKey(), name, text, arg...); name == "" {
|
block, code := "", []string{}
|
||||||
return _wiki_template(m, name, text, arg...)
|
text := func() {
|
||||||
}
|
if len(code) > 0 {
|
||||||
m.Echo(`<div class="story" data-type="spark" data-name="%s" style="%s">`, name, m.Option("style"))
|
m.Cmdy(SPARK, kit.Join(code, ice.NL))
|
||||||
defer m.Echo("</div>")
|
code = []string{}
|
||||||
switch name {
|
}
|
||||||
case "inner", FIELD:
|
|
||||||
return m.Echo(text)
|
|
||||||
}
|
|
||||||
prompt := kit.Select(name+"> ", mdb.Config(m, kit.Keys(ssh.PROMPT, name)))
|
|
||||||
for _, l := range kit.SplitLine(text) {
|
|
||||||
m.Echo(Format("div", Format("label", prompt), Format("span", l)))
|
|
||||||
}
|
}
|
||||||
|
m.Cmd(nfs.CAT, arg[0], func(line string) {
|
||||||
|
for _, ls := range [][]string{[]string{"# ", TITLE}, []string{"## ", TITLE, CHAPTER}, []string{"### ", TITLE, SECTION}} {
|
||||||
|
if strings.HasPrefix(line, ls[0]) {
|
||||||
|
text()
|
||||||
|
m.Cmdy(ls[1:], strings.TrimPrefix(line, ls[0]))
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if strings.HasPrefix(line, "```") {
|
||||||
|
if block == "" {
|
||||||
|
text()
|
||||||
|
block = "```"
|
||||||
|
} else {
|
||||||
|
m.Cmdy(SPARK, SHELL, kit.Join(code, ice.NL))
|
||||||
|
block, code = "", []string{}
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
code = append(code, line)
|
||||||
|
})
|
||||||
|
text()
|
||||||
return m
|
return m
|
||||||
}
|
}
|
||||||
|
func _spark_show(m *ice.Message, name, text string, arg ...string) *ice.Message {
|
||||||
|
return _wiki_template(m.Options(mdb.LIST, kit.SplitLine(text)), name, name, text, arg...)
|
||||||
|
}
|
||||||
|
|
||||||
const (
|
const (
|
||||||
PROMPT = "prompt"
|
SHELL = "shell"
|
||||||
BREAK = "break"
|
|
||||||
SHELL = "shell"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
const SPARK = "spark"
|
const SPARK = "spark"
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
Index.MergeCommands(ice.Commands{
|
Index.MergeCommands(ice.Commands{
|
||||||
SPARK: {Name: "spark [name] text auto field:text value:text", Help: "段落", Actions: ice.MergeActions(ice.Actions{
|
SPARK: {Name: "spark type=inner,shell,redis,mysql text", Help: "段落", Actions: ice.MergeActions(ice.Actions{
|
||||||
ice.CTX_INIT: {Hand: func(m *ice.Message, arg ...string) {
|
ice.CTX_INIT: {Hand: func(m *ice.Message, arg ...string) {
|
||||||
ice.AddRender(ice.RENDER_SCRIPT, func(m *ice.Message, args ...ice.Any) string {
|
ice.AddRender(ice.RENDER_SCRIPT, func(msg *ice.Message, args ...ice.Any) string { return m.Cmdx(SPARK, SHELL, args) })
|
||||||
arg := kit.Simple(args...)
|
|
||||||
if m.IsCliUA() {
|
|
||||||
if len(arg) > 1 {
|
|
||||||
arg = arg[1:]
|
|
||||||
}
|
|
||||||
return strings.Join(arg, ice.NL)
|
|
||||||
}
|
|
||||||
if len(arg) == 1 && arg[0] != BREAK {
|
|
||||||
arg = []string{SHELL, arg[0]}
|
|
||||||
}
|
|
||||||
list := []string{kit.Format(`<div class="story" data-type="spark" data-name="%s">`, arg[0])}
|
|
||||||
for _, l := range kit.SplitLine(strings.Join(arg[1:], ice.NL)) {
|
|
||||||
list = append(list, Format("div", Format("label", kit.Select("> ", "$ ", arg[0] == SHELL)), Format("span", l)))
|
|
||||||
}
|
|
||||||
return strings.Join(append(list, "</div>"), "")
|
|
||||||
})
|
|
||||||
}},
|
}},
|
||||||
"md": {Name: "md file", Help: "md", Hand: func(m *ice.Message, arg ...string) {
|
}), Hand: func(m *ice.Message, arg ...string) {
|
||||||
block, code := "", []string{}
|
if kit.Ext(arg[0]) == "md" {
|
||||||
text := func() {
|
_spark_md(m, arg...)
|
||||||
if len(code) > 0 {
|
|
||||||
m.Cmdy(SPARK, kit.Join(code, ice.NL))
|
|
||||||
code = []string{}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
m.Cmd(nfs.CAT, m.Option(nfs.FILE), func(line string) {
|
|
||||||
for _, ls := range [][]string{
|
|
||||||
[]string{"# ", TITLE}, []string{"## ", TITLE, CHAPTER}, []string{"### ", TITLE, SECTION},
|
|
||||||
} {
|
|
||||||
if strings.HasPrefix(line, ls[0]) {
|
|
||||||
text()
|
|
||||||
m.Cmdy(ls[1:], strings.TrimPrefix(line, ls[0]))
|
|
||||||
return
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if strings.HasPrefix(line, "```") {
|
|
||||||
if block == "" {
|
|
||||||
text()
|
|
||||||
block = "```"
|
|
||||||
} else {
|
|
||||||
m.Cmdy(SPARK, SHELL, kit.Join(code, ice.NL))
|
|
||||||
block, code = "", []string{}
|
|
||||||
}
|
|
||||||
return
|
|
||||||
}
|
|
||||||
code = append(code, line)
|
|
||||||
})
|
|
||||||
text()
|
|
||||||
}},
|
|
||||||
}, WordAction(`<p {{.OptionTemplate}}>{{.Option "text"}}</p>`, ssh.PROMPT, kit.Dict(SHELL, "$ "))), Hand: func(m *ice.Message, arg ...string) {
|
|
||||||
if len(arg) == 0 {
|
|
||||||
m.Echo(`<br class="story" data-type="spark">`)
|
|
||||||
} else if kit.Ext(arg[0]) == "md" {
|
|
||||||
m.Cmdy(SPARK, "md", arg)
|
|
||||||
} else {
|
} else {
|
||||||
if arg[0] == "shell" && arg[1] == "inner" {
|
|
||||||
arg = arg[1:]
|
|
||||||
}
|
|
||||||
arg = _name(m, arg)
|
arg = _name(m, arg)
|
||||||
_spark_show(m, arg[0], strings.TrimSpace(arg[1]), arg[2:]...)
|
_spark_show(m, arg[0], strings.TrimSpace(arg[1]), arg[2:]...)
|
||||||
}
|
}
|
||||||
}},
|
}},
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
func Format(tag string, arg ...ice.Any) string {
|
|
||||||
return kit.Format("<%s>%s</%s>", tag, strings.Join(kit.Simple(arg), ""), tag)
|
|
||||||
}
|
|
||||||
|
@ -8,20 +8,14 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func _table_run(m *ice.Message, arg ...string) {
|
func _table_run(m *ice.Message, arg ...string) {
|
||||||
msg := m.Cmd(arg)
|
|
||||||
list := [][]string{}
|
list := [][]string{}
|
||||||
msg.Table(func(index int, value ice.Maps, head []string) {
|
m.Cmd(arg).Table(func(index int, value ice.Maps, head []string) {
|
||||||
if index == 0 {
|
kit.If(index == 0, func() { m.Optionv("head", head) })
|
||||||
m.Optionv("head", head)
|
|
||||||
}
|
|
||||||
line := []string{}
|
line := []string{}
|
||||||
for _, h := range head {
|
kit.For(head, func(h string) { line = append(line, value[h]) })
|
||||||
line = append(line, value[h])
|
|
||||||
}
|
|
||||||
list = append(list, line)
|
list = append(list, line)
|
||||||
})
|
})
|
||||||
m.Optionv("list", list)
|
_wiki_template(m.Options("list", list), "", "", "")
|
||||||
_wiki_template(m, "", "")
|
|
||||||
}
|
}
|
||||||
func _table_show(m *ice.Message, text string, arg ...string) {
|
func _table_show(m *ice.Message, text string, arg ...string) {
|
||||||
head, list := []string{}, [][]string{}
|
head, list := []string{}, [][]string{}
|
||||||
@ -30,22 +24,14 @@ func _table_show(m *ice.Message, text string, arg ...string) {
|
|||||||
head = kit.SplitWord(line)
|
head = kit.SplitWord(line)
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
list = append(list, transList(kit.SplitWord(line), func(value string) string {
|
list = append(list, kit.Simple(kit.SplitWord(line), func(value string) string {
|
||||||
if ls := kit.SplitWord(value); len(ls) > 1 {
|
if ls := kit.SplitWord(value); len(ls) > 1 {
|
||||||
return kit.Format(`<span style="%s">%s</span>`, kit.JoinKV(":", ";", transArgKey(ls[1:])...), ls[0])
|
return kit.Format(`<span style="%s">%s</span>`, kit.JoinKV(":", ";", transArgKey(ls[1:])...), ls[0])
|
||||||
}
|
}
|
||||||
return value
|
return value
|
||||||
}))
|
}))
|
||||||
}
|
}
|
||||||
m.Optionv("head", head)
|
_wiki_template(m.Options("head", head, "list", list), "", "", text, arg...)
|
||||||
m.Optionv("list", list)
|
|
||||||
_wiki_template(m, "", text, arg...)
|
|
||||||
}
|
|
||||||
func transList(arg []string, cb func(string) string) []string {
|
|
||||||
for i, v := range arg {
|
|
||||||
arg[i] = cb(v)
|
|
||||||
}
|
|
||||||
return arg
|
|
||||||
}
|
}
|
||||||
func transArgKey(arg []string) []string {
|
func transArgKey(arg []string) []string {
|
||||||
for i := 0; i < len(arg)-1; i += 2 {
|
for i := 0; i < len(arg)-1; i += 2 {
|
||||||
@ -65,9 +51,6 @@ func init() {
|
|||||||
Index.MergeCommands(ice.Commands{
|
Index.MergeCommands(ice.Commands{
|
||||||
TABLE: {Name: "table text", Help: "表格", Actions: ice.MergeActions(ice.Actions{
|
TABLE: {Name: "table text", Help: "表格", Actions: ice.MergeActions(ice.Actions{
|
||||||
ice.RUN: {Hand: func(m *ice.Message, arg ...string) { _table_run(m, arg...) }},
|
ice.RUN: {Hand: func(m *ice.Message, arg ...string) { _table_run(m, arg...) }},
|
||||||
}, WordAction(`<table {{.OptionTemplate}}>
|
}), Hand: func(m *ice.Message, arg ...string) { _table_show(m, arg[0], arg[1:]...) }},
|
||||||
<tr>{{range $i, $v := .Optionv "head"}}<th>{{$v}}</th>{{end}}</tr>
|
|
||||||
{{range $index, $value := .Optionv "list"}}<tr>{{range $i, $v := $value}}<td>{{$v}}</td>{{end}}</tr>{{end}}
|
|
||||||
</table>`)), Hand: func(m *ice.Message, arg ...string) { _table_show(m, arg[0], arg[1:]...) }},
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -7,48 +7,38 @@ import (
|
|||||||
"shylinux.com/x/icebergs/base/lex"
|
"shylinux.com/x/icebergs/base/lex"
|
||||||
"shylinux.com/x/icebergs/base/mdb"
|
"shylinux.com/x/icebergs/base/mdb"
|
||||||
"shylinux.com/x/icebergs/base/nfs"
|
"shylinux.com/x/icebergs/base/nfs"
|
||||||
|
"shylinux.com/x/icebergs/base/web"
|
||||||
kit "shylinux.com/x/toolkits"
|
kit "shylinux.com/x/toolkits"
|
||||||
)
|
)
|
||||||
|
|
||||||
func _title_parse(m *ice.Message, dir string, text string) string {
|
func _title_parse(m *ice.Message, text string) string {
|
||||||
return m.Cmdx(lex.SPLIT, "", "name,link", kit.Dict(nfs.CAT_CONTENT, text), func(ls []string) []string {
|
return m.Cmdx(lex.SPLIT, "", "name,link", kit.Dict(nfs.CAT_CONTENT, text), func(ls []string) []string {
|
||||||
if len(ls) > 1 {
|
kit.If(!kit.HasPrefix(ls[1], nfs.PS, web.HTTP), func() { ls[1] = path.Join(path.Dir(m.Option(ice.MSG_SCRIPT)), ls[1]) })
|
||||||
ls[1] = path.Join(dir, ls[1])
|
|
||||||
}
|
|
||||||
return ls
|
return ls
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
func _title_menu(m *ice.Message, kind, text string, arg ...string) *ice.Message {
|
func _title_menu(m *ice.Message, name, text string, arg ...string) *ice.Message {
|
||||||
if kind == NAVMENU {
|
m.Options(mdb.DATA, _title_parse(m, text))
|
||||||
m.Option(mdb.DATA, _title_parse(m, path.Dir(m.Option(ice.MSG_SCRIPT)), text))
|
return _wiki_template(m, name, name, text, arg...)
|
||||||
}
|
|
||||||
return _option(m, kind, "", text, arg...).RenderTemplate(mdb.Config(m, kind), &Message{m})
|
|
||||||
}
|
}
|
||||||
func _title_show(m *ice.Message, kind, text string, arg ...string) *ice.Message {
|
func _title_show(m *ice.Message, name, text string, arg ...string) *ice.Message {
|
||||||
switch title, _ := m.Optionv(TITLE).(map[string]int); kind {
|
switch title, _ := m.Optionv(TITLE).(map[string]int); name {
|
||||||
case SECTION:
|
case SECTION:
|
||||||
title[SECTION]++
|
title[SECTION]++
|
||||||
m.Option(LEVEL, "h3")
|
m.Options(LEVEL, "h3", PREFIX, kit.Format("%d.%d ", title[CHAPTER], title[SECTION]))
|
||||||
m.Option(PREFIX, kit.Format("%d.%d ", title[CHAPTER], title[SECTION]))
|
|
||||||
case CHAPTER:
|
case CHAPTER:
|
||||||
title[CHAPTER]++
|
title[CHAPTER]++
|
||||||
title[SECTION] = 0
|
title[SECTION] = 0
|
||||||
m.Option(LEVEL, "h2")
|
m.Options(LEVEL, "h2", PREFIX, kit.Format("%d ", title[CHAPTER]))
|
||||||
m.Option(PREFIX, kit.Format("%d ", title[CHAPTER]))
|
|
||||||
default:
|
default:
|
||||||
m.Option(LEVEL, "h1")
|
m.Options(LEVEL, "h1", PREFIX, "")
|
||||||
m.Option(PREFIX, "")
|
|
||||||
}
|
}
|
||||||
_wiki_template(m, "", text, arg...)
|
return _wiki_template(m, "", name, text, arg...)
|
||||||
menu, _ := m.Optionv(MENU).(ice.Map)
|
|
||||||
menu[mdb.LIST] = append(menu[mdb.LIST].([]ice.Any), kit.Dict(m.OptionSimple("level,prefix,text")))
|
|
||||||
return m
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const (
|
const (
|
||||||
PREFIX = "prefix"
|
|
||||||
LEVEL = "level"
|
LEVEL = "level"
|
||||||
MENU = "menu"
|
PREFIX = "prefix"
|
||||||
)
|
)
|
||||||
const (
|
const (
|
||||||
NAVMENU = "navmenu"
|
NAVMENU = "navmenu"
|
||||||
@ -61,21 +51,15 @@ const TITLE = "title"
|
|||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
Index.MergeCommands(ice.Commands{
|
Index.MergeCommands(ice.Commands{
|
||||||
TITLE: {Name: "title [navmenu|premenu|chapter|section|endmenu] text", Actions: WordAction(
|
TITLE: {Name: "title type=navmenu,premenu,chapter,section,endmenu text", Help: "标题", Hand: func(m *ice.Message, arg ...string) {
|
||||||
`<{{.Option "level"}} {{.OptionTemplate}}>{{.Option "prefix"}} {{.Option "text"}}</{{.Option "level"}}>`,
|
|
||||||
NAVMENU, `<div {{.OptionTemplate}} data-data='{{.Option "data"}}'></div>`,
|
|
||||||
PREMENU, `<ul {{.OptionTemplate}}></ul>`,
|
|
||||||
ENDMENU, `<ul {{.OptionTemplate}}>{{$menu := .Optionv "menu"}}
|
|
||||||
{{range $index, $value := Value $menu "list"}}<li>{{Value $value "prefix"}} {{Value $value "text"}}</li>{{end}}
|
|
||||||
</ul>`), Help: "标题", Hand: func(m *ice.Message, arg ...string) {
|
|
||||||
switch arg[0] {
|
switch arg[0] {
|
||||||
case NAVMENU:
|
case NAVMENU: // navmenu text arg...
|
||||||
_title_menu(m, arg[0], arg[1], arg[2:]...)
|
_title_menu(m, arg[0], arg[1], arg[2:]...)
|
||||||
case PREMENU, ENDMENU:
|
case PREMENU, ENDMENU: // premenu arg...
|
||||||
_title_menu(m, arg[0], "", arg[1:]...)
|
_title_menu(m, arg[0], "", arg[1:]...)
|
||||||
case CHAPTER, SECTION:
|
case CHAPTER, SECTION: // chapter text arg...
|
||||||
_title_show(m, arg[0], arg[1], arg[2:]...)
|
_title_show(m, arg[0], arg[1], arg[2:]...)
|
||||||
default:
|
default: // title text arg...
|
||||||
_title_show(m, "", arg[0], arg[1:]...)
|
_title_show(m, "", arg[0], arg[1:]...)
|
||||||
}
|
}
|
||||||
}},
|
}},
|
||||||
|
@ -2,6 +2,7 @@ package wiki
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
ice "shylinux.com/x/icebergs"
|
ice "shylinux.com/x/icebergs"
|
||||||
|
"shylinux.com/x/icebergs/base/ctx"
|
||||||
"shylinux.com/x/icebergs/base/nfs"
|
"shylinux.com/x/icebergs/base/nfs"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -14,8 +15,8 @@ const VIDEO = "video"
|
|||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
Index.MergeCommands(ice.Commands{
|
Index.MergeCommands(ice.Commands{
|
||||||
VIDEO: {Name: "video url run", Help: "视频", Actions: WordAction(
|
VIDEO: {Name: "video url run", Help: "视频", Actions: ice.MergeActions(ctx.ConfAction(nfs.PATH, ice.USR_LOCAL_IMAGE)), Hand: func(m *ice.Message, arg ...string) {
|
||||||
`<video {{.OptionTemplate}} title="{{.Option "text"}}" src="{{.Option "text"}}" controls></video>`, nfs.PATH, ice.USR_LOCAL_IMAGE,
|
_image_show(m, arg[0], arg[1:]...)
|
||||||
), Hand: func(m *ice.Message, arg ...string) { _image_show(m, arg[0], arg[1:]...) }},
|
}},
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -14,45 +14,31 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func _name(m *ice.Message, arg []string) []string {
|
func _name(m *ice.Message, arg []string) []string {
|
||||||
if len(arg) == 1 {
|
kit.If(len(arg) == 1, func() { arg = []string{"", arg[0]} })
|
||||||
return []string{"", arg[0]}
|
|
||||||
}
|
|
||||||
return arg
|
return arg
|
||||||
}
|
}
|
||||||
func _option(m *ice.Message, kind, name, text string, arg ...string) *ice.Message {
|
func _option(m *ice.Message, kind, name, text string, arg ...string) *ice.Message {
|
||||||
m.Option(mdb.TYPE, kind)
|
|
||||||
m.Option(mdb.NAME, name)
|
|
||||||
m.Option(mdb.TEXT, text)
|
|
||||||
|
|
||||||
extra := kit.Dict()
|
extra := kit.Dict()
|
||||||
m.Optionv(mdb.EXTRA, extra)
|
kit.For(arg, func(k, v string) { extra[k] = kit.Format(kit.Parse(nil, "", kit.Split(v)...)) })
|
||||||
for i := 0; i < len(arg)-1; i += 2 {
|
return m.Options(mdb.TYPE, kind, mdb.NAME, name, mdb.TEXT, text, mdb.EXTRA, extra)
|
||||||
extra[arg[i]] = kit.Format(kit.Parse(nil, "", kit.Split(arg[i+1])...))
|
|
||||||
}
|
|
||||||
return m
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func _wiki_path(m *ice.Message, arg ...string) string {
|
func _wiki_path(m *ice.Message, arg ...string) string {
|
||||||
return path.Join(mdb.Config(m, nfs.PATH), path.Join(arg...))
|
return path.Join(mdb.Config(m, nfs.PATH), path.Join(arg...))
|
||||||
}
|
}
|
||||||
func _wiki_link(m *ice.Message, text string) string {
|
func _wiki_link(m *ice.Message, text string) string {
|
||||||
if !kit.HasPrefix(text, ice.PS, ice.HTTP) {
|
kit.If(!kit.HasPrefix(text, ice.PS, ice.HTTP), func() { text = path.Join(web.SHARE_LOCAL, _wiki_path(m, text)) })
|
||||||
text = path.Join(web.SHARE_LOCAL, _wiki_path(m, text))
|
|
||||||
}
|
|
||||||
return text
|
return text
|
||||||
}
|
}
|
||||||
func _wiki_list(m *ice.Message, arg ...string) bool {
|
func _wiki_list(m *ice.Message, arg ...string) bool {
|
||||||
if m.Option(nfs.DIR_ROOT, _wiki_path(m)); len(arg) == 0 || kit.HasSuffix(arg[0], ice.PS) {
|
if m.Option(nfs.DIR_ROOT, _wiki_path(m)); len(arg) == 0 || kit.HasSuffix(arg[0], ice.PS) {
|
||||||
if m.Option(nfs.DIR_DEEP) != ice.TRUE {
|
kit.If(m.Option(nfs.DIR_DEEP) != ice.TRUE, func() { m.Cmdy(nfs.DIR, kit.Slice(arg, 0, 1), kit.Dict(nfs.DIR_TYPE, nfs.DIR)) })
|
||||||
m.Cmdy(nfs.DIR, kit.Slice(arg, 0, 1), kit.Dict(nfs.DIR_TYPE, nfs.DIR))
|
|
||||||
}
|
|
||||||
m.Cmdy(nfs.DIR, kit.Slice(arg, 0, 1), kit.Dict(nfs.DIR_TYPE, nfs.CAT, nfs.DIR_REG, mdb.Config(m, lex.REGEXP)))
|
m.Cmdy(nfs.DIR, kit.Slice(arg, 0, 1), kit.Dict(nfs.DIR_TYPE, nfs.CAT, nfs.DIR_REG, mdb.Config(m, lex.REGEXP)))
|
||||||
m.StatusTimeCount()
|
m.SortStrR(mdb.TIME).StatusTimeCount()
|
||||||
m.SortStrR(mdb.TIME)
|
|
||||||
return true
|
return true
|
||||||
|
} else {
|
||||||
|
ctx.DisplayLocal(m, path.Join(kit.PathName(2), kit.Keys(kit.FileName(2), nfs.JS)))
|
||||||
|
return false
|
||||||
}
|
}
|
||||||
ctx.DisplayLocal(m, path.Join(kit.PathName(2), kit.Keys(kit.FileName(2), ice.JS)))
|
|
||||||
return false
|
|
||||||
}
|
}
|
||||||
func _wiki_show(m *ice.Message, name string, arg ...string) {
|
func _wiki_show(m *ice.Message, name string, arg ...string) {
|
||||||
m.Cmdy(nfs.CAT, name, kit.Dict(nfs.DIR_ROOT, _wiki_path(m)))
|
m.Cmdy(nfs.CAT, name, kit.Dict(nfs.DIR_ROOT, _wiki_path(m)))
|
||||||
@ -63,8 +49,8 @@ func _wiki_save(m *ice.Message, name, text string, arg ...string) {
|
|||||||
func _wiki_upload(m *ice.Message, dir string) {
|
func _wiki_upload(m *ice.Message, dir string) {
|
||||||
m.Cmdy(web.CACHE, web.WATCH, m.Option(ice.MSG_UPLOAD), _wiki_path(m, dir, m.Option(mdb.NAME)))
|
m.Cmdy(web.CACHE, web.WATCH, m.Option(ice.MSG_UPLOAD), _wiki_path(m, dir, m.Option(mdb.NAME)))
|
||||||
}
|
}
|
||||||
func _wiki_template(m *ice.Message, name, text string, arg ...string) *ice.Message {
|
func _wiki_template(m *ice.Message, file, name, text string, arg ...string) *ice.Message {
|
||||||
return _option(m, m.CommandKey(), name, strings.TrimSpace(text), arg...).RenderTemplate(mdb.Config(m, nfs.TEMPLATE), &Message{m})
|
return m.Echo(nfs.Template(&Message{_option(m, m.CommandKey(), name, strings.TrimSpace(text), arg...)}, kit.Keys(kit.Select(m.CommandKey(), file), nfs.HTML)))
|
||||||
}
|
}
|
||||||
|
|
||||||
const WIKI = "wiki"
|
const WIKI = "wiki"
|
||||||
@ -73,9 +59,9 @@ var Index = &ice.Context{Name: WIKI, Help: "文档中心"}
|
|||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
web.Index.Register(Index, &web.Frame{},
|
web.Index.Register(Index, &web.Frame{},
|
||||||
TITLE, BRIEF, REFER, SPARK, FIELD, PARSE,
|
TITLE, BRIEF, REFER, SPARK, PARSE, FIELD,
|
||||||
ORDER, TABLE, CHART, IMAGE, VIDEO, AUDIO,
|
ORDER, TABLE, CHART, IMAGE, VIDEO, AUDIO,
|
||||||
FEEL, DRAW, DATA, WORD,
|
WORD, DATA, DRAW, FEEL,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
func Prefix(arg ...string) string { return web.Prefix(WIKI, kit.Keys(arg)) }
|
func Prefix(arg ...string) string { return web.Prefix(WIKI, kit.Keys(arg)) }
|
||||||
@ -83,8 +69,10 @@ func Prefix(arg ...string) string { return web.Prefix(WIKI, kit.Keys(arg)) }
|
|||||||
func WikiAction(dir string, ext ...string) ice.Actions {
|
func WikiAction(dir string, ext ...string) ice.Actions {
|
||||||
return ice.Actions{ice.CTX_INIT: mdb.AutoConfig(nfs.PATH, dir, lex.REGEXP, kit.ExtReg(ext...)),
|
return ice.Actions{ice.CTX_INIT: mdb.AutoConfig(nfs.PATH, dir, lex.REGEXP, kit.ExtReg(ext...)),
|
||||||
web.UPLOAD: {Hand: func(m *ice.Message, arg ...string) { _wiki_upload(m, m.Option(nfs.PATH)) }},
|
web.UPLOAD: {Hand: func(m *ice.Message, arg ...string) { _wiki_upload(m, m.Option(nfs.PATH)) }},
|
||||||
nfs.TRASH: {Name: "trash path*", Hand: func(m *ice.Message, arg ...string) { nfs.Trash(m, _wiki_path(m, m.Option(nfs.PATH))) }},
|
nfs.TRASH: {Hand: func(m *ice.Message, arg ...string) {
|
||||||
nfs.SAVE: {Name: "save path* text", Hand: func(m *ice.Message, arg ...string) { _wiki_save(m, m.Option(nfs.PATH), m.Option(mdb.TEXT)) }},
|
nfs.Trash(m, _wiki_path(m, kit.Select("some", kit.Select(m.Option(nfs.PATH), arg, 0))))
|
||||||
|
}},
|
||||||
|
nfs.SAVE: {Hand: func(m *ice.Message, arg ...string) { _wiki_save(m, m.Option(nfs.PATH), m.Option(mdb.TEXT)) }},
|
||||||
mdb.INPUTS: {Hand: func(m *ice.Message, arg ...string) {
|
mdb.INPUTS: {Hand: func(m *ice.Message, arg ...string) {
|
||||||
switch arg[0] {
|
switch arg[0] {
|
||||||
case nfs.PATH:
|
case nfs.PATH:
|
||||||
@ -102,36 +90,17 @@ type Message struct{ *ice.Message }
|
|||||||
func (m *Message) OptionTemplate() string {
|
func (m *Message) OptionTemplate() string {
|
||||||
res := []string{`class="story"`}
|
res := []string{`class="story"`}
|
||||||
add := func(pre, key string) {
|
add := func(pre, key string) {
|
||||||
if m.Option(key) != "" {
|
kit.If(m.Option(key), func() { res = append(res, kit.Format(`%s%s=%q`, pre, key, m.Option(key))) })
|
||||||
res = append(res, kit.Format(`%s%s="%s"`, pre, key, m.Option(key)))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
for _, key := range kit.Split("type,name,text") {
|
|
||||||
if key == mdb.TEXT && m.Option(mdb.TYPE) == SPARK {
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
add("data-", key)
|
|
||||||
}
|
|
||||||
kit.For(m.Optionv(mdb.EXTRA), func(key string, value string) {
|
|
||||||
switch key {
|
|
||||||
case PADDING:
|
|
||||||
return
|
|
||||||
}
|
|
||||||
if !strings.Contains(key, "-") {
|
|
||||||
add("data-", key)
|
|
||||||
}
|
|
||||||
})
|
|
||||||
for _, key := range kit.Split(ctx.STYLE) {
|
|
||||||
add("", key)
|
|
||||||
}
|
}
|
||||||
|
kit.For(kit.Split("type,name,text"), func(k string) { add("data-", k) })
|
||||||
|
kit.For(m.Optionv(mdb.EXTRA), func(k string, v string) { kit.If(!strings.Contains(k, "-"), func() { add("data-", k) }) })
|
||||||
|
kit.For(kit.Split(ctx.STYLE), func(k string) { add("", k) })
|
||||||
return kit.Join(res, ice.SP)
|
return kit.Join(res, ice.SP)
|
||||||
}
|
}
|
||||||
func (m *Message) OptionKV(key ...string) string {
|
func (m *Message) OptionKV(key ...string) string {
|
||||||
res := []string{}
|
res := []string{}
|
||||||
for _, k := range kit.Split(kit.Join(key)) {
|
kit.For(kit.Split(kit.Join(key)), func(k string) {
|
||||||
if m.Option(k) != "" {
|
kit.If(m.Option(k), func() { res = append(res, kit.Format("%s='%s'", k, m.Option(k))) })
|
||||||
res = append(res, kit.Format("%s='%s'", k, m.Option(k)))
|
})
|
||||||
}
|
|
||||||
}
|
|
||||||
return kit.Join(res, ice.SP)
|
return kit.Join(res, ice.SP)
|
||||||
}
|
}
|
||||||
|
@ -1,20 +1,19 @@
|
|||||||
wiki.shy
|
wiki.shy
|
||||||
wiki.go
|
wiki.go
|
||||||
|
word.go
|
||||||
|
feel.go
|
||||||
data.go
|
data.go
|
||||||
draw.go
|
draw.go
|
||||||
feel.go
|
|
||||||
word.go
|
|
||||||
|
|
||||||
title.go
|
title.go
|
||||||
brief.go
|
|
||||||
refer.go
|
refer.go
|
||||||
|
brief.go
|
||||||
spark.go
|
spark.go
|
||||||
field.go
|
|
||||||
parse.go
|
parse.go
|
||||||
|
chart.go
|
||||||
order.go
|
order.go
|
||||||
table.go
|
table.go
|
||||||
chart.go
|
field.go
|
||||||
image.go
|
image.go
|
||||||
video.go
|
video.go
|
||||||
audio.go
|
audio.go
|
||||||
|
@ -7,12 +7,13 @@ import (
|
|||||||
"shylinux.com/x/icebergs/base/mdb"
|
"shylinux.com/x/icebergs/base/mdb"
|
||||||
"shylinux.com/x/icebergs/base/nfs"
|
"shylinux.com/x/icebergs/base/nfs"
|
||||||
"shylinux.com/x/icebergs/base/ssh"
|
"shylinux.com/x/icebergs/base/ssh"
|
||||||
|
"shylinux.com/x/icebergs/core/code"
|
||||||
"shylinux.com/x/icebergs/misc/git"
|
"shylinux.com/x/icebergs/misc/git"
|
||||||
kit "shylinux.com/x/toolkits"
|
kit "shylinux.com/x/toolkits"
|
||||||
)
|
)
|
||||||
|
|
||||||
func _word_show(m *ice.Message, name string, arg ...string) {
|
func _word_show(m *ice.Message, name string, arg ...string) {
|
||||||
m.Options(ice.MSG_ALIAS, mdb.Configv(m, mdb.ALIAS), TITLE, map[string]int{}, MENU, kit.Dict(mdb.LIST, kit.List()))
|
m.Options(ice.MSG_ALIAS, mdb.Configv(m, mdb.ALIAS), TITLE, map[string]int{})
|
||||||
m.Cmdy(ssh.SOURCE, name, kit.Dict(nfs.DIR_ROOT, _wiki_path(m)))
|
m.Cmdy(ssh.SOURCE, name, kit.Dict(nfs.DIR_ROOT, _wiki_path(m)))
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -20,7 +21,7 @@ const WORD = "word"
|
|||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
Index.MergeCommands(ice.Commands{
|
Index.MergeCommands(ice.Commands{
|
||||||
WORD: {Name: "word path=src/main.shy@key list play", Help: "笔记文档", Actions: ice.MergeActions(ice.Actions{
|
WORD: {Name: "word path=src/main.shy@key auto play", Help: "笔记文档", Actions: ice.MergeActions(ice.Actions{
|
||||||
ice.CTX_INIT: {Hand: func(m *ice.Message, arg ...string) {
|
ice.CTX_INIT: {Hand: func(m *ice.Message, arg ...string) {
|
||||||
WordAlias(m, NAVMENU, TITLE, NAVMENU)
|
WordAlias(m, NAVMENU, TITLE, NAVMENU)
|
||||||
WordAlias(m, PREMENU, TITLE, PREMENU)
|
WordAlias(m, PREMENU, TITLE, PREMENU)
|
||||||
@ -35,32 +36,26 @@ func init() {
|
|||||||
mdb.INPUTS: {Hand: func(m *ice.Message, arg ...string) {
|
mdb.INPUTS: {Hand: func(m *ice.Message, arg ...string) {
|
||||||
m.Cmd(git.REPOS, ice.OptionFields(nfs.PATH)).Table(func(value ice.Maps) {
|
m.Cmd(git.REPOS, ice.OptionFields(nfs.PATH)).Table(func(value ice.Maps) {
|
||||||
if m.Option(nfs.DIR_DEEP, ice.TRUE); kit.Path(value[nfs.PATH]) == kit.Path("") {
|
if m.Option(nfs.DIR_DEEP, ice.TRUE); kit.Path(value[nfs.PATH]) == kit.Path("") {
|
||||||
_wiki_list(m, "src/")
|
_wiki_list(m, nfs.SRC)
|
||||||
} else {
|
} else {
|
||||||
_wiki_list(m, value[nfs.PATH])
|
_wiki_list(m, value[nfs.PATH])
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
m.Cut("path,size,time")
|
m.Cut("path,size,time")
|
||||||
}}, "play": {Name: "play", Help: "演示"},
|
}}, "play": {Help: "演示"},
|
||||||
ice.STORY: {Hand: func(m *ice.Message, arg ...string) {
|
ice.STORY: {Hand: func(m *ice.Message, arg ...string) { m.Cmdy(arg[0], ice.RUN, arg[2:]) }},
|
||||||
if kit.Ext(m.Option(nfs.PATH)) == nfs.SHY {
|
code.COMPLETE: {Hand: func(m *ice.Message, arg ...string) {
|
||||||
m.Option(nfs.PATH, "")
|
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) })
|
||||||
m.Cmdy(arg[0], ice.RUN, arg[2:])
|
|
||||||
}},
|
}},
|
||||||
}, WikiAction("", nfs.SHY), ctx.CmdAction(), aaa.RoleAction("story.field")), Hand: func(m *ice.Message, arg ...string) {
|
}, WikiAction("", nfs.SHY), ctx.CmdAction(), aaa.RoleAction("story.field")), Hand: func(m *ice.Message, arg ...string) {
|
||||||
if m.Option(nfs.DIR_DEEP, ice.TRUE); len(arg) == 0 {
|
if m.Option(nfs.DIR_DEEP, ice.TRUE); len(arg) == 0 {
|
||||||
arg = append(arg, "src/")
|
arg = append(arg, nfs.SRC)
|
||||||
}
|
|
||||||
if !_wiki_list(m, arg...) {
|
|
||||||
_word_show(m, arg[0])
|
|
||||||
}
|
}
|
||||||
|
kit.If(!_wiki_list(m, arg...), func() { _word_show(m, arg[0]) })
|
||||||
}},
|
}},
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
func WordAction(template string, arg ...ice.Any) ice.Actions {
|
|
||||||
return ice.Actions{ice.CTX_INIT: mdb.AutoConfig(append([]ice.Any{nfs.TEMPLATE, template}, arg...)...)}
|
|
||||||
}
|
|
||||||
func WordAlias(m *ice.Message, cmd string, cmds ...string) {
|
func WordAlias(m *ice.Message, cmd string, cmds ...string) {
|
||||||
mdb.Conf(m, WORD, kit.Keym(mdb.ALIAS, cmd), cmds)
|
mdb.Conf(m, WORD, kit.Keym(mdb.ALIAS, cmd), cmds)
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user