diff --git a/base/web/web.go b/base/web/web.go
index ef600b13..f5ee72cb 100644
--- a/base/web/web.go
+++ b/base/web/web.go
@@ -132,7 +132,7 @@ func init() {
}
func ApiAction(arg ...string) ice.Actions {
- return ice.Actions{kit.Select(ice.PS, path.Join(arg...)+ice.PS): {}}
+ return ice.Actions{kit.Select(ice.PS, arg, 0): {}}
}
func P(arg ...string) string { return path.Join(ice.PS, path.Join(arg...)) }
func PP(arg ...string) string { return P(arg...) + ice.PS }
diff --git a/conf.go b/conf.go
index 27e000dd..3e7d2d48 100644
--- a/conf.go
+++ b/conf.go
@@ -124,6 +124,7 @@ const ( // DIR
USR_LOCAL_LIB = "usr/local/lib"
USR_LOCAL_WORK = "usr/local/work"
USR_LOCAL_IMAGE = "usr/local/image"
+ USR_LOCAL_MEDIA = "usr/local/media"
USR_LOCAL_RIVER = "usr/local/river"
USR_LOCAL_DAEMON = "usr/local/daemon"
USR_LOCAL_EXPORT = "usr/local/export"
diff --git a/core/chat/cmd.go b/core/chat/cmd.go
index 83d55643..c7d33777 100644
--- a/core/chat/cmd.go
+++ b/core/chat/cmd.go
@@ -64,7 +64,7 @@ func init() {
m.Cmdy(CMD, mdb.CREATE, mdb.TYPE, k, mdb.NAME, "web.code.inner")
}
}},
- }, mdb.HashAction(mdb.SHORT, "type", nfs.PATH, nfs.PWD), ctx.CmdAction(), web.ApiAction("/cmd/")), Hand: func(m *ice.Message, arg ...string) {
+ }, mdb.HashAction(mdb.SHORT, "type", nfs.PATH, nfs.PWD), ctx.CmdAction(), web.ApiAction()), Hand: func(m *ice.Message, arg ...string) {
if _cmd_file(m, arg...) {
return
}
diff --git a/core/chat/footer.go b/core/chat/footer.go
index 2a6fe566..e4eb5764 100644
--- a/core/chat/footer.go
+++ b/core/chat/footer.go
@@ -26,7 +26,7 @@ func init() {
}
}
}},
- }, ctx.CmdAction(EMAIL, `shylinuxc@gmail.com`), web.ApiAction()), Hand: func(m *ice.Message, arg ...string) {
+ }, ctx.CmdAction(EMAIL, `shylinuxc@gmail.com`), web.ApiAction("/footer")), Hand: func(m *ice.Message, arg ...string) {
m.Result(m.Configv(EMAIL))
}},
})
diff --git a/core/chat/header.go b/core/chat/header.go
index f9d01d04..ebc7c35b 100644
--- a/core/chat/header.go
+++ b/core/chat/header.go
@@ -60,7 +60,6 @@ const HEADER = "header"
func init() {
Index.MergeCommands(ice.Commands{
web.WEB_LOGIN: {Hand: func(m *ice.Message, arg ...string) {
- m.Debug("what %v", m.FormatStack(1, 100))
switch kit.Select("", arg, 0) {
case web.P(HEADER):
switch kit.Select("", arg, 1) {
@@ -110,7 +109,7 @@ func init() {
web.SHARE: {Name: "share type", Help: "共享", Hand: func(m *ice.Message, arg ...string) {
_header_share(m, arg...)
}},
- }, ctx.ConfAction(aaa.LOGIN, kit.List("登录", "扫码")), web.ApiAction()), Hand: func(m *ice.Message, arg ...string) {
+ }, ctx.ConfAction(aaa.LOGIN, kit.List("登录", "扫码")), web.ApiAction("/header")), Hand: func(m *ice.Message, arg ...string) {
if !_header_check(m, arg...) {
return
}
diff --git a/core/chat/media.go b/core/chat/media.go
new file mode 100644
index 00000000..03468570
--- /dev/null
+++ b/core/chat/media.go
@@ -0,0 +1,37 @@
+package chat
+
+import (
+ "net/http"
+ "path"
+
+ ice "shylinux.com/x/icebergs"
+ "shylinux.com/x/icebergs/base/ctx"
+ "shylinux.com/x/icebergs/base/nfs"
+ "shylinux.com/x/icebergs/base/web"
+ kit "shylinux.com/x/toolkits"
+)
+
+func init() {
+ const MEDIA = "media"
+ Index.MergeCommands(ice.Commands{
+ MEDIA: {Name: "media path auto", Help: "媒体", Actions: ice.MergeActions(ice.Actions{
+ web.UPLOAD: {Hand: func(m *ice.Message, arg ...string) {
+ m.Cmdy(web.CACHE, web.UPLOAD_WATCH, ice.USR_LOCAL_MEDIA)
+ }},
+ nfs.TRASH: {Hand: func(m *ice.Message, arg ...string) {
+ m.Cmdy(nfs.TRASH, path.Join(ice.USR_LOCAL_MEDIA, m.Option(nfs.PATH)))
+ }},
+ }, web.ApiAction()), Hand: func(m *ice.Message, arg ...string) {
+ if len(arg) == 0 {
+ m.Option(nfs.DIR_ROOT, ice.USR_LOCAL_MEDIA)
+ ctx.DisplayStory(m.Cmdy(nfs.DIR, nfs.PWD), "media.js")
+ return
+ }
+ if m.R.Method == http.MethodGet {
+ m.RenderDownload(kit.Path(ice.USR_LOCAL_MEDIA, path.Join(arg...)))
+ } else {
+ m.EchoVideos("/chat/media/"+path.Join(arg...), m.Option("height"))
+ }
+ }},
+ })
+}
diff --git a/core/chat/pod.go b/core/chat/pod.go
index c3a05d22..e02c8575 100644
--- a/core/chat/pod.go
+++ b/core/chat/pod.go
@@ -19,7 +19,7 @@ func init() {
Index.MergeCommands(ice.Commands{
POD: {Name: "pod", Help: "节点", Actions: ice.MergeActions(ice.Actions{
ice.CTX_INIT: {Hand: func(m *ice.Message, arg ...string) { m.Cmd(aaa.ROLE, aaa.WHITE, aaa.VOID, POD) }},
- }, ctx.CmdAction(), web.ApiAction("/pod/")), Hand: func(m *ice.Message, arg ...string) {
+ }, ctx.CmdAction(), web.ApiAction()), Hand: func(m *ice.Message, arg ...string) {
if web.OptionAgentIs(m, "curl", "Wget") {
aaa.UserRoot(m)
m.Option(ice.POD, kit.Select("", arg, 0))
diff --git a/core/chat/river.go b/core/chat/river.go
index 9f16ac69..f52b4b8c 100644
--- a/core/chat/river.go
+++ b/core/chat/river.go
@@ -90,7 +90,7 @@ func init() {
aaa.INVITE: {Name: "invite", Help: "添加设备", Hand: func(m *ice.Message, arg ...string) {
m.Cmdy("publish", ice.CONTEXTS)
}},
- }, mdb.HashAction(mdb.FIELD, "time,hash,type,name,text,template"), web.ApiAction()), Hand: func(m *ice.Message, arg ...string) {
+ }, mdb.HashAction(mdb.FIELD, "time,hash,type,name,text,template"), web.ApiAction("/river")), Hand: func(m *ice.Message, arg ...string) {
if m.Warn(m.Option(ice.MSG_USERNAME) == "", ice.ErrNotLogin) {
m.RenderStatusUnauthorized()
return // 没有登录
diff --git a/core/chat/website.go b/core/chat/website.go
index ae58eebc..888eddf9 100644
--- a/core/chat/website.go
+++ b/core/chat/website.go
@@ -236,7 +236,7 @@ func init() {
m.Echo(_website_url(m, strings.TrimPrefix(path.Join(arg[2], arg[1]), SRC_WEBSITE)))
}
}},
- }, mdb.HashAction(mdb.SHORT, nfs.PATH, mdb.FIELD, "time,path,type,name,text"), ctx.CmdAction(), web.ApiAction("/website/")), Hand: func(m *ice.Message, arg ...string) {
+ }, mdb.HashAction(mdb.SHORT, nfs.PATH, mdb.FIELD, "time,path,type,name,text"), ctx.CmdAction(), web.ApiAction()), Hand: func(m *ice.Message, arg ...string) {
mdb.HashSelect(m, arg...).Tables(func(value ice.Maps) { m.PushAnchor(MergeWebsite(m, value[nfs.PATH])) })
if len(arg) == 0 { // 文件列表
m.Cmd(nfs.DIR, SRC_WEBSITE, func(f os.FileInfo, p string) {
diff --git a/core/wiki/feel.go b/core/wiki/feel.go
index c36bcc56..682db0ba 100644
--- a/core/wiki/feel.go
+++ b/core/wiki/feel.go
@@ -14,9 +14,13 @@ const FEEL = "feel"
func init() {
Index.Merge(&ice.Context{Configs: ice.Configs{
- FEEL: {Name: FEEL, Help: "影音媒体", Value: kit.Data(nfs.PATH, ice.USR_LOCAL_IMAGE, lex.REGEXP, ".*.(png|PNG|jpg|JPG|jpeg|mp4|m4v|MOV)")},
+ FEEL: {Name: FEEL, Help: "影音媒体", Value: kit.Data(nfs.PATH, ice.USR_LOCAL_IMAGE, lex.REGEXP, ".*.(png|PNG|jpg|JPG|jpeg|mp4|m4v|MOV|webm)")},
}, Commands: ice.Commands{
- FEEL: {Name: "feel path auto upload prev next actions", Help: "影音媒体", Meta: kit.Dict(ice.DisplayLocal("")), Actions: ice.Actions{
+ FEEL: {Name: "feel path auto record1 record upload prev next actions", Help: "影音媒体", Meta: kit.Dict(ice.DisplayLocal("")), Actions: ice.Actions{
+ "record1": {Name: "record1", Help: "截图", Hand: func(m *ice.Message, arg ...string) {
+ }},
+ "record": {Name: "record", Help: "录屏", Hand: func(m *ice.Message, arg ...string) {
+ }},
web.UPLOAD: {Name: "upload", Help: "上传", Hand: func(m *ice.Message, arg ...string) {
_wiki_upload(m, m.CommandKey(), m.Option(nfs.PATH))
}},
diff --git a/type.go b/type.go
index 65b28693..3ce843b6 100644
--- a/type.go
+++ b/type.go
@@ -5,6 +5,7 @@ import (
"fmt"
"io"
"net/http"
+ "path"
"strings"
"sync/atomic"
"time"
@@ -180,8 +181,8 @@ func (c *Context) Merge(s *Context) *Context {
}
}
if strings.HasPrefix(k, PS) {
- k = kit.Select(k, PS+key, k == PS)
- c.Commands[k] = &Command{Name: k, Help: cmd.Help, Hand: func(m *Message, arg ...string) { m.Cmdy(key, arg) }}
+ k = kit.Select(k, path.Join(PS, key)+PS, k == PS)
+ c.Commands[k] = &Command{Name: k, Help: cmd.Help, Hand: func(m *Message, arg ...string) { m.Cmdy(m.CommandKey(), arg) }}
continue
}