From bdc6a96a0d5d937ea8dc6296bf8395c17a338a96 Mon Sep 17 00:00:00 2001 From: harveyshao Date: Mon, 19 Dec 2022 19:03:22 +0800 Subject: [PATCH] opt vimer.css --- base/web/render.go | 36 ++++++++++++++++++++++++------------ core/code/html.go | 4 +++- core/code/js.go | 10 +++++----- core/wiki/field.go | 3 +-- 4 files changed, 33 insertions(+), 20 deletions(-) diff --git a/base/web/render.go b/base/web/render.go index ec9909b9..57b3f26e 100644 --- a/base/web/render.go +++ b/base/web/render.go @@ -36,7 +36,7 @@ func Render(m *ice.Message, cmd string, args ...ice.Any) bool { if len(arg) == 0 { args = nil } - if cmd != "" { + if cmd != "" && cmd != ice.RENDER_DOWNLOAD { defer func() { m.Logs("Render", cmd, args) }() } switch cmd { @@ -159,20 +159,30 @@ func RenderIndex(m *ice.Message, repos string, file ...string) *ice.Message { } func RenderMain(m *ice.Message, pod, index string, arg ...ice.Any) *ice.Message { if script := m.Cmdx(Space(m, pod), nfs.CAT, kit.Select(ice.SRC_MAIN_JS, index)); script != "" { - return m.Echo(kit.Format(_main_template, script)).RenderResult() + return m.Echo(kit.Renders(_main_template, ice.Maps{ + "version": renderVersion(m), "script": script, + })).RenderResult() } return RenderIndex(m, ice.VOLCANOS) } +func RenderCmd(m *ice.Message, cmd string, arg ...ice.Any) { + RenderPodCmd(m, "", cmd, arg...) +} func RenderPodCmd(m *ice.Message, pod, cmd string, arg ...ice.Any) { msg := m.Cmd(Space(m, pod), ctx.COMMAND, kit.Select("web.wiki.word", cmd)) list := kit.Format(kit.List(kit.Dict(msg.AppendSimple(mdb.NAME, mdb.HELP), ctx.INDEX, cmd, ctx.ARGS, kit.Simple(arg), ctx.DISPLAY, m.Option(ice.MSG_DISPLAY), mdb.LIST, kit.UnMarshal(msg.Append(mdb.LIST)), mdb.META, kit.UnMarshal(msg.Append(mdb.META)), ))) - m.Echo(kit.Format(_cmd_template, list)).RenderResult() + m.Echo(kit.Renders(_cmd_template, ice.Maps{ + "version": renderVersion(m), "list": list, + })).RenderResult() } -func RenderCmd(m *ice.Message, cmd string, arg ...ice.Any) { - RenderPodCmd(m, "", cmd, arg...) +func renderVersion(m *ice.Message) string { + if strings.Contains(m.R.URL.RawQuery, "debug=true") { + return kit.Format("?_v=%v&_t=%d", ice.Info.Make.Version, time.Now().Unix()) + } + return "" } var _main_template = ` @@ -180,13 +190,14 @@ var _main_template = ` volcanos - - + + - - - + + + + ` @@ -194,9 +205,10 @@ var _cmd_template = ` volcanos - + - + + ` diff --git a/core/code/html.go b/core/code/html.go index 4c6d8ff6..96cc4e52 100644 --- a/core/code/html.go +++ b/core/code/html.go @@ -5,6 +5,7 @@ import ( ice "shylinux.com/x/icebergs" "shylinux.com/x/icebergs/base/mdb" + "shylinux.com/x/icebergs/base/web" kit "shylinux.com/x/toolkits" ) @@ -12,7 +13,8 @@ func init() { Index.MergeCommands(ice.Commands{ HTML: {Name: "html path auto", Help: "网页", Actions: ice.MergeActions(ice.Actions{ mdb.RENDER: {Hand: func(m *ice.Message, arg ...string) { - m.Echo(``, kit.MergeURL(path.Join("/require/", arg[2], arg[1]), "_", kit.Hashs("uniq"))) + p := kit.MergeURL(path.Join("/require/", arg[2], arg[1]), "_", kit.Hashs("uniq")) + m.Push(mdb.LINK, p).Echo(``, p).StatusTime(web.LINK, p) }}, }, PlugAction())}, }) diff --git a/core/code/js.go b/core/code/js.go index dd27bf88..faa4b6a5 100644 --- a/core/code/js.go +++ b/core/code/js.go @@ -81,7 +81,7 @@ func _js_exec(m *ice.Message, arg ...string) { } ctx.DisplayBase(m, path.Join("/require", path.Join(arg[2], arg[1]))) key := ctx.GetFileCmd(kit.Replace(path.Join(arg[2], arg[1]), ".js", ".go")) - ctx.ProcessCommand(m, kit.Select("can.code.inner._plugin", key), kit.Simple()) + ctx.ProcessCommand(m, kit.Select("can.plugin", key), kit.Simple()) return args := kit.Simple("node", "-e", kit.Join(_js_main_script(m, arg...), ice.NL)) m.Cmdy(cli.SYSTEM, args).StatusTime(ctx.ARGS, kit.Join(append([]string{ice.ICE_BIN, m.PrefixKey(), m.ActionKey()}, arg...), ice.SP)) @@ -94,7 +94,7 @@ const JSON = "json" func init() { Index.MergeCommands(ice.Commands{ JS: {Name: "js path auto", Help: "前端", Actions: ice.MergeActions(ice.Actions{ - mdb.RENDER: {Hand: func(m *ice.Message, arg ...string) { _js_show(m, arg...) }}, + mdb.RENDER: {Hand: func(m *ice.Message, arg ...string) { _js_exec(m, arg...) }}, mdb.ENGINE: {Hand: func(m *ice.Message, arg ...string) { _js_exec(m, arg...) }}, TEMPLATE: {Hand: func(m *ice.Message, arg ...string) { m.Echo(_js_template) }}, @@ -110,12 +110,12 @@ func init() { } else if strings.HasSuffix(m.Option(mdb.TEXT), ice.PT) { // 方法 key := kit.Slice(kit.Split(m.Option(mdb.TEXT), "\t ."), -1)[0] switch key { - case "msg": - m.Cmdy("web.code.vim.tags", "msg").Cut("name,text") case "can": m.Cmdy("web.code.vim.tags").Cut(mdb.ZONE) + case "msg": + m.Cmdy("web.code.vim.tags", key).Cut("name,text") default: - m.Cmdy("web.code.vim.tags", strings.TrimPrefix(m.Option(mdb.TYPE), "can.")).Cut("name,text") + m.Cmdy("web.code.vim.tags", key).Cut("name,text") } } else { // 类型 diff --git a/core/wiki/field.go b/core/wiki/field.go index b839af3b..e2073db2 100644 --- a/core/wiki/field.go +++ b/core/wiki/field.go @@ -81,9 +81,8 @@ func _field_show(m *ice.Message, name, text string, arg ...string) { msg.Echo(strings.TrimSpace(arg[i+1])) } kit.Value(meta, "msg", msg.FormatMeta(), kit.Keys(FEATURE, "mode"), "simple") - if text == "web.code.inner" { - kit.Value(meta, kit.Keys(FEATURE, "display"), "/plugin/local/code/inner.js") + kit.Value(meta, kit.Keys(FEATURE, ctx.DISPLAY), "/plugin/local/code/inner.js") kit.Value(meta, "plug", kit.UnMarshal(m.Cmdx(mdb.PLUGIN, kit.Ext(name)))) kit.Value(meta, ARGS, kit.List(path.Dir(name)+ice.PS, path.Base(name))) }