mirror of
https://shylinux.com/x/icebergs
synced 2025-04-26 01:24:05 +08:00
opt wiki
This commit is contained in:
parent
f4258e4092
commit
51eb0852c2
@ -22,8 +22,8 @@ Volcanos("onimport", {help: "导入数据", list: [], _init: function(can, msg,
|
||||
return can.onimport._task(can, msg, get(begin_time, col, row, hash), set(begin_time, col, row))
|
||||
})}
|
||||
}) }])
|
||||
can.core.Timer(10, function() {
|
||||
var target = can.sup.task._target||can.sup.task._target
|
||||
can.core.Timer(10, function() { if (!can.sup.task) { return }
|
||||
var target = can.sup.task._target||can.task._target
|
||||
can.sup.task = null, target.click()
|
||||
can.Status("count", msg.Length())
|
||||
})
|
||||
|
@ -8,16 +8,13 @@ import (
|
||||
const BRIEF = "brief"
|
||||
|
||||
func init() {
|
||||
Index.Merge(&ice.Context{
|
||||
Commands: map[string]*ice.Command{
|
||||
BRIEF: {Name: "brief text", Help: "摘要", Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
|
||||
_wiki_template(m, cmd, "", arg[0], arg[1:]...)
|
||||
}},
|
||||
},
|
||||
Configs: map[string]*ice.Config{
|
||||
BRIEF: {Name: BRIEF, Help: "摘要", Value: kit.Data(
|
||||
kit.MDB_TEMPLATE, `<p {{.OptionTemplate}}>{{.Option "text"}}</p>`,
|
||||
)},
|
||||
},
|
||||
})
|
||||
Index.Merge(&ice.Context{Commands: map[string]*ice.Command{
|
||||
BRIEF: {Name: "brief text", Help: "摘要", Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
|
||||
_wiki_template(m, cmd, "", arg[0], arg[1:]...)
|
||||
}},
|
||||
}, Configs: map[string]*ice.Config{
|
||||
BRIEF: {Name: BRIEF, Help: "摘要", Value: kit.Data(
|
||||
kit.MDB_TEMPLATE, `<p {{.OptionTemplate}}>{{.Option "text"}}</p>`,
|
||||
)},
|
||||
}})
|
||||
}
|
||||
|
@ -2,6 +2,7 @@ package wiki
|
||||
|
||||
import (
|
||||
ice "shylinux.com/x/icebergs"
|
||||
"shylinux.com/x/icebergs/base/cli"
|
||||
kit "shylinux.com/x/toolkits"
|
||||
|
||||
"strings"
|
||||
@ -38,22 +39,22 @@ type Block struct {
|
||||
|
||||
func (b *Block) Init(m *ice.Message, arg ...string) Chart {
|
||||
b.Text = kit.Select(b.Text, arg, 0)
|
||||
b.FontSize = kit.Int(kit.Select(m.Option("font-size"), kit.Select(kit.Format(b.FontSize), arg, 1)))
|
||||
b.FontColor = kit.Select(m.Option("stroke"), kit.Select(b.FontColor, arg, 2))
|
||||
b.BackGround = kit.Select(m.Option("fill"), kit.Select(b.BackGround, arg, 3))
|
||||
b.Padding = kit.Int(kit.Select(m.Option("padding"), kit.Select(kit.Format(b.Padding), arg, 4)))
|
||||
b.MarginX = kit.Int(kit.Select(m.Option("marginx"), kit.Select(kit.Format(b.MarginX), arg, 5)))
|
||||
b.MarginY = kit.Int(kit.Select(m.Option("marginy"), kit.Select(kit.Format(b.MarginY), arg, 5)))
|
||||
b.FontSize = kit.Int(kit.Select(m.Option(FONT_SIZE), kit.Select(kit.Format(b.FontSize), arg, 1)))
|
||||
b.FontColor = kit.Select(m.Option(STROKE), kit.Select(b.FontColor, arg, 2))
|
||||
b.BackGround = kit.Select(m.Option(FILL), kit.Select(b.BackGround, arg, 3))
|
||||
b.Padding = kit.Int(kit.Select(m.Option(PADDING), kit.Select(kit.Format(b.Padding), arg, 4)))
|
||||
b.MarginX = kit.Int(kit.Select(m.Option(MARGINX), kit.Select(kit.Format(b.MarginX), arg, 5)))
|
||||
b.MarginY = kit.Int(kit.Select(m.Option(MARGINY), kit.Select(kit.Format(b.MarginY), arg, 5)))
|
||||
return b
|
||||
}
|
||||
func (b *Block) Data(m *ice.Message, root interface{}) Chart {
|
||||
b.Text = kit.Select(b.Text, kit.Value(root, "text"))
|
||||
b.Text = kit.Select(b.Text, kit.Value(root, kit.MDB_TEXT))
|
||||
kit.Fetch(root, func(key string, value string) {
|
||||
switch key {
|
||||
case "fg":
|
||||
b.TextData += kit.Format("%s='%s' ", "fill", value)
|
||||
case "bg":
|
||||
b.RectData += kit.Format("%s='%s' ", "fill", value)
|
||||
case FG:
|
||||
b.TextData += kit.Format("%s='%s' ", FILL, value)
|
||||
case BG:
|
||||
b.RectData += kit.Format("%s='%s' ", FILL, value)
|
||||
}
|
||||
})
|
||||
kit.Fetch(kit.Value(root, "data"), func(key string, value string) {
|
||||
@ -71,7 +72,7 @@ func (b *Block) Draw(m *ice.Message, x, y int) Chart {
|
||||
}
|
||||
m.Echo(`<rect x="%d" y="%d" width="%d" height="%d" rx="4" ry="4" fill="%s" %v/>`,
|
||||
x+b.MarginX/2, y+b.MarginY/2, b.GetWidth(), b.GetHeight(), b.BackGround, b.RectData)
|
||||
m.Echo("\n")
|
||||
m.Echo(ice.NL)
|
||||
m.Echo(`<text x="%d" y="%d" stroke-width="1" fill="%s" stroke=%s %v>%v</text>`,
|
||||
x+b.GetWidths()/2, y+b.GetHeights()/2+float, b.FontColor, b.FontColor, b.TextData, b.Text)
|
||||
m.Echo("\n")
|
||||
@ -109,19 +110,19 @@ type Label struct {
|
||||
|
||||
func (b *Label) Init(m *ice.Message, arg ...string) Chart {
|
||||
b.Text = kit.Select(b.Text, arg, 0)
|
||||
b.FontSize = kit.Int(m.Option("font-size"))
|
||||
b.Padding = kit.Int(m.Option("padding"))
|
||||
b.MarginX = kit.Int(m.Option("marginx"))
|
||||
b.MarginY = kit.Int(m.Option("marginy"))
|
||||
b.FontSize = kit.Int(m.Option(FONT_SIZE))
|
||||
b.Padding = kit.Int(m.Option(PADDING))
|
||||
b.MarginX = kit.Int(m.Option(MARGINX))
|
||||
b.MarginY = kit.Int(m.Option(MARGINY))
|
||||
|
||||
// 解析数据
|
||||
b.max = map[int]int{}
|
||||
for _, v := range strings.Split(arg[0], "\n") {
|
||||
l := kit.Split(v, " ", " ")
|
||||
for _, v := range strings.Split(arg[0], ice.NL) {
|
||||
l := kit.Split(v, ice.SP, ice.SP)
|
||||
for i, v := range l {
|
||||
switch data := kit.Parse(nil, "", kit.Split(v)...).(type) {
|
||||
case map[string]interface{}:
|
||||
v = kit.Select("", data["text"])
|
||||
v = kit.Select("", data[kit.MDB_TEXT])
|
||||
}
|
||||
|
||||
if w := b.GetWidth(v); w > b.max[i] {
|
||||
@ -157,9 +158,9 @@ func (b *Label) Draw(m *ice.Message, x, y int) Chart {
|
||||
if w := kit.Int(kit.Value(order, "index")); w != 0 && i%w == 0 {
|
||||
for k, v := range order {
|
||||
switch k {
|
||||
case "fg":
|
||||
case FG:
|
||||
item.FontColor = kit.Format(v)
|
||||
case "bg":
|
||||
case BG:
|
||||
item.BackGround = kit.Format(v)
|
||||
}
|
||||
}
|
||||
@ -168,13 +169,13 @@ func (b *Label) Draw(m *ice.Message, x, y int) Chart {
|
||||
|
||||
switch data := kit.Parse(nil, "", kit.Split(text)...).(type) {
|
||||
case map[string]interface{}:
|
||||
item.Init(m, kit.Select(text, data["text"])).Data(m, data)
|
||||
item.Init(m, kit.Select(text, data[kit.MDB_TEXT])).Data(m, data)
|
||||
default:
|
||||
item.Init(m, text)
|
||||
}
|
||||
|
||||
// 输出
|
||||
switch m.Option("compact") {
|
||||
switch m.Option(COMPACT) {
|
||||
case "max":
|
||||
item.Width = b.Width/len(line) - b.MarginX
|
||||
case ice.TRUE:
|
||||
@ -200,10 +201,10 @@ type Chain struct {
|
||||
}
|
||||
|
||||
func (b *Chain) Init(m *ice.Message, arg ...string) Chart {
|
||||
b.FontSize = kit.Int(m.Option("font-size"))
|
||||
b.Padding = kit.Int(m.Option("padding"))
|
||||
b.MarginX = kit.Int(m.Option("marginx"))
|
||||
b.MarginY = kit.Int(m.Option("marginy"))
|
||||
b.FontSize = kit.Int(m.Option(FONT_SIZE))
|
||||
b.Padding = kit.Int(m.Option(PADDING))
|
||||
b.MarginX = kit.Int(m.Option(MARGINX))
|
||||
b.MarginY = kit.Int(m.Option(MARGINY))
|
||||
|
||||
// 解析数据
|
||||
b.data = kit.Parse(nil, "", b.show(m, arg[0])...).(map[string]interface{})
|
||||
@ -222,7 +223,7 @@ func (b *Chain) Draw(m *ice.Message, x, y int) Chart {
|
||||
}
|
||||
func (b *Chain) show(m *ice.Message, str string) (res []string) {
|
||||
miss := []int{}
|
||||
for _, line := range kit.Split(str, "\n", "\n") {
|
||||
for _, line := range kit.Split(str, ice.NL, ice.NL) {
|
||||
// 计算缩进
|
||||
dep := 0
|
||||
loop:
|
||||
@ -269,7 +270,7 @@ func (b *Chain) size(m *ice.Message, root map[string]interface{}, depth int, wid
|
||||
meta := root[kit.MDB_META].(map[string]interface{})
|
||||
|
||||
// 最大宽度
|
||||
if w := b.GetWidths(kit.Format(meta["text"])); w > width[depth] {
|
||||
if w := b.GetWidths(kit.Format(meta[kit.MDB_TEXT])); w > width[depth] {
|
||||
width[depth] = w
|
||||
}
|
||||
|
||||
@ -283,7 +284,7 @@ func (b *Chain) size(m *ice.Message, root map[string]interface{}, depth int, wid
|
||||
height = 1
|
||||
}
|
||||
|
||||
meta["height"] = height
|
||||
meta[HEIGHT] = height
|
||||
return height
|
||||
}
|
||||
func (b *Chain) draw(m *ice.Message, root map[string]interface{}, depth int, width map[int]int, x, y int, p *Block) int {
|
||||
@ -292,19 +293,19 @@ func (b *Chain) draw(m *ice.Message, root map[string]interface{}, depth int, wid
|
||||
|
||||
// 当前节点
|
||||
item := &Block{
|
||||
BackGround: kit.Select(b.BackGround, kit.Select(p.BackGround, meta["bg"])),
|
||||
FontColor: kit.Select(b.FontColor, kit.Select(p.FontColor, meta["fg"])),
|
||||
BackGround: kit.Select(b.BackGround, kit.Select(p.BackGround, meta[BG])),
|
||||
FontColor: kit.Select(b.FontColor, kit.Select(p.FontColor, meta[FG])),
|
||||
FontSize: b.FontSize,
|
||||
Padding: b.Padding,
|
||||
MarginX: b.MarginX,
|
||||
MarginY: b.MarginY,
|
||||
}
|
||||
if m.Option("compact") != ice.TRUE {
|
||||
if m.Option(COMPACT) != ice.TRUE {
|
||||
item.Width = b.max[depth]
|
||||
}
|
||||
item.x = x
|
||||
item.y = y + (kit.Int(meta["height"])-1)*b.GetHeights()/2
|
||||
item.Init(m, kit.Format(meta["text"])).Data(m, meta)
|
||||
item.y = y + (kit.Int(meta[HEIGHT])-1)*b.GetHeights()/2
|
||||
item.Init(m, kit.Format(meta[kit.MDB_TEXT])).Data(m, meta)
|
||||
item.Draw(m, item.x, item.y)
|
||||
|
||||
if p != nil && p.y != 0 {
|
||||
@ -328,35 +329,6 @@ func (b *Chain) draw(m *ice.Message, root map[string]interface{}, depth int, wid
|
||||
return h
|
||||
}
|
||||
|
||||
// 栈
|
||||
func Stack(m *ice.Message, name string, level int, data interface{}) {
|
||||
style := []string{}
|
||||
kit.Fetch(kit.Value(data, "meta"), func(key string, value string) {
|
||||
switch key {
|
||||
case "bg":
|
||||
style = append(style, "background:"+value)
|
||||
case "fg":
|
||||
style = append(style, "color:"+value)
|
||||
}
|
||||
})
|
||||
|
||||
l, ok := kit.Value(data, "list").([]interface{})
|
||||
if !ok || len(l) == 0 {
|
||||
m.Echo(`<div class="%s" style="%s"><span class="state">o</span> %s</div>`, name, strings.Join(style, ";"), kit.Value(data, "meta.text"))
|
||||
return
|
||||
}
|
||||
m.Echo(`<div class="%s %s" style="%s"><span class="state">%s</span> %s</div>`,
|
||||
kit.Select("span", "fold", level > 2), name, strings.Join(style, ";"), kit.Select("v", ">", level > 2), kit.Value(data, "meta.text"))
|
||||
|
||||
m.Echo("<ul class='%s' %s>", name, kit.Select("", `style="display:none"`, level > 2))
|
||||
kit.Fetch(kit.Value(data, "list"), func(index int, value map[string]interface{}) {
|
||||
m.Echo("<li>")
|
||||
Stack(m, name, level+1, value)
|
||||
m.Echo("</li>")
|
||||
})
|
||||
m.Echo("</ul>")
|
||||
}
|
||||
|
||||
func _chart_show(m *ice.Message, kind, text string, arg ...string) {
|
||||
var chart Chart
|
||||
switch kind {
|
||||
@ -367,34 +339,34 @@ func _chart_show(m *ice.Message, kind, text string, arg ...string) {
|
||||
}
|
||||
|
||||
// 扩展参数
|
||||
m.Option("font-size", "24")
|
||||
m.Option("stroke", "blue")
|
||||
m.Option("fill", "yellow")
|
||||
m.Option(FONT_SIZE, "24")
|
||||
m.Option(STROKE, cli.BLUE)
|
||||
m.Option(FILL, cli.YELLOW)
|
||||
// 扩展参数
|
||||
m.Option("style", "")
|
||||
m.Option("stroke-width", "2")
|
||||
m.Option("font-family", "monospace")
|
||||
m.Option(STYLE, "")
|
||||
m.Option(STROKE_WIDTH, "2")
|
||||
m.Option(FONT_FAMILY, "monospace")
|
||||
// 扩展参数
|
||||
m.Option("compact", ice.FALSE)
|
||||
m.Option("padding", "10")
|
||||
m.Option("marginx", "10")
|
||||
m.Option("marginy", "10")
|
||||
m.Option(COMPACT, ice.FALSE)
|
||||
m.Option(PADDING, "10")
|
||||
m.Option(MARGINX, "10")
|
||||
m.Option(MARGINY, "10")
|
||||
// m.Option("font-family", kit.Select("", "monospace", len(text) == len([]rune(text))))
|
||||
|
||||
for i := 0; i < len(arg)-1; i++ {
|
||||
m.Option(arg[i], arg[i+1])
|
||||
}
|
||||
if m.Option("bg") != "" {
|
||||
m.Option("fill", m.Option("bg"))
|
||||
if m.Option(BG) != "" {
|
||||
m.Option(FILL, m.Option(BG))
|
||||
}
|
||||
if m.Option("fg") != "" {
|
||||
m.Option("stroke", m.Option("fg"))
|
||||
if m.Option(FG) != "" {
|
||||
m.Option(STROKE, m.Option(FG))
|
||||
}
|
||||
|
||||
// 计算尺寸
|
||||
chart.Init(m, text)
|
||||
m.Option("width", chart.GetWidth())
|
||||
m.Option("height", chart.GetHeight())
|
||||
m.Option(WIDTH, chart.GetWidth())
|
||||
m.Option(HEIGHT, chart.GetHeight())
|
||||
|
||||
// 渲染引擎
|
||||
_wiki_template(m, CHART, "", text)
|
||||
@ -403,27 +375,43 @@ func _chart_show(m *ice.Message, kind, text string, arg ...string) {
|
||||
}
|
||||
|
||||
const (
|
||||
FG = "fg"
|
||||
BG = "bg"
|
||||
FILL = "fill"
|
||||
STROKE = "stroke"
|
||||
|
||||
STYLE = "style"
|
||||
WIDTH = "width"
|
||||
HEIGHT = "height"
|
||||
PADDING = "padding"
|
||||
MARGINX = "marginx"
|
||||
MARGINY = "marginy"
|
||||
|
||||
FONT_SIZE = "font-size"
|
||||
FONT_FAMILY = "font-family"
|
||||
|
||||
STROKE_WIDTH = "stroke-width"
|
||||
|
||||
COMPACT = "compact"
|
||||
|
||||
LABEL = "label"
|
||||
CHAIN = "chain"
|
||||
)
|
||||
const CHART = "chart"
|
||||
|
||||
func init() {
|
||||
Index.Merge(&ice.Context{
|
||||
Commands: map[string]*ice.Command{
|
||||
CHART: {Name: "chart label|chain text", Help: "图表", Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
|
||||
_chart_show(m, arg[0], strings.TrimSpace(arg[1]), arg[2:]...)
|
||||
}},
|
||||
},
|
||||
Configs: map[string]*ice.Config{
|
||||
CHART: {Name: CHART, Help: "图表", Value: kit.Data(
|
||||
kit.MDB_TEMPLATE, `<svg {{.OptionTemplate}}
|
||||
Index.Merge(&ice.Context{Commands: map[string]*ice.Command{
|
||||
CHART: {Name: "chart label|chain text", Help: "图表", Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
|
||||
_chart_show(m, arg[0], strings.TrimSpace(arg[1]), arg[2:]...)
|
||||
}},
|
||||
}, Configs: map[string]*ice.Config{
|
||||
CHART: {Name: CHART, Help: "图表", Value: kit.Data(
|
||||
kit.MDB_TEMPLATE, `<svg {{.OptionTemplate}}
|
||||
vertion="1.1" xmlns="http://www.w3.org/2000/svg" dominant-baseline="middle" text-anchor="middle"
|
||||
font-size="{{.Option "font-size"}}" stroke="{{.Option "stroke"}}" fill="{{.Option "fill"}}"
|
||||
stroke-width="{{.Option "stroke-width"}}" font-family="{{.Option "font-family"}}"
|
||||
width="{{.Option "width"}}" height="{{.Option "height"}}"
|
||||
>`,
|
||||
)},
|
||||
},
|
||||
})
|
||||
)},
|
||||
}})
|
||||
}
|
||||
|
@ -9,24 +9,21 @@ import (
|
||||
const DATA = "data"
|
||||
|
||||
func init() {
|
||||
Index.Merge(&ice.Context{
|
||||
Configs: map[string]*ice.Config{
|
||||
DATA: {Name: DATA, Help: "数据表格", Value: kit.Data(
|
||||
kit.MDB_PATH, ice.USR_LOCAL_EXPORT, kit.MDB_REGEXP, ".*\\.csv",
|
||||
)},
|
||||
},
|
||||
Commands: map[string]*ice.Command{
|
||||
DATA: {Name: "data path auto", Help: "数据表格", Meta: kit.Dict(
|
||||
ice.Display("/plugin/local/wiki/data.js"),
|
||||
), Action: map[string]*ice.Action{
|
||||
nfs.SAVE: {Name: "save path text", Help: "保存", Hand: func(m *ice.Message, arg ...string) {
|
||||
_wiki_save(m, DATA, arg[0], arg[1])
|
||||
}},
|
||||
}, Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
|
||||
if !_wiki_list(m, DATA, kit.Select("./", arg, 0)) {
|
||||
m.CSV(m.Cmd(nfs.CAT, arg[0]).Result())
|
||||
}
|
||||
Index.Merge(&ice.Context{Configs: map[string]*ice.Config{
|
||||
DATA: {Name: DATA, Help: "数据表格", Value: kit.Data(
|
||||
kit.MDB_PATH, ice.USR_LOCAL_EXPORT, kit.MDB_REGEXP, ".*\\.csv",
|
||||
)},
|
||||
}, Commands: map[string]*ice.Command{
|
||||
DATA: {Name: "data path auto", Help: "数据表格", Meta: kit.Dict(
|
||||
ice.Display("/plugin/local/wiki/data.js"),
|
||||
), Action: map[string]*ice.Action{
|
||||
nfs.SAVE: {Name: "save path text", Help: "保存", Hand: func(m *ice.Message, arg ...string) {
|
||||
_wiki_save(m, m.CommandKey(), arg[0], arg[1])
|
||||
}},
|
||||
},
|
||||
})
|
||||
}, Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
|
||||
if !_wiki_list(m, m.CommandKey(), kit.Select("./", arg, 0)) {
|
||||
m.CSV(m.Cmd(nfs.CAT, arg[0]).Result())
|
||||
}
|
||||
}},
|
||||
}})
|
||||
}
|
||||
|
@ -11,24 +11,21 @@ import (
|
||||
const DRAW = "draw"
|
||||
|
||||
func init() {
|
||||
Index.Merge(&ice.Context{
|
||||
Configs: map[string]*ice.Config{
|
||||
DRAW: {Name: DRAW, Help: "思维导图", Value: kit.Data(
|
||||
kit.MDB_PATH, "", kit.MDB_REGEXP, ".*\\.svg",
|
||||
)},
|
||||
},
|
||||
Commands: map[string]*ice.Command{
|
||||
DRAW: {Name: "draw path=src/main.svg refresh:button=auto 编辑 save 项目 参数", Help: "思维导图", Meta: kit.Dict(
|
||||
ice.Display("/plugin/local/wiki/draw.js"),
|
||||
), Action: map[string]*ice.Action{
|
||||
nfs.SAVE: {Name: "save path", Help: "保存", Hand: func(m *ice.Message, arg ...string) {
|
||||
_wiki_save(m, DRAW, path.Join(arg...), m.Option(kit.MDB_CONTENT))
|
||||
}},
|
||||
}, Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
|
||||
if !_wiki_list(m, DRAW, kit.Select("./", path.Join(arg...))) {
|
||||
_wiki_show(m, DRAW, path.Join(arg...))
|
||||
}
|
||||
Index.Merge(&ice.Context{Configs: map[string]*ice.Config{
|
||||
DRAW: {Name: DRAW, Help: "思维导图", Value: kit.Data(
|
||||
kit.MDB_PATH, "", kit.MDB_REGEXP, ".*\\.svg",
|
||||
)},
|
||||
}, Commands: map[string]*ice.Command{
|
||||
DRAW: {Name: "draw path=src/main.svg refresh:button=auto 编辑 save 项目 参数", Help: "思维导图", Meta: kit.Dict(
|
||||
ice.Display("/plugin/local/wiki/draw.js"),
|
||||
), Action: map[string]*ice.Action{
|
||||
nfs.SAVE: {Name: "save path", Help: "保存", Hand: func(m *ice.Message, arg ...string) {
|
||||
_wiki_save(m, DRAW, path.Join(arg...), m.Option(kit.MDB_CONTENT))
|
||||
}},
|
||||
},
|
||||
})
|
||||
}, Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
|
||||
if !_wiki_list(m, DRAW, kit.Select("./", path.Join(arg...))) {
|
||||
_wiki_show(m, DRAW, path.Join(arg...))
|
||||
}
|
||||
}},
|
||||
}})
|
||||
}
|
||||
|
@ -9,22 +9,19 @@ import (
|
||||
const FEEL = "feel"
|
||||
|
||||
func init() {
|
||||
Index.Merge(&ice.Context{
|
||||
Configs: map[string]*ice.Config{
|
||||
FEEL: {Name: FEEL, Help: "影音媒体", Value: kit.Data(
|
||||
kit.MDB_PATH, ice.USR_LOCAL_IMAGE, kit.MDB_REGEXP, ".*.(png|PNG|jpg|JPG|jpeg|mp4|m4v|MOV)",
|
||||
)},
|
||||
},
|
||||
Commands: map[string]*ice.Command{
|
||||
FEEL: {Name: "feel path auto upload 上一页 下一页 参数", Help: "影音媒体", Meta: kit.Dict(
|
||||
ice.Display("/plugin/local/wiki/feel.js"),
|
||||
), Action: map[string]*ice.Action{
|
||||
web.UPLOAD: {Name: "upload", Help: "上传", Hand: func(m *ice.Message, arg ...string) {
|
||||
_wiki_upload(m, FEEL, m.Option(kit.MDB_PATH))
|
||||
}},
|
||||
}, Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
|
||||
_wiki_list(m, FEEL, kit.Select("./", arg, 0))
|
||||
Index.Merge(&ice.Context{Configs: map[string]*ice.Config{
|
||||
FEEL: {Name: FEEL, Help: "影音媒体", Value: kit.Data(
|
||||
kit.MDB_PATH, ice.USR_LOCAL_IMAGE, kit.MDB_REGEXP, ".*.(png|PNG|jpg|JPG|jpeg|mp4|m4v|MOV)",
|
||||
)},
|
||||
}, Commands: map[string]*ice.Command{
|
||||
FEEL: {Name: "feel path auto upload 上一页 下一页 参数", Help: "影音媒体", Meta: kit.Dict(
|
||||
ice.Display("/plugin/local/wiki/feel.js"),
|
||||
), Action: map[string]*ice.Action{
|
||||
web.UPLOAD: {Name: "upload", Help: "上传", Hand: func(m *ice.Message, arg ...string) {
|
||||
_wiki_upload(m, m.CommandKey(), m.Option(kit.MDB_PATH))
|
||||
}},
|
||||
},
|
||||
})
|
||||
}, Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
|
||||
_wiki_list(m, m.CommandKey(), kit.Select("./", arg, 0))
|
||||
}},
|
||||
}})
|
||||
}
|
||||
|
@ -37,7 +37,7 @@ func _field_show(m *ice.Message, name, text string, arg ...string) {
|
||||
}
|
||||
})
|
||||
|
||||
name = strings.ReplaceAll(name, " ", "_")
|
||||
name = strings.ReplaceAll(name, ice.SP, "_")
|
||||
meta[kit.MDB_NAME] = name
|
||||
meta[kit.MDB_INDEX] = text
|
||||
|
||||
@ -96,29 +96,26 @@ const (
|
||||
const FIELD = "field"
|
||||
|
||||
func init() {
|
||||
Index.Merge(&ice.Context{
|
||||
Commands: map[string]*ice.Command{
|
||||
FIELD: {Name: "field [name] cmd", Help: "插件", Action: map[string]*ice.Action{
|
||||
ice.RUN: {Name: "run", Help: "执行", Hand: func(m *ice.Message, arg ...string) {
|
||||
m.Cmdy(arg)
|
||||
}},
|
||||
}, Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
|
||||
if arg = _name(m, arg); strings.Contains(arg[1], "\n") {
|
||||
arg = append([]string{arg[0], "web.chat.div", "auto.cmd", "make", "opts.line", arg[1]}, arg[2:]...)
|
||||
}
|
||||
_field_show(m, arg[0], arg[1], arg[2:]...)
|
||||
Index.Merge(&ice.Context{Commands: map[string]*ice.Command{
|
||||
FIELD: {Name: "field [name] cmd", Help: "插件", Action: map[string]*ice.Action{
|
||||
ice.RUN: {Name: "run", Help: "执行", Hand: func(m *ice.Message, arg ...string) {
|
||||
m.Cmdy(arg)
|
||||
}},
|
||||
},
|
||||
Configs: map[string]*ice.Config{
|
||||
FIELD: {Name: FIELD, Help: "插件", Value: kit.Data(
|
||||
kit.MDB_TEMPLATE, `<fieldset {{.OptionTemplate}}" data-meta='{{.Optionv "meta"|Format}}'>
|
||||
}, Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
|
||||
if arg = _name(m, arg); strings.Contains(arg[1], ice.NL) {
|
||||
arg = append([]string{arg[0], "web.chat.div", "auto.cmd", "split", "opts.text", arg[1]}, arg[2:]...)
|
||||
}
|
||||
_field_show(m, arg[0], arg[1], arg[2:]...)
|
||||
}},
|
||||
}, Configs: map[string]*ice.Config{
|
||||
FIELD: {Name: FIELD, Help: "插件", Value: kit.Data(
|
||||
kit.MDB_TEMPLATE, `<fieldset {{.OptionTemplate}}" data-meta='{{.Optionv "meta"|Format}}'>
|
||||
<legend>{{.Option "name"}}</legend>
|
||||
<form class="option"></form>
|
||||
<div class="action"></div>
|
||||
<div class="output"></div>
|
||||
<div class="status"></div>
|
||||
</fieldset>`,
|
||||
)},
|
||||
},
|
||||
})
|
||||
)},
|
||||
}})
|
||||
}
|
||||
|
@ -20,24 +20,21 @@ const (
|
||||
const IMAGE = "image"
|
||||
|
||||
func init() {
|
||||
Index.Merge(&ice.Context{
|
||||
Commands: map[string]*ice.Command{
|
||||
ice.CTX_INIT: {Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
|
||||
m.Cmd(mdb.RENDER, mdb.CREATE, PNG, m.Prefix(IMAGE))
|
||||
Index.Merge(&ice.Context{Commands: map[string]*ice.Command{
|
||||
ice.CTX_INIT: {Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
|
||||
m.Cmd(mdb.RENDER, mdb.CREATE, PNG, m.Prefix(IMAGE))
|
||||
}},
|
||||
IMAGE: {Name: "image url", Help: "图片", Action: map[string]*ice.Action{
|
||||
mdb.RENDER: {Name: "render", Help: "渲染", Hand: func(m *ice.Message, arg ...string) {
|
||||
_image_show(m, path.Join(arg[2], arg[1]))
|
||||
}},
|
||||
IMAGE: {Name: "image url", Help: "图片", Action: map[string]*ice.Action{
|
||||
mdb.RENDER: {Name: "render", Help: "渲染", Hand: func(m *ice.Message, arg ...string) {
|
||||
_image_show(m, path.Join(arg[2], arg[1]))
|
||||
}},
|
||||
}, Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
|
||||
_image_show(m, arg[0], arg[1:]...)
|
||||
}},
|
||||
},
|
||||
Configs: map[string]*ice.Config{
|
||||
IMAGE: {Name: IMAGE, Help: "图片", Value: kit.Data(
|
||||
kit.MDB_TEMPLATE, `<img {{.OptionTemplate}} title="{{.Option "text"}}" src="{{.Option "text"}}">`,
|
||||
kit.MDB_PATH, ice.USR_LOCAL_IMAGE,
|
||||
)},
|
||||
},
|
||||
})
|
||||
}, Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
|
||||
_image_show(m, arg[0], arg[1:]...)
|
||||
}},
|
||||
}, Configs: map[string]*ice.Config{
|
||||
IMAGE: {Name: IMAGE, Help: "图片", Value: kit.Data(
|
||||
kit.MDB_TEMPLATE, `<img {{.OptionTemplate}} title="{{.Option "text"}}" src="{{.Option "text"}}">`,
|
||||
kit.MDB_PATH, ice.USR_LOCAL_IMAGE,
|
||||
)},
|
||||
}})
|
||||
}
|
||||
|
@ -50,30 +50,29 @@ func _json_show(m *ice.Message, data interface{}) {
|
||||
const JSON = "json"
|
||||
|
||||
func init() {
|
||||
Index.Merge(&ice.Context{
|
||||
Configs: map[string]*ice.Config{
|
||||
JSON: {Name: JSON, Help: "数据结构", Value: kit.Data(
|
||||
kit.MDB_PATH, ice.USR_LOCAL_EXPORT, kit.MDB_REGEXP, ".*\\.json",
|
||||
)},
|
||||
},
|
||||
Commands: map[string]*ice.Command{
|
||||
JSON: {Name: "json path auto", Help: "数据结构", Meta: kit.Dict(ice.Display("/plugin/local/wiki/json.js")), Action: map[string]*ice.Action{
|
||||
nfs.SAVE: {Name: "save path text", Help: "保存", Hand: func(m *ice.Message, arg ...string) {
|
||||
_wiki_save(m, JSON, arg[0], arg[1])
|
||||
}},
|
||||
ice.RUN: {Name: "run", Help: "执行", Hand: func(m *ice.Message, arg ...string) {
|
||||
var data interface{}
|
||||
json.Unmarshal([]byte(m.Cmdx(arg)), &data)
|
||||
m.Option("type", "json")
|
||||
m.RenderTemplate(`<div {{.OptionTemplate}}>`)
|
||||
_json_show(m, data)
|
||||
m.Echo(`</div>`)
|
||||
}},
|
||||
}, Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
|
||||
if !_wiki_list(m, JSON, kit.Select("./", arg, 0)) {
|
||||
m.Cmdy(nfs.CAT, arg[0])
|
||||
}
|
||||
Index.Merge(&ice.Context{Configs: map[string]*ice.Config{
|
||||
JSON: {Name: JSON, Help: "数据结构", Value: kit.Data(
|
||||
kit.MDB_PATH, ice.USR_LOCAL_EXPORT, kit.MDB_REGEXP, ".*\\.json",
|
||||
)},
|
||||
}, Commands: map[string]*ice.Command{
|
||||
JSON: {Name: "json path auto", Help: "数据结构", Meta: kit.Dict(
|
||||
ice.Display("/plugin/local/wiki/json.js"),
|
||||
), Action: map[string]*ice.Action{
|
||||
nfs.SAVE: {Name: "save path text", Help: "保存", Hand: func(m *ice.Message, arg ...string) {
|
||||
_wiki_save(m, JSON, arg[0], arg[1])
|
||||
}},
|
||||
},
|
||||
})
|
||||
ice.RUN: {Name: "run", Help: "执行", Hand: func(m *ice.Message, arg ...string) {
|
||||
var data interface{}
|
||||
json.Unmarshal([]byte(m.Cmdx(arg)), &data)
|
||||
m.Option("type", "json")
|
||||
m.RenderTemplate(`<div {{.OptionTemplate}}>`)
|
||||
_json_show(m, data)
|
||||
m.Echo(`</div>`)
|
||||
}},
|
||||
}, Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
|
||||
if !_wiki_list(m, JSON, kit.Select("./", arg, 0)) {
|
||||
m.Cmdy(nfs.CAT, arg[0])
|
||||
}
|
||||
}},
|
||||
}})
|
||||
}
|
||||
|
@ -14,17 +14,14 @@ func _local_show(m *ice.Message, name, text string, arg ...string) {
|
||||
const LOCAL = "local"
|
||||
|
||||
func init() {
|
||||
Index.Merge(&ice.Context{
|
||||
Commands: map[string]*ice.Command{
|
||||
LOCAL: {Name: "local [name] file", Help: "文件", Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
|
||||
arg = _name(m, arg)
|
||||
_local_show(m, arg[0], kit.Select(arg[0], arg[1]), arg[2:]...)
|
||||
}},
|
||||
},
|
||||
Configs: map[string]*ice.Config{
|
||||
LOCAL: {Name: LOCAL, Help: "文件", Value: kit.Data(
|
||||
kit.MDB_TEMPLATE, `<code {{.OptionTemplate}}>{{range $index, $value := .Optionv "input"}}{{$value}}{{end}}</code>`,
|
||||
)},
|
||||
},
|
||||
})
|
||||
Index.Merge(&ice.Context{Commands: map[string]*ice.Command{
|
||||
LOCAL: {Name: "local [name] file", Help: "文件", Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
|
||||
arg = _name(m, arg)
|
||||
_local_show(m, arg[0], kit.Select(arg[0], arg[1]), arg[2:]...)
|
||||
}},
|
||||
}, Configs: map[string]*ice.Config{
|
||||
LOCAL: {Name: LOCAL, Help: "文件", Value: kit.Data(
|
||||
kit.MDB_TEMPLATE, `<code {{.OptionTemplate}}>{{range $index, $value := .Optionv "input"}}{{$value}}{{end}}</code>`,
|
||||
)},
|
||||
}})
|
||||
}
|
||||
|
@ -15,16 +15,13 @@ func _order_show(m *ice.Message, text string, arg ...string) {
|
||||
const ORDER = "order"
|
||||
|
||||
func init() {
|
||||
Index.Merge(&ice.Context{
|
||||
Commands: map[string]*ice.Command{
|
||||
ORDER: {Name: "order `[item\n]...`", Help: "列表", Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
|
||||
_order_show(m, arg[0], arg[1:]...)
|
||||
}},
|
||||
},
|
||||
Configs: map[string]*ice.Config{
|
||||
ORDER: {Name: ORDER, Help: "列表", Value: kit.Data(
|
||||
kit.MDB_TEMPLATE, `<ul {{.OptionTemplate}}>{{range $index, $value := .Optionv "list"}}<li>{{$value}}</li>{{end}}</ul>`,
|
||||
)},
|
||||
},
|
||||
})
|
||||
Index.Merge(&ice.Context{Commands: map[string]*ice.Command{
|
||||
ORDER: {Name: "order `[item\n]...`", Help: "列表", Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
|
||||
_order_show(m, arg[0], arg[1:]...)
|
||||
}},
|
||||
}, Configs: map[string]*ice.Config{
|
||||
ORDER: {Name: ORDER, Help: "列表", Value: kit.Data(
|
||||
kit.MDB_TEMPLATE, `<ul {{.OptionTemplate}}>{{range $index, $value := .Optionv "list"}}<li>{{$value}}</li>{{end}}</ul>`,
|
||||
)},
|
||||
}})
|
||||
}
|
||||
|
@ -24,16 +24,13 @@ func _refer_show(m *ice.Message, text string, arg ...string) {
|
||||
const REFER = "refer"
|
||||
|
||||
func init() {
|
||||
Index.Merge(&ice.Context{
|
||||
Commands: map[string]*ice.Command{
|
||||
REFER: {Name: "refer `[[name] url\n]...`", Help: "参考", Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
|
||||
_refer_show(m, arg[0], arg[1:]...)
|
||||
}},
|
||||
},
|
||||
Configs: map[string]*ice.Config{
|
||||
REFER: {Name: REFER, Help: "参考", Value: kit.Data(
|
||||
kit.MDB_TEMPLATE, `<ul {{.OptionTemplate}}>{{range $index, $value := .Optionv "list"}}<li>{{index $value 0}}: <a href="{{index $value 1}}" target="_blank">{{index $value 1}}</a></li>{{end}}</ul>`,
|
||||
)},
|
||||
},
|
||||
})
|
||||
Index.Merge(&ice.Context{Commands: map[string]*ice.Command{
|
||||
REFER: {Name: "refer `[[name] url\n]...`", Help: "参考", Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
|
||||
_refer_show(m, arg[0], arg[1:]...)
|
||||
}},
|
||||
}, Configs: map[string]*ice.Config{
|
||||
REFER: {Name: REFER, Help: "参考", Value: kit.Data(
|
||||
kit.MDB_TEMPLATE, `<ul {{.OptionTemplate}}>{{range $index, $value := .Optionv "list"}}<li>{{index $value 0}}: <a href="{{index $value 1}}" target="_blank">{{index $value 1}}</a></li>{{end}}</ul>`,
|
||||
)},
|
||||
}})
|
||||
}
|
||||
|
@ -18,18 +18,15 @@ const (
|
||||
const SHELL = "shell"
|
||||
|
||||
func init() {
|
||||
Index.Merge(&ice.Context{
|
||||
Commands: map[string]*ice.Command{
|
||||
SHELL: {Name: "shell [name] cmd", Help: "命令", Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
|
||||
arg = _name(m, arg)
|
||||
_shell_show(m, arg[0], kit.Select(arg[0], arg[1]), arg[2:]...)
|
||||
}},
|
||||
},
|
||||
Configs: map[string]*ice.Config{
|
||||
SHELL: {Name: SHELL, Help: "命令", Value: kit.Data(
|
||||
kit.MDB_TEMPLATE, `<code {{.OptionTemplate}}>$ {{.Option "input"}} # {{.Option "name"}}
|
||||
Index.Merge(&ice.Context{Commands: map[string]*ice.Command{
|
||||
SHELL: {Name: "shell [name] cmd", Help: "命令", Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
|
||||
arg = _name(m, arg)
|
||||
_shell_show(m, arg[0], kit.Select(arg[0], arg[1]), arg[2:]...)
|
||||
}},
|
||||
}, Configs: map[string]*ice.Config{
|
||||
SHELL: {Name: SHELL, Help: "命令", Value: kit.Data(
|
||||
kit.MDB_TEMPLATE, `<code {{.OptionTemplate}}>$ {{.Option "input"}} # {{.Option "name"}}
|
||||
{{.Option "output"}}</code>`,
|
||||
)},
|
||||
},
|
||||
})
|
||||
)},
|
||||
}})
|
||||
}
|
||||
|
@ -14,7 +14,7 @@ func _spark_show(m *ice.Message, name, text string, arg ...string) {
|
||||
return
|
||||
}
|
||||
|
||||
prompt := kit.Select(name+"> ", m.Conf(SPARK, kit.Keym(ssh.PROMPT, name)))
|
||||
prompt := kit.Select(name+"> ", m.Config(kit.Keys(ssh.PROMPT, name)))
|
||||
m.Echo(`<div class="story" data-type="spark" data-name="%s">`, name)
|
||||
defer m.Echo("</div>")
|
||||
|
||||
@ -23,7 +23,7 @@ func _spark_show(m *ice.Message, name, text string, arg ...string) {
|
||||
return
|
||||
}
|
||||
|
||||
for _, l := range strings.Split(text, "\n") {
|
||||
for _, l := range strings.Split(text, ice.NL) {
|
||||
m.Echo("<div>")
|
||||
m.Echo("<label>").Echo(prompt).Echo("</label>")
|
||||
m.Echo("<span>").Echo(l).Echo("</span>")
|
||||
@ -33,54 +33,47 @@ func _spark_show(m *ice.Message, name, text string, arg ...string) {
|
||||
|
||||
const (
|
||||
PROMPT = "prompt"
|
||||
)
|
||||
|
||||
const (
|
||||
SSH_SHELL = "shell"
|
||||
SSH_BREAK = "break"
|
||||
BREAK = "break"
|
||||
)
|
||||
|
||||
const SPARK = "spark"
|
||||
|
||||
func init() {
|
||||
Index.Merge(&ice.Context{
|
||||
Commands: map[string]*ice.Command{
|
||||
ice.CTX_INIT: {Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
|
||||
ice.AddRender(ice.RENDER_SCRIPT, func(m *ice.Message, cmd string, args ...interface{}) string {
|
||||
arg := kit.Simple(args...)
|
||||
if len(arg) == 1 && arg[0] != SSH_BREAK {
|
||||
arg = []string{SSH_SHELL, arg[0]}
|
||||
}
|
||||
list := []string{kit.Format(`<div class="story" data-type="spark" data-name="%s">`, arg[0])}
|
||||
for _, l := range strings.Split(strings.Join(arg[1:], "\n"), "\n") {
|
||||
switch list = append(list, "<div>"); arg[0] {
|
||||
case SSH_SHELL:
|
||||
list = append(list, "<label>", "$ ", "</label>")
|
||||
default:
|
||||
list = append(list, "<label>", "> ", "</label>")
|
||||
}
|
||||
list = append(list, "<span>", l, "</span>")
|
||||
list = append(list, "</div>")
|
||||
}
|
||||
list = append(list, "</div>")
|
||||
return strings.Join(list, "")
|
||||
})
|
||||
}},
|
||||
SPARK: {Name: "spark [name] text", Help: "段落", Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
|
||||
if len(arg) == 0 {
|
||||
m.Echo(`<br class="story" data-type="spark">`)
|
||||
return
|
||||
Index.Merge(&ice.Context{Commands: map[string]*ice.Command{
|
||||
ice.CTX_INIT: {Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
|
||||
ice.AddRender(ice.RENDER_SCRIPT, func(m *ice.Message, cmd string, args ...interface{}) string {
|
||||
arg := kit.Simple(args...)
|
||||
if len(arg) == 1 && arg[0] != BREAK {
|
||||
arg = []string{SHELL, arg[0]}
|
||||
}
|
||||
list := []string{kit.Format(`<div class="story" data-type="spark" data-name="%s">`, arg[0])}
|
||||
for _, l := range strings.Split(strings.Join(arg[1:], ice.NL), ice.NL) {
|
||||
switch list = append(list, "<div>"); arg[0] {
|
||||
case SHELL:
|
||||
list = append(list, "<label>", "$ ", "</label>")
|
||||
default:
|
||||
list = append(list, "<label>", "> ", "</label>")
|
||||
}
|
||||
list = append(list, "<span>", l, "</span>")
|
||||
list = append(list, "</div>")
|
||||
}
|
||||
list = append(list, "</div>")
|
||||
return strings.Join(list, "")
|
||||
})
|
||||
}},
|
||||
SPARK: {Name: "spark [name] text", Help: "段落", Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
|
||||
if len(arg) == 0 {
|
||||
m.Echo(`<br class="story" data-type="spark">`)
|
||||
return
|
||||
}
|
||||
|
||||
arg = _name(m, arg)
|
||||
_spark_show(m, arg[0], strings.TrimSpace(arg[1]), arg[2:]...)
|
||||
}},
|
||||
},
|
||||
Configs: map[string]*ice.Config{
|
||||
SPARK: {Name: SPARK, Help: "段落", Value: kit.Data(
|
||||
kit.MDB_TEMPLATE, `<p {{.OptionTemplate}}>{{.Option "text"}}</p>`,
|
||||
ssh.PROMPT, kit.Dict("shell", "$ "),
|
||||
)},
|
||||
},
|
||||
})
|
||||
arg = _name(m, arg)
|
||||
_spark_show(m, arg[0], strings.TrimSpace(arg[1]), arg[2:]...)
|
||||
}},
|
||||
}, Configs: map[string]*ice.Config{
|
||||
SPARK: {Name: SPARK, Help: "段落", Value: kit.Data(
|
||||
kit.MDB_TEMPLATE, `<p {{.OptionTemplate}}>{{.Option "text"}}</p>`,
|
||||
ssh.PROMPT, kit.Dict(SHELL, "$ "),
|
||||
)},
|
||||
}})
|
||||
}
|
||||
|
@ -38,9 +38,9 @@ func _table_show(m *ice.Message, text string, arg ...string) {
|
||||
style := []string{}
|
||||
for i := 1; i < len(ls)-1; i += 2 {
|
||||
switch ls[i] {
|
||||
case "bg":
|
||||
case BG:
|
||||
ls[i] = "background-color"
|
||||
case "fg":
|
||||
case FG:
|
||||
ls[i] = "color"
|
||||
}
|
||||
style = append(style, ls[i]+":"+ls[i+1])
|
||||
@ -60,25 +60,22 @@ func _table_show(m *ice.Message, text string, arg ...string) {
|
||||
const TABLE = "table"
|
||||
|
||||
func init() {
|
||||
Index.Merge(&ice.Context{
|
||||
Commands: map[string]*ice.Command{
|
||||
TABLE: {Name: "table `[item item\n]...`", Help: "表格", Action: map[string]*ice.Action{
|
||||
ice.RUN: {Name: "run", Help: "执行", Hand: func(m *ice.Message, arg ...string) {
|
||||
_table_run(m, arg...)
|
||||
}},
|
||||
}, Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
|
||||
_table_show(m, arg[0], arg[1:]...)
|
||||
Index.Merge(&ice.Context{Commands: map[string]*ice.Command{
|
||||
TABLE: {Name: "table `[item item\n]...`", Help: "表格", Action: map[string]*ice.Action{
|
||||
ice.RUN: {Name: "run", Help: "执行", Hand: func(m *ice.Message, arg ...string) {
|
||||
_table_run(m, arg...)
|
||||
}},
|
||||
},
|
||||
Configs: map[string]*ice.Config{
|
||||
TABLE: {Name: TABLE, Help: "表格", Value: kit.Data(
|
||||
kit.MDB_TEMPLATE, `<table {{.OptionTemplate}}>
|
||||
}, Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
|
||||
_table_show(m, arg[0], arg[1:]...)
|
||||
}},
|
||||
}, Configs: map[string]*ice.Config{
|
||||
TABLE: {Name: TABLE, Help: "表格", Value: kit.Data(
|
||||
kit.MDB_TEMPLATE, `<table {{.OptionTemplate}}>
|
||||
<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>`,
|
||||
)},
|
||||
},
|
||||
})
|
||||
)},
|
||||
}})
|
||||
}
|
||||
|
@ -36,14 +36,11 @@ func _title_parse(m *ice.Message, dir string, root map[string]interface{}, list
|
||||
ls[1] = path.Join(dir, ls[1])
|
||||
}
|
||||
|
||||
meta := kit.Dict(
|
||||
"name", kit.Select("", ls, 0),
|
||||
"link", kit.Select("", ls, 1),
|
||||
)
|
||||
meta := kit.Dict(kit.MDB_NAME, kit.Select("", ls, 0), kit.MDB_LINK, kit.Select("", ls, 1))
|
||||
for i := 2; i < len(ls); i += 2 {
|
||||
meta[ls[i]] = ls[i+1]
|
||||
}
|
||||
last = kit.Dict("meta", meta, "list", kit.List())
|
||||
last = kit.Data(meta)
|
||||
kit.Value(root, "list.-2", last)
|
||||
}
|
||||
return len(list)
|
||||
@ -53,19 +50,19 @@ func _title_show(m *ice.Message, kind, text string, arg ...string) {
|
||||
switch title, _ := m.Optionv(TITLE).(map[string]int); kind {
|
||||
case NAVMENU: // 导航目录
|
||||
_option(m, kind, "", text, arg...)
|
||||
data := kit.Dict("meta", kit.Dict(), "list", kit.List())
|
||||
data := kit.Data()
|
||||
_title_parse(m, path.Dir(m.Option(ice.MSG_SCRIPT)), data, strings.Split(text, ice.NL))
|
||||
m.RenderTemplate(kit.Format("<div {{.OptionTemplate}} data-data='%s'></div>", kit.Format(data)))
|
||||
return
|
||||
|
||||
case PREMENU: // 前置目录
|
||||
_option(m, kind, "", "", arg...)
|
||||
m.RenderTemplate(m.Conf(TITLE, kit.Keym(kind)))
|
||||
m.RenderTemplate(m.Config(kind))
|
||||
return
|
||||
|
||||
case ENDMENU: // 后置目录
|
||||
_option(m, kind, "", "", arg...)
|
||||
m.RenderTemplate(m.Conf(TITLE, kit.Keym(kind)))
|
||||
m.RenderTemplate(m.Config(kind))
|
||||
return
|
||||
|
||||
case SECTION: // 分节标题
|
||||
@ -104,7 +101,7 @@ const TITLE = "title"
|
||||
|
||||
func init() {
|
||||
Index.Merge(&ice.Context{Commands: map[string]*ice.Command{
|
||||
TITLE: {Name: "title [premenu|chapter|section|endmenu] text", Help: "标题", Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
|
||||
TITLE: {Name: "title [navmenu|premenu|chapter|section|endmenu] text", Help: "标题", Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
|
||||
if len(arg) == 0 {
|
||||
ns := kit.Split(ice.Info.NodeName, "-")
|
||||
arg = append(arg, ns[len(ns)-1])
|
||||
|
@ -21,21 +21,18 @@ const (
|
||||
const VIDEO = "video"
|
||||
|
||||
func init() {
|
||||
Index.Merge(&ice.Context{
|
||||
Commands: map[string]*ice.Command{
|
||||
VIDEO: {Name: "video url", Help: "视频", Action: map[string]*ice.Action{
|
||||
mdb.RENDER: {Name: "render", Help: "渲染", Hand: func(m *ice.Message, arg ...string) {
|
||||
_video_show(m, path.Join(arg[2], arg[1]))
|
||||
}},
|
||||
}, Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
|
||||
_video_show(m, arg[0], arg[1:]...)
|
||||
Index.Merge(&ice.Context{Commands: map[string]*ice.Command{
|
||||
VIDEO: {Name: "video url", Help: "视频", Action: map[string]*ice.Action{
|
||||
mdb.RENDER: {Name: "render", Help: "渲染", Hand: func(m *ice.Message, arg ...string) {
|
||||
_video_show(m, path.Join(arg[2], arg[1]))
|
||||
}},
|
||||
},
|
||||
Configs: map[string]*ice.Config{
|
||||
VIDEO: {Name: "video", Help: "视频", Value: kit.Data(
|
||||
kit.MDB_TEMPLATE, `<video {{.OptionTemplate}} title="{{.Option "text"}}" src="{{.Option "text"}}" controls></video>`,
|
||||
kit.MDB_PATH, ice.USR_LOCAL_IMAGE,
|
||||
)},
|
||||
},
|
||||
})
|
||||
}, Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
|
||||
_video_show(m, arg[0], arg[1:]...)
|
||||
}},
|
||||
}, Configs: map[string]*ice.Config{
|
||||
VIDEO: {Name: "video", Help: "视频", Value: kit.Data(
|
||||
kit.MDB_TEMPLATE, `<video {{.OptionTemplate}} title="{{.Option "text"}}" src="{{.Option "text"}}" controls></video>`,
|
||||
kit.MDB_PATH, ice.USR_LOCAL_IMAGE,
|
||||
)},
|
||||
}})
|
||||
}
|
||||
|
@ -10,18 +10,36 @@ import (
|
||||
kit "shylinux.com/x/toolkits"
|
||||
)
|
||||
|
||||
func _name(m *ice.Message, arg []string) []string {
|
||||
if len(arg) == 1 {
|
||||
return []string{"", arg[0]}
|
||||
}
|
||||
return arg
|
||||
}
|
||||
func _option(m *ice.Message, kind, name, text string, arg ...string) {
|
||||
m.Option(kit.MDB_TYPE, kind)
|
||||
m.Option(kit.MDB_NAME, name)
|
||||
m.Option(kit.MDB_TEXT, text)
|
||||
|
||||
extra := kit.Dict()
|
||||
m.Optionv(kit.MDB_EXTRA, extra)
|
||||
for i := 0; i < len(arg); i += 2 {
|
||||
extra[arg[i]] = kit.Format(kit.Parse(nil, "", kit.Split(arg[i+1])...))
|
||||
}
|
||||
}
|
||||
|
||||
func _wiki_path(m *ice.Message, cmd string, arg ...string) string {
|
||||
return path.Join(m.Option(ice.MSG_LOCAL), m.Conf(cmd, kit.META_PATH), path.Join(arg...))
|
||||
return path.Join(m.Option(ice.MSG_LOCAL), m.Conf(cmd, kit.Keym(nfs.PATH)), path.Join(arg...))
|
||||
}
|
||||
func _wiki_link(m *ice.Message, cmd string, text string) string {
|
||||
if !strings.HasPrefix(text, "http") && !strings.HasPrefix(text, "/") {
|
||||
if !strings.HasPrefix(text, "http") && !strings.HasPrefix(text, ice.PS) {
|
||||
text = path.Join("/share/local", _wiki_path(m, cmd, text))
|
||||
}
|
||||
return text
|
||||
}
|
||||
func _wiki_list(m *ice.Message, cmd string, arg ...string) bool {
|
||||
m.Option(nfs.DIR_ROOT, _wiki_path(m, cmd))
|
||||
if len(arg) == 0 || strings.HasSuffix(arg[0], "/") {
|
||||
if len(arg) == 0 || strings.HasSuffix(arg[0], ice.PS) {
|
||||
if m.Option(nfs.DIR_DEEP) != ice.TRUE { // 目录列表
|
||||
m.Option(nfs.DIR_TYPE, nfs.DIR)
|
||||
m.Cmdy(nfs.DIR, kit.Select("./", arg, 0))
|
||||
@ -52,20 +70,13 @@ func _wiki_template(m *ice.Message, cmd string, name, text string, arg ...string
|
||||
|
||||
const WIKI = "wiki"
|
||||
|
||||
var Index = &ice.Context{Name: WIKI, Help: "文档中心", Commands: map[string]*ice.Command{
|
||||
ice.CTX_INIT: {Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
|
||||
m.Load()
|
||||
}},
|
||||
ice.CTX_EXIT: {Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
|
||||
m.Save()
|
||||
}},
|
||||
}}
|
||||
var Index = &ice.Context{Name: WIKI, Help: "文档中心"}
|
||||
|
||||
func init() {
|
||||
web.Index.Register(Index, &web.Frame{},
|
||||
FEEL, WORD, DATA, DRAW,
|
||||
TITLE, BRIEF, REFER, SPARK,
|
||||
ORDER, TABLE, CHART, IMAGE, VIDEO,
|
||||
TITLE, BRIEF, REFER, SPARK, CHART,
|
||||
ORDER, TABLE, IMAGE, VIDEO,
|
||||
FIELD, SHELL, LOCAL, PARSE,
|
||||
FEEL, DRAW, WORD, DATA,
|
||||
)
|
||||
}
|
||||
|
@ -1,29 +1,26 @@
|
||||
|
||||
title.go
|
||||
brief.go
|
||||
refer.go
|
||||
spark.go
|
||||
chart.go
|
||||
|
||||
order.go
|
||||
table.go
|
||||
chart.go
|
||||
image.go
|
||||
video.go
|
||||
poems.go
|
||||
|
||||
field.go
|
||||
shell.go
|
||||
local.go
|
||||
parse.go
|
||||
|
||||
data.go
|
||||
draw.go
|
||||
feel.go
|
||||
draw.go
|
||||
word.go
|
||||
data.go
|
||||
json.go
|
||||
|
||||
wiki.go
|
||||
wiki.shy
|
||||
|
||||
field "影音" web.wiki.feel
|
||||
field "数据" web.wiki.data
|
||||
field "文档" web.wiki.word
|
||||
field "绘图" web.wiki.draw
|
||||
|
||||
|
@ -1,9 +1,6 @@
|
||||
package wiki
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
"strings"
|
||||
|
||||
ice "shylinux.com/x/icebergs"
|
||||
"shylinux.com/x/icebergs/base/ctx"
|
||||
"shylinux.com/x/icebergs/base/nfs"
|
||||
@ -12,24 +9,6 @@ import (
|
||||
kit "shylinux.com/x/toolkits"
|
||||
)
|
||||
|
||||
func _name(m *ice.Message, arg []string) []string {
|
||||
if len(arg) == 1 {
|
||||
return []string{"", arg[0]}
|
||||
}
|
||||
return arg
|
||||
}
|
||||
func _option(m *ice.Message, kind, name, text string, arg ...string) {
|
||||
m.Option(kit.MDB_TYPE, kind)
|
||||
m.Option(kit.MDB_NAME, name)
|
||||
m.Option(kit.MDB_TEXT, text)
|
||||
|
||||
extra := kit.Dict()
|
||||
m.Optionv(kit.MDB_EXTRA, extra)
|
||||
for i := 0; i < len(arg); i += 2 {
|
||||
extra[arg[i]] = kit.Format(kit.Parse(nil, "", kit.Split(arg[i+1])...))
|
||||
}
|
||||
}
|
||||
|
||||
func _word_show(m *ice.Message, name string, arg ...string) {
|
||||
m.Set(ice.MSG_RESULT)
|
||||
m.Option(TITLE, map[string]int{})
|
||||
@ -40,11 +19,6 @@ func _word_show(m *ice.Message, name string, arg ...string) {
|
||||
m.Cmdy(ssh.SOURCE, name)
|
||||
}
|
||||
|
||||
func _word_template(m *ice.Message, cmd string, arg ...string) {
|
||||
arg = _name(m, arg)
|
||||
_wiki_template(m, cmd, arg[0], kit.Select(arg[0], arg[1]), arg[2:]...)
|
||||
}
|
||||
|
||||
const WORD = "word"
|
||||
|
||||
func init() {
|
||||
@ -62,35 +36,17 @@ func init() {
|
||||
)},
|
||||
}, Commands: map[string]*ice.Command{
|
||||
WORD: {Name: "word path=src/main.shy auto play", Help: "语言文字", Meta: kit.Dict(
|
||||
ice.Display("/plugin/local/wiki/word.js", WORD),
|
||||
ice.Display("/plugin/local/wiki/word.js"),
|
||||
), Action: ice.MergeAction(map[string]*ice.Action{
|
||||
"play": {Name: "play", Help: "演示"},
|
||||
web.STORY: {Name: "story", Help: "运行", Hand: func(m *ice.Message, arg ...string) {
|
||||
m.Cmdy(arg[0], ctx.ACTION, ice.RUN, arg[2:])
|
||||
}},
|
||||
"play": {Name: "play", Help: "演示"},
|
||||
}, ctx.CmdAction()), Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
|
||||
m.Option(nfs.DIR_REG, m.Conf(WORD, kit.Keym(kit.MDB_REGEXP)))
|
||||
m.Option(nfs.DIR_REG, m.Config(kit.MDB_REGEXP))
|
||||
if m.Option(nfs.DIR_DEEP, ice.TRUE); !_wiki_list(m, cmd, arg...) {
|
||||
_word_show(m, arg[0])
|
||||
}
|
||||
}},
|
||||
"/word/": {Name: "word", Help: "文档", Meta: kit.Dict(
|
||||
ice.Display("/plugin/local/wiki/word.js", WORD),
|
||||
), Action: ice.MergeAction(map[string]*ice.Action{
|
||||
web.STORY: {Name: "story", Help: "运行", Hand: func(m *ice.Message, arg ...string) {
|
||||
m.Cmdy(arg[0], ctx.ACTION, ice.RUN, arg[2:])
|
||||
}},
|
||||
ctx.COMMAND: {Name: "command", Help: "命令", Hand: func(m *ice.Message, arg ...string) {
|
||||
m.Cmdy(ctx.COMMAND, "web.wiki.word")
|
||||
if ls := strings.Split(m.Option("_names"), "/word/"); len(ls) > 1 {
|
||||
m.Push("args", ls[1])
|
||||
}
|
||||
}},
|
||||
}, ctx.CmdAction()), Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
|
||||
if m.R.Method == http.MethodGet {
|
||||
m.RenderIndex(web.SERVE, ice.VOLCANOS, "page/cmd.html")
|
||||
return // 目录
|
||||
}
|
||||
}},
|
||||
}})
|
||||
}
|
||||
|
@ -76,7 +76,7 @@ func init() {
|
||||
if arg[0] == path.Base(kit.Pwd()) {
|
||||
m.Option(nfs.DIR_ROOT, path.Join(ice.SRC))
|
||||
} else {
|
||||
m.Option(nfs.DIR_ROOT, path.Join(ice.USR, arg[0]))
|
||||
m.Option(nfs.DIR_ROOT, path.Join(ice.USR, arg[0])+ice.PS)
|
||||
}
|
||||
|
||||
if len(arg) == 1 { // 目录列表
|
||||
|
Loading…
x
Reference in New Issue
Block a user