From 626b765de512e5e105e97306996004ad55d48b7f Mon Sep 17 00:00:00 2001 From: harveyshao Date: Mon, 9 May 2022 10:07:03 +0800 Subject: [PATCH] opt zml --- base/cli/runtime.go | 2 ++ base/ctx/command.go | 10 ++++++-- base/nfs/cat.go | 8 ++++--- core/chat/cmd.go | 4 ++-- core/chat/website.go | 2 +- core/code/zml.go | 57 ++++++++++++++++++++++++++++++++++++++++++++ misc/git/trend.go | 2 +- 7 files changed, 76 insertions(+), 9 deletions(-) create mode 100644 core/code/zml.go diff --git a/base/cli/runtime.go b/base/cli/runtime.go index adb19de3..c195919e 100644 --- a/base/cli/runtime.go +++ b/base/cli/runtime.go @@ -192,6 +192,7 @@ func init() { m.Push(mdb.NAME, ls[0]) m.Push(mdb.VALUE, ls[1]) } + m.StatusTimeCount() }}, "file": {Name: "file", Help: "模块文件", Hand: func(m *ice.Message, arg ...string) { for k, v := range ice.Info.File { @@ -207,6 +208,7 @@ func init() { m.Push(nfs.FILE, v) } m.Sort(nfs.PATH) + m.StatusTimeCount() }}, MAKE_DOMAIN: {Name: "make.domain", Help: "编译主机", Hand: func(m *ice.Message, arg ...string) { if os.Getenv(CTX_DEV) == "" || os.Getenv(CTX_POD) == "" { diff --git a/base/ctx/command.go b/base/ctx/command.go index 6fc953f7..08f8c9ac 100644 --- a/base/ctx/command.go +++ b/base/ctx/command.go @@ -6,10 +6,18 @@ import ( ice "shylinux.com/x/icebergs" "shylinux.com/x/icebergs/base/aaa" "shylinux.com/x/icebergs/base/mdb" + "shylinux.com/x/icebergs/base/nfs" kit "shylinux.com/x/toolkits" ) func _command_list(m *ice.Message, name string) { + switch kit.Ext(name) { + case nfs.JS: + m.Push("display", ice.FileURI(name)) + name = ice.GetFileCmd(name) + case nfs.GO: + name = ice.GetFileCmd(name) + } if strings.HasPrefix(name, "can.") { m.Push(mdb.INDEX, name) return @@ -90,8 +98,6 @@ func init() { _command_search(m, arg[0], kit.Select("", arg, 1), kit.Select("", arg, 2)) } }}, - INDEX: {Name: "index", Help: "索引", Hand: func(m *ice.Message, arg ...string) { - }}, }, Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) { if len(arg) == 0 { arg = append(arg, "") diff --git a/base/nfs/cat.go b/base/nfs/cat.go index 91200652..7eb11d67 100644 --- a/base/nfs/cat.go +++ b/base/nfs/cat.go @@ -143,9 +143,11 @@ const ( CSV = ice.CSV JSON = ice.JSON - YML = "yml" - IML = "iml" TXT = "txt" + IML = "iml" + XML = "xml" + YML = "yml" + ZML = "zml" SVG = "svg" PWD = "./" @@ -165,7 +167,7 @@ func init() { SOURCE, kit.Dict( HTML, ice.TRUE, CSS, ice.TRUE, JS, ice.TRUE, GO, ice.TRUE, SH, ice.TRUE, CSV, ice.TRUE, JSON, ice.TRUE, "md", ice.TRUE, "shy", ice.TRUE, "makefile", ice.TRUE, "license", ice.TRUE, - "conf", ice.TRUE, YML, ice.TRUE, IML, ice.TRUE, "txt", ice.TRUE, + "conf", ice.TRUE, YML, ice.TRUE, ZML, ice.TRUE, IML, ice.TRUE, "txt", ice.TRUE, "py", ice.TRUE, ), )}, diff --git a/core/chat/cmd.go b/core/chat/cmd.go index 029ae251..28e54c35 100644 --- a/core/chat/cmd.go +++ b/core/chat/cmd.go @@ -56,10 +56,10 @@ func _cmd_file(m *ice.Message, arg ...string) bool { m.RenderResult() } - case "txt": + case nfs.ZML: m.RenderCmd("can.parse", m.Cmdx(nfs.CAT, p)) - case "iml": + case nfs.IML: if m.Option(ice.MSG_USERPOD) == "" { m.RenderRedirect(path.Join(CHAT_WEBSITE, strings.TrimPrefix(p, SRC_WEBSITE))) m.Option(ice.MSG_ARGS, m.Option(ice.MSG_ARGS)) diff --git a/core/chat/website.go b/core/chat/website.go index 16614fdb..6551f477 100644 --- a/core/chat/website.go +++ b/core/chat/website.go @@ -163,7 +163,7 @@ func _website_render(m *ice.Message, w http.ResponseWriter, r *http.Request, kin r.URL.Path = "/chat/cmd/web.chat.div" return false } - case nfs.TXT: + case nfs.ZML: msg.RenderCmd("can.parse", text) case nfs.IML: diff --git a/core/code/zml.go b/core/code/zml.go new file mode 100644 index 00000000..88eafc96 --- /dev/null +++ b/core/code/zml.go @@ -0,0 +1,57 @@ +package code + +import ( + "path" + "strings" + + ice "shylinux.com/x/icebergs" + "shylinux.com/x/icebergs/base/mdb" + "shylinux.com/x/icebergs/base/nfs" + kit "shylinux.com/x/toolkits" +) + +const ( + SRC_WEBSITE = "src/website/" + CHAT_WEBSITE = "/chat/website/" +) + +func _website_url(m *ice.Message, file string) string { + const WEBSITE = "website" + p := path.Join(WEBSITE, file) + if m.Option(ice.MSG_USERPOD) != "" { + p = path.Join(ice.POD, m.Option(ice.MSG_USERPOD), WEBSITE, file) + } + return strings.Split(kit.MergeURL2(m.Option(ice.MSG_USERWEB), path.Join("/chat", p)), "?")[0] +} + +const ZML = nfs.ZML + +func init() { + Index.Register(&ice.Context{Name: ZML, Help: "网页", Commands: map[string]*ice.Command{ + ZML: {Name: "zml", Help: "网页", Action: ice.MergeAction(map[string]*ice.Action{ + ice.CTX_INIT: {Hand: func(m *ice.Message, arg ...string) { + m.Cmd(mdb.PLUGIN, mdb.CREATE, nfs.ZML, m.PrefixKey()) + m.Cmd(mdb.RENDER, mdb.CREATE, nfs.ZML, m.PrefixKey()) + LoadPlug(m, ZML) + }}, + mdb.RENDER: {Hand: func(m *ice.Message, arg ...string) { + m.EchoIFrame(_website_url(m, strings.TrimPrefix(path.Join(arg[2], arg[1]), SRC_WEBSITE))) + }}, + }, PlugAction())}, + }, Configs: map[string]*ice.Config{ + ZML: {Name: ZML, Help: "网页", Value: kit.Data(PLUG, kit.Dict(PREFIX, kit.Dict("# ", COMMENT), PREPARE, kit.Dict( + KEYWORD, kit.Simple( + "head", "left", "main", "foot", + "tabs", + ), + CONSTANT, kit.Simple( + "auto", "username", + ), + FUNCTION, kit.Simple( + "index", "action", "args", "type", + "style", "width", + ), + ), KEYWORD, kit.Dict(), + ))}, + }}, nil) +} diff --git a/misc/git/trend.go b/misc/git/trend.go index 9c8da778..3a4f70e2 100644 --- a/misc/git/trend.go +++ b/misc/git/trend.go @@ -12,7 +12,7 @@ const TREND = "trend" func init() { Index.Merge(&ice.Context{Commands: map[string]*ice.Command{ - TREND: {Name: "trend repos begin_time@date auto", Help: "趋势图", Meta: kit.Dict( + TREND: {Name: "trend repos@key begin_time@date auto", Help: "趋势图", Meta: kit.Dict( ice.Display("/plugin/story/trend.js"), ), Action: ice.MergeAction(map[string]*ice.Action{ mdb.INPUTS: {Name: "inputs", Help: "补全", Hand: func(m *ice.Message, arg ...string) {