mirror of
https://shylinux.com/x/icebergs
synced 2025-04-26 01:24: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))
|
||||
defer m.Event(DREAM_CREATE, kit.SimpleKV("", m.Option(mdb.TYPE), name)...)
|
||||
m.Sleep300ms()
|
||||
m.Sleep3s()
|
||||
}
|
||||
|
||||
const (
|
||||
|
@ -123,3 +123,7 @@ func (b *Buffer) Close() error { return nil }
|
||||
func PushStream(m *ice.Message) {
|
||||
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)
|
||||
|
||||
if s, e := os.Stat(pp); e == nil && !s.IsDir() {
|
||||
@ -97,6 +97,15 @@ const (
|
||||
RIVER = "river"
|
||||
STORM = "storm"
|
||||
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"
|
||||
|
||||
@ -157,26 +166,26 @@ func init() {
|
||||
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"))
|
||||
}},
|
||||
"/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/cache/": {Name: "/share/cache/", 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_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/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/"))
|
||||
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))
|
||||
}},
|
||||
"/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/"))
|
||||
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))
|
||||
}},
|
||||
}})
|
||||
}
|
||||
|
@ -319,6 +319,7 @@ const (
|
||||
SPIDE_HEADER = "header"
|
||||
SPIDE_COOKIE = "cookie"
|
||||
|
||||
FORM = "form"
|
||||
ADDRESS = "address"
|
||||
REQUEST = "request"
|
||||
RESPONSE = "response"
|
||||
|
1
conf.go
1
conf.go
@ -20,6 +20,7 @@ const (
|
||||
INIT = "init"
|
||||
LOAD = "load"
|
||||
AUTO = "auto"
|
||||
SHOW = "show"
|
||||
HELP = "help"
|
||||
HTTP = "http"
|
||||
SAVE = "save"
|
||||
|
@ -152,16 +152,20 @@ func init() {
|
||||
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.KEY, kit.Keys("web.code", m.Option(mdb.ZONE), m.Option(mdb.NAME)))
|
||||
switch m.Option(mdb.TYPE) {
|
||||
case "Zone":
|
||||
_defs(m, "list", m.Option(mdb.NAME)+" zone id auto insert")
|
||||
case "Hash":
|
||||
_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":
|
||||
_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")))
|
||||
|
||||
|
@ -100,7 +100,7 @@ func init() {
|
||||
}
|
||||
|
||||
if b, ok := ice.Info.Pack[name]; ok {
|
||||
m.Logs("binpack", len(b), name)
|
||||
m.Logs(BINPACK, len(b), name)
|
||||
return b // 打包文件
|
||||
}
|
||||
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.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.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) {
|
||||
if len(arg) == 0 {
|
||||
|
@ -11,8 +11,8 @@ var Index = &ice.Context{Name: CODE, Help: "编程中心"}
|
||||
|
||||
func init() {
|
||||
web.Index.Register(Index, &web.Frame{},
|
||||
AUTOGEN, WEBPACK, BINPACK, COMPILE, PUBLISH, UPGRADE, INSTALL,
|
||||
VIMER, INNER, FAVOR, BENCH, PPROF,
|
||||
WEBPACK, BINPACK, AUTOGEN, COMPILE, PUBLISH, UPGRADE, INSTALL,
|
||||
INNER, VIMER, FAVOR, BENCH, PPROF,
|
||||
C, SH, SHY, GO, JS,
|
||||
)
|
||||
}
|
||||
|
@ -1,48 +1,28 @@
|
||||
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
|
||||
binpack.go
|
||||
autogen.go
|
||||
compile.go
|
||||
publish.go
|
||||
upgrade.go
|
||||
install.go
|
||||
|
||||
vimer.go
|
||||
inner.go
|
||||
vimer.go
|
||||
favor.go
|
||||
bench.go
|
||||
pprof.go
|
||||
|
||||
c.go
|
||||
js.go
|
||||
go.go
|
||||
sh.go
|
||||
shy.go
|
||||
go.go
|
||||
js.go
|
||||
|
||||
python.go
|
||||
python.shy
|
||||
case.go
|
||||
code.go
|
||||
code.shy
|
||||
|
||||
|
@ -24,7 +24,7 @@ func init() {
|
||||
), GO, kit.List(GO, cli.BUILD),
|
||||
)},
|
||||
}, 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) {
|
||||
m.Cmdy(nfs.DIR, ice.SRC, "path,size,time", ice.Option{nfs.DIR_REG, `.*\.go$`})
|
||||
m.Sort(nfs.PATH)
|
||||
|
@ -10,9 +10,7 @@ const FAVOR = "favor"
|
||||
|
||||
func init() {
|
||||
Index.Merge(&ice.Context{Configs: map[string]*ice.Config{
|
||||
FAVOR: {Name: FAVOR, Help: "收藏夹", Value: kit.Data(
|
||||
mdb.SHORT, mdb.ZONE, mdb.FIELD, "time,id,type,name,text,path,file,line",
|
||||
)},
|
||||
FAVOR: {Name: FAVOR, Help: "收藏夹", Value: kit.Data(mdb.SHORT, mdb.ZONE, mdb.FIELD, "time,id,type,name,text,path,file,line")},
|
||||
}, Commands: map[string]*ice.Command{
|
||||
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: "添加"},
|
||||
|
@ -73,7 +73,7 @@ const INNER = "inner"
|
||||
func init() {
|
||||
Index.Merge(&ice.Context{Commands: map[string]*ice.Command{
|
||||
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{
|
||||
mdb.PLUGIN: {Name: "plugin", Help: "插件", Hand: func(m *ice.Message, arg ...string) {
|
||||
if m.Cmdy(mdb.PLUGIN, arg); m.Result() == "" {
|
||||
|
@ -153,9 +153,7 @@ const INSTALL = "install"
|
||||
|
||||
func init() {
|
||||
Index.Merge(&ice.Context{Configs: map[string]*ice.Config{
|
||||
INSTALL: {Name: INSTALL, Help: "安装", Value: kit.Data(
|
||||
mdb.SHORT, mdb.NAME, nfs.PATH, ice.USR_INSTALL,
|
||||
)},
|
||||
INSTALL: {Name: INSTALL, Help: "安装", Value: kit.Data(mdb.SHORT, mdb.NAME, nfs.PATH, ice.USR_INSTALL)},
|
||||
}, Commands: map[string]*ice.Command{
|
||||
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) {
|
||||
|
@ -62,7 +62,7 @@ func init() {
|
||||
Index.Merge(&ice.Context{Configs: map[string]*ice.Config{
|
||||
PUBLISH: {Name: PUBLISH, Help: "发布", Value: kit.Data(
|
||||
nfs.PATH, ice.USR_PUBLISH, ice.CONTEXTS, _contexts,
|
||||
SH, `#!/bin/bash
|
||||
SH, `#! /bin/sh
|
||||
echo "hello world"
|
||||
`,
|
||||
JS, `Volcanos("onengine", {})
|
||||
|
@ -15,7 +15,7 @@ const VIMER = "vimer"
|
||||
func init() {
|
||||
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(
|
||||
ice.Display("/plugin/local/code/vimer.js", INNER),
|
||||
ice.DisplayLocal("", INNER),
|
||||
), Action: map[string]*ice.Action{
|
||||
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)))
|
||||
|
@ -14,8 +14,6 @@ func init() {
|
||||
_wiki_template(m, cmd, "", arg[0], arg[1:]...)
|
||||
}},
|
||||
}, Configs: map[string]*ice.Config{
|
||||
BRIEF: {Name: BRIEF, Help: "摘要", Value: kit.Data(
|
||||
nfs.TEMPLATE, `<p {{.OptionTemplate}}>{{.Option "text"}}</p>`,
|
||||
)},
|
||||
BRIEF: {Name: BRIEF, Help: "摘要", Value: kit.Data(nfs.TEMPLATE, `<p {{.OptionTemplate}}>{{.Option "text"}}</p>`)},
|
||||
}})
|
||||
}
|
||||
|
@ -2,6 +2,7 @@ package wiki
|
||||
|
||||
import (
|
||||
ice "shylinux.com/x/icebergs"
|
||||
"shylinux.com/x/icebergs/base/lex"
|
||||
"shylinux.com/x/icebergs/base/nfs"
|
||||
kit "shylinux.com/x/toolkits"
|
||||
)
|
||||
@ -10,13 +11,9 @@ const DATA = "data"
|
||||
|
||||
func init() {
|
||||
Index.Merge(&ice.Context{Configs: map[string]*ice.Config{
|
||||
DATA: {Name: DATA, Help: "数据表格", Value: kit.Data(
|
||||
nfs.PATH, ice.USR_LOCAL_EXPORT, REGEXP, ".*\\.csv",
|
||||
)},
|
||||
DATA: {Name: DATA, Help: "数据表格", Value: kit.Data(nfs.PATH, ice.USR_LOCAL_EXPORT, lex.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{
|
||||
DATA: {Name: "data path auto", Help: "数据表格", Meta: kit.Dict(ice.DisplayLocal("")), 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])
|
||||
}},
|
||||
|
@ -3,6 +3,7 @@ package wiki
|
||||
import (
|
||||
ice "shylinux.com/x/icebergs"
|
||||
"shylinux.com/x/icebergs/base/ctx"
|
||||
"shylinux.com/x/icebergs/base/lex"
|
||||
"shylinux.com/x/icebergs/base/nfs"
|
||||
kit "shylinux.com/x/toolkits"
|
||||
)
|
||||
@ -11,11 +12,9 @@ const DRAW = "draw"
|
||||
|
||||
func init() {
|
||||
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{
|
||||
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{
|
||||
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{
|
||||
nfs.SAVE: {Name: "save", Help: "保存", Hand: func(m *ice.Message, arg ...string) {
|
||||
_wiki_save(m, DRAW, arg[0], m.Option("content"))
|
||||
}},
|
||||
|
@ -5,6 +5,7 @@ import (
|
||||
"strings"
|
||||
|
||||
ice "shylinux.com/x/icebergs"
|
||||
"shylinux.com/x/icebergs/base/lex"
|
||||
"shylinux.com/x/icebergs/base/mdb"
|
||||
"shylinux.com/x/icebergs/base/nfs"
|
||||
"shylinux.com/x/icebergs/base/web"
|
||||
@ -15,18 +16,14 @@ const FEEL = "feel"
|
||||
|
||||
func init() {
|
||||
Index.Merge(&ice.Context{Configs: map[string]*ice.Config{
|
||||
FEEL: {Name: FEEL, Help: "影音媒体", Value: kit.Data(
|
||||
nfs.PATH, ice.USR_LOCAL_IMAGE, REGEXP, ".*.(png|PNG|jpg|JPG|jpeg|mp4|m4v|MOV)",
|
||||
)},
|
||||
FEEL: {Name: FEEL, Help: "影音媒体", Value: kit.Data(nfs.PATH, ice.USR_LOCAL_IMAGE, lex.REGEXP, ".*.(png|PNG|jpg|JPG|jpeg|mp4|m4v|MOV)")},
|
||||
}, Commands: map[string]*ice.Command{
|
||||
FEEL: {Name: "feel path auto upload 上一页 下一页 actions", Help: "影音媒体", Meta: kit.Dict(
|
||||
ice.Display("/plugin/local/wiki/feel.js"),
|
||||
), Action: map[string]*ice.Action{
|
||||
FEEL: {Name: "feel path auto upload 上一页 下一页 actions", Help: "影音媒体", Meta: kit.Dict(ice.DisplayLocal("")), Action: map[string]*ice.Action{
|
||||
web.UPLOAD: {Name: "upload", Help: "上传", Hand: func(m *ice.Message, arg ...string) {
|
||||
_wiki_upload(m, m.CommandKey(), m.Option(nfs.PATH))
|
||||
}},
|
||||
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) {
|
||||
_wiki_list(m, m.CommandKey(), kit.Select(ice.PWD, arg, 0))
|
||||
|
@ -15,7 +15,7 @@ func Parse(m *ice.Message, meta string, key string, arg ...string) *ice.Message
|
||||
for _, line := range kit.Split(strings.Join(arg, ice.SP), ice.NL) {
|
||||
ls := kit.Split(line)
|
||||
for i := 0; i < len(ls); i++ {
|
||||
if strings.HasPrefix(ls[i], "#") {
|
||||
if strings.HasPrefix(ls[i], "# ") {
|
||||
ls = ls[:i]
|
||||
break
|
||||
}
|
||||
@ -41,8 +41,7 @@ func _field_show(m *ice.Message, name, text string, arg ...string) {
|
||||
})
|
||||
|
||||
name = strings.ReplaceAll(name, ice.SP, "_")
|
||||
meta[mdb.NAME] = name
|
||||
meta[mdb.INDEX] = text
|
||||
meta[mdb.NAME], meta[mdb.INDEX] = name, text
|
||||
|
||||
// 扩展参数
|
||||
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 {
|
||||
list := meta[INPUTS].([]interface{})
|
||||
for i := count; i < len(args); i++ {
|
||||
list = append(list, kit.Dict(
|
||||
mdb.TYPE, "text", mdb.NAME, "args", mdb.VALUE, args[i],
|
||||
))
|
||||
list = append(list, kit.Dict(mdb.TYPE, "text", mdb.NAME, ARGS, mdb.VALUE, args[i]))
|
||||
}
|
||||
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"
|
||||
"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"
|
||||
)
|
||||
|
||||
@ -22,17 +25,17 @@ func init() {
|
||||
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], "[") {
|
||||
arg[0] = "json"
|
||||
} else if strings.HasPrefix(arg[1], "http") {
|
||||
arg[0] = "http"
|
||||
arg[0] = nfs.JSON
|
||||
} else if strings.HasPrefix(arg[1], ice.HTTP) {
|
||||
arg[0] = ice.HTTP
|
||||
} else if strings.Contains(arg[1], "=") {
|
||||
arg[0] = "form"
|
||||
arg[0] = web.FORM
|
||||
} else if _, e := strconv.ParseInt(arg[1], 10, 64); e == nil {
|
||||
arg[0] = "time"
|
||||
arg[0] = mdb.TIME
|
||||
} else {
|
||||
arg[0] = "list"
|
||||
arg[0] = mdb.LIST
|
||||
}
|
||||
}
|
||||
|
||||
@ -43,14 +46,14 @@ func init() {
|
||||
m.Echo(hex.EncodeToString(buf))
|
||||
}
|
||||
|
||||
case "json":
|
||||
case nfs.JSON:
|
||||
m.Echo(kit.Formats(kit.UnMarshal(arg[1])))
|
||||
|
||||
case "http":
|
||||
case ice.HTTP:
|
||||
u, _ := url.Parse(arg[1])
|
||||
m.Push("proto", u.Scheme)
|
||||
m.Push("host", u.Host)
|
||||
m.Push("path", u.Path)
|
||||
m.Push(tcp.PROTO, u.Scheme)
|
||||
m.Push(tcp.HOST, u.Host)
|
||||
m.Push(nfs.PATH, u.Path)
|
||||
for k, v := range u.Query() {
|
||||
for _, v := range v {
|
||||
m.Push(k, v)
|
||||
@ -58,7 +61,7 @@ func init() {
|
||||
}
|
||||
m.EchoQRCode(arg[1])
|
||||
|
||||
case "form":
|
||||
case web.FORM:
|
||||
for _, v := range kit.Split(arg[1], "&", "&", "&") {
|
||||
ls := kit.Split(v, "=", "=", "=")
|
||||
key, _ := url.QueryUnescape(ls[0])
|
||||
@ -66,12 +69,12 @@ func init() {
|
||||
m.Push(key, value)
|
||||
}
|
||||
|
||||
case "time":
|
||||
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 "list":
|
||||
case mdb.LIST:
|
||||
for i, v := range kit.Split(arg[1]) {
|
||||
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"
|
||||
"shylinux.com/x/icebergs/base/nfs"
|
||||
"shylinux.com/x/icebergs/base/ssh"
|
||||
"shylinux.com/x/icebergs/base/web"
|
||||
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) {
|
||||
m.Echo("<div>")
|
||||
m.Echo("<label>").Echo(prompt).Echo("</label>")
|
||||
m.Echo("<span>").Echo(l).Echo("</span>")
|
||||
m.Echo("</div>")
|
||||
m.Echo(web.Format("div", web.Format("label", prompt), web.Format("span", l)))
|
||||
}
|
||||
}
|
||||
|
||||
@ -60,13 +58,14 @@ func init() {
|
||||
}
|
||||
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] {
|
||||
list = append(list, "<div>")
|
||||
switch arg[0] {
|
||||
case SHELL:
|
||||
list = append(list, "<label>", "$ ", "</label>")
|
||||
list = append(list, web.Format("label", "$ "))
|
||||
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>")
|
||||
|
@ -2,59 +2,29 @@ package wiki
|
||||
|
||||
import (
|
||||
"path"
|
||||
"strings"
|
||||
|
||||
ice "shylinux.com/x/icebergs"
|
||||
"shylinux.com/x/icebergs/base/lex"
|
||||
"shylinux.com/x/icebergs/base/mdb"
|
||||
"shylinux.com/x/icebergs/base/nfs"
|
||||
kit "shylinux.com/x/toolkits"
|
||||
)
|
||||
|
||||
func _title_deep(str string) int {
|
||||
for i, c := range str {
|
||||
if c != ' ' {
|
||||
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:
|
||||
func _title_parse(m *ice.Message, dir string, text string) string {
|
||||
return m.Cmdx(lex.SPLIT, "", "name,link", kit.Dict(nfs.CAT_CONTENT, text), func(ls []string, data map[string]interface{}) []string {
|
||||
if len(ls) > 1 {
|
||||
ls[1] = path.Join(dir, ls[1])
|
||||
}
|
||||
|
||||
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)
|
||||
return ls
|
||||
})
|
||||
}
|
||||
|
||||
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.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)))
|
||||
data := _title_parse(m, path.Dir(m.Option(ice.MSG_SCRIPT)), text)
|
||||
m.RenderTemplate(kit.Format("<div {{.OptionTemplate}} data-data='%s'></div>", data))
|
||||
return
|
||||
|
||||
case PREMENU: // 前置目录
|
||||
@ -100,7 +70,6 @@ const (
|
||||
)
|
||||
|
||||
const (
|
||||
REGEXP = "regexp"
|
||||
PREFIX = "prefix"
|
||||
LEVEL = "level"
|
||||
MENU = "menu"
|
||||
@ -111,8 +80,7 @@ func init() {
|
||||
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) {
|
||||
if len(arg) == 0 {
|
||||
ns := kit.Split(ice.Info.NodeName, "-")
|
||||
arg = append(arg, ns[len(ns)-1])
|
||||
arg = append(arg, kit.Slice(kit.Split(ice.Info.NodeName, "-"), -1)[0])
|
||||
}
|
||||
switch arg[0] {
|
||||
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...))
|
||||
}
|
||||
func _wiki_link(m *ice.Message, cmd string, text string) string {
|
||||
if !strings.HasPrefix(text, "http") && !strings.HasPrefix(text, ice.PS) {
|
||||
text = path.Join("/share/local", _wiki_path(m, cmd, text))
|
||||
if !strings.HasPrefix(text, ice.HTTP) && !strings.HasPrefix(text, ice.PS) {
|
||||
text = path.Join(web.SHARE_LOCAL, _wiki_path(m, cmd, text))
|
||||
}
|
||||
return text
|
||||
}
|
||||
|
@ -9,7 +9,6 @@ order.go
|
||||
table.go
|
||||
image.go
|
||||
video.go
|
||||
poems.go
|
||||
|
||||
field.go
|
||||
shell.go
|
||||
|
@ -3,6 +3,7 @@ package wiki
|
||||
import (
|
||||
ice "shylinux.com/x/icebergs"
|
||||
"shylinux.com/x/icebergs/base/ctx"
|
||||
"shylinux.com/x/icebergs/base/lex"
|
||||
"shylinux.com/x/icebergs/base/mdb"
|
||||
"shylinux.com/x/icebergs/base/nfs"
|
||||
"shylinux.com/x/icebergs/base/ssh"
|
||||
@ -11,13 +12,11 @@ import (
|
||||
)
|
||||
|
||||
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(MENU, kit.Dict(mdb.LIST, []interface{}{}))
|
||||
|
||||
m.Option(ice.MSG_ALIAS, m.Confv(WORD, kit.Keym(mdb.ALIAS)))
|
||||
m.Option(nfs.DIR_ROOT, _wiki_path(m, WORD))
|
||||
m.Cmdy(ssh.SOURCE, name)
|
||||
m.Option(MENU, kit.Dict(mdb.LIST, kit.List()))
|
||||
m.Option(ice.MSG_ALIAS, m.Configv(mdb.ALIAS))
|
||||
m.Cmdy(ssh.SOURCE, name, kit.Dict(nfs.DIR_ROOT, _wiki_path(m, WORD)))
|
||||
}
|
||||
|
||||
const WORD = "word"
|
||||
@ -25,7 +24,7 @@ const WORD = "word"
|
||||
func init() {
|
||||
Index.Merge(&ice.Context{Configs: map[string]*ice.Config{
|
||||
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),
|
||||
PREMENU, kit.List(TITLE, PREMENU),
|
||||
CHAPTER, kit.List(TITLE, CHAPTER),
|
||||
@ -36,8 +35,8 @@ func init() {
|
||||
),
|
||||
)},
|
||||
}, Commands: map[string]*ice.Command{
|
||||
WORD: {Name: "word path=src/main.shy@key auto play", Help: "语言文字", Meta: kit.Dict(
|
||||
ice.Display("/plugin/local/wiki/word.js"),
|
||||
WORD: {Name: "word path=src/main.shy@key auto show", Help: "语言文字", Meta: kit.Dict(
|
||||
ice.DisplayLocal(""),
|
||||
), Action: ice.MergeAction(map[string]*ice.Action{
|
||||
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")
|
||||
@ -45,9 +44,9 @@ func init() {
|
||||
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: "演示"},
|
||||
ice.SHOW: {Name: "show", Help: "演示"},
|
||||
}, 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...) {
|
||||
_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/toolkits v0.4.5 h1:e9Ni6wvdEJKi09iBeWTrZqXNNadnHuvii7eTO6FiMv0=
|
||||
shylinux.com/x/toolkits v0.4.5/go.mod h1:8LbYHe7oxBIqb6s4MSOD+4d28QvPdvkyCVtwB/JW7AA=
|
||||
|
Loading…
x
Reference in New Issue
Block a user