1
0
mirror of https://shylinux.com/x/ContextOS synced 2025-04-25 08:48:06 +08:00

del componet_ prefix

This commit is contained in:
shaoying 2019-09-12 20:13:28 +08:00
parent 88b9cdf868
commit 09d1f96090
10 changed files with 1127 additions and 1126 deletions

1066
README.md

File diff suppressed because it is too large Load Diff

1
README.md Symbolic link
View File

@ -0,0 +1 @@
usr/local/wiki/自然/编程/index.md

View File

@ -4,5 +4,5 @@ var version = struct {
host string
self int
}{
"2019-09-12 14:33:20", "centos", 524,
"2019-09-12 16:21:30", "centos", 529,
}

View File

@ -47,10 +47,11 @@ func dir(m *ctx.Message, root string, name string, level int, deep bool, dir_typ
}
p := path.Join(name, f.Name())
f, e := os.Stat(p)
if e != nil {
if f, e = os.Lstat(p); e != nil {
m.Log("info", "%s", e)
continue
} else if (f.Mode() & os.ModeSymlink) != 0 {
continue
}
if !(dir_type == "file" && f.IsDir() || dir_type == "dir" && !f.IsDir()) && (dir_reg == nil || dir_reg.MatchString(f.Name())) {

View File

@ -83,47 +83,47 @@ var Index = &ctx.Context{Name: "ssh", Help: "集群中心",
Configs: map[string]*ctx.Config{
"componet": {Name: "componet", Value: map[string]interface{}{
"index": []interface{}{
map[string]interface{}{"componet_name": "ifconfig", "componet_help": "ifconfig",
"componet_tmpl": "componet", "componet_view": "", "componet_init": "",
"componet_type": "private", "componet_ctx": "ssh", "componet_cmd": "_route",
"componet_args": []interface{}{"_", "tcp.ifconfig"}, "inputs": []interface{}{
map[string]interface{}{"name": "ifconfig", "help": "ifconfig",
"tmpl": "componet", "view": "", "init": "",
"type": "private", "ctx": "ssh", "cmd": "_route",
"args": []interface{}{"_", "tcp.ifconfig"}, "inputs": []interface{}{
map[string]interface{}{"type": "text", "name": "pod", "value": "", "imports": "plugin_pod"},
map[string]interface{}{"type": "button", "value": "查看"},
},
},
map[string]interface{}{"componet_name": "proc", "componet_help": "proc",
"componet_tmpl": "componet", "componet_view": "", "componet_init": "",
"componet_type": "private", "componet_ctx": "ssh", "componet_cmd": "_route",
"componet_args": []interface{}{"_", "cli.proc"}, "inputs": []interface{}{
map[string]interface{}{"name": "proc", "help": "proc",
"tmpl": "componet", "view": "", "init": "",
"type": "private", "ctx": "ssh", "cmd": "_route",
"args": []interface{}{"_", "cli.proc"}, "inputs": []interface{}{
map[string]interface{}{"type": "text", "name": "pod", "value": "", "imports": "plugin_pod"},
map[string]interface{}{"type": "text", "name": "arg", "value": ""},
map[string]interface{}{"type": "text", "name": "filter", "view": "long"},
map[string]interface{}{"type": "button", "value": "执行"},
},
},
map[string]interface{}{"componet_name": "spide", "componet_help": "爬虫",
"componet_tmpl": "componet", "componet_view": "Context", "componet_init": "",
"componet_type": "private", "componet_ctx": "ssh", "componet_cmd": "_route",
"componet_args": []interface{}{"_", "context", "web", "spide"}, "inputs": []interface{}{
map[string]interface{}{"name": "spide", "help": "爬虫",
"tmpl": "componet", "view": "Context", "init": "",
"type": "private", "ctx": "ssh", "cmd": "_route",
"args": []interface{}{"_", "context", "web", "spide"}, "inputs": []interface{}{
map[string]interface{}{"type": "text", "name": "pod", "imports": "plugin_pod"},
map[string]interface{}{"type": "button", "value": "执行"},
},
"exports": []interface{}{"site", "key"},
},
map[string]interface{}{"componet_name": "post", "componet_help": "请求",
"componet_tmpl": "componet", "componet_view": "Context", "componet_init": "",
"componet_type": "private", "componet_ctx": "ssh", "componet_cmd": "_route",
"componet_args": []interface{}{"_", "web.post", "__", "content_type", "application/json", "parse", "json"}, "inputs": []interface{}{
map[string]interface{}{"name": "post", "help": "请求",
"tmpl": "componet", "view": "Context", "init": "",
"type": "private", "ctx": "ssh", "cmd": "_route",
"args": []interface{}{"_", "web.post", "__", "content_type", "application/json", "parse", "json"}, "inputs": []interface{}{
map[string]interface{}{"type": "text", "name": "pod", "imports": "plugin_pod"},
map[string]interface{}{"type": "text", "name": "spide", "value": "dev", "imports": "plugin_site"},
map[string]interface{}{"type": "text", "name": "url", "value": "/", "view": "long"},
map[string]interface{}{"type": "button", "value": "执行"},
},
},
map[string]interface{}{"componet_name": "get", "componet_help": "请求",
"componet_tmpl": "componet", "componet_view": "Context", "componet_init": "",
"componet_type": "private", "componet_ctx": "ssh", "componet_cmd": "_route",
"componet_args": []interface{}{"_", "web.get", "__", "method", "GET", "parse", "json"}, "inputs": []interface{}{
map[string]interface{}{"name": "get", "help": "请求",
"tmpl": "componet", "view": "Context", "init": "",
"type": "private", "ctx": "ssh", "cmd": "_route",
"args": []interface{}{"_", "web.get", "__", "method", "GET", "parse", "json"}, "inputs": []interface{}{
map[string]interface{}{"type": "text", "name": "pod", "imports": "plugin_pod"},
map[string]interface{}{"type": "text", "name": "spide", "value": "dev", "imports": "plugin_site"},
map[string]interface{}{"type": "text", "name": "url", "value": "/", "view": "long"},
@ -303,14 +303,14 @@ var Index = &ctx.Context{Name: "ssh", Help: "集群中心",
"tool": {Name: "tool [group index][run group index chatid arg...]", Help: "工具", Hand: func(m *ctx.Message, c *ctx.Context, key string, arg ...string) (e error) {
if len(arg) == 0 {
m.Confm("componet", func(key string, index int, value map[string]interface{}) {
if kit.Format(value["componet_type"]) != "public" && m.Option("userrole") != "root" {
if kit.Format(value["type"]) != "public" && m.Option("userrole") != "root" {
return
}
m.Push("key", key)
m.Push("index", index)
m.Push("name", value["componet_name"])
m.Push("help", value["componet_help"])
m.Push("name", value["name"])
m.Push("help", value["help"])
})
m.Table()
return
@ -321,7 +321,7 @@ var Index = &ctx.Context{Name: "ssh", Help: "集群中心",
m.Option("plugin", arg[1])
tool := m.Confm("componet", []string{arg[1], arg[2]})
if m.Option("userrole") != "root" {
switch kit.Format(tool["componet_type"]) {
switch kit.Format(tool["type"]) {
case "private":
m.Echo("private componet of %s", m.Conf("runtime", "work.name"))
return
@ -333,7 +333,7 @@ var Index = &ctx.Context{Name: "ssh", Help: "集群中心",
}
}
msg := m.Find(kit.Format(tool["componet_ctx"]))
msg := m.Find(kit.Format(tool["ctx"]))
if option, ok := tool["options"].(map[string]interface{}); ok {
for k, v := range option {
msg.Option(k, v)
@ -345,7 +345,7 @@ var Index = &ctx.Context{Name: "ssh", Help: "集群中心",
arg = arg[4:]
args := []string{}
for _, v := range kit.Trans(tool["componet_args"]) {
for _, v := range kit.Trans(tool["args"]) {
if strings.HasPrefix(v, "__") {
if len(arg) > 0 {
args, arg = append(args, arg...), nil
@ -361,31 +361,31 @@ var Index = &ctx.Context{Name: "ssh", Help: "集群中心",
}
}
msg.Log("time", "check: %v", m.Format("cost"))
if msg.Cmd(tool["componet_cmd"], args, arg).CopyTo(m); !msg.Hand {
msg.Log("warn", "not found %v:%v", tool["componet_ctx"], tool["componet_cmd"])
if msg.Cmd(tool["cmd"], args, arg).CopyTo(m); !msg.Hand {
msg.Log("warn", "not found %v:%v", tool["ctx"], tool["cmd"])
}
default:
m.Confm("componet", arg[0:], func(value map[string]interface{}) {
if kit.Format(value["componet_type"]) == "private" && m.Option("userrole") != "root" {
if kit.Format(value["type"]) == "private" && m.Option("userrole") != "root" {
return
}
m.Push("name", value["componet_name"])
m.Push("help", value["componet_help"])
if kit.Right(value["componet_init"]) {
script := m.Cmdx("nfs.load", path.Join(m.Conf("cli.project", "plugin.path"), arg[0], kit.Format(value["componet_init"])), -1)
m.Push("name", value["name"])
m.Push("help", value["help"])
if kit.Right(value["init"]) {
script := m.Cmdx("nfs.load", path.Join(m.Conf("cli.project", "plugin.path"), arg[0], kit.Format(value["init"])), -1)
if script == "" {
script = m.Cmdx("nfs.load", path.Join("usr/librarys/plugin", kit.Format(value["componet_init"])), -1)
script = m.Cmdx("nfs.load", path.Join("usr/librarys/plugin", kit.Format(value["init"])), -1)
}
m.Push("init", script)
} else {
m.Push("init", "")
}
if kit.Right(value["componet_view"]) {
script := m.Cmdx("nfs.load", path.Join(m.Conf("cli.project", "plugin.path"), arg[0], kit.Format(value["componet_view"])), -1)
if kit.Right(value["view"]) {
script := m.Cmdx("nfs.load", path.Join(m.Conf("cli.project", "plugin.path"), arg[0], kit.Format(value["view"])), -1)
if script == "" {
script = m.Cmdx("nfs.load", path.Join("usr/librarys/plugin", kit.Format(value["componet_view"])), -1)
script = m.Cmdx("nfs.load", path.Join("usr/librarys/plugin", kit.Format(value["view"])), -1)
}
m.Push("view", script)
} else {

View File

@ -1168,15 +1168,15 @@ var Index = &ctx.Context{Name: "yac", Help: "语法中心",
}
m.Confv("_index", []interface{}{-2}, map[string]interface{}{
"componet_name": kit.Select("", arg, 1),
"componet_help": kit.Select("", arg, 2),
"componet_view": view,
"componet_init": init,
"componet_type": right,
"name": kit.Select("", arg, 1),
"help": kit.Select("", arg, 2),
"view": view,
"init": init,
"type": right,
"componet_ctx": m.Cap("module"),
"componet_cmd": cmd,
"componet_args": args,
"ctx": m.Cap("module"),
"cmd": cmd,
"args": args,
"inputs": inputs,
"exports": exports,
"feature": feature,

View File

@ -1,6 +1,6 @@
{init: function(run, field, option, output) {return {
ondaemon: {
table: function(msg, cb) {if (msg.event.type == "blur") {return}
table: function(msg, cb) {if (msg.event && msg.event.type == "blur") {return}
var plugin = field.Plugin
output.innerHTML = "", msg.append && kit.OrderTable(kit.AppendTable(kit.AppendChild(output, "table"), ctx.Table(msg), msg.append), "", function(event, value, name, line, index) {
if (name == "id") {

View File

@ -28,7 +28,7 @@ legend {
}
fieldset>form.option div {
margin-right:6px;
margin-right:3px;
float:left;
}
fieldset>form.option div.hide {
@ -38,7 +38,7 @@ fieldset>form.option div.clear {
clear:both;
}
fieldset>form.option label {
margin-right:6px;
margin-right:3px;
}
fieldset>form.option div input.args {
width:80px;

View File

@ -711,10 +711,7 @@ function Plugin(page, pane, field, runs) {
item[k] == undefined && (item[k] = typeof cb == "function"? function(event) {
cb(event, action, item.type, name, item)
}: cb)
})
var count = kit.Selector(option, ".args").length
args && count < args.length && (item.value = value||args[count++]||item.value||"");
});
(item.title || item.name) && (item.title = item.title || item.name)
item.title && (item.placeholder = item.title)
@ -736,10 +733,13 @@ function Plugin(page, pane, field, runs) {
case "text":
item.className = "args"
item.autocomplete = "off"
var count = kit.Selector(option, ".args").length
args && count < args.length && (item.value = value||args[count++]||item.value||"");
break
}
var ui = kit.AppendChild(option, [{view: [item.view||""], data: {title: item.title}, list: [{type: "label", inner: item.label||""}, input]}])
var ui = kit.AppendChild(option, [{view: [item.view||""], list: [{type: "label", inner: item.label||""}, input]}])
var action = Meta(ui[name] || {}, item, plugin.onaction, plugin);
(typeof item.imports == "object"? item.imports: typeof item.imports == "string"? [item.imports]: []).forEach(function(imports) {
@ -993,7 +993,7 @@ function Plugin(page, pane, field, runs) {
page.action.scrollTo(0, field.offsetTop)
break
case "b":
plugin.Append({className: "args temp"}).focus()
plugin.Append({className: "args temp", type: "text"}).focus()
break
case "m":
plugin.Clone().Select()
@ -1012,6 +1012,6 @@ function Plugin(page, pane, field, runs) {
exports: JSON.parse(meta.exports||'["",""]'),
})
inputs.map(plugin.Append)
inputs.map(function(item) {plugin.Append(item)})
return page[field.id] = pane[field.id] = pane[name] = field, field.Plugin = plugin
}

View File

@ -268,7 +268,7 @@ kit = toolkit = {
}
} else if (child.view) {
child.data["className"] = child.view[0]
(child.view.length > 0 && child.view[0]) && (child.data["className"] = child.view[0])
child.type = child.view.length > 1? child.view[1]: "div"
child.view.length > 2 && (child.data["innerHTML"] = child.view[2])
child.view.length > 3 && (child.name = child.view[3])

View File

@ -1 +0,0 @@
终端工具链/context.md

File diff suppressed because it is too large Load Diff