1
0
forked from x/icebergs

opt render

This commit is contained in:
harveyshao 2022-02-24 17:30:28 +08:00
parent d2c1f62102
commit 1e654f3f94
15 changed files with 55 additions and 29 deletions

View File

@ -21,7 +21,7 @@ func init() {
FOREVER: {Name: "forever", Help: "启动", Action: map[string]*ice.Action{ FOREVER: {Name: "forever", Help: "启动", Action: map[string]*ice.Action{
SERVE: {Name: "serve", Help: "服务", Hand: func(m *ice.Message, arg ...string) { SERVE: {Name: "serve", Help: "服务", Hand: func(m *ice.Message, arg ...string) {
env := []string{PATH, BinPath(), HOME, kit.Select(kit.Path(""), os.Getenv(HOME))} env := []string{PATH, BinPath(), HOME, kit.Select(kit.Path(""), os.Getenv(HOME))}
for _, k := range []string{SHELL, CTX_SHY, CTX_DEV, CTX_OPS, CTX_ARG, CTX_PID, CTX_USER, CTX_SHARE, CTX_RIVER} { for _, k := range []string{TERM, SHELL, CTX_SHY, CTX_DEV, CTX_OPS, CTX_ARG, CTX_PID, CTX_USER, CTX_SHARE, CTX_RIVER} {
if kit.Env(k) != "" { if kit.Env(k) != "" {
env = append(env, k, kit.Env(k)) env = append(env, k, kit.Env(k))
} }

View File

@ -120,6 +120,7 @@ const (
) )
const ( const (
SHELL = "SHELL" SHELL = "SHELL"
TERM = "TERM"
USER = "USER" USER = "USER"
HOME = "HOME" HOME = "HOME"
PATH = "PATH" PATH = "PATH"

View File

@ -13,6 +13,8 @@ func init() {
}, Commands: map[string]*ice.Command{ }, Commands: map[string]*ice.Command{
ENGINE: {Name: "engine type name text auto", Help: "引擎", Action: ice.MergeAction(map[string]*ice.Action{ ENGINE: {Name: "engine type name text auto", Help: "引擎", Action: ice.MergeAction(map[string]*ice.Action{
CREATE: {Name: "create type name text", Help: "创建", Hand: func(m *ice.Message, arg ...string) { CREATE: {Name: "create type name text", Help: "创建", Hand: func(m *ice.Message, arg ...string) {
m.Option(NAME, kit.Select(m.Option(TYPE), m.Option(NAME)))
m.Option(TYPE, kit.Ext(m.Option(TYPE)))
m.Cmdy(INSERT, m.PrefixKey(), "", HASH, m.OptionSimple("type,name,text")) m.Cmdy(INSERT, m.PrefixKey(), "", HASH, m.OptionSimple("type,name,text"))
}}, }},
}, HashAction()), Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) { }, HashAction()), Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {

View File

@ -13,6 +13,8 @@ func init() {
}, Commands: map[string]*ice.Command{ }, Commands: map[string]*ice.Command{
PLUGIN: {Name: "plugin type name text auto", Help: "插件", Action: map[string]*ice.Action{ PLUGIN: {Name: "plugin type name text auto", Help: "插件", Action: map[string]*ice.Action{
CREATE: {Name: "create type name text", Help: "创建", Hand: func(m *ice.Message, arg ...string) { CREATE: {Name: "create type name text", Help: "创建", Hand: func(m *ice.Message, arg ...string) {
m.Option(NAME, kit.Select(m.Option(TYPE), m.Option(NAME)))
m.Option(TYPE, kit.Ext(m.Option(TYPE)))
m.Cmdy(INSERT, m.PrefixKey(), "", HASH, m.OptionSimple("type,name,text")) m.Cmdy(INSERT, m.PrefixKey(), "", HASH, m.OptionSimple("type,name,text"))
}}, }},
}, Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) { }, Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
@ -24,6 +26,9 @@ func init() {
} }
if HashSelect(m, arg...); len(arg) == 0 { if HashSelect(m, arg...); len(arg) == 0 {
m.Sort(TYPE) m.Sort(TYPE)
} else if len(arg) == 1 {
m.DisplayStory("json.js")
m.Echo(kit.Formats(m.Confv(m.Append(NAME), "meta.plug")))
} }
}}, }},
}}) }})

View File

@ -13,6 +13,8 @@ func init() {
}, Commands: map[string]*ice.Command{ }, Commands: map[string]*ice.Command{
RENDER: {Name: "render type name text auto", Help: "渲染", Action: map[string]*ice.Action{ RENDER: {Name: "render type name text auto", Help: "渲染", Action: map[string]*ice.Action{
CREATE: {Name: "create type name text", Help: "创建", Hand: func(m *ice.Message, arg ...string) { CREATE: {Name: "create type name text", Help: "创建", Hand: func(m *ice.Message, arg ...string) {
m.Option(NAME, kit.Select(m.Option(TYPE), m.Option(NAME)))
m.Option(TYPE, kit.Ext(m.Option(TYPE)))
m.Cmdy(INSERT, m.PrefixKey(), "", HASH, m.OptionSimple("type,name,text")) m.Cmdy(INSERT, m.PrefixKey(), "", HASH, m.OptionSimple("type,name,text"))
}}, }},
}, Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) { }, Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
@ -24,6 +26,9 @@ func init() {
} }
if HashSelect(m, arg...); len(arg) == 0 { if HashSelect(m, arg...); len(arg) == 0 {
m.Sort(TYPE) m.Sort(TYPE)
} else if len(arg) == 1 {
m.DisplayStory("json.js")
m.Echo(kit.Formats(m.Confv(m.Append(NAME), "meta.plug")))
} }
}}, }},
}}) }})

