From b936d4dbb9749c8980ef12d7c15f9be0da0981b4 Mon Sep 17 00:00:00 2001 From: shaoying Date: Sun, 17 Nov 2019 14:13:58 +0800 Subject: [PATCH] add ShyTask.vim --- etc/conf/auto.vim | 6 +++- src/contexts/ssh/ssh.go | 4 ++- src/examples/code/code.go | 5 ++++ src/examples/team/team.go | 53 ++++++++++++++++++++++-------------- src/examples/wiki/wiki.go | 6 ++-- src/plugin/feature/index.js | 3 +- src/plugin/feature/index.shy | 22 ++++++++------- src/plugin/story/index.js | 2 +- usr/librarys/example.css | 4 +++ usr/librarys/example.js | 11 +++++--- 10 files changed, 73 insertions(+), 43 deletions(-) diff --git a/etc/conf/auto.vim b/etc/conf/auto.vim index 61a90a1a..73439a5a 100644 --- a/etc/conf/auto.vim +++ b/etc/conf/auto.vim @@ -85,6 +85,9 @@ fun! ShyFavor(note) endif call ShyPost({"cmd": "favor", "tab": g:favor_tab, "note": g:favor_note, "arg": getline("."), "line": getpos(".")[1], "col": getpos(".")[2]}) endfun +fun! ShyTask() + call ShyPost({"cmd": "tasklet", "arg": input("target: "), "sub": input("detail: ")}) +endfun fun! ShyGrep(word) if !exists("g:grep_dir") | let g:grep_dir = "./" | endif let g:grep_dir = input("dir: ", g:grep_dir, "file") @@ -116,7 +119,8 @@ autocmd InsertLeave * call ShySync("insert") command ShyHelp echo ShyPost({"cmd": "help"}) nnoremap :call ShyGrep(expand("")) -nnoremap :call ShyTag(expand("")) +" nnoremap :call ShyTag(expand("")) +nnoremap :call ShyTask() nnoremap :call ShyCheck("cache") nnoremap :call ShyFavor("note") nnoremap f :call ShyFavor("") diff --git a/src/contexts/ssh/ssh.go b/src/contexts/ssh/ssh.go index ea3a762a..be809c2f 100644 --- a/src/contexts/ssh/ssh.go +++ b/src/contexts/ssh/ssh.go @@ -403,7 +403,9 @@ var Index = &ctx.Context{Name: "ssh", Help: "集群中心", } return }}, - "data": {Name: "data show|insert|update [table [index] [key value]...]", Help: "数据", Form: map[string]int{"format": 1, "fields": -1}, Hand: func(m *ctx.Message, c *ctx.Context, key string, arg ...string) (e error) { + "data": {Name: "data show|insert|update [table [index] [key value]...]", Help: "数据", Form: map[string]int{ + "format": 1, "fields": -1, + }, Hand: func(m *ctx.Message, c *ctx.Context, key string, arg ...string) (e error) { if len(arg) == 0 { arg = append(arg, "show") } diff --git a/src/examples/code/code.go b/src/examples/code/code.go index 2f3ba9c5..3f2c48d3 100644 --- a/src/examples/code/code.go +++ b/src/examples/code/code.go @@ -865,6 +865,8 @@ var Index = &ctx.Context{Name: "code", Help: "代码中心", m.Option("arg", strings.Replace(m.Option("arg"), "XXXXXsingleXXXXX", "'", -1)) m.Option("sub", strings.Replace(m.Option("sub"), "XXXXXsingleXXXXX", "'", -1)) m.Log("info", "%v %v %v %v", cmd, m.Option("cmd"), m.Option("arg"), m.Option("sub")) + m.Option("river", m.Conf("login", []string{"hash", m.Option("sid"), "river"})) + m.Option("dream", m.Conf("login", []string{"hash", m.Option("sid"), "dream"})) switch m.Option("cmd") { case "help": @@ -873,6 +875,9 @@ var Index = &ctx.Context{Name: "code", Help: "代码中心", m.Cmd("login", "init", cmd) case "logout": m.Cmd("login", "exit") + case "tasklet": + m.Cmd("web.team.task", "create", "task", "3", "add", "action", m.Time(), m.Time("10m"), m.Option("arg"), m.Option("sub")) + case "favors": data := map[string][]string{} m.Cmd(".favor", "post").Table(func(index int, value map[string]string) { diff --git a/src/examples/team/team.go b/src/examples/team/team.go index 747208d1..0c51837b 100644 --- a/src/examples/team/team.go +++ b/src/examples/team/team.go @@ -4,53 +4,64 @@ import ( "contexts/ctx" "contexts/web" "fmt" + "toolkit" ) var Index = &ctx.Context{Name: "team", Help: "团队中心", Caches: map[string]*ctx.Cache{}, Configs: map[string]*ctx.Config{}, Commands: map[string]*ctx.Command{ - "task": {Name: "task table index level status begin_time close_time target detail", Help: "任务", Hand: func(m *ctx.Message, c *ctx.Context, key string, arg ...string) (e error) { + "task": {Name: "task create table level class status begin_time close_time target detail arg...", Help: "任务", Hand: func(m *ctx.Message, c *ctx.Context, key string, arg ...string) (e error) { switch arg[0] { case "progress": + // 任务进度 if len(arg) > 2 { switch arg[2] { case "prepare", "action", "cancel", "finish": - m.Cmd("ssh.data", "update", m.Option("table"), arg[1], "status", arg[2]) + time := "close_time" + switch arg[2] { + case "prepare", "action": + time = "begin_time" + case "cancel", "finish": + time = "close_time" + default: + time = "update_time" + } + + m.Cmd("ssh.data", "update", m.Option("table"), arg[1], "status", arg[2], time, m.Time()) arg = []string{arg[0], m.Option("table")} } } + m.Option("cache.limit", kit.Select("30", arg, 2)) + m.Option("cache.offset", kit.Select("0", arg, 3)) m.Meta["append"] = []string{"prepare", "action", "cancel", "finish"} - m.Cmd("ssh.data", "show", arg[1:]).Table(func(index int, value map[string]string) { + m.Cmd("ssh.data", "show", arg[1]).Table(func(index int, value map[string]string) { m.Push(value["status"], fmt.Sprintf("%s", value["id"], value["detail"], value["target"])) }) m.Table() + case "create": + // 创建任务 + if len(arg) < 9 { + arg = append(arg, "") + } + m.Cmdy("ssh.data", "insert", arg[1], "level", arg[2], "class", arg[3], + "status", arg[4], "begin_time", arg[5], "close_time", arg[6], + "target", arg[7], "detail", arg[8], arg[9:]) + default: + // 修改任务 if len(arg) > 1 && arg[1] == "modify" { m.Cmdy("ssh.data", "update", m.Option("table"), m.Option("index"), arg[2], arg[3]) - return + break } - if len(arg) < 8 { - if len(arg) > 2 { - arg = arg[:2] - } - if len(arg) > 1 && arg[1] == "" { - arg = arg[:1] - } - if len(arg) > 0 && arg[0] == "" { - arg = arg[:0] - } - m.Cmdy("ssh.data", "show", arg, "fields", "id", "status", "level", "target", "begin_time", "close_time") - return + // 查看任务 + if len(arg) > 0 && arg[0] == "" { + arg = arg[:0] } - m.Cmdy("ssh.data", "insert", arg[0], - "level", arg[2], "status", arg[3], - "begin_time", arg[4], "close_time", arg[5], - "target", arg[6], "detail", arg[7], arg[8:], - ) + m.Cmdy("ssh.data", "show", arg, "fields", "id", "level", "class", "status", "target", "begin_time", "close_time") } return }}, diff --git a/src/examples/wiki/wiki.go b/src/examples/wiki/wiki.go index 13335189..8b4961aa 100644 --- a/src/examples/wiki/wiki.go +++ b/src/examples/wiki/wiki.go @@ -84,7 +84,7 @@ var Index = &ctx.Context{Name: "wiki", Help: "文档中心", tmpl = template.Must(tmpl.ParseGlob(path.Join(m.Conf("route", "template_dir"), m.Cap("route"), "/*.tmpl"))) tmpl = template.Must(tmpl.ParseFiles(which)) for i, v := range tmpl.Templates() { - m.Log("fuck", "%v, %v", i, v.Name()) + m.Log("info", "%v, %v", i, v.Name()) } m.Optionv("title", map[string]int{}) m.Optionv("tmpl", tmpl) @@ -217,14 +217,14 @@ var Index = &ctx.Context{Name: "wiki", Help: "文档中心", head = kit.Split(l, ' ', 100) continue } - for j, v := range strings.Split(l, " ") { + for j, v := range kit.Split(l, ' ', 100) { m.Push(head[j], v) } } return }}, "refer": {Name: "refer", Help: "链接地址", Hand: func(m *ctx.Message, c *ctx.Context, cmd string, arg ...string) (e error) { - m.Set("option", "render", "raw").Echo("%s: %s", arg[0], arg[1]) + m.Set("option", "render", "raw").Echo(`%s: %s`, arg[0], arg[1], arg[1]) return }}, diff --git a/src/plugin/feature/index.js b/src/plugin/feature/index.js index f937afb9..1740b31d 100644 --- a/src/plugin/feature/index.js +++ b/src/plugin/feature/index.js @@ -1,3 +1,2 @@ -Script["feature/index.js"] = function(field, option, output) {return { +Plugin["feature/index.js"] = function(field, option, output) {return { }} - diff --git a/src/plugin/feature/index.shy b/src/plugin/feature/index.shy index daad3588..6dd83516 100644 --- a/src/plugin/feature/index.shy +++ b/src/plugin/feature/index.shy @@ -16,19 +16,21 @@ end kit progress "任务进度" public "web.team.task" progress \ text "task" name table \ - feature detail prepare action cancel finish \ - button "查看" + text "30" name limit \ + text "0" name offset \ + feature detail action finish cancel prepare \ + button "查看" action auto -kit create "创建任务" public "web.team.task" \ +kit create "创建任务" public "web.team.task" create \ text "task" name table \ - text "" name index \ select "3" name level values 1 values 2 values 3 values 4 values 5 \ - select "prepare" name status values prepare values action values finish values cancel \ - text "" name begin_time init date \ - text "" name close_time init date \ - text "" name target view full \ - textarea "" name detail half "1.5" \ - button "添加" + select "" name class values add values opt values fix \ + select "" name status values prepare values action values finish values cancel \ + text "" name begin_time init date width "108px" before br \ + text "" name close_time init date width "108px" \ + text "" name target view long before br \ + textarea "" name detail half "4" \ + button "添加" before br kit select "查看任务" public "web.team.task" \ text "task" name table imports pluing_table \ diff --git a/src/plugin/story/index.js b/src/plugin/story/index.js index 5115abc4..ee67e08e 100644 --- a/src/plugin/story/index.js +++ b/src/plugin/story/index.js @@ -1,3 +1,3 @@ -Script["story/index.js"] = function(field, option, output) {return { +Plugin["story/index.js"] = function(field, option, output) {return { }} diff --git a/usr/librarys/example.css b/usr/librarys/example.css index 715a5984..94ad597d 100644 --- a/usr/librarys/example.css +++ b/usr/librarys/example.css @@ -65,6 +65,10 @@ fieldset>form.option input.args.long { fieldset>form.option input.args.full { width:480px; } +fieldset>form.option div.item.textarea { + float:left; + clear:both; +} fieldset>div.action { padding:6px; } diff --git a/usr/librarys/example.js b/usr/librarys/example.js index 0077c68d..7d1a8231 100644 --- a/usr/librarys/example.js +++ b/usr/librarys/example.js @@ -63,7 +63,7 @@ function Meta(zone, target, obj) { return datas[name] }), View: shy("添加视图", function(output, type, line, key) { - var text = line, list = [], item = false + var text = line, list = [], item = false, style = "" switch (type) { case "icon": list.push({img: [line[key[0]]]}) @@ -88,6 +88,7 @@ function Meta(zone, target, obj) { break case "input": + style = " "+line.type list.push(line) break @@ -102,8 +103,8 @@ function Meta(zone, target, obj) { break } - var ui = kit.AppendChild(output, item? list: [{view: ["item"], data: {id: "item"+meta.ID(), draggable: false}, list:list}]) - return ui.item.Meta = text, ui + var ui = kit.AppendChild(output, item? list: [{view: ["item"+style], data: {id: "item"+meta.ID(), draggable: false}, list:list}]) + return ui["item"+style].Meta = text, ui }), Include: shy("加载脚本", function(src, cb) {src = kit.List(src) function next(event) {src.length > 1? meta.Include(src.slice(1), cb): cb(event)} @@ -1048,6 +1049,9 @@ function Plugin(page, pane, field, inits, runs) { var count = kit.Selector(option, ".args").length args && count < args.length && (value = value || args[count] || "") + item.before && kit.AppendChild(option, item.before) + item && item.width && (item.style = {}, item.style.width = item.width) + item.view == "full" && kit.AppendChild(option, "br") var input = {plug: meta.name, type: "input", name: name || item.name || item.value || "input", data: item} switch (item.type) { case "upfile": item.type = "file"; break @@ -1060,7 +1064,6 @@ function Plugin(page, pane, field, inits, runs) { break case "textarea": var half = parseFloat(item.half||"1")||1 - kit.AppendChild(option, "br") input.type = "textarea", item.style = "height:"+(item.height||"50px")+";width:"+parseInt(((pane.target.clientWidth-35)/half))+"px" // no break case "text":