mirror of
https://shylinux.com/x/icebergs
synced 2025-04-25 17:18:05 +08:00
add publish
This commit is contained in:
parent
85e1f1dcb6
commit
6fc5cbde02
@ -176,11 +176,14 @@ func init() {
|
||||
action.Hand = ice.MergeHand(func(m *ice.Message, arg ...string) {
|
||||
up := Upload(m)
|
||||
m.Assert(len(up) > 1)
|
||||
if m.Cmd(CACHE, m.Option(ice.MSG_UPLOAD)).Table(func(value ice.Maps) { m.Options(value) }).Length() == 0 {
|
||||
msg := m.Cmd(CACHE, m.Option(ice.MSG_UPLOAD))
|
||||
// if m.Cmd(CACHE, m.Option(ice.MSG_UPLOAD)).Table(func(value ice.Maps) { m.Options(value) }).Length() == 0 {
|
||||
if msg.Length() == 0 {
|
||||
SpideCache(m.Spawn(), m.MergeLink(SHARE_CACHE+up[0]))
|
||||
}
|
||||
if m.Options(mdb.HASH, up[0], mdb.NAME, up[1]); watch {
|
||||
m.Cmdy(CACHE, WATCH, m.Option(mdb.HASH), path.Join(m.Option(nfs.PATH), up[1]))
|
||||
// if m.Options(mdb.HASH, up[0], mdb.NAME, up[1]); watch {
|
||||
if watch {
|
||||
m.Cmdy(CACHE, WATCH, up[0], path.Join(msg.Append(nfs.PATH), up[1]))
|
||||
}
|
||||
}, action.Hand)
|
||||
}
|
||||
@ -188,12 +191,13 @@ func init() {
|
||||
}
|
||||
func Upload(m *ice.Message) []string {
|
||||
if up := kit.Simple(m.Optionv(ice.MSG_UPLOAD)); len(up) == 1 {
|
||||
if m.Cmdy(CACHE, UPLOAD).Optionv(ice.MSG_UPLOAD, kit.Simple(m.Append(mdb.HASH), m.Append(mdb.NAME), m.Append(nfs.SIZE))); m.Option(ice.MSG_USERPOD) != "" {
|
||||
if nfs.Exists(m, "usr/local/work/"+m.Option(ice.MSG_USERPOD)) {
|
||||
m.Cmd(nfs.LINK, path.Join("usr/local/work/"+m.Option(ice.MSG_USERPOD), m.Append(nfs.FILE)), m.Append(nfs.FILE))
|
||||
m.Cmd(SPACE, m.Option(ice.MSG_USERPOD), CACHE, mdb.CREATE, m.AppendSimple(mdb.NAME, mdb.TEXT, nfs.FILE, nfs.SIZE))
|
||||
msg := m.Cmd(CACHE, UPLOAD)
|
||||
if m.Optionv(ice.MSG_UPLOAD, kit.Simple(msg.Append(mdb.HASH), msg.Append(mdb.NAME), msg.Append(nfs.SIZE))); m.Option(ice.MSG_USERPOD) != "" {
|
||||
if nfs.Exists(m, nfs.USR_LOCAL_WORK+m.Option(ice.MSG_USERPOD)) {
|
||||
m.Cmd(nfs.LINK, path.Join(nfs.USR_LOCAL_WORK+m.Option(ice.MSG_USERPOD), msg.Append(nfs.FILE)), msg.Append(nfs.FILE))
|
||||
m.Cmd(SPACE, m.Option(ice.MSG_USERPOD), CACHE, mdb.CREATE, msg.AppendSimple(mdb.NAME, mdb.TEXT, nfs.FILE, nfs.SIZE))
|
||||
} else {
|
||||
m.Cmd(SPACE, m.Option(ice.MSG_USERPOD), SPIDE, ice.DEV, SPIDE_CACHE, http.MethodGet, tcp.PublishLocalhost(m, m.MergeLink(PP(SHARE, CACHE, m.Append(mdb.HASH)))))
|
||||
m.Cmd(SPACE, m.Option(ice.MSG_USERPOD), SPIDE, ice.DEV, SPIDE_CACHE, http.MethodGet, tcp.PublishLocalhost(m, m.MergeLink(PP(SHARE, CACHE, msg.Append(mdb.HASH)))))
|
||||
}
|
||||
}
|
||||
return kit.Simple(m.Optionv(ice.MSG_UPLOAD))
|
||||
|
34
core/code/publish/client.go
Normal file
34
core/code/publish/client.go
Normal file
@ -0,0 +1,34 @@
|
||||
package publish
|
||||
|
||||
import (
|
||||
"path"
|
||||
|
||||
"shylinux.com/x/ice"
|
||||
"shylinux.com/x/icebergs/base/mdb"
|
||||
"shylinux.com/x/icebergs/base/nfs"
|
||||
"shylinux.com/x/icebergs/base/web"
|
||||
)
|
||||
|
||||
type client struct {
|
||||
list string `name:"list client.name auto" help:"软件包"`
|
||||
}
|
||||
|
||||
func (s client) List(m *ice.Message, arg ...string) {
|
||||
if len(arg) == 0 {
|
||||
m.Cmd(web.SPIDE).Table(func(value ice.Maps) {
|
||||
if value[web.CLIENT_TYPE] == nfs.REPOS {
|
||||
m.PushRecord(value, mdb.ICONS, web.CLIENT_NAME)
|
||||
}
|
||||
})
|
||||
m.Display("")
|
||||
} else {
|
||||
m.SplitIndex(m.Cmdx(web.SPIDE, arg[0], "/c/"+m.Prefix("server")))
|
||||
m.PushAction(s.Download)
|
||||
}
|
||||
}
|
||||
func (s client) Download(m *ice.Message, arg ...string) {
|
||||
name := path.Base(m.Option(nfs.PATH))
|
||||
m.Cmd(web.SPIDE, m.Option(web.CLIENT_NAME), web.SPIDE_SAVE, nfs.USR+name, "/publish/"+name)
|
||||
}
|
||||
|
||||
func init() { ice.Cmd("web.code.publish.client", client{}) }
|
14
core/code/publish/client.js
Normal file
14
core/code/publish/client.js
Normal file
@ -0,0 +1,14 @@
|
||||
Volcanos(chat.ONIMPORT, {
|
||||
_init: function(can, msg) {
|
||||
can.ui = can.onappend.layout(can)
|
||||
msg.Table(function(value) {
|
||||
can.onimport.item(can, {icons: value.icons, name: value["client.name"]}, function(event, item) {
|
||||
if (can.onmotion.cache(can, function() { return item.name }, can.ui.content)) { return }
|
||||
can.run(event, [item.name], function(msg) {
|
||||
can.onappend.table(can, msg, null, can.ui.content)
|
||||
|
||||
})
|
||||
})
|
||||
})
|
||||
},
|
||||
})
|
49
core/code/publish/server.go
Normal file
49
core/code/publish/server.go
Normal file
@ -0,0 +1,49 @@
|
||||
package publish
|
||||
|
||||
import (
|
||||
"shylinux.com/x/ice"
|
||||
"shylinux.com/x/icebergs/base/mdb"
|
||||
"shylinux.com/x/icebergs/base/nfs"
|
||||
)
|
||||
|
||||
type server struct {
|
||||
ice.Hash
|
||||
short string `data:"name"`
|
||||
field string `data:"time,name*,text,path,version*,compile,runtime,os,cpu"`
|
||||
list string `name:"list name auto" help:"软件源" role:"void"`
|
||||
}
|
||||
|
||||
func (s server) Inputs(m *ice.Message, arg ...string) {
|
||||
switch arg[0] {
|
||||
case "path":
|
||||
m.Cmdy(nfs.DIR, nfs.USR_PUBLISH, nfs.PATH)
|
||||
case "compile":
|
||||
m.Push(arg[0], "go")
|
||||
m.Push(arg[0], "javac")
|
||||
case "runtime":
|
||||
m.Push(arg[0], "python")
|
||||
m.Push(arg[0], "java")
|
||||
m.Push(arg[0], "php")
|
||||
case "os":
|
||||
m.Push(arg[0], "Linux")
|
||||
m.Push(arg[0], "macOS")
|
||||
m.Push(arg[0], "Windows")
|
||||
case "cpu":
|
||||
m.Push(arg[0], "amd64")
|
||||
m.Push(arg[0], "x86")
|
||||
m.Push(arg[0], "arm")
|
||||
m.Push(arg[0], "arm64")
|
||||
default:
|
||||
s.Hash.Inputs(m, arg...)
|
||||
}
|
||||
}
|
||||
func (s server) Upload(m *ice.Message, arg ...string) {
|
||||
s.Modify(m, mdb.NAME, m.Option(mdb.NAME), nfs.PATH, m.UploadSave(nfs.USR_PUBLISH))
|
||||
}
|
||||
func (s server) List(m *ice.Message, arg ...string) {
|
||||
if s.Hash.List(m, arg...); m.IsTech() {
|
||||
m.PushAction(s.Detail, s.Upload, s.Remove)
|
||||
}
|
||||
}
|
||||
|
||||
func init() { ice.Cmd("web.code.publish.server", server{}) }
|
10
core/code/publish/trans.json
Normal file
10
core/code/publish/trans.json
Normal file
@ -0,0 +1,10 @@
|
||||
{
|
||||
"icons": {},
|
||||
"input": {
|
||||
"compile": "编译器",
|
||||
"runtime": "运行时",
|
||||
"os": "操作系统",
|
||||
"cpu": "芯片架构"
|
||||
},
|
||||
"value": {}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user