forked from x/icebergs
opt draw
This commit is contained in:
parent
98e018df6d
commit
36b23b5c9b
@ -19,7 +19,6 @@ import (
|
||||
const LOGIN = "_login"
|
||||
|
||||
func _serve_login(msg *ice.Message, cmds []string, w http.ResponseWriter, r *http.Request) ([]string, bool) {
|
||||
msg.Debug("what", msg.Conf("aaa.user"))
|
||||
msg.Option(ice.MSG_USERNAME, "")
|
||||
msg.Option(ice.MSG_USERROLE, "")
|
||||
|
||||
|
@ -15,7 +15,6 @@ import (
|
||||
func _inner_ext(name string) string {
|
||||
return strings.ToLower(kit.Select(path.Base(name), strings.TrimPrefix(path.Ext(name), ".")))
|
||||
}
|
||||
|
||||
func _inner_list(m *ice.Message, ext, file, dir string, arg ...string) {
|
||||
if !m.Right(strings.Split(dir, "/"), file) {
|
||||
return
|
||||
@ -35,13 +34,15 @@ func _inner_show(m *ice.Message, ext, file, dir string, arg ...string) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const (
|
||||
LIST = "list"
|
||||
PLUG = "plug"
|
||||
SHOW = "show"
|
||||
SAVE = "save"
|
||||
)
|
||||
func _vimer_save(m *ice.Message, ext, file, dir string, text string) {
|
||||
if f, p, e := kit.Create(path.Join(dir, file)); e == nil {
|
||||
defer f.Close()
|
||||
if n, e := f.WriteString(text); m.Assert(e) {
|
||||
m.Log_EXPORT("file", path.Join(dir, file), "size", n)
|
||||
}
|
||||
m.Echo(p)
|
||||
}
|
||||
}
|
||||
|
||||
const (
|
||||
INNER = "inner"
|
||||
@ -51,17 +52,9 @@ const (
|
||||
func init() {
|
||||
Index.Merge(&ice.Context{
|
||||
Commands: map[string]*ice.Command{
|
||||
INNER: {Name: "inner path=usr/demo file=hi.sh line=1 auto", Help: "阅读器", Meta: kit.Dict(
|
||||
INNER: {Name: "inner path=usr/demo file=hi.sh line=1 auto 运行:button 项目:button 搜索:button", Help: "阅读器", Meta: kit.Dict(
|
||||
"display", "/plugin/local/code/inner.js", "style", "editor",
|
||||
), Action: map[string]*ice.Action{
|
||||
web.UPLOAD: {Name: "upload path name", Help: "上传", Hand: func(m *ice.Message, arg ...string) {
|
||||
m.Cmdy(web.CACHE, web.UPLOAD)
|
||||
m.Cmdy(web.CACHE, web.WATCH, m.Option(web.DATA), path.Join(m.Option("path"), m.Option("name")))
|
||||
}},
|
||||
|
||||
mdb.SEARCH: {Name: "search type name text arg...", Help: "搜索", Hand: func(m *ice.Message, arg ...string) {
|
||||
m.Cmdy(mdb.SEARCH, arg)
|
||||
}},
|
||||
mdb.PLUGIN: {Name: "plugin type name text arg...", Help: "插件", Hand: func(m *ice.Message, arg ...string) {
|
||||
if m.Cmdy(mdb.PLUGIN, arg); m.Result() == "" {
|
||||
if m.Echo(m.Conf(INNER, kit.Keys("meta.plug", arg[0]))); m.Result() == "" {
|
||||
@ -69,6 +62,9 @@ func init() {
|
||||
}
|
||||
}
|
||||
}},
|
||||
mdb.SEARCH: {Name: "search type name text arg...", Help: "搜索", Hand: func(m *ice.Message, arg ...string) {
|
||||
m.Cmdy(mdb.SEARCH, arg)
|
||||
}},
|
||||
mdb.RENDER: {Name: "render type name text arg...", Help: "渲染", Hand: func(m *ice.Message, arg ...string) {
|
||||
_inner_list(m, arg[0], arg[1], arg[2], arg[3:]...)
|
||||
}},
|
||||
@ -82,9 +78,21 @@ func init() {
|
||||
}
|
||||
_inner_list(m, _inner_ext(arg[1]), arg[1], arg[0])
|
||||
}},
|
||||
VIMER: {Name: "vimer path=usr/demo file=hi.sh line=1 auto", Help: "编辑器", Meta: kit.Dict(
|
||||
VIMER: {Name: "vimer path=usr/demo file=hi.sh line=1 刷新:button=auto 编辑:button 保存:button 运行:button 项目:button", Help: "编辑器", Meta: kit.Dict(
|
||||
"display", "/plugin/local/code/vimer.js", "style", "editor",
|
||||
), Action: map[string]*ice.Action{}, Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
|
||||
), Action: map[string]*ice.Action{
|
||||
web.UPLOAD: {Name: "upload path name", Help: "上传", Hand: func(m *ice.Message, arg ...string) {
|
||||
m.Cmdy(web.CACHE, web.UPLOAD)
|
||||
m.Cmdy(web.CACHE, web.WATCH, m.Option(web.DATA), path.Join(m.Option("path"), m.Option("name")))
|
||||
}},
|
||||
nfs.SAVE: {Name: "save type file path", Help: "保存", Hand: func(m *ice.Message, arg ...string) {
|
||||
_vimer_save(m, arg[0], arg[1], arg[2], m.Option("content"))
|
||||
}},
|
||||
|
||||
"cmd": {Name: "cmd type file path", Help: "命令", Hand: func(m *ice.Message, arg ...string) {
|
||||
m.Cmdy(arg)
|
||||
}},
|
||||
}, Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
|
||||
m.Cmdy(INNER, arg)
|
||||
}},
|
||||
},
|
||||
@ -94,62 +102,57 @@ func init() {
|
||||
"license", "true",
|
||||
"makefile", "true",
|
||||
"shy", "true", "py", "true",
|
||||
|
||||
"md", "true", "csv", "true",
|
||||
"csv", "true", "json", "true",
|
||||
"css", "true", "html", "true",
|
||||
"txt", "true", "url", "true",
|
||||
"conf", "true", "json", "true",
|
||||
|
||||
"md", "true", "conf", "true",
|
||||
"ts", "true", "tsx", "true", "vue", "true", "sass", "true",
|
||||
"html", "true", "css", "true",
|
||||
),
|
||||
"plug", kit.Dict(
|
||||
"makefile", kit.Dict(
|
||||
"prefix", kit.Dict("#", "comment"),
|
||||
"suffix", kit.Dict(":", "comment"),
|
||||
"keyword", kit.Dict(
|
||||
"ifeq", "keyword",
|
||||
"ifneq", "keyword",
|
||||
"else", "keyword",
|
||||
"endif", "keyword",
|
||||
),
|
||||
),
|
||||
"shy", kit.Dict(
|
||||
"prefix", kit.Dict("#", "comment"),
|
||||
"keyword", kit.Dict(
|
||||
"title", "keyword",
|
||||
"chapter", "keyword",
|
||||
"section", "keyword",
|
||||
"refer", "keyword",
|
||||
"field", "keyword",
|
||||
"label", "keyword",
|
||||
"chain", "keyword",
|
||||
),
|
||||
),
|
||||
"py", kit.Dict(
|
||||
"prefix", kit.Dict("#", "comment"),
|
||||
"keyword", kit.Dict("print", "keyword"),
|
||||
),
|
||||
"md", kit.Dict("display", true, "profile", true),
|
||||
"csv", kit.Dict("display", true),
|
||||
"ts", kit.Dict(
|
||||
"prefix", kit.Dict("//", "comment"),
|
||||
"json", kit.Dict("link", true),
|
||||
"html", kit.Dict(
|
||||
"split", kit.Dict(
|
||||
"space", " ",
|
||||
"operator", "{[(.:,;!|)]}",
|
||||
"operator", "<>",
|
||||
),
|
||||
"keyword", kit.Dict(
|
||||
"import", "keyword",
|
||||
"from", "keyword",
|
||||
"new", "keyword",
|
||||
"as", "keyword",
|
||||
"const", "keyword",
|
||||
"export", "keyword",
|
||||
"default", "keyword",
|
||||
|
||||
"if", "keyword",
|
||||
"return", "keyword",
|
||||
|
||||
"class", "keyword",
|
||||
"extends", "keyword",
|
||||
"interface", "keyword",
|
||||
"declare", "keyword",
|
||||
"async", "keyword",
|
||||
"await", "keyword",
|
||||
"try", "keyword",
|
||||
"catch", "keyword",
|
||||
|
||||
"function", "function",
|
||||
"arguments", "function",
|
||||
"console", "function",
|
||||
"this", "function",
|
||||
|
||||
"string", "datatype",
|
||||
"number", "datatype",
|
||||
|
||||
"true", "string",
|
||||
"false", "string",
|
||||
"head", "keyword",
|
||||
"body", "keyword",
|
||||
),
|
||||
),
|
||||
"tsx", kit.Dict("link", "ts"),
|
||||
"vue", kit.Dict("link", "ts"),
|
||||
"sass", kit.Dict("link", "ts"),
|
||||
"css", kit.Dict(
|
||||
"suffix", kit.Dict("{", "comment"),
|
||||
),
|
||||
|
||||
"md", kit.Dict("display", true, "profile", true),
|
||||
),
|
||||
"show", kit.Dict(
|
||||
"sh", []string{"sh"},
|
||||
|
@ -2,69 +2,33 @@ package wiki
|
||||
|
||||
import (
|
||||
ice "github.com/shylinux/icebergs"
|
||||
"github.com/shylinux/icebergs/base/mdb"
|
||||
"github.com/shylinux/icebergs/base/nfs"
|
||||
"github.com/shylinux/icebergs/base/web"
|
||||
kit "github.com/shylinux/toolkits"
|
||||
)
|
||||
|
||||
func _draw_show(m *ice.Message, zone, kind, name, text string, arg ...string) {
|
||||
m.Cmdy(kit.Keys(zone, kind), name, text, arg)
|
||||
}
|
||||
func _draw_plugin(m *ice.Message, arg ...string) {
|
||||
m.Travel(func(p *ice.Context, s *ice.Context, key string, cmd *ice.Command) {
|
||||
if m.Target() == s {
|
||||
return
|
||||
}
|
||||
m.Push(s.Name, cmd.Name)
|
||||
})
|
||||
}
|
||||
"path"
|
||||
)
|
||||
|
||||
const DRAW = "draw"
|
||||
const (
|
||||
DrawPlugin = "/plugin/local/wiki/draw.js"
|
||||
)
|
||||
|
||||
func init() {
|
||||
sub := Index.Register(&ice.Context{Name: "draw", Help: "思维导图",
|
||||
Index.Register(&ice.Context{Name: "draw", Help: "思维导图",
|
||||
Configs: map[string]*ice.Config{
|
||||
DRAW: {Name: "draw", Help: "思维导图", Value: kit.Data(
|
||||
"path", "", "regs", ".*\\.svg",
|
||||
"prefix", `<svg vertion="1.1" xmlns="http://www.w3.org/2000/svg" width="%v" height="%v">`, "suffix", `</svg>`,
|
||||
)},
|
||||
},
|
||||
Commands: map[string]*ice.Command{
|
||||
DRAW: {Name: "draw path=src/main.svg auto", Help: "思维导图", Meta: kit.Dict(mdb.PLUGIN, DrawPlugin), Action: map[string]*ice.Action{
|
||||
nfs.SAVE: {Name: "save path text", Help: "保存", Hand: func(m *ice.Message, arg ...string) {
|
||||
_wiki_save(m, DRAW, arg[0], kit.Select(m.Option("content"), arg, 1))
|
||||
}},
|
||||
"run": {Name: "show zone type name text", Help: "运行", Hand: func(m *ice.Message, arg ...string) {
|
||||
_draw_show(m, arg[0], arg[1], arg[2], arg[3], arg[4:]...)
|
||||
}},
|
||||
mdb.PLUGIN: {Name: "plugin", Help: "插件", Hand: func(m *ice.Message, arg ...string) {
|
||||
_draw_plugin(m, arg...)
|
||||
DRAW: {Name: "draw path=src/ file=demo.svg 刷新:button=auto 编辑:button 保存:button 项目:button 变参:button", Help: "思维导图", Meta: kit.Dict(
|
||||
"display", "/plugin/local/wiki/draw.js", "style", "drawer",
|
||||
), Action: map[string]*ice.Action{
|
||||
nfs.SAVE: {Name: "save path file text", Help: "保存", Hand: func(m *ice.Message, arg ...string) {
|
||||
_wiki_save(m, DRAW, path.Join(arg...), m.Option("content"))
|
||||
}},
|
||||
}, Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
|
||||
if !_wiki_list(m, DRAW, kit.Select("./", arg, 0)) {
|
||||
_wiki_show(m, DRAW, arg[0])
|
||||
if !_wiki_list(m, DRAW, kit.Select("./", path.Join(arg...))) {
|
||||
_wiki_show(m, DRAW, path.Join(arg...))
|
||||
}
|
||||
}},
|
||||
},
|
||||
}, nil)
|
||||
|
||||
sub.Register(&ice.Context{Name: "工作", Help: "工作",
|
||||
Commands: map[string]*ice.Command{
|
||||
"项目开发": {Name: "项目开发", Help: "项目开发", Action: map[string]*ice.Action{
|
||||
"run": {Hand: func(m *ice.Message, arg ...string) {
|
||||
m.Echo("hello world")
|
||||
}},
|
||||
}, Hand: func(m *ice.Message, c *ice.Context, key string, arg ...string) {
|
||||
m.Echo("hello world")
|
||||
}},
|
||||
"项目测试": {Name: "项目测试", Help: "项目测试", Hand: func(m *ice.Message, c *ice.Context, key string, arg ...string) {
|
||||
|
||||
}},
|
||||
},
|
||||
}, &web.Frame{})
|
||||
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user