1
0
forked from x/ContextOS

add usr/librarys/plugin

This commit is contained in:
shaoying 2019-05-24 02:15:58 +08:00
parent c049690d83
commit 778fecd781
5 changed files with 62 additions and 81 deletions

View File

@ -311,7 +311,7 @@ func (web *WEB) Begin(m *ctx.Message, arg ...string) ctx.Server {
web.ServeMux = http.NewServeMux()
web.Template = template.New("render").Funcs(ctx.CGI)
web.Template.ParseGlob(path.Join(m.Conf("serve", "template_dir"), m.Cap("route"), "/*.tmpl"))
web.Template.ParseGlob(path.Join(m.Cap("directory"), m.Conf("serve", "template_dir"), m.Cap("route"), "/*.tmpl"))
return web
}
func (web *WEB) Start(m *ctx.Message, arg ...string) bool {
@ -412,7 +412,7 @@ var Index = &ctx.Context{Name: "web", Help: "应用中心",
}, Help: "服务配置"},
"route": &ctx.Config{Name: "route", Value: map[string]interface{}{
"index": "/render",
"template_dir": "usr/template",
"template_dir": "template",
"template_debug": true,
"componet_index": "index",
"toolkit_view": map[string]interface{}{
@ -837,7 +837,7 @@ var Index = &ctx.Context{Name: "web", Help: "应用中心",
web.Template = template.New("render").Funcs(ctx.CGI)
}
dir := path.Join(m.Confx("template_dir", arg, 1), arg[0])
dir := path.Join(m.Cap("directory"), m.Confx("template_dir", arg, 1), arg[0])
if t, e := web.Template.ParseGlob(dir); e == nil {
web.Template = t
} else {
@ -920,8 +920,9 @@ var Index = &ctx.Context{Name: "web", Help: "应用中心",
tmpl := web.Template
if m.Confs("route", "template_debug") {
tmpl = template.New("render").Funcs(ctx.CGI)
tmpl.ParseGlob(path.Join(m.Conf("route", "template_dir"), "/*.tmpl"))
tmpl.ParseGlob(path.Join(m.Conf("route", "template_dir"), m.Cap("route"), "/*.tmpl"))
t, e := tmpl.ParseGlob(path.Join(m.Cap("directory"), m.Conf("route", "template_dir"), "/*.tmpl"))
m.Log("fuck", "what %v %v", e, t)
tmpl.ParseGlob(path.Join(m.Cap("directory"), m.Conf("route", "template_dir"), m.Cap("route"), "/*.tmpl"))
}
// 权限检查

View File

@ -139,9 +139,9 @@ var Index = &ctx.Context{Name: "chat", Help: "会议中心",
switch arg[1] {
case "create":
h := kit.Hashs("uniq")
h := kit.Select(kit.Hashs("uniq"), arg, 2)
user := map[string]interface{}{}
for _, v := range arg[3:] {
for _, v := range arg[4:] {
u := m.Cmdx("ssh.remote", m.Conf("runtime", "work.route"), "check", "work", v)
user[v] = map[string]interface{}{
"user": u,
@ -152,7 +152,8 @@ var Index = &ctx.Context{Name: "chat", Help: "会议中心",
"conf": map[string]interface{}{
"create_user": m.Option("username"),
"create_time": m.Time(),
"name": kit.Select("what", arg, 2),
"name": kit.Select("what", arg, 3),
"route": kit.Select(m.Conf("runtime", "node.route"), m.Option("node.route"), arg[2] != ""),
},
"user": user,
"text": map[string]interface{}{},
@ -160,7 +161,18 @@ var Index = &ctx.Context{Name: "chat", Help: "会议中心",
})
m.Echo(h)
m.Option("username", m.Conf("runtime", "user.name"))
m.Confm("flow", []string{h, "user"}, func(key string, value map[string]interface{}) {
m.Cmd("ssh.remote", value["user"], "context", "chat", "flow", "river", "create", h, arg[3])
})
case "user":
if m.Conf("flow", []string{arg[2], "conf.route"}) != m.Conf("runtime", "node.route") {
m.Cmdy("ssh.remote", m.Conf("flow", []string{arg[2], "conf.route"}), "context", "chat", "flow", arg)
m.Log("info", "upstream")
return
}
if len(arg) == 3 {
m.Confm("flow", []string{arg[2], "user"}, func(key string, value map[string]interface{}) {
m.Add("append", "key", key)
@ -169,9 +181,6 @@ var Index = &ctx.Context{Name: "chat", Help: "会议中心",
m.Table()
return
}
switch arg[3] {
case "add":
}
case "wave":
if len(arg) == 3 {
@ -184,6 +193,13 @@ var Index = &ctx.Context{Name: "chat", Help: "会议中心",
return
}
if m.Conf("flow", []string{arg[2], "conf.route"}) != m.Conf("runtime", "node.route") && len(arg) == 5 {
m.Cmdy("ssh.remote", m.Conf("flow", []string{arg[2], "conf.route"}),
"context", "chat", "flow", "river", "wave", arg[2], arg[3], arg[4])
m.Log("info", "upstream")
return
}
m.Conf("flow", []string{arg[2], "text.list.-2"}, map[string]interface{}{
"create_user": m.Option("username"),
"create_time": m.Time(),
@ -197,59 +213,7 @@ var Index = &ctx.Context{Name: "chat", Help: "会议中心",
m.Option("username", m.Conf("runtime", "user.name"))
m.Confm("flow", []string{arg[2], "user"}, func(key string, value map[string]interface{}) {
m.Cmd("ssh.remote", value["user"], "context", "chat", "flow", "river", "wave", arg[2], arg[3], arg[4])
})
case "tool":
if len(arg) == 3 {
m.Confm("flow", []string{arg[2], "tool"}, func(key string, value map[string]interface{}) {
m.Add("append", "key", key)
m.Add("append", "create_user", value["create_user"])
m.Add("append", "create_time", value["create_time"])
if list, ok := kit.Chain(value, "list").([]interface{}); ok {
m.Add("append", "count", len(list))
} else {
m.Add("append", "count", 0)
}
})
m.Table()
return
}
if m.Confs("flow", []string{arg[2], "tool", arg[3]}) {
if len(arg) == 4 {
m.Confm("flow", []string{arg[2], "tool", arg[3], "list"}, func(index int, value map[string]interface{}) {
m.Add("append", "cmd", value["cmd"])
})
m.Table()
} else {
switch arg[4] {
case "add":
for _, v := range arg[5:] {
m.Conf("flow", []interface{}{arg[2], "tool", arg[3], "list", -2}, map[string]interface{}{
"cmd": v,
})
}
default:
if cmd := m.Confm("flow", []string{arg[2], "tool", arg[3], "list", arg[4]}); cmd != nil {
m.Cmdy("ctx.context", "cli", cmd["cmd"])
}
}
}
return
}
list := []interface{}{}
for _, v := range arg[4:] {
list = append(list, map[string]interface{}{
"cmd": v,
})
}
m.Conf("flow", []string{arg[2], "tool", arg[3]}, map[string]interface{}{
"create_user": m.Option("username"),
"create_time": m.Time(),
"list": list,
m.Cmd("ssh.remote", value["user"], "context", "chat", "flow", "river", "wave", arg[2], arg[3], arg[4], "sync")
})
}
@ -269,12 +233,6 @@ var Index = &ctx.Context{Name: "chat", Help: "会议中心",
"list": list,
})
case "wind":
switch arg[2] {
case "text":
}
default:
if len(arg) == 2 {
m.Confm("flow", []string{arg[1], "tool"}, func(key string, value map[string]interface{}) {

View File

@ -67,7 +67,7 @@ var page = Page({
return
}
var cmd = ["river", "create", ui.name.value]
var cmd = ["river", "create", "", ui.name.value]
ui.list.querySelectorAll("pre").forEach(function(item) {
cmd.push(item.innerText)
})
@ -200,10 +200,6 @@ var page = Page({
})
}
pane.Action = {
"添加": function(event) {
var name = prompt("name")
name && form.Run(["river", "tool", river, water, "add", name], pane.Show)
},
"恢复": function(event) {
page.onlayout(event, page.conf.layout)
},
@ -217,7 +213,7 @@ var page = Page({
page.onlayout(event, {river:0, action: -1, storm:0})
},
}
return {"button": ["添加", "恢复", "放大", "最宽", "最大"], "action": pane.Action}
return {"button": ["恢复", "放大", "最宽", "最大"], "action": pane.Action}
},
initStorm: function(page, pane, form, output) {
var river = ""

View File

@ -0,0 +1,15 @@
{
show: function(item, index, intpus, event, option) {
var args = item.value == "所有"? ["all"]: []
option.Run(event, args, function(msg) {
option.ondaemon(msg)
})
},
init: function(page, pane, plugin, option, output) {
option.ondaemon = function(msg) {
output.innerHTML = ""
kit.AppendChild(output, [{type: "code", list: [{text: [msg.result.join(""), "pre"]}]}])
}
output.innerHTML = "hello"
}
}

View File

@ -268,15 +268,26 @@ $ cat etc/local.shy
chat模块提供了信息管理。
访问http://localhost:9094/chat
启动服务节点
boot.sh
```
~cli
runtime work.route mac
~ssh
cert work serve
```
启动用户节点
```
~ssh
cert user create
cert work create
```
访问用户节点http://localhost:9094/chat
- 左侧添加群聊
- 右侧添加组件
- 中间发送消息
- 下边发送命令
### 所有目录
#### 一级目录