From 901fede9174eff402be2cbc5061b2037f9a09018 Mon Sep 17 00:00:00 2001 From: shaoying Date: Sun, 3 May 2020 13:43:17 +0800 Subject: [PATCH] opt some --- base/web/web.go | 29 ++++++++++++++++++++++------- go.mod | 2 +- 2 files changed, 23 insertions(+), 8 deletions(-) diff --git a/base/web/web.go b/base/web/web.go index 2fc345ef..a313bee7 100644 --- a/base/web/web.go +++ b/base/web/web.go @@ -363,7 +363,7 @@ func (web *Frame) ServeHTTP(w http.ResponseWriter, r *http.Request) { m.Conf(ice.WEB_SERVE, "meta.init", "true") } m.W = w - Render(m, "refresh") + Render(m, "refresh", m.Conf(ice.WEB_SERVE, "meta.volcanos.refresh")) m.Event(ice.SYSTEM_INIT) m.W = nil } else if r.URL.Path == "/share" && r.Method == "GET" { @@ -454,12 +454,12 @@ var Index = &ice.Context{Name: "web", Help: "网络模块", "share", "usr/volcanos/page/share.html", ), "static", kit.Dict("/", "usr/volcanos/", - "/static/volcanos/", "usr/volcanos/", "/publish/", "usr/publish/", ), "volcanos", kit.Dict("path", "usr/volcanos", "branch", "master", "repos", "https://github.com/shylinux/volcanos", "require", "usr/local", + "refresh", "5", ), "template", kit.Dict("path", "usr/template", "list", []interface{}{ `{{define "raw"}}{{.Result}}{{end}}`, @@ -503,11 +503,6 @@ var Index = &ice.Context{Name: "web", Help: "网络模块", m.Cmd(ice.WEB_SPIDE, "add", "dev", kit.Select("http://:9020", m.Conf(ice.CLI_RUNTIME, "conf.ctx_dev"))) m.Cmd(ice.WEB_SPIDE, "add", "shy", kit.Select("https://shylinux.com:443", m.Conf(ice.CLI_RUNTIME, "conf.ctx_shy"))) - m.Watch(ice.SYSTEM_INIT, "web.code.git.repos", "volcanos", m.Conf(ice.WEB_SERVE, "meta.volcanos.path"), - m.Conf(ice.WEB_SERVE, "meta.volcanos.repos"), m.Conf(ice.WEB_SERVE, "meta.volcanos.branch")) - m.Conf(ice.WEB_FAVOR, "meta.template", favor_template) - m.Conf(ice.WEB_SHARE, "meta.template", share_template) - m.Cmd(ice.APP_SEARCH, "add", "favor", "base", m.AddCmd(&ice.Command{Name: "search word", Help: "搜索引擎", Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) { switch arg[0] { case "set": @@ -859,6 +854,11 @@ var Index = &ice.Context{Name: "web", Help: "网络模块", for _, k := range arg { m.Cmd(ice.WEB_SPACE, "connect", k) } + + m.Watch(ice.SYSTEM_INIT, "web.code.git.repos", "volcanos", m.Conf(ice.WEB_SERVE, "meta.volcanos.path"), + m.Conf(ice.WEB_SERVE, "meta.volcanos.repos"), m.Conf(ice.WEB_SERVE, "meta.volcanos.branch")) + m.Conf(ice.WEB_FAVOR, "meta.template", favor_template) + m.Conf(ice.WEB_SHARE, "meta.template", share_template) }}, ice.WEB_SPACE: {Name: "space name auto", Help: "空间站", Meta: kit.Dict( "exports", []string{"pod", "name"}, @@ -2416,6 +2416,21 @@ var Index = &ice.Context{Name: "web", Help: "网络模块", } m.Render(ice.RENDER_DOWNLOAD, path.Join(prefix, cmd)) }}, + "/github.com/": {Name: "/space/", Help: "空间站", Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) { + prefix := m.Conf(ice.WEB_SERVE, "meta.volcanos.require") + if _, e := os.Stat(path.Join(prefix, cmd)); e != nil { + m.Cmd(ice.CLI_SYSTEM, "git", "clone", "https://"+strings.Join(strings.Split(cmd, "/")[1:4], "/"), + path.Join(prefix, strings.Join(strings.Split(cmd, "/")[1:4], "/"))) + } + m.Render(ice.RENDER_DOWNLOAD, path.Join(prefix, cmd)) + }}, + "/local/": {Name: "/space/", Help: "空间站", Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) { + p := path.Join(cmd) + switch strings.TrimSuffix(path.Ext(p), ".") { + case "js": + m.Render(ice.RENDER_DOWNLOAD, p) + } + }}, }, } diff --git a/go.mod b/go.mod index 7be5fa1c..bea17ea1 100644 --- a/go.mod +++ b/go.mod @@ -4,6 +4,6 @@ go 1.13 require ( github.com/gorilla/websocket v1.4.1 - github.com/shylinux/toolkits v0.1.4 + github.com/shylinux/toolkits v0.1.5 github.com/skip2/go-qrcode v0.0.0-20191027152451-9434209cb086 )