1
0
forked from x/icebergs

add media

This commit is contained in:
IT 老营长 @云轩领航-创始人 2022-08-08 08:22:25 +08:00
parent b6aa318322
commit 2af002441a
11 changed files with 54 additions and 12 deletions

View File

@ -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 }

View File

@ -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"

View File

@ -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
}

View File

@ -26,7 +26,7 @@ func init() {
}
}
}},
}, ctx.CmdAction(EMAIL, `<a href="mailto:shylinuxc@gmail.com">shylinuxc@gmail.com</a>`), web.ApiAction()), Hand: func(m *ice.Message, arg ...string) {
}, ctx.CmdAction(EMAIL, `<a href="mailto:shylinuxc@gmail.com">shylinuxc@gmail.com</a>`), web.ApiAction("/footer")), Hand: func(m *ice.Message, arg ...string) {
m.Result(m.Configv(EMAIL))
}},
})

View File

@ -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
}

37
core/chat/media.go Normal file
View File

@ -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"))
}
}},
})
}

View File

@ -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))

View File

@ -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 // 没有登录

View File

@ -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) {

View File

@ -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))
}},

View File

@ -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
}