mirror of
https://shylinux.com/x/ContextOS
synced 2025-04-25 16:58:06 +08:00
add ShyTask.vim
This commit is contained in:
parent
dc63f5ec62
commit
b936d4dbb9
@ -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 <C-g><C-g> :call ShyGrep(expand("<cword>"))<CR>
|
||||
nnoremap <C-g><C-t> :call ShyTag(expand("<cword>"))<CR>
|
||||
" nnoremap <C-g><C-t> :call ShyTag(expand("<cword>"))<CR>
|
||||
nnoremap <C-g><C-t> :call ShyTask()<CR>
|
||||
nnoremap <C-g><C-r> :call ShyCheck("cache")<CR>
|
||||
nnoremap <C-g><C-f> :call ShyFavor("note")<CR>
|
||||
nnoremap <C-g>f :call ShyFavor("")<CR>
|
||||
|
@ -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")
|
||||
}
|
||||
|
@ -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) {
|
||||
|
@ -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("<span data-id='%s' title='%s'>%s</span>", 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
|
||||
}},
|
||||
|
@ -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: <a href="%s" target="_blank">%s</a>`, arg[0], arg[1], arg[1])
|
||||
return
|
||||
}},
|
||||
|
||||
|
@ -1,3 +1,2 @@
|
||||
Script["feature/index.js"] = function(field, option, output) {return {
|
||||
Plugin["feature/index.js"] = function(field, option, output) {return {
|
||||
}}
|
||||
|
||||
|
@ -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 \
|
||||
|
@ -1,3 +1,3 @@
|
||||
Script["story/index.js"] = function(field, option, output) {return {
|
||||
Plugin["story/index.js"] = function(field, option, output) {return {
|
||||
}}
|
||||
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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":
|
||||
|
Loading…
x
Reference in New Issue
Block a user