diff --git a/etc/exit.shy b/etc/exit.shy index c7e88a73..9f2061c4 100644 --- a/etc/exit.shy +++ b/etc/exit.shy @@ -1,4 +1,6 @@ # 应用配置 +~wiki + config save var/tmp/story.json story ~code config save var/tmp/vim/vim.json vim config save var/tmp/zsh.json zsh diff --git a/etc/init.shy b/etc/init.shy index be69fb0a..a9b14462 100644 --- a/etc/init.shy +++ b/etc/init.shy @@ -21,6 +21,8 @@ config load tmp/code.json login config load tmp/zsh.json zsh config load tmp/vim/vim.json vim +~wiki + config load tmp/story.json story # 终端配置 ~cli diff --git a/src/examples/wiki/wiki.go b/src/examples/wiki/wiki.go index b6b24304..3db9aa13 100644 --- a/src/examples/wiki/wiki.go +++ b/src/examples/wiki/wiki.go @@ -52,11 +52,11 @@ var Index = &ctx.Context{Name: "wiki", Help: "文档中心", "class": {Name: "class", Value: "", Help: "文档目录"}, "favor": {Name: "favor", Value: "index.md", Help: "默认文档"}, - "commit": {Name: "data", Value: map[string]interface{}{ + "story": {Name: "story", Value: map[string]interface{}{ "data": map[string]interface{}{}, - "ship": map[string]interface{}{}, + "node": map[string]interface{}{}, "head": map[string]interface{}{}, - }, Help: "数据"}, + }, Help: "故事会"}, }, Commands: map[string]*ctx.Command{ "tree": {Name: "tree", Help: "目录", Form: map[string]int{"level": 1, "class": 1}, Hand: func(m *ctx.Message, c *ctx.Context, key string, arg ...string) (e error) { @@ -80,65 +80,117 @@ var Index = &ctx.Context{Name: "wiki", Help: "文档中心", return }}, "note": {Name: "note file", Help: "便签", Hand: func(m *ctx.Message, c *ctx.Context, key string, arg ...string) (e error) { - if len(arg) > 1 && arg[0] == "commit" { - m.Cmd("commit", arg[1:]) - } else if len(arg) > 0 { - m.Cmd(kit.Select("tree", "text", strings.HasSuffix(arg[0], ".md")), arg[0]) - } else { + if len(arg) == 0 { m.Cmd("tree") + return + } + + switch arg[0] { + case "favor", "commit": + m.Cmd("story", arg[0], arg[1:]) + default: + m.Cmd(kit.Select("tree", "text", strings.HasSuffix(arg[0], ".md")), arg[0]) } return }}, - "commit": {Name: "commit file name type text", Help: "提交", Hand: func(m *ctx.Message, c *ctx.Context, key string, arg ...string) (e error) { - head := kit.Hashs(arg[0], arg[1]) - prev := m.Conf("commit", []string{"head", head, "ship"}) - m.Log("info", "head: %v %v", head, m.Conf("commit", []string{"head", head})) - if len(arg) == 2 { - meta := m.Confm("commit", []string{"ship", prev}) - m.Push("time", meta["time"]) - m.Push("data", m.Conf("commit", []string{"data", kit.Format(meta["data"])})) + "story": {Name: "story commit story scene enjoy happy", Help: "故事会", Hand: func(m *ctx.Message, c *ctx.Context, cmd string, arg ...string) (e error) { + switch arg[0] { + case "favor": + if len(arg) < 4 { + m.Cmdy("ssh.data", "show", arg[1:]) + break + } + + head := kit.Hashs(arg[2], arg[4]) + prev := m.Conf(cmd, []string{"head", head, "node"}) + m.Cmdy("ssh.data", "insert", arg[1], "story", arg[2], "scene", arg[3], "enjoy", arg[4], "node", prev) + + case "commit": + head := kit.Hashs(arg[1], arg[3]) + prev := m.Conf(cmd, []string{"head", head, "node"}) + m.Log("info", "head: %v %#v", head, prev) + + if len(arg) > 4 { + data := kit.Hashs(arg[4]) + m.Log("info", "data: %v %v", data, arg[4]) + if m.Conf(cmd, []string{"node", prev, "data"}) != data { + m.Conf(cmd, []string{"data", data}, arg[4]) + + meta := map[string]interface{}{ + "time": m.Time(), + "story": arg[1], + "scene": arg[2], + "enjoy": arg[3], + "data": data, + "prev": prev, + } + node := kit.Hashs(kit.Format(meta)) + m.Log("info", "node: %v %v", node, meta) + m.Conf(cmd, []string{"node", node}, meta) + + m.Log("info", "head: %v %v", head, node) + m.Conf(cmd, []string{"head", head, "node"}, node) + m.Echo("%v", kit.Formats(meta)) + break + } + } + + for prev != "" { + node := m.Confm(cmd, []string{"node", prev}) + m.Push("node", kit.Short(prev, 6)) + m.Push("time", node["time"]) + m.Push("data", m.Conf(cmd, []string{"data", kit.Format(node["data"])})) + prev = kit.Format(node["prev"]) + } m.Table() return + + case "branch": + m.Confm(cmd, "head", func(key string, value map[string]interface{}) { + node := kit.Format(value["node"]) + m.Push("key", kit.Short(key, 6)) + m.Push("story", m.Conf(cmd, []string{"node", node, "story"})) + m.Push("scene", m.Conf(cmd, []string{"node", node, "scene"})) + m.Push("enjoy", m.Conf(cmd, []string{"node", node, "enjoy"})) + m.Push("node", kit.Short(value["node"], 6)) + }) + m.Table() + case "remote": } - - data := kit.Hashs(arg[3]) - m.Log("info", "data: %v %v", data, arg[3]) - m.Conf("commit", []string{"data", data}, arg[3]) - - meta := map[string]interface{}{ - "prev": prev, - "time": m.Time(), - "file": arg[0], - "name": arg[1], - "type": arg[2], - "data": data, - } - ship := kit.Hashs(kit.Format(meta)) - m.Log("info", "ship: %v %v", ship, meta) - m.Conf("commit", []string{"ship", ship}, meta) - - m.Log("info", "head: %v %v", head, ship) - m.Conf("commit", []string{"head", head, "ship"}, ship) - m.Echo("%v", kit.Formats(meta)) return }}, - "table": {Name: "table", Help: "表格", Hand: func(m *ctx.Message, c *ctx.Context, key string, arg ...string) (e error) { - if len(arg) == 0 { + "table": {Name: "table", Help: "表格", Hand: func(m *ctx.Message, c *ctx.Context, cmd string, arg ...string) (e error) { + switch len(arg) { + case 0: return - } - switch arg[1] { - case "data": - arg = []string{arg[0], m.Conf("commit", []string{"data", arg[2]})} - + case 2: + if arg[1] != "head" { + break + } + fallthrough + case 1: + arg = []string{arg[0], "head", kit.Hashs(m.Option("filename"), arg[1])} + fallthrough default: - msg := m.Spawn().Cmd("commit", m.Option("filename"), arg[0]) - m.Option("prev_data", msg.Append("data")) - m.Option("prev_time", msg.Append("time")) - m.Option("file", m.Option("filename")) - m.Option("name", arg[0]) - m.Option("data", arg[1]) + switch arg[1] { + case "name": + arg = []string{arg[0], "head", kit.Hashs(m.Option("filename"), arg[2])} + fallthrough + case "head": + arg = []string{arg[0], "node", m.Conf("story", []string{"head", arg[2], "node"})} + fallthrough + case "node": + arg = []string{arg[0], "data", m.Conf("story", []string{"node", arg[2], "data"})} + fallthrough + case "data": + arg = []string{arg[0], m.Conf("story", []string{"data", arg[2]})} + } } + m.Option("scene", cmd) + m.Option("enjoy", arg[0]) + m.Option("happy", arg[1]) + head := []string{} for i, l := range strings.Split(strings.TrimSpace(arg[1]), "\n") { if i == 0 { diff --git a/src/plugin/story/index.css b/src/plugin/story/index.css new file mode 100644 index 00000000..887ea6f1 --- /dev/null +++ b/src/plugin/story/index.css @@ -0,0 +1,3 @@ +fieldset.item.story div.output { +} + diff --git a/src/plugin/story/index.go b/src/plugin/story/index.go new file mode 100644 index 00000000..e6feffe3 --- /dev/null +++ b/src/plugin/story/index.go @@ -0,0 +1,36 @@ +package main + +import ( + "contexts/cli" + "contexts/ctx" + "toolkit" + + "fmt" + "os" +) + +var Index = &ctx.Context{Name: `story`, Help: `plugin`, + Caches: map[string]*ctx.Cache{}, + Configs: map[string]*ctx.Config{ + "_index": &ctx.Config{Name: "index", Value: []interface{}{ + map[string]interface{}{"name": "demo", "help": "demo", + "tmpl": "componet", "view": "", "init": "", + "type": "public", "ctx": "demo", "cmd": "demo", + "args": []interface{}{}, "inputs": []interface{}{ + map[string]interface{}{"type": "text", "name": "pod", "value": "hello world"}, + map[string]interface{}{"type": "button", "value": "执行"}, + }, + }, + }}, + }, + Commands: map[string]*ctx.Command{ + "demo": {Name: "demo", Help: "demo", Hand: func(m *ctx.Message, c *ctx.Context, key string, arg ...string) (e error) { + m.Echo(kit.Select("hello world", arg, 0)) + return + }}, + }, +} + +func main() { + fmt.Print(cli.Index.Plugin(Index, os.Args[1:])) +} diff --git a/src/plugin/story/index.js b/src/plugin/story/index.js new file mode 100644 index 00000000..5115abc4 --- /dev/null +++ b/src/plugin/story/index.js @@ -0,0 +1,3 @@ +Script["story/index.js"] = function(field, option, output) {return { +}} + diff --git a/src/plugin/story/index.shy b/src/plugin/story/index.shy new file mode 100644 index 00000000..6af99e9b --- /dev/null +++ b/src/plugin/story/index.shy @@ -0,0 +1,41 @@ +kit note "记事本" public "ssh._route" _ "web.wiki.note" \ + text "" name dream imports plugin_dream action auto \ + text "" name story imports plugin_story view long action auto \ + button "查看" action auto \ + button "返回" cb Last \ + exports story file \ + feature display inner + +kit favor "收藏夹" public "ssh._route" _ "web.wiki.story" favor \ + text "" name dream imports plugin_you action auto \ + text "see" name table imports plugin_story_table action auto \ + text "" name index imports plugin_story_id view tiny action auto \ + feature detail "修改" "复制" "下载" \ + exports story_table table "" story_id id "" \ + button "记录" action auto \ + button "返回" cb Last + +kit commit "记录" public "ssh._route" _ "web.wiki.story" commit \ + text "" name dream imports plugin_dream \ + text "" name story imports plugin_story \ + text "table" name sence \ + text "hello" name enjoy \ + textarea "" name happy half 4 \ + button "提交" + +kit branch "分支" public "ssh._route" _ "web.wiki.story" branch \ + text "" name dream imports plugin_dream \ + button "查看" + +kit remote "仓库" public "ssh._route" _ "web.wiki.story" remote \ + text "" name dream imports plugin_dream \ + button "查看" + +kit xls "表格" "index.js" "index.css" private "web.wiki.xls" \ + text "" name scene imports plugin_xls_id action auto \ + text "" name content \ + button "执行" \ + button "返回" cb Last \ + feature style "mind" \ + exports xls_id id + diff --git a/src/plugin/vim/index.shy b/src/plugin/vim/index.shy index 7dd1f79f..e70b4415 100644 --- a/src/plugin/vim/index.shy +++ b/src/plugin/vim/index.shy @@ -1,11 +1,3 @@ -kit note "记事本" public "ssh._route" _ "web.wiki.note" \ - text "" name you imports plugin_you action auto \ - text "" name doc imports plugin_doc view long action auto \ - button "查看" action auto \ - button "返回" cb Last \ - exports doc file \ - feature display inner - kit tips "便签" private "web.code.favor" list \ text "" name dream imports plugin_you action auto \ text "tip" name table imports plugin_vim_table action auto \ diff --git a/usr/librarys/example.js b/usr/librarys/example.js index f284c7c1..143b3579 100644 --- a/usr/librarys/example.js +++ b/usr/librarys/example.js @@ -1059,8 +1059,9 @@ function Plugin(page, pane, field, inits, runs) { kit.classList.add(item, "args") break case "textarea": + var half = parseInt(item.half||"1")||1 kit.AppendChild(option, "br") - input.type = "textarea", item.style = "height:"+(item.height||"50px")+";width:"+(pane.target.clientWidth-35)+"px" + input.type = "textarea", item.style = "height:"+(item.height||"50px")+";width:"+((pane.target.clientWidth-35)/half)+"px" // no break case "text": item.value = value || item.value || "" @@ -1531,9 +1532,26 @@ function Output(plugin, type, msg, cb, target, option) { kit.Selector(target, ".commit", function(item) { var data = item.dataset item.oncontextmenu = function(event) { - plugin.oncarte(event, shy("", {}, ["提交"], function(event, value, meta) { - plugin.Run(event, [option.you.vaule||"", "commit", option.doc.value||"", data.name, "table", data.data], function(msg) { - }, true) + plugin.oncarte(event, shy("", { + "提交": function(event) { + plugin.Run(event, [option.dream.value, "commit", option.story.value, data.scene, data.enjoy, data.happy], function(msg) { + }, true) + }, + "复制": function(event) { + plugin.ontoast(kit.CopyText(data.happy)) + }, + "收藏": function(event) { + kit.prompt("收藏到", function(table) { + plugin.Run(event, [option.dream.value, "favor", table, option.story.value, data.scene, data.enjoy, data.happy], function(msg) { + }, true) + }) + }, + "共享": function(event) { + plugin.Run(event, [option.dream.value, "share", option.story.value, data.scene, data.enjoy, data.happy], function(msg) { + }, true) + }, + }, ["提交", "复制", "收藏", "共享"], function(event, value, meta) { + meta[value](event) })) } }) diff --git a/usr/template/wiki/wiki.tmpl b/usr/template/wiki/wiki.tmpl index 4042322e..00ed7226 100644 --- a/usr/template/wiki/wiki.tmpl +++ b/usr/template/wiki/wiki.tmpl @@ -1,6 +1,6 @@ -{{define "table"}}
{{$v}} | {{end}}
---|