forked from x/icebergs
opt some
This commit is contained in:
parent
a36d017203
commit
10819db8ef
@ -46,11 +46,14 @@ func _dream_show(m *ice.Message, name string) {
|
|||||||
|
|
||||||
// 任务模板
|
// 任务模板
|
||||||
if m.Option(nfs.TEMPLATE) != "" {
|
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)) {
|
if kit.FileExists(path.Join(p, file)) {
|
||||||
continue
|
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:
|
case ice.GO_MOD:
|
||||||
kit.Rewrite(path.Join(p, file), func(line string) string {
|
kit.Rewrite(path.Join(p, file), func(line string) string {
|
||||||
return kit.Select(line, "module "+name, strings.HasPrefix(line, "module"))
|
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{
|
Index.Merge(&ice.Context{Commands: map[string]*ice.Command{
|
||||||
DREAM: {Name: "dream name path auto start", Help: "梦想家", Action: map[string]*ice.Action{
|
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) {
|
mdb.INPUTS: {Name: "inputs", Help: "补全", Hand: func(m *ice.Message, arg ...string) {
|
||||||
|
switch arg[0] {
|
||||||
|
case "repos":
|
||||||
|
default:
|
||||||
_dream_list(m).Cut("name,status,time")
|
_dream_list(m).Cut("name,status,time")
|
||||||
|
}
|
||||||
}},
|
}},
|
||||||
cli.START: {Name: "start name repos river", Help: "启动", Hand: func(m *ice.Message, arg ...string) {
|
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))))
|
_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_develop
|
||||||
ish_miss_prepare_install
|
ish_miss_prepare_install
|
||||||
|
|
||||||
# ish_miss_prepare wubi-dict
|
# ish_miss_prepare redis-story
|
||||||
# ish_miss_prepare word-dict
|
|
||||||
|
|
||||||
# ish_miss_prepare linux-story
|
|
||||||
# ish_miss_prepare mysql-story
|
# ish_miss_prepare mysql-story
|
||||||
# ish_miss_prepare release
|
# ish_miss_prepare release
|
||||||
|
|
||||||
ish_miss_prepare_contexts
|
|
||||||
ish_miss_prepare_intshell
|
ish_miss_prepare_intshell
|
||||||
|
ish_miss_prepare_contexts
|
||||||
# ish_miss_prepare_icebergs
|
# ish_miss_prepare_icebergs
|
||||||
# ish_miss_prepare_toolkits
|
# ish_miss_prepare_toolkits
|
||||||
# ish_miss_prepare_volcanos
|
# ish_miss_prepare_volcanos
|
||||||
|
@ -279,7 +279,6 @@ func init() {
|
|||||||
cli.NodeInfo(m, WORKER, ice.Info.PathName)
|
cli.NodeInfo(m, WORKER, ice.Info.PathName)
|
||||||
AddRewrite(func(w http.ResponseWriter, r *http.Request) bool {
|
AddRewrite(func(w http.ResponseWriter, r *http.Request) bool {
|
||||||
if r.Method == SPIDE_GET && r.URL.Path == ice.PS {
|
if r.Method == SPIDE_GET && r.URL.Path == ice.PS {
|
||||||
|
|
||||||
msg := m.Spawn(SERVE, w, r)
|
msg := m.Spawn(SERVE, w, r)
|
||||||
if share := r.URL.Query().Get("share"); share != "" {
|
if share := r.URL.Query().Get("share"); share != "" {
|
||||||
switch msg := msg.Cmd(SHARE, share); msg.Append(mdb.TYPE) {
|
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"))
|
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))))
|
Render(msg, ice.RENDER_DOWNLOAD, path.Join(msg.Config(kit.Keys(repos, nfs.PATH)), msg.Config(kit.Keys(repos, INDEX))))
|
||||||
return true // 网站主页
|
return true // 网站主页
|
||||||
}
|
}
|
||||||
|
3
conf.go
3
conf.go
@ -145,10 +145,11 @@ const ( // DIR
|
|||||||
SRC_VERSION_GO = "src/version.go"
|
SRC_VERSION_GO = "src/version.go"
|
||||||
SRC_BINPACK_GO = "src/binpack.go"
|
SRC_BINPACK_GO = "src/binpack.go"
|
||||||
SRC_RELAY_GO = "src/relay.go"
|
SRC_RELAY_GO = "src/relay.go"
|
||||||
|
README_MD = "README.md"
|
||||||
MAKEFILE = "Makefile"
|
MAKEFILE = "Makefile"
|
||||||
ICE_BIN = "ice.bin"
|
ICE_BIN = "ice.bin"
|
||||||
GO_MOD = "go.mod"
|
|
||||||
GO_SUM = "go.sum"
|
GO_SUM = "go.sum"
|
||||||
|
GO_MOD = "go.mod"
|
||||||
)
|
)
|
||||||
const ( // MSG
|
const ( // MSG
|
||||||
MSG_DETAIL = "detail"
|
MSG_DETAIL = "detail"
|
||||||
|
@ -5,7 +5,6 @@ import (
|
|||||||
|
|
||||||
ice "shylinux.com/x/icebergs"
|
ice "shylinux.com/x/icebergs"
|
||||||
"shylinux.com/x/icebergs/base/ctx"
|
"shylinux.com/x/icebergs/base/ctx"
|
||||||
"shylinux.com/x/icebergs/base/nfs"
|
|
||||||
"shylinux.com/x/icebergs/base/web"
|
"shylinux.com/x/icebergs/base/web"
|
||||||
kit "shylinux.com/x/toolkits"
|
kit "shylinux.com/x/toolkits"
|
||||||
)
|
)
|
||||||
@ -27,8 +26,6 @@ func init() {
|
|||||||
if len(arg) == 1 {
|
if len(arg) == 1 {
|
||||||
if s := m.Cmdx(web.SPACE, arg[0], "web.chat.website", "show", "index.iml", "Header", "", "River", "", "Action", "", "Footer", ""); s != "" {
|
if s := m.Cmdx(web.SPACE, arg[0], "web.chat.website", "show", "index.iml", "Header", "", "River", "", "Action", "", "Footer", ""); s != "" {
|
||||||
m.RenderResult(s)
|
m.RenderResult(s)
|
||||||
} else if s := m.Cmdx(web.SPACE, arg[0], nfs.CAT, "/page/index.html"); s != "" {
|
|
||||||
m.RenderResult(s)
|
|
||||||
} else {
|
} else {
|
||||||
m.RenderIndex(web.SERVE, ice.VOLCANOS)
|
m.RenderIndex(web.SERVE, ice.VOLCANOS)
|
||||||
}
|
}
|
||||||
|
@ -191,6 +191,7 @@ func init() {
|
|||||||
})
|
})
|
||||||
}},
|
}},
|
||||||
"show": {Hand: func(m *ice.Message, arg ...string) {
|
"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 {
|
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))
|
m.Echo(_website_template2, kit.Format(res))
|
||||||
}
|
}
|
||||||
|
@ -38,6 +38,9 @@ func _binpack_dir(m *ice.Message, f *os.File, dir string) {
|
|||||||
if path.Base(value[nfs.PATH]) == "binpack.go" {
|
if path.Base(value[nfs.PATH]) == "binpack.go" {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
if strings.HasPrefix(value[nfs.PATH], "website/") {
|
||||||
|
return
|
||||||
|
}
|
||||||
fmt.Fprintln(f, _binpack_file(m, path.Join(dir, value[nfs.PATH])))
|
fmt.Fprintln(f, _binpack_file(m, path.Join(dir, value[nfs.PATH])))
|
||||||
})
|
})
|
||||||
fmt.Fprintln(f)
|
fmt.Fprintln(f)
|
||||||
@ -69,65 +72,48 @@ func init() {
|
|||||||
Index.Merge(&ice.Context{Commands: map[string]*ice.Command{
|
Index.Merge(&ice.Context{Commands: map[string]*ice.Command{
|
||||||
BINPACK: {Name: "binpack path auto create remove export", Help: "打包", Action: map[string]*ice.Action{
|
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.CTX_INIT: {Hand: func(m *ice.Message, arg ...string) {
|
||||||
|
if kit.FileExists(path.Join(ice.USR_VOLCANOS, ice.PROTO_JS)) {
|
||||||
|
m.Cmd(BINPACK, mdb.REMOVE)
|
||||||
|
} else {
|
||||||
ice.Dump = func(w io.Writer, name string, cb func(string)) bool {
|
ice.Dump = func(w io.Writer, name string, cb func(string)) bool {
|
||||||
for _, key := range []string{name, strings.TrimPrefix(name, ice.USR_VOLCANOS)} {
|
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 b, ok := ice.Info.Pack[key]; ok {
|
||||||
if cb != nil {
|
if cb != nil {
|
||||||
cb(name)
|
cb(name)
|
||||||
}
|
}
|
||||||
w.Write(b)
|
w.Write(b)
|
||||||
return true
|
return true // 打包文件
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return false
|
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 {
|
web.AddRewrite(func(w http.ResponseWriter, r *http.Request) bool {
|
||||||
if len(ice.Info.Pack) == 0 {
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
if ice.Dump(w, r.URL.Path, func(name string) { web.RenderType(w, name, "") }) {
|
if ice.Dump(w, r.URL.Path, func(name string) { web.RenderType(w, name, "") }) {
|
||||||
return true // 打包文件
|
return true // 打包文件
|
||||||
}
|
}
|
||||||
return false
|
return false
|
||||||
})
|
})
|
||||||
nfs.AddRewrite(func(msg *ice.Message, name string) []byte {
|
|
||||||
if len(ice.Info.Pack) == 0 {
|
|
||||||
return nil
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
nfs.AddRewrite(func(msg *ice.Message, name string) []byte {
|
||||||
if strings.HasPrefix(name, ice.SRC) && kit.FileExists(name) {
|
if strings.HasPrefix(name, ice.SRC) && kit.FileExists(name) {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
if b, ok := ice.Info.Pack[name]; ok {
|
if b, ok := ice.Info.Pack[name]; ok {
|
||||||
m.Logs(BINPACK, len(b), name)
|
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 // 打包文件
|
|
||||||
}
|
}
|
||||||
if b, ok := ice.Info.Pack[path.Join(m.Option(nfs.DIR_ROOT), name)]; ok && len(b) > 0 {
|
if b, ok := ice.Info.Pack[path.Join(m.Option(nfs.DIR_ROOT), name)]; ok && len(b) > 0 {
|
||||||
m.Logs(BINPACK, len(b), name)
|
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 {
|
if b, ok := ice.Info.Pack[strings.TrimPrefix(name, ice.USR_VOLCANOS)]; ok && len(b) > 0 {
|
||||||
m.Logs(BINPACK, len(b), name)
|
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
|
return nil
|
||||||
})
|
})
|
||||||
|
Loading…
x
Reference in New Issue
Block a user