mirror of
https://shylinux.com/x/icebergs
synced 2025-04-26 01:24:05 +08:00
opt pack
This commit is contained in:
parent
e0dc333601
commit
c5d8e0a7d4
@ -2,7 +2,10 @@ package chat
|
||||
|
||||
import (
|
||||
"github.com/shylinux/icebergs"
|
||||
"github.com/shylinux/icebergs/base/nfs"
|
||||
"github.com/shylinux/toolkits"
|
||||
|
||||
"fmt"
|
||||
)
|
||||
|
||||
const (
|
||||
@ -11,6 +14,24 @@ const (
|
||||
TITLE = "title"
|
||||
)
|
||||
const HEADER = "header"
|
||||
const _pack = `
|
||||
<!DOCTYPE html>
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width,initial-scale=0.7,user-scalable=no">
|
||||
<title>volcanos</title>
|
||||
<link rel="shortcut icon" type="image/ico" href="favicon.ico">
|
||||
<style type="text/css">%s</style>
|
||||
<style type="text/css">%s</style>
|
||||
</head>
|
||||
<body>
|
||||
<script>%s</script>
|
||||
<script>%s</script>
|
||||
<script>%s</script>
|
||||
<script>%s</script>
|
||||
<script>Volcanos.meta.webpack = true</script>
|
||||
</body>
|
||||
`
|
||||
|
||||
func init() {
|
||||
Index.Merge(&ice.Context{
|
||||
@ -29,13 +50,26 @@ func init() {
|
||||
}},
|
||||
|
||||
"pack": {Name: "pack", Help: "打包", Hand: func(m *ice.Message, arg ...string) {
|
||||
if f, p, e := kit.Create("usr/volcanos/cache_data.js"); m.Assert(e) {
|
||||
m.Cmdy("web.code.webpack", "pack")
|
||||
|
||||
if f, _, e := kit.Create("usr/volcanos/pack/" + m.Option("name") + "/cache.js"); m.Assert(e) {
|
||||
defer f.Close()
|
||||
data := kit.UnMarshal(m.Option("content"))
|
||||
f.WriteString(`Volcanos.meta.pack = ` + kit.Formats(data))
|
||||
}
|
||||
|
||||
if f, p, e := kit.Create("usr/volcanos/pack/" + m.Option("name") + "/index.html"); m.Assert(e) {
|
||||
f.WriteString(fmt.Sprintf(_pack,
|
||||
m.Cmdx(nfs.CAT, "usr/volcanos/cache.css"),
|
||||
m.Cmdx(nfs.CAT, "usr/volcanos/index.css"),
|
||||
|
||||
m.Cmdx(nfs.CAT, "usr/volcanos/proto.js"),
|
||||
m.Cmdx(nfs.CAT, "usr/volcanos/cache.js"),
|
||||
m.Cmdx(nfs.CAT, "usr/volcanos/pack/"+m.Option("name")+"/cache.js"),
|
||||
m.Cmdx(nfs.CAT, "usr/volcanos/index.js"),
|
||||
))
|
||||
m.Echo(p)
|
||||
}
|
||||
m.Cmdy("web.code.webpack")
|
||||
}},
|
||||
}, Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
|
||||
m.Echo(m.Conf(HEADER, TITLE))
|
||||
|
@ -2,7 +2,9 @@ package code
|
||||
|
||||
import (
|
||||
ice "github.com/shylinux/icebergs"
|
||||
"github.com/shylinux/icebergs/base/mdb"
|
||||
"github.com/shylinux/icebergs/base/nfs"
|
||||
"github.com/shylinux/icebergs/base/web"
|
||||
kit "github.com/shylinux/toolkits"
|
||||
|
||||
"fmt"
|
||||
@ -120,66 +122,46 @@ const (
|
||||
func init() {
|
||||
Index.Merge(&ice.Context{
|
||||
Commands: map[string]*ice.Command{
|
||||
WEBPACK: {Name: "webpack", Help: "打包", Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
|
||||
WEBPACK: {Name: "webpack", Help: "打包", Action: map[string]*ice.Action{
|
||||
"pack": {Name: "pack", Help: "打包", Hand: func(m *ice.Message, arg ...string) {
|
||||
m.Option(nfs.DIR_ROOT, "usr/volcanos")
|
||||
m.Option(nfs.DIR_DEEP, "true")
|
||||
m.Option(nfs.DIR_TYPE, nfs.FILE)
|
||||
|
||||
js, p, e := kit.Create("usr/volcanos/cache.js")
|
||||
m.Assert(e)
|
||||
defer js.Close()
|
||||
m.Echo(p)
|
||||
|
||||
css, _, e := kit.Create("usr/volcanos/cache.css")
|
||||
m.Assert(e)
|
||||
defer css.Close()
|
||||
|
||||
for _, k := range []string{"lib", "pane", "plugin"} {
|
||||
m.Cmd(nfs.DIR, k).Table(func(index int, value map[string]string, head []string) {
|
||||
if strings.HasSuffix(value["path"], ".css") {
|
||||
js.WriteString(`Volcanos.meta.cache["` + path.Join("/", value["path"]) + "\"] = []\n")
|
||||
css.WriteString(m.Cmdx(nfs.CAT, "usr/volcanos/"+value["path"]))
|
||||
}
|
||||
if strings.HasSuffix(value["path"], ".js") {
|
||||
js.WriteString(`_can_name = "` + path.Join("/", value["path"]) + "\"\n")
|
||||
js.WriteString(m.Cmdx(nfs.CAT, "usr/volcanos/"+value["path"]))
|
||||
}
|
||||
})
|
||||
}
|
||||
for _, k := range []string{"frame.js"} {
|
||||
js.WriteString(`_can_name = "` + path.Join("/", k) + "\"\n")
|
||||
js.WriteString(m.Cmdx(nfs.CAT, "usr/volcanos/"+k))
|
||||
}
|
||||
}},
|
||||
}, Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
|
||||
m.Option(nfs.DIR_ROOT, "usr/volcanos")
|
||||
m.Option(nfs.DIR_DEEP, "true")
|
||||
m.Option(nfs.DIR_TYPE, nfs.FILE)
|
||||
|
||||
js, p, e := kit.Create("usr/volcanos/cache.js")
|
||||
m.Assert(e)
|
||||
defer js.Close()
|
||||
m.Echo(p)
|
||||
|
||||
css, _, e := kit.Create("usr/volcanos/cache.css")
|
||||
m.Assert(e)
|
||||
defer css.Close()
|
||||
|
||||
for _, k := range []string{"lib", "pane", "plugin"} {
|
||||
m.Cmd(nfs.DIR, k).Table(func(index int, value map[string]string, head []string) {
|
||||
if strings.HasSuffix(value["path"], ".css") {
|
||||
js.WriteString(`Volcanos.meta.cache["` + path.Join("/", value["path"]) + "\"] = []\n")
|
||||
css.WriteString(m.Cmdx(nfs.CAT, "usr/volcanos/"+value["path"]))
|
||||
}
|
||||
if strings.HasSuffix(value["path"], ".js") {
|
||||
js.WriteString(`_can_name = "` + path.Join("/", value["path"]) + "\"\n")
|
||||
js.WriteString(m.Cmdx(nfs.CAT, "usr/volcanos/"+value["path"]))
|
||||
}
|
||||
})
|
||||
}
|
||||
for _, k := range []string{"frame.js"} {
|
||||
js.WriteString(`_can_name = "` + path.Join("/", k) + "\"\n")
|
||||
js.WriteString(m.Cmdx(nfs.CAT, "usr/volcanos/"+k))
|
||||
}
|
||||
js.WriteString(`_can_name = ""` + "\n")
|
||||
|
||||
if f, _, e := kit.Create("usr/volcanos/cache.html"); m.Assert(e) {
|
||||
f.WriteString(fmt.Sprintf(`
|
||||
<!DOCTYPE html>
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width,initial-scale=0.7,user-scalable=no">
|
||||
<title>volcanos</title>
|
||||
<link rel="shortcut icon" type="image/ico" href="favicon.ico">
|
||||
<style type="text/css">%s</style>
|
||||
<style type="text/css">%s</style>
|
||||
</head>
|
||||
<body>
|
||||
<script>%s</script>
|
||||
<script>%s</script>
|
||||
<script>%s</script>
|
||||
<script>%s</script>
|
||||
<script>Volcanos.meta.webpack = true</script>
|
||||
</body>
|
||||
`,
|
||||
m.Cmdx(nfs.CAT, "usr/volcanos/cache.css"),
|
||||
m.Cmdx(nfs.CAT, "usr/volcanos/index.css"),
|
||||
|
||||
m.Cmdx(nfs.CAT, "usr/volcanos/proto.js"),
|
||||
m.Cmdx(nfs.CAT, "usr/volcanos/cache.js"),
|
||||
m.Cmdx(nfs.CAT, "usr/volcanos/cache_data.js"),
|
||||
m.Cmdx(nfs.CAT, "usr/volcanos/index.js"),
|
||||
))
|
||||
}
|
||||
m.Option(nfs.DIR_DEEP, "true")
|
||||
m.Cmdy(nfs.DIR, "pack")
|
||||
m.Table(func(index int, value map[string]string, head []string) {
|
||||
m.Push("link", m.Cmdx(mdb.RENDER, web.RENDER.A, "/"+value["path"]))
|
||||
})
|
||||
}},
|
||||
BINPACK: {Name: "binpack", Help: "打包", Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
|
||||
pack, p, e := kit.Create("usr/icebergs/pack/binpack.go")
|
||||
@ -202,5 +184,4 @@ func init() {
|
||||
}},
|
||||
},
|
||||
}, nil)
|
||||
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user