View File

@ -13,6 +13,8 @@ func init() {
}, Commands: map[string]*ice.Command{ }, Commands: map[string]*ice.Command{
SEARCH: {Name: "search type name text auto", Help: "搜索", Action: map[string]*ice.Action{ SEARCH: {Name: "search type name text auto", Help: "搜索", Action: map[string]*ice.Action{
CREATE: {Name: "create type name text", Help: "创建", Hand: func(m *ice.Message, arg ...string) { CREATE: {Name: "create type name text", Help: "创建", Hand: func(m *ice.Message, arg ...string) {
m.Option(NAME, kit.Select(m.Option(TYPE), m.Option(NAME)))
m.Option(TYPE, kit.Ext(m.Option(TYPE)))
m.Cmdy(INSERT, m.PrefixKey(), "", HASH, m.OptionSimple("type,name,text")) m.Cmdy(INSERT, m.PrefixKey(), "", HASH, m.OptionSimple("type,name,text"))
}}, }},
}, Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) { }, Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {

View File

@ -110,7 +110,8 @@ func (f *Frame) alias(m *ice.Message, ls []string) []string {
return ls return ls
} }
func (f *Frame) parse(m *ice.Message, line string) string { func (f *Frame) parse(m *ice.Message, line string) string {
for _, one := range kit.Split(line, ";", ";", ";") { // for _, one := range kit.Split(line, ";", ";", ";") {
for _, one := range kit.Simple(line) {
msg := m.Spawn(f.target) msg := m.Spawn(f.target)
ls := f.change(msg, f.alias(msg, kit.Split(strings.TrimSpace(one)))) ls := f.change(msg, f.alias(msg, kit.Split(strings.TrimSpace(one))))
if len(ls) == 0 { if len(ls) == 0 {

View File

@ -76,6 +76,7 @@ func _dream_show(m *ice.Message, name string) {
m.Optionv(cli.CMD_ENV, kit.Simple( m.Optionv(cli.CMD_ENV, kit.Simple(
cli.CTX_OPS, "http://:"+m.Cmd(SERVE, ice.OptionFields("")).Append(tcp.PORT), cli.CTX_OPS, "http://:"+m.Cmd(SERVE, ice.OptionFields("")).Append(tcp.PORT),
cli.PATH, cli.BinPath(kit.Path(p, ice.BIN)), cli.HOME, kit.Env(cli.HOME), cli.PATH, cli.BinPath(kit.Path(p, ice.BIN)), cli.HOME, kit.Env(cli.HOME),
cli.SHELL, kit.Env(cli.SHELL), cli.TERM, kit.Env(cli.TERM),
cli.USER, ice.Info.UserName, m.Configv(cli.ENV), cli.USER, ice.Info.UserName, m.Configv(cli.ENV),
)) ))
m.Optionv(cli.CMD_OUTPUT, path.Join(p, ice.BIN_BOOT_LOG)) m.Optionv(cli.CMD_OUTPUT, path.Join(p, ice.BIN_BOOT_LOG))

View File

@ -348,6 +348,11 @@ func init() {
return return
} }
} }
if strings.HasPrefix(arg[0], "ice.") && m.Option(ice.POD) != "" {
aaa.UserRoot(m)
_share_local(m, "bin/ice.bin")
return
}
_share_local(m, m.Conf(SERVE, kit.Keym(ice.PUBLISH)), path.Join(arg...)) _share_local(m, m.Conf(SERVE, kit.Keym(ice.PUBLISH)), path.Join(arg...))
}}, }},
"/help/": {Name: "/help/", Help: "帮助", Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) { "/help/": {Name: "/help/", Help: "帮助", Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {

View File

@ -80,7 +80,7 @@ func _share_local(m *ice.Message, arg ...string) {
} }
// 上传文件 // 上传文件
m.Cmdy(SPACE, m.Option(ice.POD), SPIDE, ice.DEV, SPIDE_RAW, m.MergeURL2(SHARE_PROXY, nfs.PATH, ""), m.Cmd(SPACE, m.Option(ice.POD), SPIDE, ice.DEV, SPIDE_RAW, m.MergeURL2(SHARE_PROXY, nfs.PATH, ""),
SPIDE_PART, m.OptionSimple(ice.POD), nfs.PATH, p, CACHE, cache.Format(ice.MOD_TIME), UPLOAD, "@"+p) SPIDE_PART, m.OptionSimple(ice.POD), nfs.PATH, p, CACHE, cache.Format(ice.MOD_TIME), UPLOAD, "@"+p)
if s, e := os.Stat(pp); e == nil && !s.IsDir() { if s, e := os.Stat(pp); e == nil && !s.IsDir() {
@ -88,7 +88,7 @@ func _share_local(m *ice.Message, arg ...string) {
} }
} }
if strings.HasSuffix(p, path.Join(ice.USR_PUBLISH, ice.ORDER_JS)) { if strings.HasSuffix(p, path.Join(ice.USR_PUBLISH, ice.ORDER_JS)) {
if _, e := os.Stat(p); os.IsNotExist(e) { if !kit.FileExists(p) {
m.RenderResult("") m.RenderResult("")
return return
} }

View File

@ -60,7 +60,7 @@ func _inner_make(m *ice.Message, msg *ice.Message) {
func LoadPlug(m *ice.Message, language ...string) { func LoadPlug(m *ice.Message, language ...string) {
for _, language := range language { for _, language := range language {
m.Conf(nfs.CAT, kit.Keym(nfs.SOURCE, language), ice.TRUE) m.Conf(nfs.CAT, kit.Keym(nfs.SOURCE, kit.Ext(language)), ice.TRUE)
m.Confm(language, kit.Keym(PLUG, PREPARE), func(key string, value interface{}) { m.Confm(language, kit.Keym(PLUG, PREPARE), func(key string, value interface{}) {
for _, v := range kit.Simple(value) { for _, v := range kit.Simple(value) {
m.Conf(language, kit.Keym(PLUG, KEYWORD, v), key) m.Conf(language, kit.Keym(PLUG, KEYWORD, v), key)

View File

@ -1,6 +1,7 @@
package wiki package wiki
import ( import (
"path"
"strings" "strings"
ice "shylinux.com/x/icebergs" ice "shylinux.com/x/icebergs"
@ -10,7 +11,7 @@ import (
kit "shylinux.com/x/toolkits" kit "shylinux.com/x/toolkits"
) )
func Parse(m *ice.Message, meta string, key string, arg ...string) *ice.Message { func Parse(m *ice.Message, meta string, key string, arg ...string) (data interface{}) {
list := []string{} list := []string{}
for _, line := range kit.Split(strings.Join(arg, ice.SP), ice.NL) { for _, line := range kit.Split(strings.Join(arg, ice.SP), ice.NL) {
ls := kit.Split(line) ls := kit.Split(line)
@ -23,13 +24,13 @@ func Parse(m *ice.Message, meta string, key string, arg ...string) *ice.Message
list = append(list, ls...) list = append(list, ls...)
} }
switch data := kit.Parse(nil, "", list...); meta { switch data = kit.Parse(nil, "", list...); meta {
case ice.MSG_OPTION: case ice.MSG_OPTION:
m.Option(key, data) m.Option(key, data)
case ice.MSG_APPEND: case ice.MSG_APPEND:
m.Append(key, data) m.Append(key, data)
} }
return m return data
} }
func _field_show(m *ice.Message, name, text string, arg ...string) { func _field_show(m *ice.Message, name, text string, arg ...string) {
// 命令参数 // 命令参数
@ -47,17 +48,13 @@ func _field_show(m *ice.Message, name, text string, arg ...string) {
// 扩展参数 // 扩展参数
for i := 0; i < len(arg)-1; i += 2 { for i := 0; i < len(arg)-1; i += 2 {
if strings.HasPrefix(arg[i], "opts.") { if strings.HasPrefix(arg[i], "opts.") {
m.Option(arg[i], strings.TrimSpace(arg[i+1])) kit.Value(meta, arg[i], m.Optionv(arg[i], strings.TrimSpace(arg[i+1])))
kit.Value(meta, arg[i], m.Option(arg[i]))
} else if strings.HasPrefix(arg[i], "args.") { } else if strings.HasPrefix(arg[i], "args.") {
m.Option(arg[i], strings.TrimSpace(arg[i+1])) kit.Value(meta, arg[i], m.Optionv(arg[i], strings.TrimSpace(arg[i+1])))
kit.Value(meta, arg[i], m.Option(arg[i]))
} else if strings.HasPrefix(arg[i], ARGS) { } else if strings.HasPrefix(arg[i], ARGS) {
m.Option(arg[i], kit.Split(strings.TrimSuffix(strings.TrimPrefix(arg[i+1], "["), "]"))) kit.Value(meta, arg[i], m.Optionv(arg[i], kit.Split(strings.TrimSuffix(strings.TrimPrefix(arg[i+1], "["), "]"))))
kit.Value(meta, arg[i], m.Optionv(arg[i]))
} else { } else {
Parse(m, ice.MSG_OPTION, arg[i], arg[i+1]) kit.Value(meta, arg[i], Parse(m, ice.MSG_OPTION, arg[i], arg[i+1]))
kit.Value(meta, arg[i], m.Optionv(arg[i]))
} }
switch arg[i] { switch arg[i] {
@ -65,9 +62,17 @@ func _field_show(m *ice.Message, name, text string, arg ...string) {
meta[arg[i]] = arg[i+1] meta[arg[i]] = arg[i+1]
case SPARK: case SPARK:
msg.Echo(strings.TrimSpace(arg[i+1])) if arg[i+1][0] == '@' && kit.FileExists(arg[i+1][1:]) {
meta["msg"] = msg.FormatMeta() msg.Cmdy(nfs.CAT, arg[i+1][1:])
} else {
msg.Echo(strings.TrimSpace(arg[i+1]))
}
kit.Value(meta, kit.Keys(FEATURE, "mode"), "simple") kit.Value(meta, kit.Keys(FEATURE, "mode"), "simple")
if meta["msg"] = msg.FormatMeta(); text == "web.code.inner" {
meta["plug"] = kit.UnMarshal(m.Cmdx(mdb.PLUGIN, kit.Ext(name)))
kit.Value(meta, ARGS, kit.List(path.Dir(name)+ice.PS, path.Base(name)))
}
case TABLE: case TABLE:
ls := kit.Split(arg[i+1], ice.NL, ice.NL, ice.NL) ls := kit.Split(arg[i+1], ice.NL, ice.NL, ice.NL)
@ -98,8 +103,7 @@ func _field_show(m *ice.Message, name, text string, arg ...string) {
meta[INPUTS] = list meta[INPUTS] = list
} }
default: default:
msg.Option(arg[i], arg[i+1]) kit.Value(meta, kit.Keys(FEATURE, arg[i]), msg.Optionv(arg[i], arg[i+1]))
kit.Value(meta, kit.Keys(FEATURE, arg[i]), arg[i+1])
} }
} }
m.Option(mdb.META, meta) m.Option(mdb.META, meta)

View File

@ -111,11 +111,11 @@ func Run(arg ...string) string {
switch Index.Merge(Index).Begin(Pulse.Spawn(), arg...); kit.Select("", arg, 0) { switch Index.Merge(Index).Begin(Pulse.Spawn(), arg...); kit.Select("", arg, 0) {
case SERVE, SPACE: // 启动服务 case SERVE, SPACE: // 启动服务
switch path.Base(os.Getenv("SHELL")) { switch strings.Split(os.Getenv("TERM"), "-")[0] {
case "", ".": case "xterm", "screen":
Info.Colors = false
default:
Info.Colors = true Info.Colors = true
default:
Info.Colors = false
} }
if log.LogDisable = false; Index.Start(Pulse, arg...) { if log.LogDisable = false; Index.Start(Pulse, arg...) {
Pulse.TryCatch(Pulse, true, func(Pulse *Message) { Index.wg.Wait() }) Pulse.TryCatch(Pulse, true, func(Pulse *Message) { Index.wg.Wait() })

View File

@ -136,13 +136,10 @@ func (m *Message) ToastProcess(arg ...interface{}) func() {
arg = append(arg, "-1") arg = append(arg, "-1")
} }
m.Toast(PROCESS, arg...) m.Toast(PROCESS, arg...)
return func() { return func() { m.Toast(SUCCESS) }
m.Debug("what ----- %v", 123)
m.Toast(SUCCESS, arg...)
}
} }
func (m *Message) ToastRestart(arg ...interface{}) { m.Toast(RESTART, arg...) } func (m *Message) ToastRestart(arg ...interface{}) { m.Toast(RESTART, arg...) }
func (m *Message) ToastFailure(arg ...interface{}) { m.Toast(SUCCESS, arg...) } func (m *Message) ToastFailure(arg ...interface{}) { m.Toast(FAILURE, arg...) }
func (m *Message) ToastSuccess(arg ...interface{}) { m.Toast(SUCCESS, arg...) } func (m *Message) ToastSuccess(arg ...interface{}) { m.Toast(SUCCESS, arg...) }
func (m *Message) Toast(text string, arg ...interface{}) { // [title [duration [progress]]] func (m *Message) Toast(text string, arg ...interface{}) { // [title [duration [progress]]]
if len(arg) > 1 { if len(arg) > 1 {

View File

@ -223,6 +223,9 @@ func (m *Message) EchoDownload(arg ...interface{}) *Message { // [name] file
} }
func (m *Message) DisplayBase(file string, arg ...interface{}) *Message { func (m *Message) DisplayBase(file string, arg ...interface{}) *Message {
if !strings.Contains(file, PT) {
file += ".js"
}
m.Option(MSG_DISPLAY, kit.MergeURL(DisplayBase(file)[DISPLAY], arg...)) m.Option(MSG_DISPLAY, kit.MergeURL(DisplayBase(file)[DISPLAY], arg...))
return m return m
} }