forked from x/icebergs
opt wiki
This commit is contained in:
parent
8a8e06cd10
commit
a4eb75e5f5
@ -9,6 +9,7 @@ const (
|
||||
RSA = "rsa"
|
||||
SIGN = "sign"
|
||||
VERIFY = "verify"
|
||||
BASE64 = "base64"
|
||||
)
|
||||
const AAA = "aaa"
|
||||
|
||||
|
@ -146,6 +146,7 @@ const (
|
||||
FIND = "find"
|
||||
GREP = "grep"
|
||||
EXEC = "exec"
|
||||
ECHO = "echo"
|
||||
REST = "rest"
|
||||
OPENS = "opens"
|
||||
)
|
||||
|
@ -78,7 +78,7 @@ func (f *Frame) change(m *ice.Message, ls []string) []string {
|
||||
func (f *Frame) alias(m *ice.Message, ls []string) []string {
|
||||
if len(ls) == 0 {
|
||||
return ls
|
||||
} else if alias := kit.Simple(kit.Value(m.Optionv(ice.MSG_ALIAS), ls[0])); len(alias) > 0 {
|
||||
} else if alias := kit.Simple(kit.Value(m.Optionv(ice.SSH_ALIAS), ls[0])); len(alias) > 0 {
|
||||
ls = append(alias, ls[1:]...)
|
||||
}
|
||||
return ls
|
||||
@ -163,7 +163,11 @@ func (f *Frame) Start(m *ice.Message, arg ...string) {
|
||||
f.stdin, f.stdout = bytes.NewBufferString(msg.Result()), buf
|
||||
defer func() { m.Echo(buf.String()) }()
|
||||
}
|
||||
f.target = m.Source()
|
||||
if target, ok := m.Optionv(ice.SSH_TARGET).(*ice.Context); ok {
|
||||
f.target = target
|
||||
} else {
|
||||
f.target = m.Source()
|
||||
}
|
||||
f.scan(m, "", "")
|
||||
}
|
||||
}
|
||||
|
@ -6,6 +6,11 @@ import (
|
||||
kit "shylinux.com/x/toolkits"
|
||||
)
|
||||
|
||||
const (
|
||||
H1 = "h1"
|
||||
H2 = "h2"
|
||||
H3 = "h3"
|
||||
)
|
||||
const (
|
||||
DARK = "dark"
|
||||
LIGHT = "light"
|
||||
@ -23,6 +28,9 @@ const (
|
||||
OUTPUT = "output"
|
||||
LAYOUT = "layout"
|
||||
RESIZE = "resize"
|
||||
|
||||
COLOR = "color"
|
||||
BACKGROUND_COLOR = "background-color"
|
||||
)
|
||||
|
||||
const (
|
||||
|
4
conf.go
4
conf.go
@ -25,6 +25,7 @@ const (
|
||||
HTTPS = "https"
|
||||
HTTP = "http"
|
||||
HELP = "help"
|
||||
DEMO = "demo"
|
||||
MAIN = "main"
|
||||
AUTO = "auto"
|
||||
LIST = "list"
|
||||
@ -193,7 +194,6 @@ const ( // MSG
|
||||
MSG_STATUS = "_status"
|
||||
|
||||
MSG_INDEX = "_index"
|
||||
MSG_ALIAS = "_alias"
|
||||
MSG_SCRIPT = "_script"
|
||||
MSG_OUTPUT = "_output"
|
||||
MSG_ARGS = "_args"
|
||||
@ -226,6 +226,8 @@ const ( // MSG
|
||||
LOG_DISABLE = "log.disable"
|
||||
YAC_MESSAGE = "yac.message"
|
||||
YAC_STACK = "yac.stack"
|
||||
SSH_ALIAS = "ssh.alias"
|
||||
SSH_TARGET = "ssh.target"
|
||||
)
|
||||
const ( // RENDER
|
||||
RENDER_BUTTON = "_button"
|
||||
|
@ -16,6 +16,7 @@ repos.go
|
||||
favor.go
|
||||
bench.go
|
||||
pprof.go
|
||||
parse.go
|
||||
|
||||
c.go
|
||||
sh.go
|
||||
|
@ -2,19 +2,15 @@ package wiki
|
||||
|
||||
import (
|
||||
ice "shylinux.com/x/icebergs"
|
||||
"shylinux.com/x/icebergs/base/ctx"
|
||||
"shylinux.com/x/icebergs/base/nfs"
|
||||
)
|
||||
|
||||
const (
|
||||
M4A = "m4a"
|
||||
)
|
||||
const AUDIO = "audio"
|
||||
|
||||
func init() {
|
||||
Index.MergeCommands(ice.Commands{
|
||||
AUDIO: {Name: "audio url", Help: "音频", Actions: ctx.ConfAction(nfs.PATH, ice.USR_LOCAL_IMAGE), Hand: func(m *ice.Message, arg ...string) {
|
||||
_image_show(m, arg[0], arg[1:]...)
|
||||
AUDIO: {Name: "audio path", Help: "音频", Hand: func(m *ice.Message, arg ...string) {
|
||||
arg = _name(m, arg)
|
||||
_image_show(m, arg[0], arg[1], arg[2:]...)
|
||||
}},
|
||||
})
|
||||
}
|
||||
|
@ -6,6 +6,7 @@ import (
|
||||
ice "shylinux.com/x/icebergs"
|
||||
"shylinux.com/x/icebergs/base/lex"
|
||||
"shylinux.com/x/icebergs/base/mdb"
|
||||
"shylinux.com/x/icebergs/base/web/html"
|
||||
kit "shylinux.com/x/toolkits"
|
||||
)
|
||||
|
||||
@ -14,7 +15,9 @@ type Item struct {
|
||||
args []ice.Any
|
||||
}
|
||||
|
||||
func NewItem(str string, args ...ice.Any) *Item { return &Item{[]string{str}, args} }
|
||||
func NewItem(str string, args ...ice.Any) *Item {
|
||||
return &Item{[]string{str}, args}
|
||||
}
|
||||
func (item *Item) Push(str string, arg ice.Any) *Item {
|
||||
switch arg := arg.(type) {
|
||||
case string:
|
||||
@ -55,27 +58,21 @@ func (g *Group) Get(group string) *ice.Message { return g.list[group] }
|
||||
func (g *Group) Echo(group string, str string, arg ...ice.Any) *ice.Message {
|
||||
return g.Get(group).Echo(str, arg...)
|
||||
}
|
||||
func (g *Group) EchoRect(group string, height, width, x, y int, arg ...string) *ice.Message { // rx ry
|
||||
return g.Echo(group, "<rect x=%d y=%d height=%d width=%d rx=%s ry=%s %s/>",
|
||||
x, y, height, width, kit.Select("4", arg, 0), kit.Select("4", arg, 1), formatStyle(kit.Slice(arg, 2)...))
|
||||
}
|
||||
func (g *Group) EchoLine(group string, x1, y1, x2, y2 int, arg ...string) *ice.Message {
|
||||
return g.Echo(group, "<line x1=%d y1=%d x2=%d y2=%d %s></line>", x1, y1, x2, y2, formatStyle(arg...))
|
||||
}
|
||||
func (g *Group) EchoPath(group string, str string, arg ...ice.Any) *ice.Message {
|
||||
return g.Echo(group, `<path d="%s"></path>`, kit.Format(str, arg...))
|
||||
}
|
||||
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)
|
||||
}
|
||||
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, kit.JoinKV(mdb.EQ, lex.SP, kit.Slice(arg, 2)...))
|
||||
}
|
||||
func (g *Group) EchoText(group string, x, y int, text string, arg ...string) *ice.Message {
|
||||
float := kit.Int(kit.Select("2", "6", strings.Contains(g.Get(group).Option(ice.MSG_USERUA), "Chrome")))
|
||||
return g.Echo(group, "<text x=%d y=%d %s>%s</text>", x, y+float, kit.JoinKV(mdb.EQ, lex.SP, arg...), text)
|
||||
}
|
||||
func (g *Group) EchoTexts(group string, x, y int, text string, arg ...string) *ice.Message {
|
||||
m := g.Get(group)
|
||||
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"))))
|
||||
return g.EchoText(group, x, y+float, text, arg...)
|
||||
return g.Echo(group, "<text x=%d y=%d %s>%s</text>", x, y+8, formatStyle(arg...), text)
|
||||
}
|
||||
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))
|
||||
return g.EchoLine(group, x1, y1, x2, y2, "marker-end", kit.Format("url(#%s)", kit.Select("arrowhead", arg, 0)))
|
||||
}
|
||||
func (g *Group) DefsArrow(group string, height, width int, arg ...string) *ice.Message { // name
|
||||
return g.Echo(group, `<defs>
|
||||
@ -114,11 +111,19 @@ func _chart_show(m *ice.Message, name, text string, arg ...string) {
|
||||
chart.Init(m, text)
|
||||
m.Options(HEIGHT, chart.GetHeight(), WIDTH, chart.GetWidth())
|
||||
_wiki_template(m, "", name, text, arg...)
|
||||
defer m.Echo("</svg>")
|
||||
defer m.RenderResult()
|
||||
defer m.Echo("</svg>")
|
||||
chart.Draw(m, 0, 0)
|
||||
}
|
||||
|
||||
func formatStyle(arg ...string) string {
|
||||
return kit.JoinKV(mdb.EQ, lex.SP, kit.TransArgKey(arg, transKey)...)
|
||||
}
|
||||
|
||||
var transKey = map[string]string{
|
||||
BG: html.BACKGROUND_COLOR, FG: html.COLOR,
|
||||
}
|
||||
|
||||
const (
|
||||
FG = "fg"
|
||||
BG = "bg"
|
||||
@ -145,7 +150,7 @@ const CHART = "chart"
|
||||
|
||||
func init() {
|
||||
Index.MergeCommands(ice.Commands{
|
||||
CHART: {Name: "chart type=label,chain,sequence auto text", Help: "图表", Hand: func(m *ice.Message, arg ...string) {
|
||||
CHART: {Name: "chart type=label,chain,sequence", Help: "图表", Hand: func(m *ice.Message, arg ...string) {
|
||||
_chart_show(m, arg[0], strings.TrimSpace(arg[1]), arg[2:]...)
|
||||
}},
|
||||
})
|
||||
|
@ -53,7 +53,7 @@ func (b *Block) Data(m *ice.Message, meta ice.Any) wiki.Chart {
|
||||
func (b *Block) Draw(m *ice.Message, x, y int) wiki.Chart {
|
||||
float := kit.Int(kit.Select("2", "6", strings.Contains(m.Option(ice.MSG_USERUA), "Chrome")))
|
||||
if m.Option(HIDE_BLOCK) != ice.TRUE {
|
||||
item := wiki.NewItem(`<rect height="%d" width="%d" rx="4" ry="4" x="%d" y="%d"`, b.GetHeight(), b.GetWidth(), x+b.MarginX/2, y+b.MarginY/2)
|
||||
item := wiki.NewItem(`<rect x="%d" y="%d" height="%d" width="%d" rx="4" ry="4"`, x+b.MarginX/2, y+b.MarginY/2, b.GetHeight(), b.GetWidth())
|
||||
item.Push(`fill="%s"`, b.BackGround).Push(`%v`, b.RectData).Echo("/>").Dump(m)
|
||||
}
|
||||
item := wiki.NewItem(`<text x="%d" y="%d"`, x+b.GetWidths()/2, y+b.GetHeights()/2+float)
|
||||
|
@ -69,7 +69,7 @@ func (c *Chain) draw(m *ice.Message, root ice.Map, x, y int, p *Block, gs *wiki.
|
||||
} else {
|
||||
gs.EchoLine(LINE, item.x+item.MarginX/2, item.y+item.GetHeights()-item.MarginY/2, item.x+item.GetWidths()-item.MarginX/2, item.y+item.GetHeights()-item.MarginY/2)
|
||||
}
|
||||
gs.EchoTexts(TEXT, item.x+item.GetWidths()/2, item.y+item.GetHeights()/2, item.Text, item.TextData)
|
||||
gs.EchoText(TEXT, item.x+item.GetWidths()/2, item.y+item.GetHeights()/2, item.Text, item.TextData)
|
||||
h, x := 0, x+item.GetWidths()
|
||||
if kit.For(root[mdb.LIST], func(value ice.Map) { h += c.draw(m, value, x, y+h, item, gs) }); h == 0 {
|
||||
return item.GetHeights()
|
||||
|
@ -59,7 +59,7 @@ func (s *Label) Draw(m *ice.Message, x, y int) wiki.Chart {
|
||||
if m.Option(HIDE_BLOCK) != ice.TRUE {
|
||||
gs.EchoRect(RECT, item.GetHeight(), item.GetWidth(), left+item.MarginX/2, top+item.MarginY/2)
|
||||
}
|
||||
gs.EchoTexts(TEXT, left+item.GetWidths()/2, top+item.GetHeights()/2, item.Text)
|
||||
gs.EchoText(TEXT, left+item.GetWidths()/2, top+item.GetHeights()/2, item.Text)
|
||||
if left += item.GetWidths(); item.GetHeights() > height {
|
||||
height = item.GetHeights()
|
||||
}
|
||||
|
@ -89,7 +89,7 @@ func (s *Sequence) Draw(m *ice.Message, x, y int) wiki.Chart {
|
||||
pos := x + item.GetWidths()/2
|
||||
gs.EchoLine(LINE, pos, item.GetHeight()+item.MarginY/2, pos, s.Height-s.MarginY/2)
|
||||
gs.EchoRect(HEAD, item.GetHeight(), item.GetWidth(), x+item.MarginX/2, y+item.MarginY/2)
|
||||
gs.EchoTexts(TITLE, pos, y+item.GetHeights()/2, head)
|
||||
gs.EchoText(TITLE, pos, y+item.GetHeights()/2, head)
|
||||
height = item.GetHeight() + item.MarginY/2
|
||||
line_pos[i], x = pos, x+item.GetWidths()
|
||||
}
|
||||
|
@ -29,12 +29,11 @@ func init() {
|
||||
}},
|
||||
nfs.PUSH: {Name: "push path record", Help: "添加", Hand: func(m *ice.Message, arg ...string) {
|
||||
m.Cmd(nfs.PUSH, path.Join(mdb.Config(m, nfs.PATH), arg[0]), kit.Join(arg[1:], mdb.FS)+lex.NL)
|
||||
}}, "draw": {Help: "绘图"},
|
||||
}},
|
||||
}, WikiAction(ice.USR_LOCAL_EXPORT, nfs.CSV, nfs.JSON)), Hand: func(m *ice.Message, arg ...string) {
|
||||
kit.If(!_wiki_list(m, arg...), func() {
|
||||
if kit.Ext(arg[0]) == nfs.JSON {
|
||||
m.Cmdy(nfs.CAT, arg[0])
|
||||
ctx.DisplayStoryJSON(m)
|
||||
ctx.DisplayStoryJSON(m.Cmdy(nfs.CAT, arg[0]))
|
||||
} else {
|
||||
CSV(m, m.Cmdx(nfs.CAT, arg[0])).StatusTimeCount()
|
||||
}
|
||||
@ -46,11 +45,11 @@ func CSV(m *ice.Message, text string, head ...string) *ice.Message {
|
||||
r := csv.NewReader(bytes.NewBufferString(text))
|
||||
kit.If(len(head) == 0, func() { head, _ = r.Read() })
|
||||
for {
|
||||
line, e := r.Read()
|
||||
if e != nil {
|
||||
if line, e := r.Read(); e != nil {
|
||||
break
|
||||
} else {
|
||||
kit.For(head, func(i int, k string) { m.Push(k, kit.Select("", line, i)) })
|
||||
}
|
||||
kit.For(head, func(i int, k string) { m.Push(k, kit.Select("", line, i)) })
|
||||
}
|
||||
return m
|
||||
}
|
||||
|
@ -7,7 +7,7 @@ import (
|
||||
"shylinux.com/x/icebergs/base/aaa"
|
||||
"shylinux.com/x/icebergs/base/ctx"
|
||||
"shylinux.com/x/icebergs/base/mdb"
|
||||
"shylinux.com/x/icebergs/base/web"
|
||||
"shylinux.com/x/icebergs/base/web/html"
|
||||
kit "shylinux.com/x/toolkits"
|
||||
)
|
||||
|
||||
@ -24,7 +24,7 @@ func _field_show(m *ice.Message, name, text string, arg ...string) {
|
||||
if k == ctx.ARGS {
|
||||
kit.Value(meta, k, kit.Split(strings.TrimSuffix(strings.TrimPrefix(v, "["), "]")))
|
||||
} else if k == ice.MSG_RESULT {
|
||||
m.Option("output", strings.TrimSpace(v))
|
||||
m.Option(html.OUTPUT, strings.TrimSpace(v))
|
||||
kit.Value(meta, "meta.mode", ice.MSG_RESULT)
|
||||
kit.Value(meta, "msg", kit.Dict())
|
||||
} else {
|
||||
@ -40,10 +40,8 @@ const FIELD = "field"
|
||||
func init() {
|
||||
Index.MergeCommands(ice.Commands{
|
||||
FIELD: {Name: "field name cmd", Help: "插件", Hand: func(m *ice.Message, arg ...string) {
|
||||
kit.If(kit.IsIn(kit.Select("", arg, 1), ctx.ARGS, ice.MSG_RESULT), func() { arg = kit.Simple("", arg) })
|
||||
if arg = _name(m, arg); arg[0] == "inner" {
|
||||
arg = append([]string{"", web.CODE_INNER, ctx.ARGS, "src/ main.go", ice.MSG_RESULT, arg[1], "meta.display", "/plugin/local/code/inner.js", ctx.STYLE, "output"}, arg[2:]...)
|
||||
}
|
||||
kit.If(kit.IsIn(kit.Select("", arg, 1), ctx.ARGS), func() { arg = kit.Simple("", arg) })
|
||||
arg = _name(m, arg)
|
||||
_field_show(m, arg[0], arg[1], arg[2:]...)
|
||||
}},
|
||||
})
|
||||
|
@ -6,7 +6,7 @@ const IFRAME = "iframe"
|
||||
|
||||
func init() {
|
||||
Index.MergeCommands(ice.Commands{
|
||||
IFRAME: {Name: "iframe link auto", Hand: func(m *ice.Message, arg ...string) {
|
||||
IFRAME: {Name: "iframe link", Hand: func(m *ice.Message, arg ...string) {
|
||||
_wiki_template(m, "", "", arg[0], arg[1:]...)
|
||||
}},
|
||||
})
|
||||
|
@ -1,27 +1,27 @@
|
||||
package wiki
|
||||
|
||||
import (
|
||||
"path"
|
||||
|
||||
ice "shylinux.com/x/icebergs"
|
||||
"shylinux.com/x/icebergs/base/ctx"
|
||||
"shylinux.com/x/icebergs/base/nfs"
|
||||
"shylinux.com/x/icebergs/base/web"
|
||||
)
|
||||
|
||||
func _image_show(m *ice.Message, text string, arg ...string) {
|
||||
_wiki_template(m, "", "", _wiki_link(m, text), arg...)
|
||||
func _image_show(m *ice.Message, name, text string, arg ...string) {
|
||||
_text := text
|
||||
nfs.Exists(m, path.Join(ice.USR_LOCAL_IMAGE, text), func(p string) { text = p })
|
||||
nfs.Exists(m, path.Join(ice.USR_ICONS, text), func(p string) { text = p })
|
||||
_wiki_template(m.Options(web.LINK, _wiki_link(m, text)), "", name, _text, arg...)
|
||||
}
|
||||
|
||||
const (
|
||||
IMG = "img"
|
||||
PNG = "png"
|
||||
JPG = "jpg"
|
||||
JPEG = "jpeg"
|
||||
)
|
||||
const IMAGE = "image"
|
||||
|
||||
func init() {
|
||||
Index.MergeCommands(ice.Commands{
|
||||
IMAGE: {Name: "image path auto", Help: "图片", Actions: ice.MergeActions(ctx.ConfAction(nfs.PATH, ice.USR_LOCAL_IMAGE)), Hand: func(m *ice.Message, arg ...string) {
|
||||
_image_show(m, arg[0], arg[1:]...)
|
||||
IMAGE: {Name: "image path", Help: "图片", Hand: func(m *ice.Message, arg ...string) {
|
||||
arg = _name(m, arg)
|
||||
_image_show(m, arg[0], arg[1], arg[2:]...)
|
||||
}},
|
||||
})
|
||||
}
|
||||
|
@ -1,66 +0,0 @@
|
||||
package wiki
|
||||
|
||||
import (
|
||||
"encoding/base64"
|
||||
"encoding/hex"
|
||||
"strconv"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
ice "shylinux.com/x/icebergs"
|
||||
"shylinux.com/x/icebergs/base/ctx"
|
||||
"shylinux.com/x/icebergs/base/mdb"
|
||||
"shylinux.com/x/icebergs/base/nfs"
|
||||
"shylinux.com/x/icebergs/base/tcp"
|
||||
"shylinux.com/x/icebergs/base/web"
|
||||
kit "shylinux.com/x/toolkits"
|
||||
)
|
||||
|
||||
const PARSE = "parse"
|
||||
|
||||
func init() {
|
||||
Index.MergeCommands(ice.Commands{
|
||||
PARSE: {Name: "parse type=auto,base64,json,http,form,time,list auto text", Help: "解析", Hand: func(m *ice.Message, arg ...string) {
|
||||
if len(arg) < 2 {
|
||||
return
|
||||
}
|
||||
if arg[1] = strings.TrimSpace(arg[1]); arg[0] == ice.AUTO {
|
||||
if strings.HasPrefix(arg[1], "{") || strings.HasPrefix(arg[1], "[") {
|
||||
arg[0] = nfs.JSON
|
||||
} else if strings.HasPrefix(arg[1], web.HTTP) {
|
||||
arg[0] = web.HTTP
|
||||
} else if strings.Contains(arg[1], mdb.EQ) {
|
||||
arg[0] = web.FORM
|
||||
} else if _, e := strconv.ParseInt(arg[1], 10, 64); e == nil {
|
||||
arg[0] = mdb.TIME
|
||||
} else {
|
||||
arg[0] = mdb.LIST
|
||||
}
|
||||
}
|
||||
switch m.OptionFields(mdb.DETAIL); arg[0] {
|
||||
case nfs.JSON:
|
||||
m.Echo(kit.Formats(kit.UnMarshal(arg[1])))
|
||||
ctx.DisplayStoryJSON(m)
|
||||
case web.HTTP:
|
||||
u := kit.ParseURL(arg[1])
|
||||
m.Push(tcp.PROTO, u.Scheme).Push(tcp.HOST, u.Host).Push(nfs.PATH, u.Path)
|
||||
kit.For(u, func(k string, v []string) { m.Push(k, v) })
|
||||
m.EchoQRCode(arg[1])
|
||||
case web.FORM:
|
||||
kit.SplitKV("=", "&", arg[1], func(k string, v []string) {
|
||||
kit.For(v, func(v string) { m.Push(kit.QueryUnescape(k), kit.QueryUnescape(v)) })
|
||||
})
|
||||
case mdb.TIME:
|
||||
if i, e := strconv.ParseInt(arg[1], 10, 64); e == nil {
|
||||
m.Echo(time.Unix(i, 0).Format(ice.MOD_TIME))
|
||||
}
|
||||
case mdb.LIST:
|
||||
kit.For(kit.Split(arg[1]), func(i int, v string) { m.Push(kit.Format(i), v) })
|
||||
case "base64":
|
||||
if buf, err := base64.StdEncoding.DecodeString(arg[1]); err == nil {
|
||||
m.Echo(hex.EncodeToString(buf))
|
||||
}
|
||||
}
|
||||
}},
|
||||
})
|
||||
}
|
@ -14,8 +14,6 @@ import (
|
||||
kit "shylinux.com/x/toolkits"
|
||||
)
|
||||
|
||||
const PORTAL = "portal"
|
||||
|
||||
func _portal_commands(m *ice.Message, arg ...string) {
|
||||
const (
|
||||
MAIN = "main"
|
||||
@ -69,6 +67,8 @@ const (
|
||||
INDEX_SHY = "index.shy"
|
||||
)
|
||||
|
||||
const PORTAL = "portal"
|
||||
|
||||
func init() {
|
||||
Index.MergeCommands(ice.Commands{
|
||||
PORTAL: {Name: "portal path auto", Help: "网站门户", Actions: ice.MergeActions(ice.Actions{
|
||||
@ -82,9 +82,9 @@ func init() {
|
||||
}
|
||||
}},
|
||||
web.DREAM_TABLES: {Hand: func(m *ice.Message, arg ...string) {
|
||||
kit.Switch(m.Option(mdb.TYPE), kit.Simple(web.SERVER, web.WORKER), func() { m.PushButton(ice.Maps{PORTAL: "官网"}) })
|
||||
kit.Switch(m.Option(mdb.TYPE), kit.Simple(web.WORKER, web.SERVER), func() { m.PushButton(ice.Maps{PORTAL: "官网"}) })
|
||||
}},
|
||||
web.DREAM_ACTION: {Hand: func(m *ice.Message, arg ...string) { web.DreamProcess(m, []string{}, arg...) }},
|
||||
web.DREAM_ACTION: {Hand: func(m *ice.Message, arg ...string) { web.DreamProcess(m, nil, arg...) }},
|
||||
}, aaa.WhiteAction(), aaa.RoleAction()), Hand: func(m *ice.Message, arg ...string) {
|
||||
if m.Push(HEADER, m.Cmdx(WORD, path.Join(nfs.SRC_DOCUMENT, INDEX_SHY))); len(arg) > 0 {
|
||||
kit.If(path.Join(arg...) == "commands", func() { _portal_commands(m, arg...) })
|
||||
|
@ -44,7 +44,7 @@ Volcanos(chat.ONIMPORT, {
|
||||
},
|
||||
content: function(can, file) {
|
||||
can.runActionCommand(event, web.WIKI_WORD, [(can.base.beginWith(file, "usr/", "src/")? "": nfs.SRC_DOCUMENT+can.db.current)+file], function(msg) { can.ui.main.innerHTML = msg.Result(), can.onmotion.clear(can, can.ui.aside)
|
||||
can.onimport._display(can, can.ui.main, function(target, meta) {
|
||||
can.onimport._content(can, can.ui.main, function(target, meta) {
|
||||
meta.type == wiki.TITLE && can.onappend.style(can, meta.name, target._menu = can.onimport.item(can, {name: meta.text}, function(event) { target.scrollIntoView() }, function() {}, can.ui.aside))
|
||||
}), can.onmotion.select(can, can.ui.aside, html.DIV_ITEM, 0)
|
||||
can.sup.onimport.size(can.sup, can.sup.ConfHeight(), can.sup.ConfWidth())
|
||||
|
@ -6,19 +6,22 @@ import (
|
||||
|
||||
ice "shylinux.com/x/icebergs"
|
||||
"shylinux.com/x/icebergs/base/mdb"
|
||||
"shylinux.com/x/icebergs/base/nfs"
|
||||
kit "shylinux.com/x/toolkits"
|
||||
)
|
||||
|
||||
func _refer_show(m *ice.Message, text string, arg ...string) {
|
||||
list := [][]string{}
|
||||
for _, v := range kit.SplitLine(text) {
|
||||
if ls := kit.SplitWord(v); len(ls) == 1 {
|
||||
m.Cmd(nfs.CAT, "", kit.Dict(nfs.CAT_CONTENT, text), func(ls []string) {
|
||||
if len(ls) == 0 {
|
||||
|
||||
} else if len(ls) == 1 {
|
||||
p := kit.QueryUnescape(ls[0])
|
||||
list = append(list, []string{kit.Select(ls[0], path.Base(strings.Split(p, mdb.QS)[0])), ls[0], p})
|
||||
} else if len(ls) > 1 {
|
||||
list = append(list, append(ls, kit.QueryUnescape(ls[1])))
|
||||
}
|
||||
}
|
||||
})
|
||||
_wiki_template(m.Options(mdb.LIST, list), "", "", text, arg...)
|
||||
}
|
||||
|
||||
|
@ -1,7 +1,6 @@
|
||||
package wiki
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"path"
|
||||
"strings"
|
||||
|
||||
@ -12,43 +11,38 @@ import (
|
||||
"shylinux.com/x/icebergs/base/lex"
|
||||
"shylinux.com/x/icebergs/base/mdb"
|
||||
"shylinux.com/x/icebergs/base/nfs"
|
||||
"shylinux.com/x/icebergs/base/web"
|
||||
"shylinux.com/x/icebergs/base/web/html"
|
||||
kit "shylinux.com/x/toolkits"
|
||||
)
|
||||
|
||||
func _spark_md(m *ice.Message, arg ...string) *ice.Message {
|
||||
block, code := "", []string{}
|
||||
text := func() {
|
||||
if len(code) > 0 {
|
||||
m.Cmdy(SPARK, kit.Join(code, lex.NL))
|
||||
code = []string{}
|
||||
}
|
||||
show := func(arg ...string) {
|
||||
kit.If(len(code) > 0, func() { m.Cmdy(SPARK, arg, kit.Join(code, lex.NL)); code = []string{} })
|
||||
}
|
||||
defer show()
|
||||
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()
|
||||
show()
|
||||
m.Cmdy(ls[1:], strings.TrimPrefix(line, ls[0]))
|
||||
return
|
||||
}
|
||||
}
|
||||
if strings.HasPrefix(line, "```") {
|
||||
if block == "" {
|
||||
text()
|
||||
show()
|
||||
block = "```"
|
||||
} else {
|
||||
m.Cmdy(SPARK, SHELL, kit.Join(code, lex.NL))
|
||||
block, code = "", []string{}
|
||||
show(SHELL)
|
||||
}
|
||||
return
|
||||
} else {
|
||||
code = append(code, line)
|
||||
}
|
||||
code = append(code, line)
|
||||
})
|
||||
text()
|
||||
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...)
|
||||
}
|
||||
func _spark_tabs(m *ice.Message, arg ...string) {
|
||||
defer m.Echo(`<div class="story" data-type="spark_tabs">`).Echo(`</div>`)
|
||||
func() {
|
||||
@ -57,8 +51,12 @@ func _spark_tabs(m *ice.Message, arg ...string) {
|
||||
}()
|
||||
kit.For(arg[1:], func(k, v string) { m.Cmdy("", arg[0], v) })
|
||||
}
|
||||
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 (
|
||||
INNER = "inner"
|
||||
SHELL = "shell"
|
||||
)
|
||||
|
||||
@ -69,11 +67,18 @@ func init() {
|
||||
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.AddRender(ice.RENDER_SCRIPT, func(msg *ice.Message, args ...ice.Any) string {
|
||||
m.Option(ice.MSG_COUNT, "0")
|
||||
return m.Cmdx(SPARK, SHELL, args)
|
||||
return m.Options(ice.MSG_COUNT, "0").Cmdx(SPARK, SHELL, args)
|
||||
})
|
||||
}},
|
||||
"inner": {Hand: func(m *ice.Message, arg ...string) {
|
||||
ice.DEMO: {Hand: func(m *ice.Message, arg ...string) {
|
||||
if aaa.Right(m.Spawn(), arg[0]) {
|
||||
m.Cmdy(FIELD, "", arg[0], arg[1:])
|
||||
} else {
|
||||
p := kit.Format("http://localhost:9020/chat/cmd/%s", arg[0])
|
||||
m.Cmdy(SPARK, p, arg[1:]).Cmdy(IFRAME, p, arg[1:])
|
||||
}
|
||||
}},
|
||||
INNER: {Hand: func(m *ice.Message, arg ...string) {
|
||||
if strings.Contains(arg[0], lex.NL) {
|
||||
|
||||
} else if nfs.Exists(m, arg[0]) {
|
||||
@ -83,28 +88,18 @@ func init() {
|
||||
arg = append(arg, kit.Simple(ctx.ARGS, kit.Join(nfs.SplitPath(m, p), lex.SP))...)
|
||||
arg[0] = m.Cmdx(nfs.CAT, p)
|
||||
}
|
||||
m.Cmdy(FIELD, "", "web.code.inner", ice.MSG_RESULT, arg[0], ctx.DISPLAY, "/plugin/local/code/inner.js", ctx.STYLE, "output", arg[1:])
|
||||
}},
|
||||
"demo": {Hand: func(m *ice.Message, arg ...string) {
|
||||
if aaa.Right(m.Spawn(), arg[0]) {
|
||||
m.Cmdy(FIELD, "", arg[0], arg[1:])
|
||||
} else {
|
||||
m.Cmdy(SPARK, fmt.Sprintf("<a>http://localhost:9020/chat/cmd/%s</a>", arg[0]), arg[1:])
|
||||
m.Cmdy(IFRAME, fmt.Sprintf("http://localhost:9020/chat/cmd/%s", arg[0]), arg[1:])
|
||||
}
|
||||
m.Cmdy(FIELD, "", web.CODE_INNER, ice.MSG_RESULT, arg[0], ctx.DISPLAY, "/plugin/local/code/inner.js", ctx.STYLE, html.OUTPUT, arg[1:])
|
||||
}},
|
||||
}), Hand: func(m *ice.Message, arg ...string) {
|
||||
if kit.Ext(arg[0]) == "md" {
|
||||
_spark_md(m, arg...)
|
||||
} else if arg[0] == SHELL && kit.IsIn(kit.Select("", arg, 1), cli.ALPINE, cli.CENTOS, cli.LINUX, cli.MACOS, cli.DARWIN, cli.WINDOWS) {
|
||||
} else if arg[0] == SHELL && kit.IsIn(kit.Select("", arg, 1), cli.ALPINE, cli.CENTOS, cli.LINUX, cli.DARWIN, cli.MACOS, cli.WINDOWS) {
|
||||
_spark_tabs(m, arg...)
|
||||
} else {
|
||||
arg = _name(m, arg)
|
||||
if arg[0] == "shell" && len(arg) > 3 && arg[2] == "with" && arg[3] == "echo" {
|
||||
m.Option("echo", m.Cmdx(cli.SYSTEM, kit.Split(arg[1])))
|
||||
if arg = _name(m, arg); arg[0] == SHELL && len(arg) > 3 && arg[2] == "with" && arg[3] == cli.ECHO {
|
||||
m.Option(cli.ECHO, m.Cmdx(cli.SYSTEM, kit.Split(arg[1])))
|
||||
}
|
||||
arg[1] = kit.Renders(arg[1], ice.Info)
|
||||
_spark_show(m, arg[0], strings.TrimSpace(arg[1]), arg[2:]...)
|
||||
_spark_show(m, arg[0], strings.TrimSpace(kit.Renders(arg[1], ice.Info)), arg[2:]...)
|
||||
}
|
||||
}},
|
||||
})
|
||||
|
@ -9,15 +9,15 @@ const STYLE = "style"
|
||||
|
||||
func init() {
|
||||
Index.MergeCommands(ice.Commands{
|
||||
STYLE: {Name: "style class auto", Help: "样式", Hand: func(m *ice.Message, arg ...string) {
|
||||
STYLE: {Name: "style class", Help: "样式", Hand: func(m *ice.Message, arg ...string) {
|
||||
switch kit.Select("end", arg, 0) {
|
||||
case "end":
|
||||
m.Echo("</div>")
|
||||
default:
|
||||
if len(arg) > 1 {
|
||||
m.Echo(`<div class="%s %s" style="%s">`, "story", arg[0], kit.JoinKV(":", ";", arg[1:]...))
|
||||
m.Echo(`<div class="story %s" style="%s">`, arg[0], kit.JoinKV(":", ";", kit.TransArgKey(arg[1:], transKey)...))
|
||||
} else {
|
||||
m.Echo(`<div class="%s %s">`, "story", arg[0])
|
||||
m.Echo(`<div class="story %s">`, arg[0])
|
||||
}
|
||||
}
|
||||
}},
|
||||
|
@ -1,51 +1,44 @@
|
||||
package wiki
|
||||
|
||||
import (
|
||||
"strings"
|
||||
|
||||
ice "shylinux.com/x/icebergs"
|
||||
"shylinux.com/x/icebergs/base/ctx"
|
||||
"shylinux.com/x/icebergs/base/nfs"
|
||||
"shylinux.com/x/icebergs/base/web/html"
|
||||
kit "shylinux.com/x/toolkits"
|
||||
)
|
||||
|
||||
func _table_run(m *ice.Message, arg ...string) {
|
||||
list := [][]string{}
|
||||
m.Cmd(arg).Table(func(index int, value ice.Maps, head []string) {
|
||||
kit.If(index == 0, func() { m.Optionv("head", head) })
|
||||
line := []string{}
|
||||
kit.For(head, func(h string) { line = append(line, value[h]) })
|
||||
list = append(list, line)
|
||||
ls := []string{}
|
||||
kit.If(index == 0, func() { m.Options(HEAD, head) })
|
||||
kit.For(head, func(h string) { ls = append(ls, value[h]) })
|
||||
list = append(list, ls)
|
||||
})
|
||||
_wiki_template(m.Options("list", list), "", "", "")
|
||||
_wiki_template(m.Options(LIST, list), "", "", "")
|
||||
}
|
||||
func _table_show(m *ice.Message, text string, arg ...string) {
|
||||
head, list := []string{}, [][]string{}
|
||||
for i, line := range kit.SplitLine(text) {
|
||||
if line = strings.Replace(line, "%", "%%", -1); i == 0 {
|
||||
head = kit.SplitWord(line)
|
||||
continue
|
||||
m.Cmd(nfs.CAT, "", kit.Dict(nfs.CAT_CONTENT, text), func(ls []string) {
|
||||
if len(head) == 0 {
|
||||
head = ls
|
||||
return
|
||||
}
|
||||
list = append(list, kit.Simple(kit.SplitWord(line), func(value string) string {
|
||||
list = append(list, kit.Simple(ls, func(value string) string {
|
||||
if ls := kit.SplitWord(value); len(ls) > 1 {
|
||||
return kit.Format(`<span style="%s">%s</span>`, kit.JoinKV(":", ";", transArgKey(ls[1:])...), ls[0])
|
||||
}
|
||||
return value
|
||||
}))
|
||||
}
|
||||
_wiki_template(m.Options("head", head, "list", list), "", "", text, arg...)
|
||||
}
|
||||
func transArgKey(arg []string) []string {
|
||||
for i := 0; i < len(arg)-1; i += 2 {
|
||||
switch arg[i] {
|
||||
case BG:
|
||||
arg[i] = "background-color"
|
||||
case FG:
|
||||
arg[i] = "color"
|
||||
}
|
||||
}
|
||||
return arg
|
||||
})
|
||||
_wiki_template(m.Options(HEAD, head, LIST, list), "", "", text, arg...)
|
||||
}
|
||||
|
||||
const (
|
||||
HEAD = "head"
|
||||
LIST = "list"
|
||||
)
|
||||
const TABLE = "table"
|
||||
|
||||
func init() {
|
||||
@ -55,3 +48,15 @@ func init() {
|
||||
}), Hand: func(m *ice.Message, arg ...string) { _table_show(m, arg[0], arg[1:]...) }},
|
||||
})
|
||||
}
|
||||
|
||||
func transArgKey(arg []string) []string {
|
||||
for i := 0; i < len(arg)-1; i += 2 {
|
||||
switch arg[i] {
|
||||
case BG:
|
||||
arg[i] = html.BACKGROUND_COLOR
|
||||
case FG:
|
||||
arg[i] = html.COLOR
|
||||
}
|
||||
}
|
||||
return arg
|
||||
}
|
||||
|
@ -9,6 +9,7 @@ import (
|
||||
"shylinux.com/x/icebergs/base/mdb"
|
||||
"shylinux.com/x/icebergs/base/nfs"
|
||||
"shylinux.com/x/icebergs/base/web"
|
||||
"shylinux.com/x/icebergs/base/web/html"
|
||||
kit "shylinux.com/x/toolkits"
|
||||
)
|
||||
|
||||
@ -16,16 +17,14 @@ func _title_parse(m *ice.Message, text string) string {
|
||||
deep, list := []int{}, []string{}
|
||||
return m.Cmdx(lex.SPLIT, "", "name,link", kit.Dict(nfs.CAT_CONTENT, text), func(indent int, ls []string) []string {
|
||||
for len(deep) > 0 && indent <= deep[len(deep)-1] {
|
||||
deep = deep[:len(deep)-1]
|
||||
list = list[:len(list)-1]
|
||||
deep, list = deep[:len(deep)-1], list[:len(list)-1]
|
||||
}
|
||||
if len(ls) > 1 {
|
||||
kit.If(!kit.HasPrefix(ls[1], nfs.PS, web.HTTP, nfs.SRC, nfs.USR), func() {
|
||||
ls[1] = path.Join(kit.Select(path.Dir(m.Option(ice.MSG_SCRIPT)), list, -1), ls[1]) + kit.Select("", nfs.PS, strings.HasSuffix(ls[1], nfs.PS))
|
||||
})
|
||||
}
|
||||
deep = append(deep, indent)
|
||||
list = append(list, kit.Select("", ls, 1))
|
||||
deep, list = append(deep, indent), append(list, kit.Select("", ls, 1))
|
||||
return ls
|
||||
})
|
||||
}
|
||||
@ -34,16 +33,16 @@ func _title_menu(m *ice.Message, name, text string, arg ...string) *ice.Message
|
||||
return _wiki_template(m, name, name, text, arg...)
|
||||
}
|
||||
func _title_show(m *ice.Message, name, text string, arg ...string) *ice.Message {
|
||||
switch title, _ := m.Optionv(TITLE).(map[string]int); name {
|
||||
switch title := m.Optionv(TITLE).(map[string]int); name {
|
||||
case SECTION:
|
||||
title[SECTION]++
|
||||
m.Options(LEVEL, "h3", PREFIX, kit.Format("%d.%d ", title[CHAPTER], title[SECTION]))
|
||||
m.Options(LEVEL, html.H3, PREFIX, kit.Format("%d.%d ", title[CHAPTER], title[SECTION]))
|
||||
case CHAPTER:
|
||||
title[CHAPTER]++
|
||||
title[SECTION] = 0
|
||||
m.Options(LEVEL, "h2", PREFIX, kit.Format("%d ", title[CHAPTER]))
|
||||
m.Options(LEVEL, html.H2, PREFIX, kit.Format("%d ", title[CHAPTER]))
|
||||
default:
|
||||
m.Options(LEVEL, "h1", PREFIX, "")
|
||||
m.Options(LEVEL, html.H1, PREFIX, "")
|
||||
}
|
||||
return _wiki_template(m, "", name, text, arg...)
|
||||
}
|
||||
|
@ -2,21 +2,15 @@ package wiki
|
||||
|
||||
import (
|
||||
ice "shylinux.com/x/icebergs"
|
||||
"shylinux.com/x/icebergs/base/ctx"
|
||||
"shylinux.com/x/icebergs/base/nfs"
|
||||
)
|
||||
|
||||
const (
|
||||
m4v = "m4v"
|
||||
mp4 = "mp4"
|
||||
MOV = "mov"
|
||||
)
|
||||
const VIDEO = "video"
|
||||
|
||||
func init() {
|
||||
Index.MergeCommands(ice.Commands{
|
||||
VIDEO: {Name: "video url run", Help: "视频", Actions: ice.MergeActions(ctx.ConfAction(nfs.PATH, ice.USR_LOCAL_IMAGE)), Hand: func(m *ice.Message, arg ...string) {
|
||||
_image_show(m, arg[0], arg[1:]...)
|
||||
VIDEO: {Name: "video path", Help: "视频", Hand: func(m *ice.Message, arg ...string) {
|
||||
arg = _name(m, arg)
|
||||
_image_show(m, arg[0], arg[1], arg[2:]...)
|
||||
}},
|
||||
})
|
||||
}
|
||||
|
@ -6,6 +6,7 @@ import (
|
||||
"strings"
|
||||
|
||||
ice "shylinux.com/x/icebergs"
|
||||
"shylinux.com/x/icebergs/base/cli"
|
||||
"shylinux.com/x/icebergs/base/ctx"
|
||||
"shylinux.com/x/icebergs/base/lex"
|
||||
"shylinux.com/x/icebergs/base/mdb"
|
||||
@ -21,8 +22,8 @@ func _name(m *ice.Message, arg []string) []string {
|
||||
func _option(m *ice.Message, kind, name, text string, arg ...string) *ice.Message {
|
||||
extra := kit.Dict()
|
||||
kit.For(arg, func(k, v string) {
|
||||
kit.If(k == "fg", func() { k = "style.color" })
|
||||
kit.If(k == "bg", func() { k = "style.background" })
|
||||
kit.If(k == cli.FG, func() { k = "style.color" })
|
||||
kit.If(k == cli.BG, func() { k = "style.background" })
|
||||
kit.Value(extra, k, kit.Format(kit.Parse(nil, "", kit.Split(v)...)))
|
||||
})
|
||||
m.OptionDefault(mdb.META, kit.Format(extra))
|
||||
@ -40,12 +41,6 @@ func _wiki_list(m *ice.Message, arg ...string) bool {
|
||||
m.Copy(m.Cmd(nfs.DIR, kit.Slice(arg, 0, 1), kit.Dict(nfs.DIR_TYPE, nfs.CAT, nfs.DIR_REG, mdb.Config(m, lex.REGEXP))).SortStr(nfs.PATH))
|
||||
return true
|
||||
} else {
|
||||
p := ctx.GetCmdFile(m, m.PrefixKey())
|
||||
m.Debug("what %v", p)
|
||||
p = nfs.Relative(m, p)
|
||||
m.Debug("what %v", p)
|
||||
p = ctx.FileURI(p)
|
||||
m.Debug("what %v", p)
|
||||
ctx.Display(m, ctx.FileURI(nfs.Relative(m, ctx.GetCmdFile(m, m.PrefixKey()))))
|
||||
// ctx.DisplayLocal(m, path.Join(kit.PathName(2), kit.Keys(kit.FileName(2), nfs.JS)))
|
||||
return false
|
||||
@ -71,9 +66,9 @@ var Index = &ice.Context{Name: WIKI, Help: "文档中心"}
|
||||
|
||||
func init() {
|
||||
web.Index.Register(Index, &web.Frame{},
|
||||
TITLE, BRIEF, REFER, SPARK, PARSE, FIELD,
|
||||
FEEL, DRAW, DATA, WORD, PORTAL, STYLE,
|
||||
TITLE, BRIEF, REFER, SPARK, FIELD,
|
||||
ORDER, TABLE, CHART, IMAGE, VIDEO, AUDIO,
|
||||
WORD, DATA, DRAW, FEEL, STYLE, PORTAL,
|
||||
)
|
||||
}
|
||||
func Prefix(arg ...string) string { return web.Prefix(WIKI, kit.Keys(arg)) }
|
||||
|
@ -7,10 +7,9 @@ data.go
|
||||
word.go
|
||||
|
||||
title.go
|
||||
refer.go
|
||||
brief.go
|
||||
refer.go
|
||||
spark.go
|
||||
parse.go
|
||||
field.go
|
||||
|
||||
order.go
|
||||
@ -19,9 +18,9 @@ chart.go
|
||||
image.go
|
||||
video.go
|
||||
audio.go
|
||||
iframe.go
|
||||
|
||||
style.go
|
||||
iframe.go
|
||||
portal.go
|
||||
portal.js
|
||||
portal.css
|
||||
|
@ -2,7 +2,7 @@ package wiki
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
"strings"
|
||||
"path"
|
||||
|
||||
ice "shylinux.com/x/icebergs"
|
||||
"shylinux.com/x/icebergs/base/aaa"
|
||||
@ -16,10 +16,8 @@ import (
|
||||
)
|
||||
|
||||
func _word_show(m *ice.Message, name string, arg ...string) {
|
||||
if strings.HasPrefix(name, "/require/") {
|
||||
m.Option(nfs.CAT_CONTENT, m.Cmdx(web.SPIDE, ice.OPS, web.SPIDE_RAW, http.MethodGet, name))
|
||||
}
|
||||
m.Options(ice.MSG_ALIAS, mdb.Configv(m, mdb.ALIAS), TITLE, map[string]int{})
|
||||
kit.If(kit.HasPrefix(name, nfs.PS, web.HTTP), func() { m.Option(nfs.CAT_CONTENT, m.Cmdx(web.SPIDE, ice.OPS, web.SPIDE_RAW, http.MethodGet, name)) })
|
||||
m.Options(ice.SSH_TARGET, m.Target(), ice.SSH_ALIAS, mdb.Configv(m, mdb.ALIAS), TITLE, map[string]int{})
|
||||
m.Cmdy(ssh.SOURCE, name, kit.Dict(nfs.DIR_ROOT, _wiki_path(m)))
|
||||
}
|
||||
|
||||
@ -44,19 +42,17 @@ func init() {
|
||||
if m.Option(nfs.DIR_DEEP, ice.TRUE); kit.Path(value[nfs.PATH]) == kit.Path("") {
|
||||
_wiki_list(m, nfs.SRC)
|
||||
} else {
|
||||
_wiki_list(m, value[nfs.PATH])
|
||||
_wiki_list(m, path.Join(value[nfs.PATH], nfs.SRC))
|
||||
}
|
||||
})
|
||||
m.Cut("path,size,time")
|
||||
}}, "play": {Help: "演示"},
|
||||
}},
|
||||
code.COMPLETE: {Hand: func(m *ice.Message, arg ...string) {
|
||||
ls := kit.Split(m.Option(mdb.TEXT))
|
||||
kit.If(kit.IsIn(ls[0], IMAGE, VIDEO, AUDIO), func() { m.Cmdy(FEEL).CutTo(nfs.PATH, mdb.NAME) })
|
||||
kit.If(kit.IsIn(kit.Split(m.Option(mdb.TEXT))[0], IMAGE, VIDEO, AUDIO), func() { m.Cmdy(FEEL).CutTo(nfs.PATH, mdb.NAME) })
|
||||
}},
|
||||
}, aaa.RoleAction(), WikiAction("", nfs.SHY)), Hand: func(m *ice.Message, arg ...string) {
|
||||
if m.Option(nfs.DIR_DEEP, ice.TRUE); len(arg) == 0 {
|
||||
arg = append(arg, nfs.SRC)
|
||||
}
|
||||
m.Option(nfs.DIR_DEEP, ice.TRUE)
|
||||
kit.If(len(arg) == 0, func() { arg = append(arg, nfs.SRC) })
|
||||
kit.If(!_wiki_list(m, arg...), func() { _word_show(m, arg[0]) })
|
||||
}},
|
||||
})
|
||||
|
@ -29,7 +29,7 @@ func (s spide) List(m *ice.Message, arg ...string) {
|
||||
m.PushAudios(mdb.SHOW, value[mdb.LINK])
|
||||
case wiki.VIDEO:
|
||||
m.PushVideos(mdb.SHOW, value[mdb.LINK])
|
||||
case wiki.IMG:
|
||||
case "img":
|
||||
m.PushImages(mdb.SHOW, value[mdb.LINK])
|
||||
default:
|
||||
m.Push(mdb.SHOW, "")
|
||||
|
Loading…
x
Reference in New Issue
Block a user