1
0
forked from x/ContextOS

tce mod some

This commit is contained in:
shaoying 2018-09-28 23:28:33 +08:00
parent 29430ae745
commit 5f7d55da1a
3 changed files with 82 additions and 85 deletions

View File

@ -6,16 +6,17 @@ install:
@go get github.com/nsf/termbox-go @go get github.com/nsf/termbox-go
@go get github.com/skip2/go-qrcode @go get github.com/skip2/go-qrcode
@go get github.com/gomarkdown/markdown @go get github.com/gomarkdown/markdown
@touch etc/local.shy
@touch etc/local_exit.shy
@touch etc/init.shy
@touch etc/exit.shy
@touch etc/login.txt
@touch etc/history.txt
go install $(BENCH) go install $(BENCH)
# @[ `uname` = "Darwin" ] && md5 `which bench`
@date @date
install_all: install
touch etc/local.shy
touch etc/local_exit.shy
touch etc/init.shy
touch etc/exit.shy
touch etc/login.txt
touch etc/history.txt
build: build:
go build $(BENCH) go build $(BENCH)

View File

@ -17,31 +17,33 @@ syn keyword shStatement if else elif end for
syn keyword shStatement let var syn keyword shStatement let var
" ctx command " ctx command
syn match shStatement "\(^\|\t\|$(\)cache" syn match shStatement "\(^\|\t\|$(\|\ \ \)cache"
syn match shStatement "\(^\|\t\|$(\)config" syn match shStatement "\(^\|\t\|$(\|\ \ \)config"
syn match shStatement "\(^\|\t\|$(\)detail"
syn match shStatement "\(^\|\t\|$(\)option" syn match shStatement "\(^\|\t\|$(\|\ \ \)detail"
syn match shStatement "\(^\|\t\|$(\)append" syn match shStatement "\(^\|\t\|$(\|\ \ \)option"
syn match shStatement "\(^\|\t\|$(\)result" syn match shStatement "\(^\|\t\|$(\|\ \ \)append"
syn match shStatement "\(^\|\t\|$(\|\ \ \)result"
" ctx command " ctx command
syn match shCommand "\(^\|\t\|$(\)message" syn match shCommand "\(^\|\t\|$(\|\ \ \)command"
syn match shCommand "\(^\|\t\|$(\)session" syn match shCommand "\(^\|\t\|$(\|\ \ \)context"
syn match shCommand "\(^\|\t\|$(\)context" syn match shCommand "\(^\|\t\|$(\|\ \ \)message"
syn match shCommand "\(^\|\t\|$(\)server" syn match shCommand "\(^\|\t\|$(\|\ \ \)session"
syn match shCommand "\(^\|\t\|$(\)command" syn match shCommand "\(^\|\t\|$(\|\ \ \)server"
syn match shCommand "\(^\|\t\|$(\)right" syn match shCommand "\(^\|\t\|$(\|\ \ \)right"
" tcp command " tcp command
syn match shCommand "\(^\|\t\|$(\)listen" syn match shCommand "\(^\|\t\|$(\|\ \ \)listen"
" web command " web command
syn match shCommand "\(^\|\t\|$(\)serve" syn match shCommand "\(^\|\t\|$(\|\ \ \)client"
syn match shCommand "\(^\|\t\|$(\)route" syn match shCommand "\(^\|\t\|$(\|\ \ \)serve\$"
syn match shCommand "\(^\|\t\|$(\|\ \ \)route"
syn match shCommand "\(^\|\t\|$(\)open" syn match shCommand "\(^\|\t\|$(\|\ \ \)open"
syn match shCommand "\(^\|\t\|$(\)cookie" syn match shCommand "\(^\|\t\|$(\|\ \ \)cookie"
syn match shCommand "\(^\|\t\|$(\)login" syn match shCommand "\(^\|\t\|$(\|\ \ \)login"
hi def link shComment Comment hi def link shComment Comment
hi def link shString String hi def link shString String

View File

@ -773,16 +773,16 @@ var Index = &ctx.Context{Name: "web", Help: "应用中心",
if k == "" { if k == "" {
continue continue
} }
fields[k] = true if fields[k] = true; len(fields) == 1 {
if len(fields) == 1 {
m.Meta["append"] = append(m.Meta["append"], "index") m.Meta["append"] = append(m.Meta["append"], "index")
} }
m.Meta["append"] = append(m.Meta["append"], k) m.Meta["append"] = append(m.Meta["append"], k)
} }
if len(fields) > 0 {
switch ret := result.(type) { switch ret := result.(type) {
case map[string]interface{}: case map[string]interface{}:
m.Log("fuck", "fuck %v", ret)
m.Append("index", "0") m.Append("index", "0")
for k, v := range ret { for k, v := range ret {
switch value := v.(type) { switch value := v.(type) {
@ -796,8 +796,6 @@ var Index = &ctx.Context{Name: "web", Help: "应用中心",
} }
} }
} }
m.Table()
return
case []interface{}: case []interface{}:
for i, r := range ret { for i, r := range ret {
m.Add("append", "index", i) m.Add("append", "index", i)
@ -810,7 +808,7 @@ var Index = &ctx.Context{Name: "web", Help: "应用中心",
} }
case float64: case float64:
if _, ok := fields[k]; len(fields) == 0 || ok { if _, ok := fields[k]; len(fields) == 0 || ok {
m.Add("append", k, fmt.Sprintf("%v", value)) m.Add("append", k, fmt.Sprintf("%d", int64(value)))
} }
case bool: case bool:
if _, ok := fields[k]; len(fields) == 0 || ok { if _, ok := fields[k]; len(fields) == 0 || ok {
@ -839,16 +837,14 @@ var Index = &ctx.Context{Name: "web", Help: "应用中心",
for i, _ := range ret { for i, _ := range ret {
m.Add("append", "index", i) m.Add("append", "index", i)
} }
m.Table() }
return
} }
} }
result := string(buf) if m.Table(); len(m.Meta["append"]) == 0 {
m.Echo("%s", result) m.Echo("%s", string(buf))
// m.Append("response", result) }
} // }}} } // }}}
}}, }},
"post": &ctx.Command{Name: "post", Help: "访问服务", "post": &ctx.Command{Name: "post", Help: "访问服务",
Hand: func(m *ctx.Message, c *ctx.Context, key string, arg ...string) { Hand: func(m *ctx.Message, c *ctx.Context, key string, arg ...string) {
@ -1597,9 +1593,7 @@ var Index = &ctx.Context{Name: "web", Help: "应用中心",
var data WXMsg var data WXMsg
b, e := ioutil.ReadAll(r.Body) b, e := ioutil.ReadAll(r.Body)
m.Log("fuck", "b: %v", string(b))
e = xml.Unmarshal(b, &data) e = xml.Unmarshal(b, &data)
m.Log("fuck", "b: %#v", data)
// de := xml.NewDecoder(r.Body) // de := xml.NewDecoder(r.Body)
// e := de.Decode(&data) // e := de.Decode(&data)