diff --git a/core/chat/header.go b/core/chat/header.go index cb26eada..a6ac521d 100644 --- a/core/chat/header.go +++ b/core/chat/header.go @@ -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 = ` + + + + + volcanos + + + + + + + + + + + +` 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)) diff --git a/core/code/pack.go b/core/code/pack.go index 3a613798..4cdc0335 100644 --- a/core/code/pack.go +++ b/core/code/pack.go @@ -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(` - - - - - volcanos - - - - - - - - - - - -`, - 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) - }