1
0
forked from x/icebergs
This commit is contained in:
shaoying 2019-12-30 20:05:05 +08:00
parent 2ea6bfde97
commit 032bbe81d4
5 changed files with 17 additions and 4 deletions

View File

@ -18,7 +18,9 @@ import (
func dir(m *ice.Message, root string, name string, level int, deep bool, dir_type string, dir_reg *regexp.Regexp, fields []string, format string) {
if fs, e := ioutil.ReadDir(path.Join(root, name)); m.Assert(e) {
if fs, e := ioutil.ReadDir(path.Join(root, name)); e != nil {
m.Log(ice.LOG_WARN, "%s", e)
} else {
for _, f := range fs {
if f.Name() == "." || f.Name() == ".." {
continue

View File

@ -739,7 +739,7 @@ var Index = &ice.Context{Name: "web", Help: "网页模块",
if len(arg) > 0 {
// 规范命名
if !strings.Contains(arg[0], "-") {
if !strings.Contains(arg[0], "-") || !strings.HasPrefix(arg[0], "20") {
arg[0] = m.Time("20060102-") + arg[0]
}
@ -1256,6 +1256,8 @@ var Index = &ice.Context{Name: "web", Help: "网页模块",
}
if s, e := websocket.Upgrade(m.W, m.R, nil, m.Confi(ice.WEB_SPACE, "meta.buffer.r"), m.Confi(ice.WEB_SPACE, "meta.buffer.w")); m.Assert(e) {
m.Option("name", strings.Replace(m.Option("name"), ".", "_", -1))
// 共享空间
share := m.Option("share")
if m.Richs(ice.WEB_SHARE, nil, share, nil) == nil {

View File

@ -47,7 +47,7 @@ prepare() {
curl \$ctx_dev/publish/\${bin} -o ice.bin && chmod u+x ice.bin
}
start() {
while true; do
trap HUP hup && while true; do
date && ice.bin \$@ 2>boot.log && echo -e "\n\nrestarting..." || break
done
}

View File

@ -189,7 +189,9 @@ var Index = &ice.Context{Name: "code", Help: "编程模块",
m.Cmdy("login", "exit")
case "upload":
// 缓存文件
msg := m.Cmd(ice.WEB_CACHE, "upload")
you := m.Option("you")
m.Option("you", "")
msg := m.Cmd(ice.WEB_STORY, "upload")
m.Echo("data: %s\n", msg.Append("data"))
m.Echo("time: %s\n", msg.Append("time"))
m.Echo("type: %s\n", msg.Append("type"))
@ -198,6 +200,7 @@ var Index = &ice.Context{Name: "code", Help: "编程模块",
m.Push("_output", "result")
// 下发文件
m.Option("you", you)
m.Cmd(ice.WEB_SPACE, msg.Option("you"), ice.WEB_SPACE, "download", msg.Append("type"), msg.Append("name"), "self", msg.Append("data"))
case "download":

View File

@ -190,6 +190,12 @@ func (m *Message) Format(key interface{}) string {
return kit.FmtTime(kit.Int64(time.Now().Sub(m.time)))
case "meta":
return kit.Format(m.meta)
case "append":
if len(m.meta["append"]) == 0 {
return fmt.Sprintf("%dx%d %s", 0, len(m.meta["append"]), kit.Format(m.meta["append"]))
} else {
return fmt.Sprintf("%dx%d %s", len(m.meta[m.meta["append"][0]]), len(m.meta["append"]), kit.Format(m.meta["append"]))
}
case "time":
return m.Time()
case "ship":