forked from x/icebergs
opt some
This commit is contained in:
parent
3bd1ab44e5
commit
2c13b454f9
@ -44,7 +44,7 @@ func Render(msg *ice.Message, cmd string, args ...interface{}) {
|
|||||||
case ice.RENDER_DOWNLOAD: // file [type [name]]
|
case ice.RENDER_DOWNLOAD: // file [type [name]]
|
||||||
msg.W.Header().Set("Content-Disposition", fmt.Sprintf("filename=%s", kit.Select(path.Base(arg[0]), arg, 2)))
|
msg.W.Header().Set("Content-Disposition", fmt.Sprintf("filename=%s", kit.Select(path.Base(arg[0]), arg, 2)))
|
||||||
if RenderType(msg.W, arg[0], kit.Select("", arg, 1)); !ice.DumpBinPack(msg.W, arg[0], nil) {
|
if RenderType(msg.W, arg[0], kit.Select("", arg, 1)); !ice.DumpBinPack(msg.W, arg[0], nil) {
|
||||||
http.ServeFile(msg.W, msg.R, arg[0])
|
http.ServeFile(msg.W, msg.R, kit.Path(arg[0]))
|
||||||
}
|
}
|
||||||
|
|
||||||
case ice.RENDER_QRCODE: // text [size]
|
case ice.RENDER_QRCODE: // text [size]
|
||||||
|
@ -59,15 +59,12 @@ func _serve_main(m *ice.Message, w http.ResponseWriter, r *http.Request) bool {
|
|||||||
if r.Method == "GET" && r.URL.Path == "/" {
|
if r.Method == "GET" && r.URL.Path == "/" {
|
||||||
msg := m.Spawn()
|
msg := m.Spawn()
|
||||||
if msg.W, msg.R = w, r; strings.Contains(r.Header.Get("User-Agent"), "curl") {
|
if msg.W, msg.R = w, r; strings.Contains(r.Header.Get("User-Agent"), "curl") {
|
||||||
if ice.DumpBinPack(w, "usr/intshell/index.sh", func(name string) { RenderType(w, name, "") }) {
|
Render(msg, ice.RENDER_DOWNLOAD, path.Join(m.Conf(SERVE, "meta.intshell.path"), m.Conf(SERVE, "meta.intshell.index")))
|
||||||
return false
|
|
||||||
}
|
|
||||||
Render(msg, ice.RENDER_DOWNLOAD, kit.Path(m.Conf(SERVE, "meta.intshell.path"), m.Conf(SERVE, "meta.intshell.index")))
|
|
||||||
} else {
|
} else {
|
||||||
if ice.DumpBinPack(w, r.URL.Path, func(name string) { RenderType(w, name, "") }) {
|
if ice.DumpBinPack(w, r.URL.Path, func(name string) { RenderType(w, name, "") }) {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
Render(msg, ice.RENDER_DOWNLOAD, kit.Path(m.Conf(SERVE, "meta.volcanos.path"), m.Conf(SERVE, "meta.volcanos.index")))
|
Render(msg, ice.RENDER_DOWNLOAD, path.Join(m.Conf(SERVE, "meta.volcanos.path"), m.Conf(SERVE, "meta.volcanos.index")))
|
||||||
}
|
}
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
@ -209,7 +206,7 @@ func init() {
|
|||||||
), "logheaders", false,
|
), "logheaders", false,
|
||||||
|
|
||||||
"static", kit.Dict("/", "usr/volcanos/"),
|
"static", kit.Dict("/", "usr/volcanos/"),
|
||||||
"volcanos", kit.Dict("path", "usr/volcanos", "index", "index.html",
|
"volcanos", kit.Dict("path", "usr/volcanos", "index", "page/index.html",
|
||||||
"repos", "https://github.com/shylinux/volcanos", "branch", "master",
|
"repos", "https://github.com/shylinux/volcanos", "branch", "master",
|
||||||
), "publish", "usr/publish/",
|
), "publish", "usr/publish/",
|
||||||
|
|
||||||
|
@ -109,12 +109,11 @@ func init() {
|
|||||||
}
|
}
|
||||||
}},
|
}},
|
||||||
}, Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
|
}, Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
|
||||||
m.Option(nfs.DIR_ROOT, path.Join(m.Conf(PUBLISH, kit.META_PATH)))
|
for k, v := range ice.BinPack {
|
||||||
m.Option(nfs.DIR_TYPE, nfs.FILE)
|
m.Push(kit.MDB_NAME, k)
|
||||||
|
m.Push(kit.MDB_SIZE, len(v))
|
||||||
m.Cmdy(nfs.DIR, BINPACK).Table(func(index int, value map[string]string, head []string) {
|
}
|
||||||
m.PushDownload(value[kit.MDB_PATH])
|
m.Sort(kit.MDB_NAME)
|
||||||
})
|
|
||||||
}},
|
}},
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
@ -49,11 +49,14 @@ func init() {
|
|||||||
_publish_file(m, m.Option(kit.MDB_FILE))
|
_publish_file(m, m.Option(kit.MDB_FILE))
|
||||||
}},
|
}},
|
||||||
"can": {Name: "can", Help: "火山架", Hand: func(m *ice.Message, arg ...string) {
|
"can": {Name: "can", Help: "火山架", Hand: func(m *ice.Message, arg ...string) {
|
||||||
|
defer func() { m.Cmdy(PUBLISH, "contexts", "miss") }()
|
||||||
|
m.Cmd(PUBLISH, mdb.CREATE, kit.MDB_FILE, "etc/miss.sh")
|
||||||
|
m.Cmd(PUBLISH, mdb.CREATE, kit.MDB_FILE, "go.mod")
|
||||||
|
|
||||||
m.Option(nfs.DIR_DEEP, true)
|
m.Option(nfs.DIR_DEEP, true)
|
||||||
m.Option(nfs.DIR_REG, `.*\.(html|css|js)$`)
|
m.Option(nfs.DIR_REG, `.*\.(html|css|js)$`)
|
||||||
m.Option(nfs.DIR_ROOT, m.Conf(PUBLISH, kit.META_PATH))
|
m.Option(nfs.DIR_ROOT, m.Conf(PUBLISH, kit.META_PATH))
|
||||||
m.Cmdy(nfs.DIR, "./", "time,size,line,path,link")
|
m.Cmdy(nfs.DIR, "./", "time,size,line,path,link")
|
||||||
m.Cmdy(PUBLISH, "contexts", "miss")
|
|
||||||
}},
|
}},
|
||||||
"ice": {Name: "ice", Help: "冰山架", Hand: func(m *ice.Message, arg ...string) {
|
"ice": {Name: "ice", Help: "冰山架", Hand: func(m *ice.Message, arg ...string) {
|
||||||
defer func() { m.Cmdy(PUBLISH, "contexts", "base") }()
|
defer func() { m.Cmdy(PUBLISH, "contexts", "base") }()
|
||||||
@ -75,11 +78,13 @@ func init() {
|
|||||||
m.SortTimeR(kit.MDB_TIME)
|
m.SortTimeR(kit.MDB_TIME)
|
||||||
}},
|
}},
|
||||||
"ish": {Name: "ish", Help: "神农架", Hand: func(m *ice.Message, arg ...string) {
|
"ish": {Name: "ish", Help: "神农架", Hand: func(m *ice.Message, arg ...string) {
|
||||||
|
defer func() { m.Cmdy(PUBLISH, "contexts", "tmux") }()
|
||||||
|
m.Cmd(PUBLISH, mdb.CREATE, kit.MDB_FILE, "etc/miss.sh")
|
||||||
|
|
||||||
m.Option(nfs.DIR_DEEP, true)
|
m.Option(nfs.DIR_DEEP, true)
|
||||||
m.Option(nfs.DIR_REG, ".*\\.(sh|vim|conf)$")
|
m.Option(nfs.DIR_REG, ".*\\.(sh|vim|conf)$")
|
||||||
m.Option(nfs.DIR_ROOT, m.Conf(PUBLISH, kit.META_PATH))
|
m.Option(nfs.DIR_ROOT, m.Conf(PUBLISH, kit.META_PATH))
|
||||||
m.Cmdy(nfs.DIR, "./", "time,size,line,path,link")
|
m.Cmdy(nfs.DIR, "./", "time,size,line,path,link")
|
||||||
m.Cmdy(PUBLISH, "contexts", "tmux")
|
|
||||||
}},
|
}},
|
||||||
"contexts": {Name: "contexts", Help: "环境", Hand: func(m *ice.Message, arg ...string) {
|
"contexts": {Name: "contexts", Help: "环境", Hand: func(m *ice.Message, arg ...string) {
|
||||||
u := kit.ParseURL(m.Option(ice.MSG_USERWEB))
|
u := kit.ParseURL(m.Option(ice.MSG_USERWEB))
|
||||||
|
@ -16,19 +16,15 @@ func init() {
|
|||||||
SERVE: {Name: SERVE, Help: "服务", Value: kit.Data(
|
SERVE: {Name: SERVE, Help: "服务", Value: kit.Data(
|
||||||
kit.MDB_SHORT, kit.MDB_NAME, kit.MDB_FIELD, "time,name,branch,commit",
|
kit.MDB_SHORT, kit.MDB_NAME, kit.MDB_FIELD, "time,name,branch,commit",
|
||||||
"owner", "https://github.com/shylinux",
|
"owner", "https://github.com/shylinux",
|
||||||
|
kit.MDB_PATH, ".ish/pluged",
|
||||||
)},
|
)},
|
||||||
},
|
},
|
||||||
Commands: map[string]*ice.Command{
|
Commands: map[string]*ice.Command{
|
||||||
web.WEB_LOGIN: {Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
|
web.WEB_LOGIN: {Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
|
||||||
m.Render(ice.RENDER_RESULT)
|
m.Render(ice.RENDER_VOID)
|
||||||
}},
|
}},
|
||||||
"/github.com/": {Name: "github.com", Help: "github.com", Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
|
"/github.com/": {Name: "github.com", Help: "github.com", Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
|
||||||
m.Render(ice.RENDER_VOID)
|
githttp.New(kit.Path(m.Conf(SERVE, kit.META_PATH))).ServeHTTP(m.W, m.R)
|
||||||
p := kit.Path(".ish/pluged")
|
|
||||||
m.Debug("what %v", p)
|
|
||||||
git := githttp.New(p)
|
|
||||||
m.Debug("what %v", p)
|
|
||||||
git.ServeHTTP(m.W, m.R)
|
|
||||||
}},
|
}},
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
Loading…
x
Reference in New Issue
Block a user