1
0
forked from x/icebergs
This commit is contained in:
IT 老营长 @云轩领航-创始人 2024-01-10 14:41:09 +08:00
parent 4d891fd380
commit fb3b822496
7 changed files with 64 additions and 66 deletions

View File

@ -103,7 +103,7 @@ func _dir_list(m *ice.Message, root string, dir string, level int, deep bool, di
m.PushDownload(mdb.LINK, p)
}
case mdb.SHOW:
switch p := m.MergeLink(ice.SHARE_LOCAL+p, ice.POD, m.Option(ice.MSG_USERPOD)); kit.Ext(s.Name()) {
switch p := m.MergeLink(SHARE_LOCAL+p, ice.POD, m.Option(ice.MSG_USERPOD)); kit.Ext(s.Name()) {
case PNG, JPG:
m.PushImages(field, p)
case MP4:
@ -142,6 +142,7 @@ const (
BIN = "bin/"
VAR = "var/"
USR = "usr/"
USR_PORTAL = ice.USR_PORTAL
USR_PUBLISH = ice.USR_PUBLISH
USR_ICEBERGS = ice.USR_ICEBERGS
@ -149,6 +150,10 @@ const (
USR_LOCAL = ice.USR_LOCAL
SRC_DOCUMENT = ice.SRC_DOCUMENT
SRC_TEMPLATE = ice.SRC_TEMPLATE
USR_PACKAGE = "usr/package.json"
USR_MODULES = "usr/node_modules/"
SHARE_LOCAL = "/share/local/"
REQUIRE_MODULES = "/require/modules/"
REQUIRE_SRC = "/require/src/"
REQUIRE_USR = "/require/usr/"
REQUIRE = "/require/"
@ -230,7 +235,7 @@ func Relative(m *ice.Message, p string) string {
}
}
func SplitPath(m *ice.Message, p string) []string {
if kit.HasPrefix(p, ice.REQUIRE_SRC, ice.REQUIRE_USR) {
if kit.HasPrefix(p, REQUIRE_SRC, REQUIRE_USR) {
p = strings.TrimPrefix(p, REQUIRE)
} else if kit.HasPrefix(p, REQUIRE) {
ls := kit.Split(p, PS)
@ -262,7 +267,7 @@ func DirDeepAll(m *ice.Message, root, dir string, cb func(ice.Maps), arg ...stri
}
}
func Show(m *ice.Message, file string) bool {
p := ice.SHARE_LOCAL + file
p := SHARE_LOCAL + file
kit.If(m.Option(ice.MSG_USERPOD), func(pod string) {
p += "?" + kit.JoinKV("=", "&", ice.POD, pod)
})

View File

@ -84,10 +84,10 @@ func _serve_static(msg *ice.Message, w http.ResponseWriter, r *http.Request) boo
return Render(msg, ice.RENDER_DOWNLOAD, p)
} else if p = path.Join(nfs.USR, r.URL.Path); kit.HasPrefix(r.URL.Path, nfs.VOLCANOS, nfs.INTSHELL) && nfs.Exists(msg, p) {
return Render(msg, ice.RENDER_DOWNLOAD, p)
} else if p = strings.TrimPrefix(r.URL.Path, nfs.REQUIRE); kit.HasPrefix(r.URL.Path, ice.REQUIRE_SRC, nfs.REQUIRE+ice.USR_ICONS, nfs.REQUIRE+ice.USR_ICEBERGS) && nfs.Exists(msg, p) {
} else if p = strings.TrimPrefix(r.URL.Path, nfs.REQUIRE); kit.HasPrefix(r.URL.Path, nfs.REQUIRE_SRC, nfs.REQUIRE+ice.USR_ICONS, nfs.REQUIRE+ice.USR_ICEBERGS) && nfs.Exists(msg, p) {
ispod := kit.Contains(r.URL.String(), CHAT_POD, "pod=") || kit.Contains(r.Header.Get(html.Referer), CHAT_POD, "pod=")
return !ispod && Render(msg, ice.RENDER_DOWNLOAD, p)
} else if p = path.Join(ice.USR_MODULES, strings.TrimPrefix(r.URL.Path, ice.REQUIRE_MODULES)); kit.HasPrefix(r.URL.Path, ice.REQUIRE_MODULES) && nfs.Exists(msg, p) {
} else if p = path.Join(nfs.USR_MODULES, strings.TrimPrefix(r.URL.Path, nfs.REQUIRE_MODULES)); kit.HasPrefix(r.URL.Path, nfs.REQUIRE_MODULES) && nfs.Exists(msg, p) {
return Render(msg, ice.RENDER_DOWNLOAD, p)
} else {
return false

42
conf.go
View File

@ -24,6 +24,8 @@ const (
HTTPS = "https"
HTTP = "http"
MAIL = "mail"
DEMO = "demo"
HELP = "help"
MAIN = "main"
AUTO = "auto"
@ -37,12 +39,10 @@ const (
SHY = "shy"
DEV = "dev"
OPS = "ops"
DEMO = "demo"
MAIL = "mail"
APP = "app"
ICE = "ice"
CAN = "can"
APP = "app"
POD = "pod"
CMD = "cmd"
@ -54,14 +54,14 @@ const (
)
const ( // REPOS
CONTEXTS = "contexts"
LEARNING = "learning"
RELEASE = "release"
ICONS = "icons"
VOLCANOS = "volcanos"
INTSHELL = "intshell"
ICEBERGS = "icebergs"
VOLCANOS = "volcanos"
LEARNING = "learning"
TOOLKITS = "toolkits"
ICEBERGS = "icebergs"
RELEASE = "release"
MATRIX = "matrix"
ICONS = "icons"
INSTALL = "install"
REQUIRE = "require"
@ -107,32 +107,26 @@ const ( // DIR
FRAME_JS = "frame.js"
INDEX_SH = "index.sh"
FAVICON_ICO = "/favicon.ico"
PLUGIN_INPUT = "/plugin/input/"
PLUGIN_LOCAL = "/plugin/local/"
PLUGIN_STORY = "/plugin/story/"
PLUGIN_TABLE_JS = "/plugin/table.js"
REQUIRE_MODULES = "/require/modules/"
REQUIRE_USR = "/require/usr/"
REQUIRE_SRC = "/require/src/"
SHARE_LOCAL = "/share/local/"
ISH_PLUGED = ".ish/pluged/"
USR_PACKAGE = "usr/package.json"
USR_MODULES = "usr/node_modules/"
USR_GEOAREA = "usr/geoarea/"
USR_RELEASE = "usr/release/"
USR_LEARNING = "usr/learning/"
USR_VOLCANOS = "usr/volcanos/"
USR_INTSHELL = "usr/intshell/"
USR_ICEBERGS = "usr/icebergs/"
USR_TOOLKITS = "usr/toolkits/"
USR_LOCAL = "usr/local/"
USR_PORTAL = "usr/portal/"
USR_INSTALL = "usr/install/"
USR_REQUIRE = "usr/require/"
USR_PUBLISH = "usr/publish/"
USR_RELEASE = "usr/release/"
USR_ICEBERGS = "usr/icebergs/"
USR_TOOLKITS = "usr/toolkits/"
USR_VOLCANOS = "usr/volcanos/"
USR_LEARNING = "usr/learning/"
USR_INTSHELL = "usr/intshell/"
USR_PROGRAM = "usr/program/"
USR_PORTAL = "usr/portal/"
USR_LOCAL = "usr/local/"
USR_GEOAREA = "usr/geoarea/"
USR_ICONS = "usr/icons/"
USR_LOCAL_GO = "usr/local/go/"

View File

@ -16,7 +16,7 @@ const ICON = "icon"
func init() {
Index.MergeCommands(ice.Commands{
ICON: {Help: "图标", Actions: ctx.ConfAction(nfs.PATH, "bootstrap-icons/font/bootstrap-icons.css"), Hand: func(m *ice.Message, arg ...string) {
m.Cmd(lex.SPLIT, ice.USR_MODULES+mdb.Config(m, nfs.PATH), kit.Dict(lex.SPLIT_SPACE, " {:;}"), func(text string, ls []string) {
m.Cmd(lex.SPLIT, nfs.USR_MODULES+mdb.Config(m, nfs.PATH), kit.Dict(lex.SPLIT_SPACE, " {:;}"), func(text string, ls []string) {
if len(ls) > 2 && ls[2] == nfs.CONTENT {
name := "bi " + strings.TrimPrefix(ls[0], nfs.PT)
m.Push(mdb.NAME, name).Push(mdb.ICON, kit.Format(`<i class="%s"></i>`, name))

View File

@ -58,14 +58,14 @@ const VIMER = "vimer"
func init() {
web.Index.MergeCommands(ice.Commands{ice.CTX_INIT: {Hand: func(m *ice.Message, arg ...string) { aaa.White(m, nfs.REQUIRE) }},
ice.REQUIRE_SRC: {Hand: func(m *ice.Message, arg ...string) { web.ShareLocalFile(m, ice.SRC, path.Join(arg...)) }},
ice.REQUIRE_USR: {Hand: func(m *ice.Message, arg ...string) { web.ShareLocalFile(m, ice.USR, path.Join(arg...)) }},
ice.REQUIRE_MODULES: {Hand: func(m *ice.Message, arg ...string) {
p := path.Join(ice.USR_MODULES, path.Join(arg...))
nfs.REQUIRE_SRC: {Hand: func(m *ice.Message, arg ...string) { web.ShareLocalFile(m, ice.SRC, path.Join(arg...)) }},
nfs.REQUIRE_USR: {Hand: func(m *ice.Message, arg ...string) { web.ShareLocalFile(m, ice.USR, path.Join(arg...)) }},
nfs.REQUIRE_MODULES: {Hand: func(m *ice.Message, arg ...string) {
p := path.Join(nfs.USR_MODULES, path.Join(arg...))
kit.If(!nfs.Exists(m, p), func() {
if kit.IsIn(m.Option(ice.MSG_USERROLE), aaa.TECH, aaa.ROOT) {
kit.If(!nfs.Exists(m, ice.USR_PACKAGE), func() {
m.Cmd(nfs.SAVE, ice.USR_PACKAGE, kit.Formats(kit.Dict(mdb.NAME, "usr", nfs.VERSION, "0.0.1")))
kit.If(!nfs.Exists(m, nfs.USR_PACKAGE), func() {
m.Cmd(nfs.SAVE, nfs.USR_PACKAGE, kit.Formats(kit.Dict(mdb.NAME, "usr", nfs.VERSION, "0.0.1")))
})
m.Cmd(cli.SYSTEM, "npm", INSTALL, arg[0], kit.Dict(cli.CMD_DIR, ice.USR))
}

View File

@ -19,8 +19,8 @@ import (
func _volcanos(m *ice.Message, p ...string) string { return ice.USR_VOLCANOS + path.Join(p...) }
func _publish(m *ice.Message, p ...string) string { return ice.USR_PUBLISH + path.Join(p...) }
func _require(m *ice.Message, p string) string {
if kit.HasPrefix(p, ice.USR_MODULES) {
return path.Join("/require/modules/", strings.TrimPrefix(p, ice.USR_MODULES))
if kit.HasPrefix(p, nfs.USR_MODULES) {
return path.Join("/require/modules/", strings.TrimPrefix(p, nfs.USR_MODULES))
} else if kit.HasPrefix(p, ice.USR_VOLCANOS) {
return path.Join("/volcanos/", strings.TrimPrefix(p, ice.USR_VOLCANOS))
} else if kit.HasPrefix(p, nfs.SRC, nfs.USR) {
@ -83,10 +83,10 @@ func _webpack_cache(m *ice.Message, dir string, write bool) {
mdb.HashSelects(m).Sort(nfs.PATH).Table(func(value ice.Maps) {
defer fmt.Fprintln(js, "")
if p := value[nfs.PATH]; kit.Ext(p) == nfs.CSS {
_webpack_css(m, css, js, path.Join(ice.USR_MODULES, p))
_webpack_css(m, css, js, path.Join(nfs.USR_MODULES, p))
} else {
p = kit.Select(path.Join(p, LIB, kit.Keys(p, JS)), p, kit.Ext(p) == nfs.JS)
_webpack_node(m, js, path.Join(ice.USR_MODULES, p))
_webpack_node(m, js, path.Join(nfs.USR_MODULES, p))
}
})
}

View File

@ -90,8 +90,7 @@ func (c *Context) ID() int32 { return atomic.AddInt32(&c.id, 1) }
func (c *Context) Register(s *Context, x Server, cmd ...string) *Context {
kit.For(cmd, func(cmd string) {
if s, ok := Info.Index[cmd].(*Context); ok {
println(kit.Format("%s %s registed by %v", ErrWarn, cmd, s.Name))
// panic(kit.Format("%s %s registed by %v", ErrWarn, cmd, s.Name))
panic(kit.Format("%s %s registed by %v", ErrWarn, cmd, s.Name))
}
Info.Index[cmd] = s
})