1
0
forked from x/icebergs
This commit is contained in:
shaoying 2020-05-03 13:43:17 +08:00
parent 40438021bd
commit 901fede917
2 changed files with 23 additions and 8 deletions

View File

@ -363,7 +363,7 @@ func (web *Frame) ServeHTTP(w http.ResponseWriter, r *http.Request) {
m.Conf(ice.WEB_SERVE, "meta.init", "true") m.Conf(ice.WEB_SERVE, "meta.init", "true")
} }
m.W = w m.W = w
Render(m, "refresh") Render(m, "refresh", m.Conf(ice.WEB_SERVE, "meta.volcanos.refresh"))
m.Event(ice.SYSTEM_INIT) m.Event(ice.SYSTEM_INIT)
m.W = nil m.W = nil
} else if r.URL.Path == "/share" && r.Method == "GET" { } 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", "share", "usr/volcanos/page/share.html",
), ),
"static", kit.Dict("/", "usr/volcanos/", "static", kit.Dict("/", "usr/volcanos/",
"/static/volcanos/", "usr/volcanos/",
"/publish/", "usr/publish/", "/publish/", "usr/publish/",
), ),
"volcanos", kit.Dict("path", "usr/volcanos", "branch", "master", "volcanos", kit.Dict("path", "usr/volcanos", "branch", "master",
"repos", "https://github.com/shylinux/volcanos", "repos", "https://github.com/shylinux/volcanos",
"require", "usr/local", "require", "usr/local",
"refresh", "5",
), ),
"template", kit.Dict("path", "usr/template", "list", []interface{}{ "template", kit.Dict("path", "usr/template", "list", []interface{}{
`{{define "raw"}}{{.Result}}{{end}}`, `{{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", "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.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) { 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] { switch arg[0] {
case "set": case "set":
@ -859,6 +854,11 @@ var Index = &ice.Context{Name: "web", Help: "网络模块",
for _, k := range arg { for _, k := range arg {
m.Cmd(ice.WEB_SPACE, "connect", k) 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( ice.WEB_SPACE: {Name: "space name auto", Help: "空间站", Meta: kit.Dict(
"exports", []string{"pod", "name"}, "exports", []string{"pod", "name"},
@ -2416,6 +2416,21 @@ var Index = &ice.Context{Name: "web", Help: "网络模块",
} }
m.Render(ice.RENDER_DOWNLOAD, path.Join(prefix, cmd)) 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)
}
}},
}, },
} }

2
go.mod
View File

@ -4,6 +4,6 @@ go 1.13
require ( require (
github.com/gorilla/websocket v1.4.1 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 github.com/skip2/go-qrcode v0.0.0-20191027152451-9434209cb086
) )