From b29b30a8961d6b852ed81572b687f29ddf1c539c Mon Sep 17 00:00:00 2001 From: shaoying Date: Wed, 20 Nov 2019 23:29:56 +0800 Subject: [PATCH] add dream --- etc/conf/auto.sh | 2 +- etc/conf/auto.vim | 3 +- etc/conf/tmux.conf | 2 +- etc/exit.shy | 2 +- etc/init.shy | 2 +- src/examples/code/code.go | 56 +++++++++++++++++++------------------- src/plugin/dream/index.css | 3 ++ src/plugin/dream/index.go | 36 ++++++++++++++++++++++++ src/plugin/dream/index.js | 3 ++ src/plugin/dream/index.shy | 3 ++ src/plugin/vim/index.shy | 5 +--- src/plugin/zsh/index.shy | 5 +--- usr/local/wiki/miss.md | 25 +++++++++++++++++ 13 files changed, 105 insertions(+), 42 deletions(-) create mode 100644 src/plugin/dream/index.css create mode 100644 src/plugin/dream/index.go create mode 100644 src/plugin/dream/index.js create mode 100644 src/plugin/dream/index.shy diff --git a/etc/conf/auto.sh b/etc/conf/auto.sh index 5eced900..d6d6dd68 100644 --- a/etc/conf/auto.sh +++ b/etc/conf/auto.sh @@ -102,7 +102,7 @@ ShyLogout() { echo ${ctx_goodbye} && [ "$ctx_sid" != "" ] && Shy logout } ShyLogin() { - HOST=`hostname` ctx_sid=`ShyPost cmd login pid "$$" pane "${TMUX_PANE}" hostname "${HOST}" username "${USER}"` + HOST=`hostname` ctx_sid=`ShyPost cmd login share "${ctx_share}" pid "$$" pane "${TMUX_PANE}" hostname "${HOST}" username "${USER}"` echo "sid: ${ctx_sid:0:6}" } ShyFavor() { diff --git a/etc/conf/auto.vim b/etc/conf/auto.vim index 905a4974..588b2464 100644 --- a/etc/conf/auto.vim +++ b/etc/conf/auto.vim @@ -21,8 +21,7 @@ fun! ShyLogout() endfun fun! ShyLogin() if g:ctx_sid == "" - let g:ctx_sid = ShyPost({"cmd": "login", "pid": getpid(), "pane": $TMUX_PANE, "hostname": hostname(), "username": $USER}) - "hello + let g:ctx_sid = ShyPost({"cmd": "login", "share": $ctx_share, "pid": getpid(), "pane": $TMUX_PANE, "hostname": hostname(), "username": $USER}) endif endfun diff --git a/etc/conf/tmux.conf b/etc/conf/tmux.conf index 419ace38..2a3cf95d 100644 --- a/etc/conf/tmux.conf +++ b/etc/conf/tmux.conf @@ -90,5 +90,5 @@ bind -t vi-edit C-f cursor-right bind -t vi-edit C-j enter # }}} -bind C-r send-keys "export ctx_dev=$ctx_self\ncurl -s \$ctx_dev/publish/auto.sh >auto.sh\nsource auto.sh\n" +bind C-r send-keys "export ctx_dev=$ctx_self ctx_share=$ctx_share\ncurl -s \$ctx_dev/publish/auto.sh >auto.sh\nsource auto.sh\n" source-file ~/.tmux_local diff --git a/etc/exit.shy b/etc/exit.shy index 9f2061c4..032526e8 100644 --- a/etc/exit.shy +++ b/etc/exit.shy @@ -4,7 +4,7 @@ ~code config save var/tmp/vim/vim.json vim config save var/tmp/zsh.json zsh - config save var/tmp/code.json login + config save var/tmp/code.json dream login # 系统配置 ~ssh diff --git a/etc/init.shy b/etc/init.shy index 61df1073..0f0a6af1 100644 --- a/etc/init.shy +++ b/etc/init.shy @@ -18,7 +18,7 @@ # 应用配置 ~code - config load tmp/code.json login + config load tmp/code.json dream login config load tmp/zsh.json zsh config load tmp/vim/vim.json vim ~wiki diff --git a/src/examples/code/code.go b/src/examples/code/code.go index 21072957..3e856095 100644 --- a/src/examples/code/code.go +++ b/src/examples/code/code.go @@ -118,19 +118,21 @@ var Index = &ctx.Context{Name: "code", Help: "代码中心", "least": 3, }}, "dream": {Name: "dream", Help: "使命必达", Value: map[string]interface{}{ - "hello": map[string]interface{}{ - "ship": []interface{}{"tip", "miss.md", "task", "feed"}, - "git": []interface{}{"clone https://github.com/shylinux/context"}, - "tmux": []interface{}{ - "split-window -t $dream:1.1", - "new-window -t $dream:2", - "split-window -t $dream:2.1", - "new-window -t $dream:3", - "split-window -t $dream:3.1", + "topic": map[string]interface{}{ + "hello": map[string]interface{}{ + "ship": []interface{}{"tip", "miss.md", "task", "feed"}, + "git": []interface{}{"clone https://github.com/shylinux/context"}, + "tmux": []interface{}{ + "split-window -t $dream:1.1", + "new-window -t $dream:2", + "split-window -t $dream:2.1", + "new-window -t $dream:3", + "split-window -t $dream:3.1", + }, }, }, + "share": map[string]interface{}{}, }}, - "share": {Name: "share", Help: "共享链接", Value: map[string]interface{}{}}, }, Commands: map[string]*ctx.Command{ "dream": {Name: "dream", Help: "使命必达", Hand: func(m *ctx.Message, c *ctx.Context, cmd string, arg ...string) (e error) { @@ -145,15 +147,16 @@ var Index = &ctx.Context{Name: "code", Help: "代码中心", // 下载代码 home := path.Join(m.Conf("missyou", "path"), arg[1], m.Conf("missyou", "local")) git := kit.Trans(m.Confv("prefix", "git"), "cmd_dir", home) - m.Confm("dream", []string{m.Option("topic"), "git"}, func(index int, value string) { + m.Confm("dream", []string{"topic", m.Option("topic"), "git"}, func(index int, value string) { value = strings.Replace(value, "$dream", arg[1], -1) m.Cmdx(git, strings.Split(value, " ")) }) // 创建终端 - m.Cmds(tmux, "new-session", "-ds", arg[1], "cmd_dir", home, - "cmd_env", "TMUX", "", "cmd_env", "ctx_share", m.Cmdx("dream", "share")) - m.Confm("dream", []string{m.Option("topic"), "tmux"}, func(index int, value string) { + m.Cmds(tmux, "set-environment", "-g", "ctx_share", m.Cmdx("dream", "share")) + m.Cmds(tmux, "new-session", "-ds", arg[1], "cmd_dir", home, "cmd_env", "TMUX", "") + m.Cmds(tmux, "set-environment", "-t", arg[1], "ctx_share", m.Cmdx("dream", "share")) + m.Confm("dream", []string{"topic", m.Option("topic"), "tmux"}, func(index int, value string) { value = strings.Replace(value, "$dream", arg[1], -1) m.Cmdx(tmux, strings.Split(value, " "), "cmd_dir", home) }) @@ -162,16 +165,16 @@ var Index = &ctx.Context{Name: "code", Help: "代码中心", fallthrough case "share": if len(arg) == 1 { - m.Confm("dream", []string{kit.Select("hello", m.Option("topic")), "ship"}, func(index int, value string) { + m.Confm("dream", []string{"topic", kit.Select("hello", m.Option("topic")), "ship"}, func(index int, value string) { arg = append(arg, value) }) } for i := 0; i < 10; i++ { h := kit.Hashs("uniq")[:6] - if m.Confs("share", []string{"hash", h}) { + if m.Confs("dream", []string{"share", "hash", h}) { continue } - m.Conf("share", []string{"hash", h}, map[string]interface{}{ + m.Conf("dream", []string{"share", "hash", h}, map[string]interface{}{ "river": m.Option("river"), "dream": m.Option("dream"), "favor": kit.Select("tip", arg, 1), @@ -185,12 +188,12 @@ var Index = &ctx.Context{Name: "code", Help: "代码中心", } case "bind": - m.Confm("share", []string{"hash", arg[1]}, func(value map[string]interface{}) { + m.Confm("dream", []string{"share", "hash", arg[1]}, func(value map[string]interface{}) { m.Conf("login", []string{"hash", m.Option("sid"), "ship"}, value) }) case "list": - m.Confm("share", "hash", func(key string, value map[string]interface{}) { + m.Confm("dream", "share.hash", func(key string, value map[string]interface{}) { m.Push("key", key) m.Push("river", value["river"]) m.Push("dream", value["dream"]) @@ -222,6 +225,7 @@ var Index = &ctx.Context{Name: "code", Help: "代码中心", "time": m.Time(), "type": kit.Select("vim", arg, 1), "status": "login", + "ship": m.Confv("dream", []string{"share", "hash", m.Option("share")}), "pwd": m.Option("pwd"), "pid": m.Option("pid"), "pane": m.Option("pane"), @@ -232,8 +236,8 @@ var Index = &ctx.Context{Name: "code", Help: "代码中心", case "list": // 清理终端 - if len(arg) > 2 && arg[2] == "prune" { - m.Cmd(".prune", m.Conf("login", []string{"hash", arg[1], "type"}), arg[1]) + if len(arg) > 3 && arg[3] == "prune" { + m.Cmd(".prune", m.Conf("login", []string{"hash", arg[2], "type"}), arg[2]) arg = arg[:1] } @@ -337,14 +341,10 @@ var Index = &ctx.Context{Name: "code", Help: "代码中心", case "list": if len(arg) > 2 && arg[2] == "modify" { - m.Cmdy("ssh._route", m.Option("dream"), "ssh.data", "update", m.Option("favor"), arg[1], arg[3], arg[4]) - arg = []string{"list", m.Option("dream"), m.Option("favor")} + m.Cmdy("ssh.data", "update", m.Option("favor"), arg[1], arg[3], arg[4]) + arg = []string{"list", m.Option("favor"), arg[1]} } - if len(arg) > 1 { - m.Cmdy("ssh._route", arg[1], "ssh.data", "show", arg[2:]) - break - } - m.Cmdy("ssh.data", "show") + m.Cmdy("ssh.data", "show", arg[1:]) } return }}, diff --git a/src/plugin/dream/index.css b/src/plugin/dream/index.css new file mode 100644 index 00000000..dbb6184e --- /dev/null +++ b/src/plugin/dream/index.css @@ -0,0 +1,3 @@ +fieldset.item.dream div.output { +} + diff --git a/src/plugin/dream/index.go b/src/plugin/dream/index.go new file mode 100644 index 00000000..272dfd16 --- /dev/null +++ b/src/plugin/dream/index.go @@ -0,0 +1,36 @@ +package main + +import ( + "contexts/cli" + "contexts/ctx" + "toolkit" + + "fmt" + "os" +) + +var Index = &ctx.Context{Name: `dream`, 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/dream/index.js b/src/plugin/dream/index.js new file mode 100644 index 00000000..700c6514 --- /dev/null +++ b/src/plugin/dream/index.js @@ -0,0 +1,3 @@ +Script["dream/index.js"] = function(field, option, output) {return { +}} + diff --git a/src/plugin/dream/index.shy b/src/plugin/dream/index.shy new file mode 100644 index 00000000..f15abd67 --- /dev/null +++ b/src/plugin/dream/index.shy @@ -0,0 +1,3 @@ +kit share "梦想主题" private "web.code.dream" list \ + button "查看" + diff --git a/src/plugin/vim/index.shy b/src/plugin/vim/index.shy index 64d80f2a..cea36438 100644 --- a/src/plugin/vim/index.shy +++ b/src/plugin/vim/index.shy @@ -10,10 +10,7 @@ kit tips "便签" private "_:web.code.favor" list \ kit editor "编辑器" private "web.code.login" list \ text "" name sid imports plugin_vim_sid action auto \ text "" name dream imports plugin_you \ - text "tip" name favor imports plugin_vim_favor \ - text "miss.md" name story imports plugin_story \ - text "task" name stage imports plugin_stage \ - text "feed" name order imports plugin_order \ + text "" name topic imports plugin_see \ feature detail "prune" "复制" "下载" \ exports vim_sid sid \ button "查看" action auto diff --git a/src/plugin/zsh/index.shy b/src/plugin/zsh/index.shy index b17c587f..3a5abbcb 100644 --- a/src/plugin/zsh/index.shy +++ b/src/plugin/zsh/index.shy @@ -16,10 +16,7 @@ kit taps "便签" private "_:web.code.favor" list \ kit terminal "终端" private "web.code.login" list \ text "" name sid imports plugin_zsh_sid action auto \ text "" name dream imports plugin_you \ - text "tap" name favor imports plugin_zsh_favor \ - text "miss.md" name story imports plugin_story \ - text "task" name stage imports plugin_stage \ - text "feed" name order imports plugin_order \ + text "" name topic imports plugin_see \ feature detail "prune" "复制" "下载" \ exports zsh_sid sid \ button "查看" action auto diff --git a/usr/local/wiki/miss.md b/usr/local/wiki/miss.md index 420305d1..0b0f4412 100644 --- a/usr/local/wiki/miss.md +++ b/usr/local/wiki/miss.md @@ -17,6 +17,31 @@ code wiki chat team mall 规律 平台 特征 智能 `}} +{{order "启动流程" ` +zone.sh +user.sh +node.sh +`}} + +{{order "会话流程" ` +ocean +river +action +source +target +storm +steam +`}} + +{{order "工作流程" ` +dream +favor +story +share +stage +order +`}} + ## 系统设计 {{table "context" `