mirror of
https://shylinux.com/x/icebergs
synced 2025-05-01 11:09:23 +08:00
opt wiki
This commit is contained in:
parent
c02663d87d
commit
87bb0d8dbc
@ -66,6 +66,8 @@ func _split_list(m *ice.Message, file string, arg ...string) ice.Map {
|
|||||||
ls = cb(ls, data)
|
ls = cb(ls, data)
|
||||||
case func([]string):
|
case func([]string):
|
||||||
cb(ls)
|
cb(ls)
|
||||||
|
case func([]string) []string:
|
||||||
|
ls = cb(ls)
|
||||||
case nil:
|
case nil:
|
||||||
default:
|
default:
|
||||||
m.ErrorNotImplement(cb)
|
m.ErrorNotImplement(cb)
|
||||||
|
@ -5,12 +5,15 @@ import (
|
|||||||
"shylinux.com/x/icebergs/base/nfs"
|
"shylinux.com/x/icebergs/base/nfs"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
const (
|
||||||
|
M4A = "m4a"
|
||||||
|
)
|
||||||
const AUDIO = "audio"
|
const AUDIO = "audio"
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
Index.MergeCommands(ice.Commands{
|
Index.MergeCommands(ice.Commands{
|
||||||
AUDIO: {Name: "audio url run", Help: "音频", Actions: WordAction(
|
AUDIO: {Name: "audio url", Help: "音频", Actions: WordAction(
|
||||||
`<audio {{.OptionTemplate}} title="{{.Option "text"}}" src="{{.Option "text"}}" controls></audio>`, nfs.PATH, ice.USR_LOCAL_IMAGE,
|
`<audio {{.OptionTemplate}} src="{{.Option "text"}}" controls></audio>`, nfs.PATH, ice.USR_LOCAL_IMAGE,
|
||||||
), Hand: func(m *ice.Message, arg ...string) { _image_show(m, arg[0], arg[1:]...) }},
|
), Hand: func(m *ice.Message, arg ...string) { _image_show(m, arg[0], arg[1:]...) }},
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -8,7 +8,7 @@ const BRIEF = "brief"
|
|||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
Index.MergeCommands(ice.Commands{
|
Index.MergeCommands(ice.Commands{
|
||||||
BRIEF: {Name: "brief text run", Help: "摘要", Actions: WordAction(
|
BRIEF: {Name: "brief text", Help: "摘要", Actions: WordAction(
|
||||||
`<p {{.OptionTemplate}}>{{.Option "text"}}</p>`,
|
`<p {{.OptionTemplate}}>{{.Option "text"}}</p>`,
|
||||||
), Hand: func(m *ice.Message, arg ...string) { _wiki_template(m, "", arg[0], arg[1:]...) }},
|
), Hand: func(m *ice.Message, arg ...string) { _wiki_template(m, "", arg[0], arg[1:]...) }},
|
||||||
})
|
})
|
||||||
|
@ -56,16 +56,6 @@ func (g *Group) Option(group string, key string, arg ...ice.Any) string {
|
|||||||
}
|
}
|
||||||
func (g *Group) Get(group string) *ice.Message { return g.list[group] }
|
func (g *Group) Get(group string) *ice.Message { return g.list[group] }
|
||||||
|
|
||||||
func (g *Group) Join(arg ...string) string {
|
|
||||||
res := []string{}
|
|
||||||
for i := 0; i < len(arg)-1; i += 2 {
|
|
||||||
if arg[i] == "" {
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
res = append(res, kit.Format(`%s="%s"`, arg[i], arg[i+1]))
|
|
||||||
}
|
|
||||||
return kit.Join(res, ice.SP)
|
|
||||||
}
|
|
||||||
func (g *Group) Echo(group string, str string, arg ...ice.Any) *ice.Message {
|
func (g *Group) Echo(group string, str string, arg ...ice.Any) *ice.Message {
|
||||||
return g.Get(group).Echo(str, arg...)
|
return g.Get(group).Echo(str, arg...)
|
||||||
}
|
}
|
||||||
@ -76,57 +66,42 @@ func (g *Group) EchoLine(group string, x1, y1, x2, y2 int) *ice.Message {
|
|||||||
return g.Echo(group, "<line x1=%d y1=%d x2=%d y2=%d></line>", x1, y1, x2, y2)
|
return g.Echo(group, "<line x1=%d y1=%d x2=%d y2=%d></line>", x1, y1, x2, y2)
|
||||||
}
|
}
|
||||||
func (g *Group) EchoRect(group string, height, width, x, y int, arg ...string) *ice.Message { // rx ry
|
func (g *Group) EchoRect(group string, height, width, x, y int, arg ...string) *ice.Message { // rx ry
|
||||||
return g.Echo(group, `<rect height=%d width=%d rx=%s ry=%s x=%d y=%d %s/>`, height, width, kit.Select("4", arg, 0), kit.Select("4", arg, 1), x, y, g.Join(kit.Slice(arg, 2)...))
|
return g.Echo(group, `<rect height=%d width=%d rx=%s ry=%s x=%d y=%d %s/>`,
|
||||||
|
height, width, kit.Select("4", arg, 0), kit.Select("4", arg, 1), x, y, kit.JoinKV(ice.EQ, ice.SP, kit.Slice(arg, 2)...))
|
||||||
}
|
}
|
||||||
func (g *Group) EchoText(group string, x, y int, text string, arg ...string) *ice.Message {
|
func (g *Group) EchoText(group string, x, y int, text string, arg ...string) *ice.Message {
|
||||||
if text == "" {
|
return g.Echo(group, "<text x=%d y=%d %s>%s</text>", x, y, kit.JoinKV(ice.EQ, ice.SP, arg...), text)
|
||||||
return g.Get(group)
|
|
||||||
}
|
|
||||||
return g.Echo(group, "<text x=%d y=%d %s>%s</text>", x, y, g.Join(arg...), text)
|
|
||||||
}
|
}
|
||||||
func (g *Group) EchoTexts(group string, x, y int, text string, arg ...string) *ice.Message {
|
func (g *Group) EchoTexts(group string, x, y int, text string, arg ...string) *ice.Message {
|
||||||
m := g.Get(group)
|
m := g.Get(group)
|
||||||
float := kit.Int(kit.Select("2", "7", kit.Contains(m.Option(ice.MSG_USERUA), "iPhone")))
|
float := kit.Int(kit.Select("6", "2", strings.Contains(m.Option(ice.MSG_USERUA), "Chrome") || (strings.Contains(m.Option(ice.MSG_USERUA), "Mobile") && !kit.Contains(m.Option(ice.MSG_USERUA), "iPhone"))))
|
||||||
if strings.Contains(m.Option(ice.MSG_USERUA), "Chrome") || strings.Contains(m.Option(ice.MSG_USERUA), "Mobile") {
|
|
||||||
} else {
|
|
||||||
float += 4
|
|
||||||
}
|
|
||||||
return g.EchoText(group, x, y+float, text, arg...)
|
return g.EchoText(group, x, y+float, text, arg...)
|
||||||
}
|
}
|
||||||
|
func (g *Group) EchoArrowLine(group string, x1, y1, x2, y2 int, arg ...string) *ice.Message { // marker-end
|
||||||
|
return g.Echo(group, "<line x1=%d y1=%d x2=%d y2=%d marker-end='url(#%s)'></line>", x1, y1, x2, y2, kit.Select("arrowhead", arg, 0))
|
||||||
|
}
|
||||||
func (g *Group) DefsArrow(group string, height, width int, arg ...string) *ice.Message { // name
|
func (g *Group) DefsArrow(group string, height, width int, arg ...string) *ice.Message { // name
|
||||||
return g.Echo(group, `<defs>
|
return g.Echo(group, `<defs>
|
||||||
<marker id="%s" markerHeight="%d" markerWidth="%d" refX="0" refY="%d" stroke-dasharray="none" orient="auto"><polygon points="0 0, %d %d, 0 %d"/></marker>
|
<marker id="%s" markerHeight="%d" markerWidth="%d" refX="0" refY="%d" stroke-dasharray="none" orient="auto"><polygon points="0 0, %d %d, 0 %d"/></marker>
|
||||||
</defs>`, kit.Select("arrowhead", arg, 0), height, width, height/2, width, height/2, height)
|
</defs>`, kit.Select("arrowhead", arg, 0), height, width, height/2, width, height/2, height)
|
||||||
}
|
}
|
||||||
func (g *Group) EchoArrowLine(group string, x1, y1, x2, y2 int, arg ...string) *ice.Message { // marker-end
|
|
||||||
return g.Echo(group, "<line x1=%d y1=%d x2=%d y2=%d marker-end='url(#%s)'></line>", x1, y1, x2, y2, kit.Select("arrowhead", arg, 0))
|
|
||||||
}
|
|
||||||
func (g *Group) Dump(m *ice.Message, group string, arg ...string) *Group {
|
func (g *Group) Dump(m *ice.Message, group string, arg ...string) *Group {
|
||||||
item := NewItem("<g name=%s", group)
|
item := NewItem("<g name=%s", group)
|
||||||
for _, k := range kit.Simple(STROKE_DASHARRAY, STROKE_WIDTH, STROKE, FILL, FONT_SIZE, FONT_FAMILY, arg) {
|
for _, k := range kit.Simple(STROKE_DASHARRAY, STROKE_WIDTH, STROKE, FILL, FONT_SIZE, FONT_FAMILY, arg) {
|
||||||
v := m.Option(kit.Keys(group, k))
|
item.Push(kit.Format(`%s="%%v"`, k), m.Option(kit.Keys(group, k)))
|
||||||
switch k {
|
|
||||||
case STROKE:
|
|
||||||
v = kit.Select(m.Option(kit.Keys(group, k)), m.Option(kit.Keys(group, FG)))
|
|
||||||
case FILL:
|
|
||||||
v = kit.Select(m.Option(kit.Keys(group, k)), m.Option(kit.Keys(group, BG)))
|
|
||||||
}
|
|
||||||
item.Push(kit.Format(`%s="%%v"`, k), v)
|
|
||||||
}
|
}
|
||||||
item.Echo(">").Dump(m).Copy(g.Get(group)).Echo("</g>")
|
item.Echo(">").Dump(m).Copy(g.Get(group)).Echo("</g>")
|
||||||
return g
|
return g
|
||||||
}
|
}
|
||||||
func (g *Group) DumpAll(m *ice.Message, group ...string) *Group {
|
func (g *Group) DumpAll(m *ice.Message, group ...string) {
|
||||||
for _, grp := range group {
|
for _, grp := range group {
|
||||||
g.Dump(m, grp)
|
g.Dump(m, grp)
|
||||||
}
|
}
|
||||||
return g
|
|
||||||
}
|
}
|
||||||
|
|
||||||
type Chart interface {
|
type Chart interface {
|
||||||
Init(*ice.Message, ...string) Chart
|
Init(*ice.Message, ...string) Chart
|
||||||
Draw(*ice.Message, int, int) Chart
|
Draw(*ice.Message, int, int) Chart
|
||||||
Data(*ice.Message, ice.Any) Chart
|
|
||||||
GetHeight(...string) int
|
GetHeight(...string) int
|
||||||
GetWidth(...string) int
|
GetWidth(...string) int
|
||||||
}
|
}
|
||||||
@ -159,12 +134,12 @@ const (
|
|||||||
FG = "fg"
|
FG = "fg"
|
||||||
BG = "bg"
|
BG = "bg"
|
||||||
|
|
||||||
|
FONT_SIZE = "font-size"
|
||||||
|
FONT_FAMILY = "font-family"
|
||||||
STROKE_DASHARRAY = "stroke-dasharray"
|
STROKE_DASHARRAY = "stroke-dasharray"
|
||||||
STROKE_WIDTH = "stroke-width"
|
STROKE_WIDTH = "stroke-width"
|
||||||
STROKE = "stroke"
|
STROKE = "stroke"
|
||||||
FILL = "fill"
|
FILL = "fill"
|
||||||
FONT_SIZE = "font-size"
|
|
||||||
FONT_FAMILY = "font-family"
|
|
||||||
|
|
||||||
PADDING = "padding"
|
PADDING = "padding"
|
||||||
MARGINX = "marginx"
|
MARGINX = "marginx"
|
||||||
@ -181,14 +156,10 @@ const CHART = "chart"
|
|||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
Index.MergeCommands(ice.Commands{
|
Index.MergeCommands(ice.Commands{
|
||||||
CHART: {Name: "chart type=label,chain,sequence auto text", Help: "图表", Actions: WordAction(
|
CHART: {Name: "chart type=label,chain,sequence run text", Help: "图表", Actions: WordAction(
|
||||||
`<svg xmlns="http://www.w3.org/2000/svg" vertion="1.1"
|
`<svg xmlns="http://www.w3.org/2000/svg" vertion="1.1"
|
||||||
{{.OptionTemplate}} {{.OptionKV "height,width,font-size,font-family,stroke-width,stroke,fill"}}
|
{{.OptionTemplate}} {{.OptionKV "height,width,font-size,font-family,stroke-width,stroke,fill"}}
|
||||||
text-anchor="middle" dominant-baseline="middle">`,
|
text-anchor="middle" dominant-baseline="middle">`,
|
||||||
), Hand: func(m *ice.Message, arg ...string) {
|
), Hand: func(m *ice.Message, arg ...string) { _chart_show(m, arg[0], strings.TrimSpace(arg[1]), arg[2:]...) }},
|
||||||
if len(arg) > 1 {
|
|
||||||
_chart_show(m, arg[0], strings.TrimSpace(arg[1]), arg[2:]...)
|
|
||||||
}
|
|
||||||
}},
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -23,14 +23,15 @@ func init() {
|
|||||||
}
|
}
|
||||||
}},
|
}},
|
||||||
mdb.CREATE: {Name: "create path fields value", Hand: func(m *ice.Message, arg ...string) {
|
mdb.CREATE: {Name: "create path fields value", Hand: func(m *ice.Message, arg ...string) {
|
||||||
m.Cmd("", nfs.SAVE, m.Option(nfs.PATH), kit.Join(kit.Split(m.Option("fields")), ice.FS)+ice.NL+kit.Join(kit.Split(m.Option(mdb.VALUE)))+ice.NL)
|
m.Cmd("", nfs.SAVE, m.Option(nfs.PATH), kit.Join(kit.Split(m.Option("fields")))+ice.NL+kit.Join(kit.Split(m.Option(mdb.VALUE)))+ice.NL)
|
||||||
}},
|
}},
|
||||||
nfs.PUSH: {Name: "push path record", Help: "添加", Hand: func(m *ice.Message, arg ...string) {
|
nfs.PUSH: {Name: "push path record", Help: "添加", Hand: func(m *ice.Message, arg ...string) {
|
||||||
m.Cmd(nfs.PUSH, path.Join(m.Config(nfs.PATH), arg[0]), kit.Join(arg[1:], ice.FS)+ice.NL)
|
m.Cmd(nfs.PUSH, path.Join(m.Config(nfs.PATH), arg[0]), kit.Join(arg[1:], ice.FS)+ice.NL)
|
||||||
}},
|
}},
|
||||||
|
"draw": {Name: "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...) {
|
if !_wiki_list(m, arg...) {
|
||||||
CSV(m, m.Cmd(nfs.CAT, arg[0]).Result()).StatusTimeCount()
|
CSV(m, m.Cmdx(nfs.CAT, arg[0])).StatusTimeCount()
|
||||||
}
|
}
|
||||||
}},
|
}},
|
||||||
})
|
})
|
||||||
|
@ -14,13 +14,12 @@ const DRAW = "draw"
|
|||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
Index.MergeCommands(ice.Commands{
|
Index.MergeCommands(ice.Commands{
|
||||||
DRAW: {Name: "draw path=src/main.svg pid refresh:button=auto save edit actions", Help: "思维导图", Actions: ice.MergeActions(ice.Actions{
|
DRAW: {Name: "draw path=src/main.svg pid:text refresh:button=auto save edit actions", 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) {
|
||||||
m.Cmd(mdb.RENDER, mdb.CREATE, mdb.TYPE, nfs.SVG, mdb.NAME, m.PrefixKey())
|
m.Cmd(mdb.RENDER, mdb.CREATE, mdb.TYPE, nfs.SVG, mdb.NAME, m.PrefixKey())
|
||||||
}},
|
}},
|
||||||
mdb.RENDER: {Hand: func(m *ice.Message, arg ...string) {
|
mdb.RENDER: {Hand: func(m *ice.Message, arg ...string) {
|
||||||
m.Echo("<html><body>")
|
defer m.Echo("<html><body>").Echo("</body></html>")
|
||||||
defer m.Echo("</body></html>")
|
|
||||||
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) {
|
||||||
|
@ -15,14 +15,10 @@ import (
|
|||||||
func Parse(m *ice.Message, meta string, key string, arg ...string) (data ice.Any) {
|
func Parse(m *ice.Message, meta string, key string, arg ...string) (data ice.Any) {
|
||||||
list := []string{}
|
list := []string{}
|
||||||
for _, line := range kit.SplitLine(strings.Join(arg, ice.SP)) {
|
for _, line := range kit.SplitLine(strings.Join(arg, ice.SP)) {
|
||||||
ls := kit.Split(line)
|
if strings.HasPrefix(strings.TrimSpace(line), "# ") {
|
||||||
for i := 0; i < len(ls); i++ {
|
continue
|
||||||
if strings.HasPrefix(ls[i], "# ") {
|
|
||||||
ls = ls[:i]
|
|
||||||
break
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
list = append(list, ls...)
|
list = append(list, kit.SplitWord(line)...)
|
||||||
}
|
}
|
||||||
switch data = kit.Parse(nil, "", list...); meta {
|
switch data = kit.Parse(nil, "", list...); meta {
|
||||||
case ice.MSG_OPTION:
|
case ice.MSG_OPTION:
|
||||||
@ -48,12 +44,10 @@ func _field_show(m *ice.Message, name, text string, arg ...string) {
|
|||||||
msg := m.Spawn()
|
msg := m.Spawn()
|
||||||
|
|
||||||
for i := 0; i < len(arg)-1; i += 2 {
|
for i := 0; i < len(arg)-1; i += 2 {
|
||||||
if strings.HasPrefix(arg[i], "opts.") {
|
if strings.HasPrefix(arg[i], ARGS) {
|
||||||
kit.Value(meta, arg[i], m.Option(arg[i], strings.TrimSpace(arg[i+1])))
|
kit.Value(meta, arg[i], m.Optionv(arg[i], kit.Split(strings.TrimSuffix(strings.TrimPrefix(arg[i+1], "["), "]"))))
|
||||||
} else if strings.HasPrefix(arg[i], "args.") {
|
} else if strings.HasPrefix(arg[i], "args.") {
|
||||||
kit.Value(meta, arg[i], m.Option(arg[i], strings.TrimSpace(arg[i+1])))
|
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, arg[i], Parse(m, ice.MSG_OPTION, arg[i], arg[i+1]))
|
||||||
}
|
}
|
||||||
|
@ -19,7 +19,7 @@ const IMAGE = "image"
|
|||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
Index.MergeCommands(ice.Commands{
|
Index.MergeCommands(ice.Commands{
|
||||||
IMAGE: {Name: "image url", Help: "图片", Actions: WordAction(
|
IMAGE: {Name: "image url run", Help: "图片", Actions: WordAction(
|
||||||
`<img {{.OptionTemplate}} title="{{.Option "text"}}" src="{{.Option "text"}}">`, nfs.PATH, ice.USR_LOCAL_IMAGE,
|
`<img {{.OptionTemplate}} title="{{.Option "text"}}" src="{{.Option "text"}}">`, nfs.PATH, ice.USR_LOCAL_IMAGE,
|
||||||
), Hand: func(m *ice.Message, arg ...string) { _image_show(m, arg[0], arg[1:]...) }},
|
), Hand: func(m *ice.Message, arg ...string) { _image_show(m, arg[0], arg[1:]...) }},
|
||||||
})
|
})
|
||||||
|
@ -1,15 +1,13 @@
|
|||||||
package wiki
|
package wiki
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"strings"
|
|
||||||
|
|
||||||
ice "shylinux.com/x/icebergs"
|
ice "shylinux.com/x/icebergs"
|
||||||
"shylinux.com/x/icebergs/base/mdb"
|
"shylinux.com/x/icebergs/base/mdb"
|
||||||
kit "shylinux.com/x/toolkits"
|
kit "shylinux.com/x/toolkits"
|
||||||
)
|
)
|
||||||
|
|
||||||
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.Split(strings.TrimSpace(text), ice.NL))
|
m.Optionv(mdb.LIST, kit.SplitLine(text))
|
||||||
_wiki_template(m, "", text, arg...)
|
_wiki_template(m, "", text, arg...)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -31,7 +31,7 @@ func init() {
|
|||||||
arg[0] = nfs.JSON
|
arg[0] = nfs.JSON
|
||||||
} else if strings.HasPrefix(arg[1], web.HTTP) {
|
} else if strings.HasPrefix(arg[1], web.HTTP) {
|
||||||
arg[0] = web.HTTP
|
arg[0] = web.HTTP
|
||||||
} else if strings.Contains(arg[1], "=") {
|
} else if strings.Contains(arg[1], ice.EQ) {
|
||||||
arg[0] = web.FORM
|
arg[0] = web.FORM
|
||||||
} else if _, e := strconv.ParseInt(arg[1], 10, 64); e == nil {
|
} else if _, e := strconv.ParseInt(arg[1], 10, 64); e == nil {
|
||||||
arg[0] = mdb.TIME
|
arg[0] = mdb.TIME
|
||||||
|
@ -18,7 +18,7 @@ func _spark_show(m *ice.Message, name, text string, arg ...string) *ice.Message
|
|||||||
defer m.Echo("</div>")
|
defer m.Echo("</div>")
|
||||||
|
|
||||||
switch name {
|
switch name {
|
||||||
case "inner", "field":
|
case "inner", FIELD:
|
||||||
return m.Echo(text)
|
return m.Echo(text)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -54,7 +54,7 @@ func init() {
|
|||||||
}
|
}
|
||||||
list := []string{kit.Format(`<div class="story" data-type="spark" data-name="%s">`, 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)) {
|
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)))
|
list = append(list, Format("div", Format("label", kit.Select("> ", "$ ", arg[0] == SHELL)), Format("span", l)))
|
||||||
}
|
}
|
||||||
return strings.Join(append(list, "</div>"), "")
|
return strings.Join(append(list, "</div>"), "")
|
||||||
})
|
})
|
||||||
|
@ -9,7 +9,6 @@ import (
|
|||||||
|
|
||||||
func _table_run(m *ice.Message, arg ...string) {
|
func _table_run(m *ice.Message, arg ...string) {
|
||||||
msg := m.Cmd(arg)
|
msg := m.Cmd(arg)
|
||||||
|
|
||||||
list := [][]string{}
|
list := [][]string{}
|
||||||
msg.Table(func(index int, value ice.Maps, head []string) {
|
msg.Table(func(index int, value ice.Maps, head []string) {
|
||||||
if index == 0 {
|
if index == 0 {
|
||||||
@ -26,40 +25,45 @@ func _table_run(m *ice.Message, arg ...string) {
|
|||||||
}
|
}
|
||||||
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{}
|
||||||
for i, v := range kit.SplitLine(text) {
|
for i, line := range kit.SplitLine(text) {
|
||||||
if v = strings.ReplaceAll(v, "%", "%%"); i == 0 {
|
if line = strings.ReplaceAll(line, "%", "%%"); i == 0 {
|
||||||
head = kit.SplitWord(v)
|
head = kit.SplitWord(line)
|
||||||
} else {
|
continue
|
||||||
line := kit.SplitWord(v)
|
|
||||||
for i, v := range line {
|
|
||||||
if ls := kit.SplitWord(v); len(ls) > 1 {
|
|
||||||
style := []string{}
|
|
||||||
for i := 1; i < len(ls)-1; i += 2 {
|
|
||||||
switch ls[i] {
|
|
||||||
case BG:
|
|
||||||
ls[i] = "background-color"
|
|
||||||
case FG:
|
|
||||||
ls[i] = "color"
|
|
||||||
}
|
|
||||||
style = append(style, ls[i]+":"+ls[i+1])
|
|
||||||
}
|
|
||||||
line[i] = kit.Format(`<span style="%s">%s</span>`, strings.Join(style, ";"), ls[0])
|
|
||||||
}
|
|
||||||
}
|
|
||||||
list = append(list, line)
|
|
||||||
}
|
}
|
||||||
|
list = append(list, transList(kit.SplitWord(line), func(value string) string {
|
||||||
|
if ls := kit.SplitWord(value); len(ls) > 1 {
|
||||||
|
return kit.Format(`<span style="%s">%s</span>`, kit.JoinKV(":", ";", transArgKey(ls[1:])...), ls[0])
|
||||||
|
}
|
||||||
|
return value
|
||||||
|
}))
|
||||||
}
|
}
|
||||||
m.Optionv("head", head)
|
m.Optionv("head", head)
|
||||||
m.Optionv("list", list)
|
m.Optionv("list", list)
|
||||||
_wiki_template(m, "", text, arg...)
|
_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 {
|
||||||
|
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
|
||||||
|
}
|
||||||
const TABLE = "table"
|
const TABLE = "table"
|
||||||
|
|
||||||
func init() {
|
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: {Name: "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}}>
|
}, WordAction(`<table {{.OptionTemplate}}>
|
||||||
<tr>{{range $i, $v := .Optionv "head"}}<th>{{$v}}</th>{{end}}</tr>
|
<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}}
|
{{range $index, $value := .Optionv "list"}}<tr>{{range $i, $v := $value}}<td>{{$v}}</td>{{end}}</tr>{{end}}
|
||||||
|
@ -11,23 +11,21 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func _title_parse(m *ice.Message, dir string, text string) string {
|
func _title_parse(m *ice.Message, dir string, text string) string {
|
||||||
return m.Cmdx(lex.SPLIT, "", "name,link", kit.Dict(nfs.CAT_CONTENT, text), func(ls []string, data ice.Map) []string {
|
return m.Cmdx(lex.SPLIT, "", "name,link", kit.Dict(nfs.CAT_CONTENT, text), func(ls []string) []string {
|
||||||
if len(ls) > 1 {
|
if len(ls) > 1 {
|
||||||
ls[1] = path.Join(dir, 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 {
|
||||||
|
if kind == NAVMENU {
|
||||||
|
m.Option(mdb.DATA, _title_parse(m, path.Dir(m.Option(ice.MSG_SCRIPT)), text))
|
||||||
|
}
|
||||||
|
return _option(m, kind, "", text, arg...).RenderTemplate(m.Config(kind), &Message{m})
|
||||||
|
}
|
||||||
func _title_show(m *ice.Message, kind, text string, arg ...string) *ice.Message {
|
func _title_show(m *ice.Message, kind, text string, arg ...string) *ice.Message {
|
||||||
switch title, _ := m.Optionv(TITLE).(map[string]int); kind {
|
switch title, _ := m.Optionv(TITLE).(map[string]int); kind {
|
||||||
case NAVMENU:
|
|
||||||
m.Option(mdb.DATA, _title_parse(m, path.Dir(m.Option(ice.MSG_SCRIPT)), text))
|
|
||||||
return _option(m, kind, "", text, arg...).RenderTemplate(m.Config(kind), &Message{m})
|
|
||||||
case PREMENU:
|
|
||||||
return _option(m, kind, "", "", arg...).RenderTemplate(m.Config(kind), &Message{m})
|
|
||||||
case ENDMENU:
|
|
||||||
return _option(m, kind, "", "", arg...).RenderTemplate(m.Config(kind), &Message{m})
|
|
||||||
case SECTION:
|
case SECTION:
|
||||||
title[SECTION]++
|
title[SECTION]++
|
||||||
m.Option(LEVEL, "h3")
|
m.Option(LEVEL, "h3")
|
||||||
@ -72,9 +70,9 @@ func init() {
|
|||||||
</ul>`), Help: "标题", Hand: func(m *ice.Message, arg ...string) {
|
</ul>`), Help: "标题", Hand: func(m *ice.Message, arg ...string) {
|
||||||
switch arg[0] {
|
switch arg[0] {
|
||||||
case NAVMENU:
|
case NAVMENU:
|
||||||
_title_show(m, arg[0], arg[1], arg[2:]...)
|
_title_menu(m, arg[0], arg[1], arg[2:]...)
|
||||||
case PREMENU, ENDMENU:
|
case PREMENU, ENDMENU:
|
||||||
_title_show(m, arg[0], "", arg[1:]...)
|
_title_menu(m, arg[0], "", arg[1:]...)
|
||||||
case CHAPTER, SECTION:
|
case CHAPTER, SECTION:
|
||||||
_title_show(m, arg[0], arg[1], arg[2:]...)
|
_title_show(m, arg[0], arg[1], arg[2:]...)
|
||||||
default:
|
default:
|
||||||
|
@ -6,15 +6,15 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
mp4 = "mp4"
|
|
||||||
m4v = "m4v"
|
m4v = "m4v"
|
||||||
|
mp4 = "mp4"
|
||||||
MOV = "mov"
|
MOV = "mov"
|
||||||
)
|
)
|
||||||
const VIDEO = "video"
|
const VIDEO = "video"
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
Index.MergeCommands(ice.Commands{
|
Index.MergeCommands(ice.Commands{
|
||||||
VIDEO: {Name: "video url", Help: "视频", Actions: WordAction(
|
VIDEO: {Name: "video url run", Help: "视频", Actions: WordAction(
|
||||||
`<video {{.OptionTemplate}} title="{{.Option "text"}}" src="{{.Option "text"}}" controls></video>`, nfs.PATH, ice.USR_LOCAL_IMAGE,
|
`<video {{.OptionTemplate}} title="{{.Option "text"}}" src="{{.Option "text"}}" controls></video>`, nfs.PATH, ice.USR_LOCAL_IMAGE,
|
||||||
), Hand: func(m *ice.Message, arg ...string) { _image_show(m, arg[0], arg[1:]...) }},
|
), Hand: func(m *ice.Message, arg ...string) { _image_show(m, arg[0], arg[1:]...) }},
|
||||||
})
|
})
|
||||||
|
@ -47,6 +47,7 @@ func _wiki_list(m *ice.Message, arg ...string) bool {
|
|||||||
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, m.Config(lex.REGEXP)))
|
m.Cmdy(nfs.DIR, kit.Slice(arg, 0, 1), kit.Dict(nfs.DIR_TYPE, nfs.CAT, nfs.DIR_REG, m.Config(lex.REGEXP)))
|
||||||
|
m.StatusTimeCount()
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
ctx.DisplayLocal(m, path.Join(kit.PathName(2), kit.Keys(kit.FileName(2), ice.JS)))
|
ctx.DisplayLocal(m, path.Join(kit.PathName(2), kit.Keys(kit.FileName(2), ice.JS)))
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
wiki.shy
|
wiki.shy
|
||||||
wiki.go
|
wiki.go
|
||||||
feel.go
|
|
||||||
draw.go
|
|
||||||
data.go
|
data.go
|
||||||
|
draw.go
|
||||||
|
feel.go
|
||||||
word.go
|
word.go
|
||||||
|
|
||||||
title.go
|
title.go
|
||||||
@ -12,9 +12,9 @@ spark.go
|
|||||||
field.go
|
field.go
|
||||||
parse.go
|
parse.go
|
||||||
|
|
||||||
image.go
|
|
||||||
video.go
|
|
||||||
audio.go
|
|
||||||
order.go
|
order.go
|
||||||
table.go
|
table.go
|
||||||
chart.go
|
chart.go
|
||||||
|
image.go
|
||||||
|
video.go
|
||||||
|
audio.go
|
||||||
|
@ -33,10 +33,10 @@ func init() {
|
|||||||
WordAlias(m, CHAIN, CHART, CHAIN)
|
WordAlias(m, CHAIN, CHART, CHAIN)
|
||||||
WordAlias(m, SEQUENCE, CHART, SEQUENCE)
|
WordAlias(m, SEQUENCE, CHART, SEQUENCE)
|
||||||
}},
|
}},
|
||||||
mdb.INPUTS: {Name: "inputs", Help: "补全", Hand: func(m *ice.Message, arg ...string) {
|
mdb.INPUTS: {Hand: func(m *ice.Message, arg ...string) {
|
||||||
m.Cmd(git.REPOS, ice.OptionFields(nfs.PATH)).Tables(func(value ice.Maps) {
|
m.Cmd(git.REPOS, ice.OptionFields(nfs.PATH)).Tables(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, value[nfs.PATH]+"/src/")
|
_wiki_list(m, "src/")
|
||||||
} else {
|
} else {
|
||||||
_wiki_list(m, value[nfs.PATH])
|
_wiki_list(m, value[nfs.PATH])
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user