mirror of
https://shylinux.com/x/icebergs
synced 2025-04-26 09:34:05 +08:00
opt code
This commit is contained in:
parent
f962f43d99
commit
ef11fb2bba
@ -84,7 +84,7 @@ func _dream_show(m *ice.Message, name string) {
|
|||||||
// 启动任务
|
// 启动任务
|
||||||
m.Cmd(cli.DAEMON, m.Configv(ice.CMD), ice.DEV, ice.DEV, mdb.NAME, name, m.OptionSimple(RIVER))
|
m.Cmd(cli.DAEMON, m.Configv(ice.CMD), ice.DEV, ice.DEV, mdb.NAME, name, m.OptionSimple(RIVER))
|
||||||
defer m.Event(DREAM_CREATE, kit.SimpleKV("", m.Option(mdb.TYPE), name)...)
|
defer m.Event(DREAM_CREATE, kit.SimpleKV("", m.Option(mdb.TYPE), name)...)
|
||||||
m.Sleep300ms()
|
m.Sleep3s()
|
||||||
}
|
}
|
||||||
|
|
||||||
const (
|
const (
|
||||||
|
@ -123,3 +123,7 @@ func (b *Buffer) Close() error { return nil }
|
|||||||
func PushStream(m *ice.Message) {
|
func PushStream(m *ice.Message) {
|
||||||
m.Option(cli.CMD_OUTPUT, &Buffer{m: m, n: m.Option(ice.MSG_DAEMON)})
|
m.Option(cli.CMD_OUTPUT, &Buffer{m: m, n: m.Option(ice.MSG_DAEMON)})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func Format(tag string, arg ...interface{}) string {
|
||||||
|
return kit.Format("<%s>%s</%s>", tag, strings.Join(kit.Simple(arg), ""))
|
||||||
|
}
|
||||||
|
@ -76,7 +76,7 @@ func _share_local(m *ice.Message, arg ...string) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 上传文件
|
// 上传文件
|
||||||
m.Cmdy(SPACE, m.Option(ice.POD), SPIDE, ice.DEV, SPIDE_RAW, m.MergeURL2("/share/proxy"),
|
m.Cmdy(SPACE, m.Option(ice.POD), SPIDE, ice.DEV, SPIDE_RAW, m.MergeURL2(SHARE_PROXY),
|
||||||
SPIDE_PART, m.OptionSimple(ice.POD), nfs.PATH, p, CACHE, cache.Format(ice.MOD_TIME), UPLOAD, "@"+p)
|
SPIDE_PART, m.OptionSimple(ice.POD), nfs.PATH, p, CACHE, cache.Format(ice.MOD_TIME), UPLOAD, "@"+p)
|
||||||
|
|
||||||
if s, e := os.Stat(pp); e == nil && !s.IsDir() {
|
if s, e := os.Stat(pp); e == nil && !s.IsDir() {
|
||||||
@ -97,6 +97,15 @@ const (
|
|||||||
RIVER = "river"
|
RIVER = "river"
|
||||||
STORM = "storm"
|
STORM = "storm"
|
||||||
FIELD = "field"
|
FIELD = "field"
|
||||||
|
|
||||||
|
SHARE_TOAST = "/share/toast/"
|
||||||
|
SHARE_CACHE = "/share/cache/"
|
||||||
|
SHARE_REPOS = "/share/repos/"
|
||||||
|
SHARE_PROXY = "/share/proxy/"
|
||||||
|
SHARE_LOCAL = "/share/local/"
|
||||||
|
|
||||||
|
SHARE_LOCAL_AVATAR = "/share/local/avatar"
|
||||||
|
SHARE_LOCAL_BACKGROUND = "/share/local/background"
|
||||||
)
|
)
|
||||||
const SHARE = "share"
|
const SHARE = "share"
|
||||||
|
|
||||||
@ -157,26 +166,26 @@ func init() {
|
|||||||
m.RenderIndex(SERVE, ice.VOLCANOS)
|
m.RenderIndex(SERVE, ice.VOLCANOS)
|
||||||
}},
|
}},
|
||||||
|
|
||||||
"/share/toast/": {Name: "/share/toast/", Help: "推送流", Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
|
SHARE_TOAST: {Name: "/share/toast/", Help: "推送流", Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
|
||||||
m.Cmdy(SPACE, m.Option(ice.POD), m.Optionv("cmds"))
|
m.Cmdy(SPACE, m.Option(ice.POD), m.Optionv("cmds"))
|
||||||
}},
|
}},
|
||||||
"/share/repos/": {Name: "/share/repos/", Help: "代码库", Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
|
SHARE_CACHE: {Name: "/share/cache/", Help: "缓存池", Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
|
||||||
_share_repos(m, path.Join(arg[0], arg[1], arg[2]), arg[3:]...)
|
|
||||||
}},
|
|
||||||
"/share/proxy": {Name: "/share/proxy", Help: "文件流", Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
|
|
||||||
_share_proxy(m)
|
|
||||||
}},
|
|
||||||
"/share/cache/": {Name: "/share/cache/", Help: "缓存池", Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
|
|
||||||
_share_cache(m, arg...)
|
_share_cache(m, arg...)
|
||||||
}},
|
}},
|
||||||
"/share/local/": {Name: "/share/local/", Help: "文件夹", Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
|
SHARE_REPOS: {Name: "/share/repos/", Help: "代码库", Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
|
||||||
|
_share_repos(m, path.Join(arg[0], arg[1], arg[2]), arg[3:]...)
|
||||||
|
}},
|
||||||
|
SHARE_PROXY: {Name: "/share/proxy/", Help: "文件流", Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
|
||||||
|
_share_proxy(m)
|
||||||
|
}},
|
||||||
|
SHARE_LOCAL: {Name: "/share/local/", Help: "文件夹", Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
|
||||||
_share_local(m, arg...)
|
_share_local(m, arg...)
|
||||||
}},
|
}},
|
||||||
"/share/local/avatar": {Name: "avatar", Help: "头像", Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
|
SHARE_LOCAL_AVATAR: {Name: "avatar", Help: "头像", Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
|
||||||
m.RenderDownload(strings.TrimPrefix(m.Cmd(aaa.USER, m.Option(ice.MSG_USERNAME)).Append(aaa.AVATAR), "/share/local/"))
|
m.RenderDownload(strings.TrimPrefix(m.Cmd(aaa.USER, m.Option(ice.MSG_USERNAME)).Append(aaa.AVATAR), SHARE_LOCAL))
|
||||||
}},
|
}},
|
||||||
"/share/local/background": {Name: "background", Help: "壁纸", Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
|
SHARE_LOCAL_BACKGROUND: {Name: "background", Help: "壁纸", Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
|
||||||
m.RenderDownload(strings.TrimPrefix(m.Cmd(aaa.USER, m.Option(ice.MSG_USERNAME)).Append(aaa.BACKGROUND), "/share/local/"))
|
m.RenderDownload(strings.TrimPrefix(m.Cmd(aaa.USER, m.Option(ice.MSG_USERNAME)).Append(aaa.BACKGROUND), SHARE_LOCAL))
|
||||||
}},
|
}},
|
||||||
}})
|
}})
|
||||||
}
|
}
|
||||||
|
@ -319,6 +319,7 @@ const (
|
|||||||
SPIDE_HEADER = "header"
|
SPIDE_HEADER = "header"
|
||||||
SPIDE_COOKIE = "cookie"
|
SPIDE_COOKIE = "cookie"
|
||||||
|
|
||||||
|
FORM = "form"
|
||||||
ADDRESS = "address"
|
ADDRESS = "address"
|
||||||
REQUEST = "request"
|
REQUEST = "request"
|
||||||
RESPONSE = "response"
|
RESPONSE = "response"
|
||||||
|
1
conf.go
1
conf.go
@ -20,6 +20,7 @@ const (
|
|||||||
INIT = "init"
|
INIT = "init"
|
||||||
LOAD = "load"
|
LOAD = "load"
|
||||||
AUTO = "auto"
|
AUTO = "auto"
|
||||||
|
SHOW = "show"
|
||||||
HELP = "help"
|
HELP = "help"
|
||||||
HTTP = "http"
|
HTTP = "http"
|
||||||
SAVE = "save"
|
SAVE = "save"
|
||||||
|
@ -152,16 +152,20 @@ func init() {
|
|||||||
m.RenameAppend(nfs.PATH, arg[0])
|
m.RenameAppend(nfs.PATH, arg[0])
|
||||||
}
|
}
|
||||||
}},
|
}},
|
||||||
mdb.CREATE: {Name: "create main=src/main.go@key key zone type=Zone,Hash,Data name=hi list help", Help: "模块", Hand: func(m *ice.Message, arg ...string) {
|
mdb.CREATE: {Name: "create main=src/main.go@key zone name=hi help type=Hash,Zone,Lists,Data,Code list key", Help: "模块", Hand: func(m *ice.Message, arg ...string) {
|
||||||
_defs(m, mdb.ZONE, m.Option(mdb.NAME), mdb.HELP, m.Option(mdb.NAME))
|
_defs(m, mdb.ZONE, m.Option(mdb.NAME), mdb.HELP, m.Option(mdb.NAME))
|
||||||
_defs(m, mdb.KEY, kit.Keys("web.code", m.Option(mdb.ZONE), m.Option(mdb.NAME)))
|
_defs(m, mdb.KEY, kit.Keys("web.code", m.Option(mdb.ZONE), m.Option(mdb.NAME)))
|
||||||
switch m.Option(mdb.TYPE) {
|
switch m.Option(mdb.TYPE) {
|
||||||
case "Zone":
|
|
||||||
_defs(m, "list", m.Option(mdb.NAME)+" zone id auto insert")
|
|
||||||
case "Hash":
|
case "Hash":
|
||||||
_defs(m, "list", m.Option(mdb.NAME)+" hash auto create")
|
_defs(m, "list", m.Option(mdb.NAME)+" hash auto create")
|
||||||
|
case "Zone":
|
||||||
|
_defs(m, "list", m.Option(mdb.NAME)+" zone id auto insert")
|
||||||
|
case "Lists":
|
||||||
|
_defs(m, "list", m.Option(mdb.NAME)+" id auto insert")
|
||||||
case "Data":
|
case "Data":
|
||||||
_defs(m, "list", m.Option(mdb.NAME)+" path auto upload")
|
_defs(m, "list", m.Option(mdb.NAME)+" path auto")
|
||||||
|
case "Code":
|
||||||
|
_defs(m, "list", m.Option(mdb.NAME)+" port path auto start order build download")
|
||||||
}
|
}
|
||||||
m.Option("tags", kit.Format("`name:\"%s\" help:\"%s\"`", m.Option("list"), m.Option("help")))
|
m.Option("tags", kit.Format("`name:\"%s\" help:\"%s\"`", m.Option("list"), m.Option("help")))
|
||||||
|
|
||||||
|
@ -100,7 +100,7 @@ func init() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if b, ok := ice.Info.Pack[name]; ok {
|
if b, ok := ice.Info.Pack[name]; ok {
|
||||||
m.Logs("binpack", len(b), name)
|
m.Logs(BINPACK, len(b), name)
|
||||||
return b // 打包文件
|
return b // 打包文件
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
|
@ -62,7 +62,7 @@ func init() {
|
|||||||
m.Echo(kit.Formats(kit.UnMarshal(m.Cmdx(web.SPIDE, m.Option(ice.DEV), web.SPIDE_RAW,
|
m.Echo(kit.Formats(kit.UnMarshal(m.Cmdx(web.SPIDE, m.Option(ice.DEV), web.SPIDE_RAW,
|
||||||
m.Option(ice.CMD), m.Option(cli.API), web.SPIDE_DATA, m.Option(ice.ARG)))))
|
m.Option(ice.CMD), m.Option(cli.API), web.SPIDE_DATA, m.Option(ice.ARG)))))
|
||||||
m.Info(`curl "` + m.Option(cli.API) + `" -H "Content-Type: application/json"` + ` -d '` + m.Option(ice.ARG) + `'`)
|
m.Info(`curl "` + m.Option(cli.API) + `" -H "Content-Type: application/json"` + ` -d '` + m.Option(ice.ARG) + `'`)
|
||||||
m.ProcessDisplay("/plugin/local/wiki/json.js")
|
m.ProcessDisplay("/plugin/story/json.js")
|
||||||
}},
|
}},
|
||||||
}, mdb.ZoneAction()), Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
|
}, mdb.ZoneAction()), Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
|
||||||
if len(arg) == 0 {
|
if len(arg) == 0 {
|
||||||
|
@ -11,8 +11,8 @@ var Index = &ice.Context{Name: CODE, Help: "编程中心"}
|
|||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
web.Index.Register(Index, &web.Frame{},
|
web.Index.Register(Index, &web.Frame{},
|
||||||
AUTOGEN, WEBPACK, BINPACK, COMPILE, PUBLISH, UPGRADE, INSTALL,
|
WEBPACK, BINPACK, AUTOGEN, COMPILE, PUBLISH, UPGRADE, INSTALL,
|
||||||
VIMER, INNER, FAVOR, BENCH, PPROF,
|
INNER, VIMER, FAVOR, BENCH, PPROF,
|
||||||
C, SH, SHY, GO, JS,
|
C, SH, SHY, GO, JS,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
@ -1,48 +1,28 @@
|
|||||||
chapter "源码"
|
chapter "源码"
|
||||||
|
|
||||||
field "前端" web.code.webpack
|
|
||||||
field "后端" web.code.binpack
|
|
||||||
field "生成" web.code.autogen
|
|
||||||
field "编译" web.code.compile
|
|
||||||
field "升级" web.code.upgrade
|
|
||||||
field "发布" web.code.publish
|
|
||||||
field "安装" web.code.install
|
|
||||||
|
|
||||||
field "编辑" web.code.vimer
|
|
||||||
field "查看" web.code.inner
|
|
||||||
field "收藏" web.code.favor
|
|
||||||
field "测试" web.code.bench
|
|
||||||
field "优化" web.code.pprof
|
|
||||||
|
|
||||||
field "系统" web.code.c
|
|
||||||
field "命令" web.code.sh
|
|
||||||
field "脚本" web.code.shy
|
|
||||||
field "后端" web.code.go
|
|
||||||
field "前端" web.code.js
|
|
||||||
|
|
||||||
code.go
|
|
||||||
code.shy
|
|
||||||
|
|
||||||
autogen.go
|
|
||||||
webpack.go
|
webpack.go
|
||||||
binpack.go
|
binpack.go
|
||||||
|
autogen.go
|
||||||
compile.go
|
compile.go
|
||||||
publish.go
|
publish.go
|
||||||
upgrade.go
|
upgrade.go
|
||||||
install.go
|
install.go
|
||||||
|
|
||||||
vimer.go
|
|
||||||
inner.go
|
inner.go
|
||||||
|
vimer.go
|
||||||
favor.go
|
favor.go
|
||||||
bench.go
|
bench.go
|
||||||
pprof.go
|
pprof.go
|
||||||
|
|
||||||
c.go
|
c.go
|
||||||
|
js.go
|
||||||
|
go.go
|
||||||
sh.go
|
sh.go
|
||||||
shy.go
|
shy.go
|
||||||
go.go
|
|
||||||
js.go
|
|
||||||
|
|
||||||
python.go
|
python.go
|
||||||
python.shy
|
python.shy
|
||||||
case.go
|
case.go
|
||||||
|
code.go
|
||||||
|
code.shy
|
||||||
|
|
||||||
|
@ -24,7 +24,7 @@ func init() {
|
|||||||
), GO, kit.List(GO, cli.BUILD),
|
), GO, kit.List(GO, cli.BUILD),
|
||||||
)},
|
)},
|
||||||
}, Commands: map[string]*ice.Command{
|
}, Commands: map[string]*ice.Command{
|
||||||
COMPILE: {Name: "compile arch=amd64,386,arm os=linux,darwin,windows src=src/main.go@key run:button", Help: "编译", Action: map[string]*ice.Action{
|
COMPILE: {Name: "compile arch=amd64,386,arm,arm64 os=linux,darwin,windows src=src/main.go@key run:button", Help: "编译", Action: map[string]*ice.Action{
|
||||||
mdb.INPUTS: {Name: "inputs", Help: "补全", Hand: func(m *ice.Message, arg ...string) {
|
mdb.INPUTS: {Name: "inputs", Help: "补全", Hand: func(m *ice.Message, arg ...string) {
|
||||||
m.Cmdy(nfs.DIR, ice.SRC, "path,size,time", ice.Option{nfs.DIR_REG, `.*\.go$`})
|
m.Cmdy(nfs.DIR, ice.SRC, "path,size,time", ice.Option{nfs.DIR_REG, `.*\.go$`})
|
||||||
m.Sort(nfs.PATH)
|
m.Sort(nfs.PATH)
|
||||||
|
@ -10,9 +10,7 @@ const FAVOR = "favor"
|
|||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
Index.Merge(&ice.Context{Configs: map[string]*ice.Config{
|
Index.Merge(&ice.Context{Configs: map[string]*ice.Config{
|
||||||
FAVOR: {Name: FAVOR, Help: "收藏夹", Value: kit.Data(
|
FAVOR: {Name: FAVOR, Help: "收藏夹", Value: kit.Data(mdb.SHORT, mdb.ZONE, mdb.FIELD, "time,id,type,name,text,path,file,line")},
|
||||||
mdb.SHORT, mdb.ZONE, mdb.FIELD, "time,id,type,name,text,path,file,line",
|
|
||||||
)},
|
|
||||||
}, Commands: map[string]*ice.Command{
|
}, Commands: map[string]*ice.Command{
|
||||||
FAVOR: {Name: "favor zone id auto insert", Help: "收藏夹", Action: ice.MergeAction(map[string]*ice.Action{
|
FAVOR: {Name: "favor zone id auto insert", Help: "收藏夹", Action: ice.MergeAction(map[string]*ice.Action{
|
||||||
mdb.INSERT: {Name: "insert zone=数据结构 type=go name=hi text=hello path file line", Help: "添加"},
|
mdb.INSERT: {Name: "insert zone=数据结构 type=go name=hi text=hello path file line", Help: "添加"},
|
||||||
|
@ -73,7 +73,7 @@ const INNER = "inner"
|
|||||||
func init() {
|
func init() {
|
||||||
Index.Merge(&ice.Context{Commands: map[string]*ice.Command{
|
Index.Merge(&ice.Context{Commands: map[string]*ice.Command{
|
||||||
INNER: {Name: "inner path=src/ file=main.go line=1 auto", Help: "源代码", Meta: kit.Dict(
|
INNER: {Name: "inner path=src/ file=main.go line=1 auto", Help: "源代码", Meta: kit.Dict(
|
||||||
ice.Display("/plugin/local/code/inner.js"),
|
ice.DisplayLocal(""),
|
||||||
), Action: ice.MergeAction(map[string]*ice.Action{
|
), Action: ice.MergeAction(map[string]*ice.Action{
|
||||||
mdb.PLUGIN: {Name: "plugin", Help: "插件", Hand: func(m *ice.Message, arg ...string) {
|
mdb.PLUGIN: {Name: "plugin", Help: "插件", Hand: func(m *ice.Message, arg ...string) {
|
||||||
if m.Cmdy(mdb.PLUGIN, arg); m.Result() == "" {
|
if m.Cmdy(mdb.PLUGIN, arg); m.Result() == "" {
|
||||||
|
@ -153,9 +153,7 @@ const INSTALL = "install"
|
|||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
Index.Merge(&ice.Context{Configs: map[string]*ice.Config{
|
Index.Merge(&ice.Context{Configs: map[string]*ice.Config{
|
||||||
INSTALL: {Name: INSTALL, Help: "安装", Value: kit.Data(
|
INSTALL: {Name: INSTALL, Help: "安装", Value: kit.Data(mdb.SHORT, mdb.NAME, nfs.PATH, ice.USR_INSTALL)},
|
||||||
mdb.SHORT, mdb.NAME, nfs.PATH, ice.USR_INSTALL,
|
|
||||||
)},
|
|
||||||
}, Commands: map[string]*ice.Command{
|
}, Commands: map[string]*ice.Command{
|
||||||
INSTALL: {Name: "install name port path auto download", Help: "安装", Meta: kit.Dict(), Action: map[string]*ice.Action{
|
INSTALL: {Name: "install name port path auto download", Help: "安装", Meta: kit.Dict(), Action: map[string]*ice.Action{
|
||||||
web.DOWNLOAD: {Name: "download link path", Help: "下载", Hand: func(m *ice.Message, arg ...string) {
|
web.DOWNLOAD: {Name: "download link path", Help: "下载", Hand: func(m *ice.Message, arg ...string) {
|
||||||
|
@ -62,7 +62,7 @@ func init() {
|
|||||||
Index.Merge(&ice.Context{Configs: map[string]*ice.Config{
|
Index.Merge(&ice.Context{Configs: map[string]*ice.Config{
|
||||||
PUBLISH: {Name: PUBLISH, Help: "发布", Value: kit.Data(
|
PUBLISH: {Name: PUBLISH, Help: "发布", Value: kit.Data(
|
||||||
nfs.PATH, ice.USR_PUBLISH, ice.CONTEXTS, _contexts,
|
nfs.PATH, ice.USR_PUBLISH, ice.CONTEXTS, _contexts,
|
||||||
SH, `#!/bin/bash
|
SH, `#! /bin/sh
|
||||||
echo "hello world"
|
echo "hello world"
|
||||||
`,
|
`,
|
||||||
JS, `Volcanos("onengine", {})
|
JS, `Volcanos("onengine", {})
|
||||||
|
@ -15,7 +15,7 @@ const VIMER = "vimer"
|
|||||||
func init() {
|
func init() {
|
||||||
Index.Merge(&ice.Context{Commands: map[string]*ice.Command{
|
Index.Merge(&ice.Context{Commands: map[string]*ice.Command{
|
||||||
VIMER: {Name: "vimer path=src/ file=main.go line=1 refresh:button=auto save", Help: "编辑器", Meta: kit.Dict(
|
VIMER: {Name: "vimer path=src/ file=main.go line=1 refresh:button=auto save", Help: "编辑器", Meta: kit.Dict(
|
||||||
ice.Display("/plugin/local/code/vimer.js", INNER),
|
ice.DisplayLocal("", INNER),
|
||||||
), Action: map[string]*ice.Action{
|
), Action: map[string]*ice.Action{
|
||||||
nfs.SAVE: {Name: "save type file path", Help: "保存", Hand: func(m *ice.Message, arg ...string) {
|
nfs.SAVE: {Name: "save type file path", Help: "保存", Hand: func(m *ice.Message, arg ...string) {
|
||||||
m.Cmdy(nfs.SAVE, path.Join(m.Option(nfs.PATH), m.Option(nfs.FILE)))
|
m.Cmdy(nfs.SAVE, path.Join(m.Option(nfs.PATH), m.Option(nfs.FILE)))
|
||||||
|
@ -14,8 +14,6 @@ func init() {
|
|||||||
_wiki_template(m, cmd, "", arg[0], arg[1:]...)
|
_wiki_template(m, cmd, "", arg[0], arg[1:]...)
|
||||||
}},
|
}},
|
||||||
}, Configs: map[string]*ice.Config{
|
}, Configs: map[string]*ice.Config{
|
||||||
BRIEF: {Name: BRIEF, Help: "摘要", Value: kit.Data(
|
BRIEF: {Name: BRIEF, Help: "摘要", Value: kit.Data(nfs.TEMPLATE, `<p {{.OptionTemplate}}>{{.Option "text"}}</p>`)},
|
||||||
nfs.TEMPLATE, `<p {{.OptionTemplate}}>{{.Option "text"}}</p>`,
|
|
||||||
)},
|
|
||||||
}})
|
}})
|
||||||
}
|
}
|
||||||
|
@ -2,6 +2,7 @@ package wiki
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
ice "shylinux.com/x/icebergs"
|
ice "shylinux.com/x/icebergs"
|
||||||
|
"shylinux.com/x/icebergs/base/lex"
|
||||||
"shylinux.com/x/icebergs/base/nfs"
|
"shylinux.com/x/icebergs/base/nfs"
|
||||||
kit "shylinux.com/x/toolkits"
|
kit "shylinux.com/x/toolkits"
|
||||||
)
|
)
|
||||||
@ -10,13 +11,9 @@ const DATA = "data"
|
|||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
Index.Merge(&ice.Context{Configs: map[string]*ice.Config{
|
Index.Merge(&ice.Context{Configs: map[string]*ice.Config{
|
||||||
DATA: {Name: DATA, Help: "数据表格", Value: kit.Data(
|
DATA: {Name: DATA, Help: "数据表格", Value: kit.Data(nfs.PATH, ice.USR_LOCAL_EXPORT, lex.REGEXP, ".*\\.csv")},
|
||||||
nfs.PATH, ice.USR_LOCAL_EXPORT, REGEXP, ".*\\.csv",
|
|
||||||
)},
|
|
||||||
}, Commands: map[string]*ice.Command{
|
}, Commands: map[string]*ice.Command{
|
||||||
DATA: {Name: "data path auto", Help: "数据表格", Meta: kit.Dict(
|
DATA: {Name: "data path auto", Help: "数据表格", Meta: kit.Dict(ice.DisplayLocal("")), Action: map[string]*ice.Action{
|
||||||
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) {
|
nfs.SAVE: {Name: "save path text", Help: "保存", Hand: func(m *ice.Message, arg ...string) {
|
||||||
_wiki_save(m, m.CommandKey(), arg[0], arg[1])
|
_wiki_save(m, m.CommandKey(), arg[0], arg[1])
|
||||||
}},
|
}},
|
||||||
|
@ -3,6 +3,7 @@ package wiki
|
|||||||
import (
|
import (
|
||||||
ice "shylinux.com/x/icebergs"
|
ice "shylinux.com/x/icebergs"
|
||||||
"shylinux.com/x/icebergs/base/ctx"
|
"shylinux.com/x/icebergs/base/ctx"
|
||||||
|
"shylinux.com/x/icebergs/base/lex"
|
||||||
"shylinux.com/x/icebergs/base/nfs"
|
"shylinux.com/x/icebergs/base/nfs"
|
||||||
kit "shylinux.com/x/toolkits"
|
kit "shylinux.com/x/toolkits"
|
||||||
)
|
)
|
||||||
@ -11,11 +12,9 @@ const DRAW = "draw"
|
|||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
Index.Merge(&ice.Context{Configs: map[string]*ice.Config{
|
Index.Merge(&ice.Context{Configs: map[string]*ice.Config{
|
||||||
DRAW: {Name: DRAW, Help: "思维导图", Value: kit.Data(REGEXP, ".*\\.svg")},
|
DRAW: {Name: DRAW, Help: "思维导图", Value: kit.Data(lex.REGEXP, ".*\\.svg")},
|
||||||
}, Commands: map[string]*ice.Command{
|
}, Commands: map[string]*ice.Command{
|
||||||
DRAW: {Name: "draw path=src/main.svg pid refresh:button=auto edit save actions", Help: "思维导图", Meta: kit.Dict(
|
DRAW: {Name: "draw path=src/main.svg pid refresh:button=auto edit save actions", Help: "思维导图", Meta: kit.Dict(ice.DisplayLocal("")), Action: ice.MergeAction(map[string]*ice.Action{
|
||||||
ice.DisplayLocal(""),
|
|
||||||
), Action: ice.MergeAction(map[string]*ice.Action{
|
|
||||||
nfs.SAVE: {Name: "save", Help: "保存", Hand: func(m *ice.Message, arg ...string) {
|
nfs.SAVE: {Name: "save", Help: "保存", Hand: func(m *ice.Message, arg ...string) {
|
||||||
_wiki_save(m, DRAW, arg[0], m.Option("content"))
|
_wiki_save(m, DRAW, arg[0], m.Option("content"))
|
||||||
}},
|
}},
|
||||||
|
@ -5,6 +5,7 @@ import (
|
|||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
ice "shylinux.com/x/icebergs"
|
ice "shylinux.com/x/icebergs"
|
||||||
|
"shylinux.com/x/icebergs/base/lex"
|
||||||
"shylinux.com/x/icebergs/base/mdb"
|
"shylinux.com/x/icebergs/base/mdb"
|
||||||
"shylinux.com/x/icebergs/base/nfs"
|
"shylinux.com/x/icebergs/base/nfs"
|
||||||
"shylinux.com/x/icebergs/base/web"
|
"shylinux.com/x/icebergs/base/web"
|
||||||
@ -15,18 +16,14 @@ const FEEL = "feel"
|
|||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
Index.Merge(&ice.Context{Configs: map[string]*ice.Config{
|
Index.Merge(&ice.Context{Configs: map[string]*ice.Config{
|
||||||
FEEL: {Name: FEEL, Help: "影音媒体", Value: kit.Data(
|
FEEL: {Name: FEEL, Help: "影音媒体", Value: kit.Data(nfs.PATH, ice.USR_LOCAL_IMAGE, lex.REGEXP, ".*.(png|PNG|jpg|JPG|jpeg|mp4|m4v|MOV)")},
|
||||||
nfs.PATH, ice.USR_LOCAL_IMAGE, REGEXP, ".*.(png|PNG|jpg|JPG|jpeg|mp4|m4v|MOV)",
|
|
||||||
)},
|
|
||||||
}, Commands: map[string]*ice.Command{
|
}, Commands: map[string]*ice.Command{
|
||||||
FEEL: {Name: "feel path auto upload 上一页 下一页 actions", Help: "影音媒体", Meta: kit.Dict(
|
FEEL: {Name: "feel path auto upload 上一页 下一页 actions", Help: "影音媒体", Meta: kit.Dict(ice.DisplayLocal("")), Action: map[string]*ice.Action{
|
||||||
ice.Display("/plugin/local/wiki/feel.js"),
|
|
||||||
), Action: map[string]*ice.Action{
|
|
||||||
web.UPLOAD: {Name: "upload", Help: "上传", Hand: func(m *ice.Message, arg ...string) {
|
web.UPLOAD: {Name: "upload", Help: "上传", Hand: func(m *ice.Message, arg ...string) {
|
||||||
_wiki_upload(m, m.CommandKey(), m.Option(nfs.PATH))
|
_wiki_upload(m, m.CommandKey(), m.Option(nfs.PATH))
|
||||||
}},
|
}},
|
||||||
mdb.REMOVE: {Name: "remove", Help: "删除", Hand: func(m *ice.Message, arg ...string) {
|
mdb.REMOVE: {Name: "remove", Help: "删除", Hand: func(m *ice.Message, arg ...string) {
|
||||||
os.Remove(strings.TrimPrefix(arg[0], "/share/local/"))
|
os.Remove(strings.TrimPrefix(arg[0], web.SHARE_LOCAL))
|
||||||
}},
|
}},
|
||||||
}, Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
|
}, Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
|
||||||
_wiki_list(m, m.CommandKey(), kit.Select(ice.PWD, arg, 0))
|
_wiki_list(m, m.CommandKey(), kit.Select(ice.PWD, arg, 0))
|
||||||
|
@ -41,8 +41,7 @@ func _field_show(m *ice.Message, name, text string, arg ...string) {
|
|||||||
})
|
})
|
||||||
|
|
||||||
name = strings.ReplaceAll(name, ice.SP, "_")
|
name = strings.ReplaceAll(name, ice.SP, "_")
|
||||||
meta[mdb.NAME] = name
|
meta[mdb.NAME], meta[mdb.INDEX] = name, text
|
||||||
meta[mdb.INDEX] = text
|
|
||||||
|
|
||||||
// 扩展参数
|
// 扩展参数
|
||||||
for i := 0; i < len(arg)-1; i += 2 {
|
for i := 0; i < len(arg)-1; i += 2 {
|
||||||
@ -77,9 +76,7 @@ func _field_show(m *ice.Message, name, text string, arg ...string) {
|
|||||||
if len(args) > count {
|
if len(args) > count {
|
||||||
list := meta[INPUTS].([]interface{})
|
list := meta[INPUTS].([]interface{})
|
||||||
for i := count; i < len(args); i++ {
|
for i := count; i < len(args); i++ {
|
||||||
list = append(list, kit.Dict(
|
list = append(list, kit.Dict(mdb.TYPE, "text", mdb.NAME, ARGS, mdb.VALUE, args[i]))
|
||||||
mdb.TYPE, "text", mdb.NAME, "args", mdb.VALUE, args[i],
|
|
||||||
))
|
|
||||||
}
|
}
|
||||||
meta[INPUTS] = list
|
meta[INPUTS] = list
|
||||||
}
|
}
|
||||||
|
@ -1,78 +0,0 @@
|
|||||||
package wiki
|
|
||||||
|
|
||||||
import (
|
|
||||||
"encoding/json"
|
|
||||||
|
|
||||||
ice "shylinux.com/x/icebergs"
|
|
||||||
"shylinux.com/x/icebergs/base/nfs"
|
|
||||||
kit "shylinux.com/x/toolkits"
|
|
||||||
)
|
|
||||||
|
|
||||||
func _json_show(m *ice.Message, data interface{}) {
|
|
||||||
switch data := data.(type) {
|
|
||||||
case map[string]interface{}:
|
|
||||||
i := 0
|
|
||||||
if m.Echo(`{`); len(data) > 0 {
|
|
||||||
m.Echo(`<span class="toggle">...</span>`)
|
|
||||||
}
|
|
||||||
m.Echo(`<div class="list">`)
|
|
||||||
for k, v := range data {
|
|
||||||
m.Echo(`<div class="item">`)
|
|
||||||
m.Echo(`"<span class="key">%s</span>": `, k)
|
|
||||||
_json_show(m, v)
|
|
||||||
if i++; i < len(data) {
|
|
||||||
m.Echo(",")
|
|
||||||
}
|
|
||||||
m.Echo("</div>")
|
|
||||||
}
|
|
||||||
m.Echo(`</div>`)
|
|
||||||
m.Echo("}")
|
|
||||||
case []interface{}:
|
|
||||||
if m.Echo(`[`); len(data) > 0 {
|
|
||||||
m.Echo(`<span class="toggle">...</span>`)
|
|
||||||
}
|
|
||||||
m.Echo(`<div class="list">`)
|
|
||||||
for i, v := range data {
|
|
||||||
_json_show(m, v)
|
|
||||||
if i < len(data)-1 {
|
|
||||||
m.Echo(",")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
m.Echo(`</div>`)
|
|
||||||
m.Echo("]")
|
|
||||||
case string:
|
|
||||||
m.Echo(`"<span class="value str">%v</span>"`, data)
|
|
||||||
default:
|
|
||||||
m.Echo(`<span class="value">%v</span>`, data)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
const JSON = "json"
|
|
||||||
|
|
||||||
func init() {
|
|
||||||
Index.Merge(&ice.Context{Configs: map[string]*ice.Config{
|
|
||||||
JSON: {Name: JSON, Help: "数据结构", Value: kit.Data(
|
|
||||||
nfs.PATH, ice.USR_LOCAL_EXPORT, 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(ice.PWD, arg, 0)) {
|
|
||||||
m.Cmdy(nfs.CAT, arg[0])
|
|
||||||
}
|
|
||||||
}},
|
|
||||||
}})
|
|
||||||
}
|
|
@ -10,6 +10,9 @@ import (
|
|||||||
|
|
||||||
ice "shylinux.com/x/icebergs"
|
ice "shylinux.com/x/icebergs"
|
||||||
"shylinux.com/x/icebergs/base/mdb"
|
"shylinux.com/x/icebergs/base/mdb"
|
||||||
|
"shylinux.com/x/icebergs/base/nfs"
|
||||||
|
"shylinux.com/x/icebergs/base/tcp"
|
||||||
|
"shylinux.com/x/icebergs/base/web"
|
||||||
kit "shylinux.com/x/toolkits"
|
kit "shylinux.com/x/toolkits"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -22,17 +25,17 @@ func init() {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if arg[1] = strings.TrimSpace(arg[1]); arg[0] == "auto" {
|
if arg[1] = strings.TrimSpace(arg[1]); arg[0] == ice.AUTO {
|
||||||
if strings.HasPrefix(arg[1], "{") || strings.HasPrefix(arg[1], "[") {
|
if strings.HasPrefix(arg[1], "{") || strings.HasPrefix(arg[1], "[") {
|
||||||
arg[0] = "json"
|
arg[0] = nfs.JSON
|
||||||
} else if strings.HasPrefix(arg[1], "http") {
|
} else if strings.HasPrefix(arg[1], ice.HTTP) {
|
||||||
arg[0] = "http"
|
arg[0] = ice.HTTP
|
||||||
} else if strings.Contains(arg[1], "=") {
|
} else if strings.Contains(arg[1], "=") {
|
||||||
arg[0] = "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] = "time"
|
arg[0] = mdb.TIME
|
||||||
} else {
|
} else {
|
||||||
arg[0] = "list"
|
arg[0] = mdb.LIST
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -43,14 +46,14 @@ func init() {
|
|||||||
m.Echo(hex.EncodeToString(buf))
|
m.Echo(hex.EncodeToString(buf))
|
||||||
}
|
}
|
||||||
|
|
||||||
case "json":
|
case nfs.JSON:
|
||||||
m.Echo(kit.Formats(kit.UnMarshal(arg[1])))
|
m.Echo(kit.Formats(kit.UnMarshal(arg[1])))
|
||||||
|
|
||||||
case "http":
|
case ice.HTTP:
|
||||||
u, _ := url.Parse(arg[1])
|
u, _ := url.Parse(arg[1])
|
||||||
m.Push("proto", u.Scheme)
|
m.Push(tcp.PROTO, u.Scheme)
|
||||||
m.Push("host", u.Host)
|
m.Push(tcp.HOST, u.Host)
|
||||||
m.Push("path", u.Path)
|
m.Push(nfs.PATH, u.Path)
|
||||||
for k, v := range u.Query() {
|
for k, v := range u.Query() {
|
||||||
for _, v := range v {
|
for _, v := range v {
|
||||||
m.Push(k, v)
|
m.Push(k, v)
|
||||||
@ -58,7 +61,7 @@ func init() {
|
|||||||
}
|
}
|
||||||
m.EchoQRCode(arg[1])
|
m.EchoQRCode(arg[1])
|
||||||
|
|
||||||
case "form":
|
case web.FORM:
|
||||||
for _, v := range kit.Split(arg[1], "&", "&", "&") {
|
for _, v := range kit.Split(arg[1], "&", "&", "&") {
|
||||||
ls := kit.Split(v, "=", "=", "=")
|
ls := kit.Split(v, "=", "=", "=")
|
||||||
key, _ := url.QueryUnescape(ls[0])
|
key, _ := url.QueryUnescape(ls[0])
|
||||||
@ -66,12 +69,12 @@ func init() {
|
|||||||
m.Push(key, value)
|
m.Push(key, value)
|
||||||
}
|
}
|
||||||
|
|
||||||
case "time":
|
case mdb.TIME:
|
||||||
if i, e := strconv.ParseInt(arg[1], 10, 64); e == nil {
|
if i, e := strconv.ParseInt(arg[1], 10, 64); e == nil {
|
||||||
m.Echo(time.Unix(i, 0).Format(ice.MOD_TIME))
|
m.Echo(time.Unix(i, 0).Format(ice.MOD_TIME))
|
||||||
}
|
}
|
||||||
|
|
||||||
case "list":
|
case mdb.LIST:
|
||||||
for i, v := range kit.Split(arg[1]) {
|
for i, v := range kit.Split(arg[1]) {
|
||||||
m.Push(kit.Format(i), v)
|
m.Push(kit.Format(i), v)
|
||||||
}
|
}
|
||||||
|
@ -1,35 +0,0 @@
|
|||||||
package wiki
|
|
||||||
|
|
||||||
import (
|
|
||||||
ice "shylinux.com/x/icebergs"
|
|
||||||
"shylinux.com/x/icebergs/base/mdb"
|
|
||||||
kit "shylinux.com/x/toolkits"
|
|
||||||
)
|
|
||||||
|
|
||||||
const (
|
|
||||||
AUTHOR = "author"
|
|
||||||
// TITLE = "title"
|
|
||||||
)
|
|
||||||
const poems = "poems"
|
|
||||||
|
|
||||||
func init() {
|
|
||||||
Index.Merge(&ice.Context{Configs: map[string]*ice.Config{
|
|
||||||
poems: {Name: "poems", Help: "诗词", Value: kit.Data(
|
|
||||||
mdb.SHORT, AUTHOR,
|
|
||||||
)},
|
|
||||||
}, Commands: map[string]*ice.Command{
|
|
||||||
poems: {Name: "poems author title auto insert", Help: "诗词", Action: map[string]*ice.Action{
|
|
||||||
mdb.INSERT: {Name: "insert author title content:textarea", Help: "添加", Hand: func(m *ice.Message, arg ...string) {
|
|
||||||
m.Cmd(mdb.INSERT, m.PrefixKey(), "", mdb.HASH, m.OptionSimple(AUTHOR))
|
|
||||||
m.Conf(poems, kit.KeyHash(m.Option(AUTHOR), mdb.META, mdb.SHORT), TITLE)
|
|
||||||
m.Cmd(mdb.INSERT, m.PrefixKey(), kit.KeyHash(m.Option(AUTHOR)), mdb.HASH, arg[2:])
|
|
||||||
}},
|
|
||||||
}, Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
|
|
||||||
if m.Fields(len(arg), "time,author", "time,title,content"); len(arg) == 0 {
|
|
||||||
m.Cmdy(mdb.SELECT, m.PrefixKey(), "", mdb.HASH)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
m.Cmdy(mdb.SELECT, m.PrefixKey(), kit.KeyHash(arg[0]), mdb.HASH, AUTHOR, arg[1:])
|
|
||||||
}},
|
|
||||||
}})
|
|
||||||
}
|
|
@ -6,6 +6,7 @@ import (
|
|||||||
ice "shylinux.com/x/icebergs"
|
ice "shylinux.com/x/icebergs"
|
||||||
"shylinux.com/x/icebergs/base/nfs"
|
"shylinux.com/x/icebergs/base/nfs"
|
||||||
"shylinux.com/x/icebergs/base/ssh"
|
"shylinux.com/x/icebergs/base/ssh"
|
||||||
|
"shylinux.com/x/icebergs/base/web"
|
||||||
kit "shylinux.com/x/toolkits"
|
kit "shylinux.com/x/toolkits"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -29,10 +30,7 @@ func _spark_show(m *ice.Message, name, text string, arg ...string) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
for _, l := range strings.Split(text, ice.NL) {
|
for _, l := range strings.Split(text, ice.NL) {
|
||||||
m.Echo("<div>")
|
m.Echo(web.Format("div", web.Format("label", prompt), web.Format("span", l)))
|
||||||
m.Echo("<label>").Echo(prompt).Echo("</label>")
|
|
||||||
m.Echo("<span>").Echo(l).Echo("</span>")
|
|
||||||
m.Echo("</div>")
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -60,13 +58,14 @@ 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 strings.Split(strings.Join(arg[1:], ice.NL), ice.NL) {
|
for _, l := range strings.Split(strings.Join(arg[1:], ice.NL), ice.NL) {
|
||||||
switch list = append(list, "<div>"); arg[0] {
|
list = append(list, "<div>")
|
||||||
|
switch arg[0] {
|
||||||
case SHELL:
|
case SHELL:
|
||||||
list = append(list, "<label>", "$ ", "</label>")
|
list = append(list, web.Format("label", "$ "))
|
||||||
default:
|
default:
|
||||||
list = append(list, "<label>", "> ", "</label>")
|
list = append(list, web.Format("label", "> "))
|
||||||
}
|
}
|
||||||
list = append(list, "<span>", l, "</span>")
|
list = append(list, web.Format("span", l))
|
||||||
list = append(list, "</div>")
|
list = append(list, "</div>")
|
||||||
}
|
}
|
||||||
list = append(list, "</div>")
|
list = append(list, "</div>")
|
||||||
|
@ -2,59 +2,29 @@ package wiki
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"path"
|
"path"
|
||||||
"strings"
|
|
||||||
|
|
||||||
ice "shylinux.com/x/icebergs"
|
ice "shylinux.com/x/icebergs"
|
||||||
|
"shylinux.com/x/icebergs/base/lex"
|
||||||
"shylinux.com/x/icebergs/base/mdb"
|
"shylinux.com/x/icebergs/base/mdb"
|
||||||
"shylinux.com/x/icebergs/base/nfs"
|
"shylinux.com/x/icebergs/base/nfs"
|
||||||
kit "shylinux.com/x/toolkits"
|
kit "shylinux.com/x/toolkits"
|
||||||
)
|
)
|
||||||
|
|
||||||
func _title_deep(str string) int {
|
func _title_parse(m *ice.Message, dir string, text string) string {
|
||||||
for i, c := range str {
|
return m.Cmdx(lex.SPLIT, "", "name,link", kit.Dict(nfs.CAT_CONTENT, text), func(ls []string, data map[string]interface{}) []string {
|
||||||
if c != ' ' {
|
if len(ls) > 1 {
|
||||||
return i
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return 0
|
|
||||||
}
|
|
||||||
func _title_parse(m *ice.Message, dir string, root map[string]interface{}, list []string) int {
|
|
||||||
var last map[string]interface{}
|
|
||||||
deep := _title_deep(list[0])
|
|
||||||
for i := 0; i < len(list); i++ {
|
|
||||||
if d := _title_deep(list[i]); d < deep {
|
|
||||||
return i
|
|
||||||
} else if d > deep {
|
|
||||||
i += _title_parse(m, dir, last, list[i:]) - 1
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
|
|
||||||
ls := kit.Split(list[i])
|
|
||||||
switch len(ls) {
|
|
||||||
case 0:
|
|
||||||
continue
|
|
||||||
case 1:
|
|
||||||
default:
|
|
||||||
ls[1] = path.Join(dir, ls[1])
|
ls[1] = path.Join(dir, ls[1])
|
||||||
}
|
}
|
||||||
|
return ls
|
||||||
meta := kit.Dict(mdb.NAME, kit.Select("", ls, 0), mdb.LINK, kit.Select("", ls, 1))
|
})
|
||||||
for i := 2; i < len(ls); i += 2 {
|
|
||||||
meta[ls[i]] = ls[i+1]
|
|
||||||
}
|
|
||||||
last = kit.Data(meta)
|
|
||||||
kit.Value(root, "list.-2", last)
|
|
||||||
}
|
|
||||||
return len(list)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func _title_show(m *ice.Message, kind, text string, arg ...string) {
|
func _title_show(m *ice.Message, kind, text string, arg ...string) {
|
||||||
switch title, _ := m.Optionv(TITLE).(map[string]int); kind {
|
switch title, _ := m.Optionv(TITLE).(map[string]int); kind {
|
||||||
case NAVMENU: // 导航目录
|
case NAVMENU: // 导航目录
|
||||||
_option(m, kind, "", text, arg...)
|
_option(m, kind, "", text, arg...)
|
||||||
data := kit.Data()
|
data := _title_parse(m, path.Dir(m.Option(ice.MSG_SCRIPT)), text)
|
||||||
_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>", data))
|
||||||
m.RenderTemplate(kit.Format("<div {{.OptionTemplate}} data-data='%s'></div>", kit.Format(data)))
|
|
||||||
return
|
return
|
||||||
|
|
||||||
case PREMENU: // 前置目录
|
case PREMENU: // 前置目录
|
||||||
@ -100,7 +70,6 @@ const (
|
|||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
REGEXP = "regexp"
|
|
||||||
PREFIX = "prefix"
|
PREFIX = "prefix"
|
||||||
LEVEL = "level"
|
LEVEL = "level"
|
||||||
MENU = "menu"
|
MENU = "menu"
|
||||||
@ -111,8 +80,7 @@ func init() {
|
|||||||
Index.Merge(&ice.Context{Commands: map[string]*ice.Command{
|
Index.Merge(&ice.Context{Commands: map[string]*ice.Command{
|
||||||
TITLE: {Name: "title [navmenu|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 {
|
if len(arg) == 0 {
|
||||||
ns := kit.Split(ice.Info.NodeName, "-")
|
arg = append(arg, kit.Slice(kit.Split(ice.Info.NodeName, "-"), -1)[0])
|
||||||
arg = append(arg, ns[len(ns)-1])
|
|
||||||
}
|
}
|
||||||
switch arg[0] {
|
switch arg[0] {
|
||||||
case NAVMENU:
|
case NAVMENU:
|
||||||
|
@ -33,8 +33,8 @@ func _wiki_path(m *ice.Message, cmd string, arg ...string) string {
|
|||||||
return path.Join(m.Option(ice.MSG_LOCAL), m.Conf(cmd, kit.Keym(nfs.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 {
|
func _wiki_link(m *ice.Message, cmd string, text string) string {
|
||||||
if !strings.HasPrefix(text, "http") && !strings.HasPrefix(text, ice.PS) {
|
if !strings.HasPrefix(text, ice.HTTP) && !strings.HasPrefix(text, ice.PS) {
|
||||||
text = path.Join("/share/local", _wiki_path(m, cmd, text))
|
text = path.Join(web.SHARE_LOCAL, _wiki_path(m, cmd, text))
|
||||||
}
|
}
|
||||||
return text
|
return text
|
||||||
}
|
}
|
||||||
|
@ -9,7 +9,6 @@ order.go
|
|||||||
table.go
|
table.go
|
||||||
image.go
|
image.go
|
||||||
video.go
|
video.go
|
||||||
poems.go
|
|
||||||
|
|
||||||
field.go
|
field.go
|
||||||
shell.go
|
shell.go
|
||||||
|
@ -3,6 +3,7 @@ package wiki
|
|||||||
import (
|
import (
|
||||||
ice "shylinux.com/x/icebergs"
|
ice "shylinux.com/x/icebergs"
|
||||||
"shylinux.com/x/icebergs/base/ctx"
|
"shylinux.com/x/icebergs/base/ctx"
|
||||||
|
"shylinux.com/x/icebergs/base/lex"
|
||||||
"shylinux.com/x/icebergs/base/mdb"
|
"shylinux.com/x/icebergs/base/mdb"
|
||||||
"shylinux.com/x/icebergs/base/nfs"
|
"shylinux.com/x/icebergs/base/nfs"
|
||||||
"shylinux.com/x/icebergs/base/ssh"
|
"shylinux.com/x/icebergs/base/ssh"
|
||||||
@ -11,13 +12,11 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func _word_show(m *ice.Message, name string, arg ...string) {
|
func _word_show(m *ice.Message, name string, arg ...string) {
|
||||||
m.Set(ice.MSG_RESULT)
|
m.SetResult()
|
||||||
m.Option(TITLE, map[string]int{})
|
m.Option(TITLE, map[string]int{})
|
||||||
m.Option(MENU, kit.Dict(mdb.LIST, []interface{}{}))
|
m.Option(MENU, kit.Dict(mdb.LIST, kit.List()))
|
||||||
|
m.Option(ice.MSG_ALIAS, m.Configv(mdb.ALIAS))
|
||||||
m.Option(ice.MSG_ALIAS, m.Confv(WORD, kit.Keym(mdb.ALIAS)))
|
m.Cmdy(ssh.SOURCE, name, kit.Dict(nfs.DIR_ROOT, _wiki_path(m, WORD)))
|
||||||
m.Option(nfs.DIR_ROOT, _wiki_path(m, WORD))
|
|
||||||
m.Cmdy(ssh.SOURCE, name)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const WORD = "word"
|
const WORD = "word"
|
||||||
@ -25,7 +24,7 @@ const WORD = "word"
|
|||||||
func init() {
|
func init() {
|
||||||
Index.Merge(&ice.Context{Configs: map[string]*ice.Config{
|
Index.Merge(&ice.Context{Configs: map[string]*ice.Config{
|
||||||
WORD: {Name: WORD, Help: "语言文字", Value: kit.Data(
|
WORD: {Name: WORD, Help: "语言文字", Value: kit.Data(
|
||||||
nfs.PATH, "", REGEXP, ".*\\.shy", mdb.ALIAS, kit.Dict(
|
nfs.PATH, "", lex.REGEXP, ".*\\.shy", mdb.ALIAS, kit.Dict(
|
||||||
NAVMENU, kit.List(TITLE, NAVMENU),
|
NAVMENU, kit.List(TITLE, NAVMENU),
|
||||||
PREMENU, kit.List(TITLE, PREMENU),
|
PREMENU, kit.List(TITLE, PREMENU),
|
||||||
CHAPTER, kit.List(TITLE, CHAPTER),
|
CHAPTER, kit.List(TITLE, CHAPTER),
|
||||||
@ -36,8 +35,8 @@ func init() {
|
|||||||
),
|
),
|
||||||
)},
|
)},
|
||||||
}, Commands: map[string]*ice.Command{
|
}, Commands: map[string]*ice.Command{
|
||||||
WORD: {Name: "word path=src/main.shy@key auto play", Help: "语言文字", Meta: kit.Dict(
|
WORD: {Name: "word path=src/main.shy@key auto show", Help: "语言文字", Meta: kit.Dict(
|
||||||
ice.Display("/plugin/local/wiki/word.js"),
|
ice.DisplayLocal(""),
|
||||||
), Action: ice.MergeAction(map[string]*ice.Action{
|
), Action: ice.MergeAction(map[string]*ice.Action{
|
||||||
mdb.INPUTS: {Name: "inputs", Help: "补全", Hand: func(m *ice.Message, arg ...string) {
|
mdb.INPUTS: {Name: "inputs", Help: "补全", Hand: func(m *ice.Message, arg ...string) {
|
||||||
m.Cmdy(nfs.DIR, "src/", kit.Dict(nfs.DIR_DEEP, ice.TRUE, nfs.DIR_REG, ".*\\.shy"), "path,time")
|
m.Cmdy(nfs.DIR, "src/", kit.Dict(nfs.DIR_DEEP, ice.TRUE, nfs.DIR_REG, ".*\\.shy"), "path,time")
|
||||||
@ -45,9 +44,9 @@ func init() {
|
|||||||
web.STORY: {Name: "story", Help: "运行", Hand: func(m *ice.Message, arg ...string) {
|
web.STORY: {Name: "story", Help: "运行", Hand: func(m *ice.Message, arg ...string) {
|
||||||
m.Cmdy(arg[0], ctx.ACTION, ice.RUN, arg[2:])
|
m.Cmdy(arg[0], ctx.ACTION, ice.RUN, arg[2:])
|
||||||
}},
|
}},
|
||||||
"play": {Name: "play", Help: "演示"},
|
ice.SHOW: {Name: "show", Help: "演示"},
|
||||||
}, ctx.CmdAction()), Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
|
}, ctx.CmdAction()), Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
|
||||||
m.Option(nfs.DIR_REG, m.Config(REGEXP))
|
m.Option(nfs.DIR_REG, m.Config(lex.REGEXP))
|
||||||
if m.Option(nfs.DIR_DEEP, ice.TRUE); !_wiki_list(m, cmd, arg...) {
|
if m.Option(nfs.DIR_DEEP, ice.TRUE); !_wiki_list(m, cmd, arg...) {
|
||||||
_word_show(m, arg[0])
|
_word_show(m, arg[0])
|
||||||
}
|
}
|
||||||
|
1
go.sum
1
go.sum
@ -1,3 +1,4 @@
|
|||||||
|
shylinux.com/x/go-qrcode v0.0.1 h1:/eOGqMj1qtgs9Ymd12zTUa1gcJZs9S92kj2lb0QzKsE=
|
||||||
shylinux.com/x/go-qrcode v0.0.1/go.mod h1:KAbtU+KwiiABMZ/CJ0zh9PI2AX82Uf9rRYcQ4ODm4po=
|
shylinux.com/x/go-qrcode v0.0.1/go.mod h1:KAbtU+KwiiABMZ/CJ0zh9PI2AX82Uf9rRYcQ4ODm4po=
|
||||||
shylinux.com/x/toolkits v0.4.5 h1:e9Ni6wvdEJKi09iBeWTrZqXNNadnHuvii7eTO6FiMv0=
|
shylinux.com/x/toolkits v0.4.5 h1:e9Ni6wvdEJKi09iBeWTrZqXNNadnHuvii7eTO6FiMv0=
|
||||||
shylinux.com/x/toolkits v0.4.5/go.mod h1:8LbYHe7oxBIqb6s4MSOD+4d28QvPdvkyCVtwB/JW7AA=
|
shylinux.com/x/toolkits v0.4.5/go.mod h1:8LbYHe7oxBIqb6s4MSOD+4d28QvPdvkyCVtwB/JW7AA=
|
||||||
|
Loading…
x
Reference in New Issue
Block a user