From 7bf0bd877cd4a72ba33dce4e44b9c8656b037c7b Mon Sep 17 00:00:00 2001 From: harveyshao Date: Sun, 15 Jan 2023 18:00:13 +0800 Subject: [PATCH] opt index.css --- base/cli/qrcode.go | 2 +- base/cli/runtime.go | 2 +- base/cli/system.go | 2 +- base/web/render.go | 4 ++-- base/web/serve.go | 2 +- conf.go | 22 ++++++++++++---------- core/chat/div.go | 8 ++++---- core/chat/website.go | 8 ++++---- core/code/binpack.go | 2 +- core/code/vimer.go | 20 +++++++++++++++++++- core/code/webpack.go | 5 ++--- misc/git/status.go | 6 ++++++ render.go | 4 ++-- 13 files changed, 56 insertions(+), 31 deletions(-) diff --git a/base/cli/qrcode.go b/base/cli/qrcode.go index 8a0a7952..406335c3 100644 --- a/base/cli/qrcode.go +++ b/base/cli/qrcode.go @@ -131,7 +131,7 @@ func init() { if m.IsCliUA() { _qrcode_cli(m, kit.Select(kit.Select(ice.Info.Make.Domain, ice.Info.Domain), arg, 0)) } else { - m.Option(SIZE, kit.Select(kit.Format(kit.Min(480, kit.Int(m.Option(ice.HEIGHT)), kit.Int(m.Option(ice.WIDTH)))), arg, 3)) + m.Option(SIZE, kit.Select(kit.Format(kit.Min(480, kit.Int(m.Option(ice.MSG_HEIGHT)), kit.Int(m.Option(ice.MSG_WIDTH)))), arg, 3)) _qrcode_web(m, kit.Select(m.Option(ice.MSG_USERWEB), arg, 0)) m.StatusTime(mdb.LINK, kit.Select(m.Option(ice.MSG_USERWEB), arg, 0)) } diff --git a/base/cli/runtime.go b/base/cli/runtime.go index 4d5825b6..9f90ffc0 100644 --- a/base/cli/runtime.go +++ b/base/cli/runtime.go @@ -149,7 +149,7 @@ const RUNTIME = "runtime" func init() { Index.MergeCommands(ice.Commands{ - RUNTIME: {Name: "runtime info=ifconfig,hostinfo,hostname,userinfo,procinfo,diskinfo,bootinfo,api,cli,cmd,env,chain auto", Help: "运行环境", Actions: ice.MergeActions(ice.Actions{ + RUNTIME: {Name: "runtime info=bootinfo,ifconfig,hostinfo,hostname,userinfo,procinfo,diskinfo,api,cli,cmd,env,chain auto", Help: "运行环境", Actions: ice.MergeActions(ice.Actions{ ice.CTX_INIT: {Hand: func(m *ice.Message, arg ...string) { _runtime_init(m) }}, ice.CTX_EXIT: {Hand: func(m *ice.Message, arg ...string) { m.Conf("", "", nil) }}, IFCONFIG: {Hand: func(m *ice.Message, arg ...string) { m.Cmdy("tcp.host") }}, diff --git a/base/cli/system.go b/base/cli/system.go index cd2f3311..3ba2f04a 100644 --- a/base/cli/system.go +++ b/base/cli/system.go @@ -160,7 +160,7 @@ func init() { if len(arg) == 1 { arg = append(arg, "") } - m.Option(CMD_ENV, "COLUMNS", kit.Int(kit.Select("1920", m.Option(ice.WIDTH)))/12) + m.Option(CMD_ENV, "COLUMNS", kit.Int(kit.Select("1920", m.Option(ice.MSG_WIDTH)))/12) m.Echo(SystemCmds(m, "man %s %s|col -b", kit.Select("", arg[1], arg[1] != "1"), arg[0])) }}, }, mdb.HashAction(mdb.SHORT, "cmd", mdb.FIELD, "time,cmd,arg")), Hand: func(m *ice.Message, arg ...string) { diff --git a/base/web/render.go b/base/web/render.go index 87674028..25bc6f40 100644 --- a/base/web/render.go +++ b/base/web/render.go @@ -189,9 +189,9 @@ var _main_template = ` volcanos - + - + diff --git a/base/web/serve.go b/base/web/serve.go index f4df2d64..8540f4bb 100644 --- a/base/web/serve.go +++ b/base/web/serve.go @@ -93,7 +93,7 @@ func _serve_handle(key string, cmd *ice.Command, m *ice.Message, w http.Response }) } kit.Fetch(r.Cookies(), func(k, v string) { m.Optionv(k, v) }) - m.OptionDefault(ice.HEIGHT, "480", ice.WIDTH, "320") + m.OptionDefault(ice.MSG_HEIGHT, "480", ice.MSG_WIDTH, "320") m.Option(ice.MSG_USERUA, r.Header.Get(UserAgent)) m.Option(ice.MSG_USERIP, r.Header.Get(ice.MSG_USERIP)) m.Option(ice.MSG_USERADDR, kit.Select(r.RemoteAddr, r.Header.Get(ice.MSG_USERADDR))) diff --git a/conf.go b/conf.go index 630f5ca8..e75b5fdf 100644 --- a/conf.go +++ b/conf.go @@ -85,11 +85,13 @@ const ( // DIR PLUGIN = "plugin" STORY = "story" - FAVICON_ICO = "favicon.ico" - PROTO_JS = "proto.js" - FRAME_JS = "frame.js" - INDEX_JS = "index.js" - INDEX_SH = "index.sh" + PAGE_FAVICON_ICO = "page/favicon.ico" + + INDEX_CSS = "index.css" + PROTO_JS = "proto.js" + FRAME_JS = "frame.js" + INDEX_JS = "index.js" + INDEX_SH = "index.sh" PLUGIN_INPUT = "/plugin/input/" PLUGIN_STORY = "/plugin/story/" @@ -165,7 +167,6 @@ const ( // MSG MSG_TARGET = "_target" MSG_HANDLE = "_handle" MSG_UPLOAD = "_upload" - MSG_DAEMON = "_daemon" MSG_ACTION = "_action" MSG_STATUS = "_status" @@ -195,6 +196,9 @@ const ( // MSG MSG_TOPIC = "sess.topic" MSG_RIVER = "sess.river" MSG_STORM = "sess.storm" + MSG_WIDTH = "sess.width" + MSG_HEIGHT = "sess.height" + MSG_DAEMON = "sess.daemon" MSG_FILES = "file.system" LOG_DISABLE = "log.disable" @@ -287,10 +291,8 @@ const ( // web SERVE = "serve" SPACE = "space" - TOPIC = "topic" - TITLE = "title" - WIDTH = "width" - HEIGHT = "height" + TOPIC = "topic" + TITLE = "title" ) const ( // nfs SOURCE = "source" diff --git a/core/chat/div.go b/core/chat/div.go index 62bf7895..b7a8227d 100644 --- a/core/chat/div.go +++ b/core/chat/div.go @@ -81,9 +81,9 @@ var _div_template = ` volcanos - + - + @@ -97,9 +97,9 @@ var _div_template2 = ` volcanos - + - + diff --git a/core/chat/website.go b/core/chat/website.go index b44cfd53..09934799 100644 --- a/core/chat/website.go +++ b/core/chat/website.go @@ -224,9 +224,9 @@ var _website_template = ` volcanos - + - + @@ -239,9 +239,9 @@ var _website_template2 = ` volcanos - + - + diff --git a/core/code/binpack.go b/core/code/binpack.go index e288f3e9..76bb218c 100644 --- a/core/code/binpack.go +++ b/core/code/binpack.go @@ -39,7 +39,7 @@ func _binpack_dir(m *ice.Message, w io.Writer, dir string) { } func _binpack_can(m *ice.Message, w io.Writer, dir string) { - for _, k := range []string{ice.FAVICON_ICO, ice.PROTO_JS, ice.FRAME_JS} { + for _, k := range []string{ice.PAGE_FAVICON_ICO, ice.PROTO_JS, ice.FRAME_JS} { _binpack_file(m, w, path.Join(dir, k)) } for _, k := range []string{LIB, PAGE, PANEL, PLUGIN, "publish/client/nodejs/"} { diff --git a/core/code/vimer.go b/core/code/vimer.go index 8fd1720f..145e8350 100644 --- a/core/code/vimer.go +++ b/core/code/vimer.go @@ -91,7 +91,7 @@ func init() { } p := path.Join(m.Option(nfs.PATH), m.Option(nfs.FILE)) switch m.Cmd(nfs.SAVE, p); m.Option(nfs.FILE) { - case "proto.js", "page/index.css": + case "index.css", "proto.js": m.Cmd("", DEVPACK) } switch arg[0] { @@ -111,6 +111,24 @@ func init() { web.DREAM: {Name: "dream name*=hi repos", Help: "空间", Hand: func(m *ice.Message, arg ...string) { m.Cmdy(web.DREAM, cli.START, arg) }}, + nfs.REPOS: {Name: "repos", Help: "仓库", Hand: func(m *ice.Message, arg ...string) { + m.Option("view", "change") + m.Cmd("web.code.git.status", func(value ice.Maps) { + m.Push(mdb.TYPE, value[mdb.TYPE]) + if value[nfs.REPOS] == path.Base(kit.Path("")) { + if ls := kit.Split(value[nfs.FILE]); len(ls) == 1 { + m.Push(nfs.PATH, "./") + m.Push(nfs.FILE, ls[0]) + } else { + m.Push(nfs.PATH, ls[0]+ice.PS) + m.Push(nfs.FILE, path.Join(ls[1:]...)) + } + } else { + m.Push(nfs.PATH, path.Join(ice.USR, value[nfs.REPOS])+ice.PS) + m.Push(nfs.FILE, value[nfs.FILE]) + } + }) + }}, "_open": {Help: "打开", Hand: func(m *ice.Message, arg ...string) { m.Cmd(cli.DAEMON, cli.OPEN, "-a", kit.Split(arg[0], ice.PT, ice.PT)[0]) }}, diff --git a/core/code/webpack.go b/core/code/webpack.go index bd47be75..32090302 100644 --- a/core/code/webpack.go +++ b/core/code/webpack.go @@ -23,7 +23,7 @@ func _publish(m *ice.Message, file ...string) string { } func _webpack_can(m *ice.Message) { m.Option(nfs.DIR_ROOT, "") - m.Cmd(nfs.COPY, _volcanos(m, PAGE_CAN_CSS), _volcanos(m, PAGE_INDEX_CSS), _volcanos(m, PAGE_CACHE_CSS)) + m.Cmd(nfs.COPY, _volcanos(m, PAGE_CAN_CSS), _volcanos(m, ice.INDEX_CSS), _volcanos(m, PAGE_CACHE_CSS)) m.Cmd(nfs.COPY, _volcanos(m, PAGE_CAN_JS), _volcanos(m, ice.PROTO_JS), _volcanos(m, PAGE_CACHE_JS)) m.Cmdy(nfs.DIR, _volcanos(m, PAGE)) } @@ -104,7 +104,7 @@ func _webpack_build(m *ice.Message, file string) { main_js = ice.SRC_MAIN_JS } fmt.Fprintf(f, _webpack_template, - m.Cmdx(nfs.CAT, _volcanos(m, PAGE_INDEX_CSS)), m.Cmdx(nfs.CAT, _volcanos(m, PAGE_CACHE_CSS)), + m.Cmdx(nfs.CAT, _volcanos(m, ice.INDEX_CSS)), m.Cmdx(nfs.CAT, _volcanos(m, PAGE_CACHE_CSS)), m.Cmdx(nfs.CAT, _volcanos(m, ice.PROTO_JS)), m.Cmdx(nfs.CAT, kit.Keys(file, JS)), m.Cmdx(nfs.CAT, _volcanos(m, PAGE_CACHE_JS)), m.Cmdx(nfs.CAT, main_js), ) @@ -118,7 +118,6 @@ const ( PLUGIN = "plugin" ) const ( - PAGE_INDEX_CSS = "page/index.css" PAGE_CACHE_CSS = "page/cache.css" PAGE_INDEX_JS = "page/index.js" PAGE_CACHE_JS = "page/cache.js" diff --git a/misc/git/status.go b/misc/git/status.go index 61c19a66..5c34e2bd 100644 --- a/misc/git/status.go +++ b/misc/git/status.go @@ -112,6 +112,7 @@ func _status_stat(m *ice.Message, files, adds, dels int) (int, int, int) { return files, adds, dels } func _status_list(m *ice.Message) (files, adds, dels int, last time.Time) { + onlychange := m.Option("view") == "change" ReposList(m).Tables(func(value ice.Maps) { m.Option(cli.CMD_DIR, value[nfs.PATH]) files, adds, dels = _status_stat(m, files, adds, dels) @@ -126,6 +127,9 @@ func _status_list(m *ice.Message) (files, adds, dels int, last time.Time) { case "swp", "swo", ice.BIN, ice.VAR: return } + if onlychange && ls[0] == "##" { + return + } switch m.Push(REPOS, value[REPOS]).Push(mdb.TYPE, ls[0]).Push(nfs.FILE, ls[1]); ls[0] { case "##": if m.Push(TAGS, tags); strings.Contains(ls[1], "ahead") || !strings.Contains(ls[1], "...") { @@ -242,6 +246,8 @@ func init() { } } }}, + "change": {Help: "变更", Hand: func(m *ice.Message, arg ...string) { + }}, "branch_switch": {Help: "切换", Hand: func(m *ice.Message, arg ...string) { _repos_cmd(m, m.Option(REPOS), "checkout", m.Option(BRANCH)) }}, diff --git a/render.go b/render.go index 1527bcda..33466efe 100644 --- a/render.go +++ b/render.go @@ -52,9 +52,9 @@ func Render(m *Message, cmd string, args ...Any) string { case RENDER_ANCHOR: return kit.Format(`%s`, kit.Select(arg[0], arg, 1), arg[0]) case RENDER_IMAGES: - return kit.Format(``, arg[0], m.Option(HEIGHT), m.Option(WIDTH)) + return kit.Format(``, arg[0], m.Option(MSG_HEIGHT), m.Option(MSG_WIDTH)) case RENDER_VIDEOS: - return kit.Format(`