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

View File

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

View File

@ -1,6 +1,6 @@
{init: function(run, field, option, output) {return { {init: function(run, field, option, output) {return {
ondaemon: { 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 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) { 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") { if (name == "id") {

View File

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

View File

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