1
0
mirror of https://shylinux.com/x/ContextOS synced 2025-04-25 16:58:06 +08:00

add dream

This commit is contained in:
shaoying 2019-11-20 23:29:56 +08:00
parent c7d04c114e
commit b29b30a896
13 changed files with 105 additions and 42 deletions

View File

@ -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() {

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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
}},

View File

@ -0,0 +1,3 @@
fieldset.item.dream div.output {
}

36
src/plugin/dream/index.go Normal file
View File

@ -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:]))
}

View File

@ -0,0 +1,3 @@
Script["dream/index.js"] = function(field, option, output) {return {
}}

View File

@ -0,0 +1,3 @@
kit share "梦想主题" private "web.code.dream" list \
button "查看"

View File

@ -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

View File

@ -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

View File

@ -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" `