diff --git a/base/web/dream.go b/base/web/dream.go index fdf357b0..31fd9e27 100644 --- a/base/web/dream.go +++ b/base/web/dream.go @@ -46,11 +46,14 @@ func _dream_show(m *ice.Message, name string) { // 任务模板 if m.Option(nfs.TEMPLATE) != "" { - for _, file := range []string{ice.ETC_MISS_SH, ice.SRC_MAIN_SHY, ice.SRC_MAIN_GO, ice.GO_MOD, ice.MAKEFILE} { + for _, file := range []string{ + ice.ETC_MISS_SH, ice.SRC_MAIN_SHY, ice.SRC_MAIN_GO, + ice.GO_MOD, ice.MAKEFILE, ice.README_MD, + } { if kit.FileExists(path.Join(p, file)) { continue } - switch m.Cmdy(nfs.COPY, path.Join(p, file), path.Join(m.Option(nfs.TEMPLATE), file)); file { + switch m.Cmdy(nfs.COPY, path.Join(p, file), path.Join(m.Config(nfs.PATH), m.Option(nfs.TEMPLATE), file)); file { case ice.GO_MOD: kit.Rewrite(path.Join(p, file), func(line string) string { return kit.Select(line, "module "+name, strings.HasPrefix(line, "module")) @@ -102,7 +105,11 @@ func init() { Index.Merge(&ice.Context{Commands: map[string]*ice.Command{ DREAM: {Name: "dream name path auto start", Help: "梦想家", Action: map[string]*ice.Action{ mdb.INPUTS: {Name: "inputs", Help: "补全", Hand: func(m *ice.Message, arg ...string) { - _dream_list(m).Cut("name,status,time") + switch arg[0] { + case "repos": + default: + _dream_list(m).Cut("name,status,time") + } }}, cli.START: {Name: "start name repos river", Help: "启动", Hand: func(m *ice.Message, arg ...string) { _dream_show(m, m.Option(mdb.NAME, kit.Select(path.Base(m.Option(nfs.REPOS)), m.Option(mdb.NAME)))) @@ -142,15 +149,12 @@ ish_miss_prepare_compile ish_miss_prepare_develop ish_miss_prepare_install -# ish_miss_prepare wubi-dict -# ish_miss_prepare word-dict - -# ish_miss_prepare linux-story +# ish_miss_prepare redis-story # ish_miss_prepare mysql-story # ish_miss_prepare release -ish_miss_prepare_contexts ish_miss_prepare_intshell +ish_miss_prepare_contexts # ish_miss_prepare_icebergs # ish_miss_prepare_toolkits # ish_miss_prepare_volcanos diff --git a/base/web/serve.go b/base/web/serve.go index 78859db8..22a04a7e 100644 --- a/base/web/serve.go +++ b/base/web/serve.go @@ -279,7 +279,6 @@ func init() { cli.NodeInfo(m, WORKER, ice.Info.PathName) AddRewrite(func(w http.ResponseWriter, r *http.Request) bool { if r.Method == SPIDE_GET && r.URL.Path == ice.PS { - msg := m.Spawn(SERVE, w, r) if share := r.URL.Query().Get("share"); share != "" { switch msg := msg.Cmd(SHARE, share); msg.Append(mdb.TYPE) { @@ -289,6 +288,12 @@ func init() { } repos := kit.Select(ice.INTSHELL, ice.VOLCANOS, strings.Contains(r.Header.Get("User-Agent"), "Mozilla/5.0")) + if repos == ice.VOLCANOS { + if s := m.Cmdx("web.chat.website", "show", "index.iml", "Header", "", "River", "", "Action", "", "Footer", ""); s != "" { + Render(msg, ice.RENDER_RESULT, s) + return true + } + } Render(msg, ice.RENDER_DOWNLOAD, path.Join(msg.Config(kit.Keys(repos, nfs.PATH)), msg.Config(kit.Keys(repos, INDEX)))) return true // 网站主页 } diff --git a/conf.go b/conf.go index ddf04029..a43c2d2a 100644 --- a/conf.go +++ b/conf.go @@ -145,10 +145,11 @@ const ( // DIR SRC_VERSION_GO = "src/version.go" SRC_BINPACK_GO = "src/binpack.go" SRC_RELAY_GO = "src/relay.go" + README_MD = "README.md" MAKEFILE = "Makefile" ICE_BIN = "ice.bin" - GO_MOD = "go.mod" GO_SUM = "go.sum" + GO_MOD = "go.mod" ) const ( // MSG MSG_DETAIL = "detail" diff --git a/core/chat/pod.go b/core/chat/pod.go index b2981ac8..e2a6d59a 100644 --- a/core/chat/pod.go +++ b/core/chat/pod.go @@ -5,7 +5,6 @@ import ( 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" ) @@ -27,8 +26,6 @@ func init() { if len(arg) == 1 { if s := m.Cmdx(web.SPACE, arg[0], "web.chat.website", "show", "index.iml", "Header", "", "River", "", "Action", "", "Footer", ""); s != "" { m.RenderResult(s) - } else if s := m.Cmdx(web.SPACE, arg[0], nfs.CAT, "/page/index.html"); s != "" { - m.RenderResult(s) } else { m.RenderIndex(web.SERVE, ice.VOLCANOS) } diff --git a/core/chat/website.go b/core/chat/website.go index 2427a4c9..2e65545d 100644 --- a/core/chat/website.go +++ b/core/chat/website.go @@ -191,6 +191,7 @@ func init() { }) }}, "show": {Hand: func(m *ice.Message, arg ...string) { + m.Debug(m.FormatStack()) if res, ok := _website_parse(m, m.Cmdx(nfs.CAT, path.Join(SRC_WEBSITE, arg[0])), arg[1:]...); ok { m.Echo(_website_template2, kit.Format(res)) } diff --git a/core/code/binpack.go b/core/code/binpack.go index 427af063..6d845996 100644 --- a/core/code/binpack.go +++ b/core/code/binpack.go @@ -38,6 +38,9 @@ func _binpack_dir(m *ice.Message, f *os.File, dir string) { if path.Base(value[nfs.PATH]) == "binpack.go" { return } + if strings.HasPrefix(value[nfs.PATH], "website/") { + return + } fmt.Fprintln(f, _binpack_file(m, path.Join(dir, value[nfs.PATH]))) }) fmt.Fprintln(f) @@ -69,65 +72,48 @@ func init() { Index.Merge(&ice.Context{Commands: map[string]*ice.Command{ BINPACK: {Name: "binpack path auto create remove export", Help: "打包", Action: map[string]*ice.Action{ ice.CTX_INIT: {Hand: func(m *ice.Message, arg ...string) { - ice.Dump = func(w io.Writer, name string, cb func(string)) bool { - for _, key := range []string{name, strings.TrimPrefix(name, ice.USR_VOLCANOS)} { - if key == "/page/index.html" && (kit.FileExists("src/website/index.iml") || len(ice.Info.Pack["src/website/index.iml"]) > 0) { - if s := m.Cmdx("web.chat.website", "show", "index.iml", "Header", "", "River", "", "Action", "", "Footer", ""); s != "" { - fmt.Fprint(w, s) - return true - } - } - - if b, ok := ice.Info.Pack[key]; ok { - if cb != nil { - cb(name) - } - w.Write(b) - return true - } - } - return false - } if kit.FileExists(path.Join(ice.USR_VOLCANOS, ice.PROTO_JS)) { m.Cmd(BINPACK, mdb.REMOVE) - } - if kit.FileExists("src/website/index.iml") || len(ice.Info.Pack["src/website/index.iml"]) > 0 { - if s := m.Cmdx("web.chat.website", "show", "index.iml", "Header", "", "River", "", "Action", "", "Footer", ""); s != "" { - ice.Info.Pack["/page/index.html"] = []byte(s) - } - } - - web.AddRewrite(func(w http.ResponseWriter, r *http.Request) bool { - if len(ice.Info.Pack) == 0 { + } else { + ice.Dump = func(w io.Writer, name string, cb func(string)) bool { + for _, key := range []string{name, strings.TrimPrefix(name, ice.USR_VOLCANOS)} { + if b, ok := ice.Info.Pack[key]; ok { + if cb != nil { + cb(name) + } + w.Write(b) + return true // 打包文件 + } + } return false } - if ice.Dump(w, r.URL.Path, func(name string) { web.RenderType(w, name, "") }) { - return true // 打包文件 - } - return false - }) + web.AddRewrite(func(w http.ResponseWriter, r *http.Request) bool { + if ice.Dump(w, r.URL.Path, func(name string) { web.RenderType(w, name, "") }) { + return true // 打包文件 + } + return false + }) + } + nfs.AddRewrite(func(msg *ice.Message, name string) []byte { - if len(ice.Info.Pack) == 0 { - return nil - } if strings.HasPrefix(name, ice.SRC) && kit.FileExists(name) { return nil } if b, ok := ice.Info.Pack[name]; ok { m.Logs(BINPACK, len(b), name) - return b // 打包文件 - } - if b, ok := ice.Info.Pack[path.Join(ice.PS, name)]; ok && len(b) > 0 { - m.Logs(BINPACK, len(b), name) - return b // 打包文件 + return b } if b, ok := ice.Info.Pack[path.Join(m.Option(nfs.DIR_ROOT), name)]; ok && len(b) > 0 { m.Logs(BINPACK, len(b), name) - return b // 打包文件 + return b } if b, ok := ice.Info.Pack[strings.TrimPrefix(name, ice.USR_VOLCANOS)]; ok && len(b) > 0 { m.Logs(BINPACK, len(b), name) - return b // 打包文件 + return b + } + if b, ok := ice.Info.Pack[path.Join(ice.PS, name)]; ok && len(b) > 0 { + m.Logs(BINPACK, len(b), name) + return b } return nil })