forked from x/ContextOS
opt code.login.ship
This commit is contained in:
parent
b936d4dbb9
commit
b5292c33ce
@ -6,7 +6,7 @@ fi
|
||||
|
||||
ctx_url=$ctx_dev"/code/zsh"
|
||||
ctx_get=${ctx_get:="wget -q"}
|
||||
ctx_curl=${ctx_curl:="curl -s"}
|
||||
ctx_curl=${ctx_curl:="curl"}
|
||||
ctx_head=${ctx_head:="Content-Type: application/json"}
|
||||
ctx_sync=${ctx_sync:=""}
|
||||
ctx_sid=${ctx_sid:=""}
|
||||
@ -59,24 +59,24 @@ ShyPost() {
|
||||
else
|
||||
local data=`ShyJSON "$@" SHELL "${SHELL}" pwd "${PWD}" sid "${ctx_sid}"`
|
||||
fi
|
||||
${ctx_curl} "${ctx_url}" -H "${ctx_head}" -d "${data}"
|
||||
${ctx_curl} -s "${ctx_url}" -H "${ctx_head}" -d "${data}"
|
||||
}
|
||||
ShyDownload() {
|
||||
${ctx_curl} "${ctx_url}" -F "cmd=download" -F "arg=$1" -F "sid=$ctx_sid"
|
||||
${ctx_curl} -s "${ctx_url}" -F "cmd=download" -F "arg=$1" -F "sid=$ctx_sid"
|
||||
}
|
||||
ShyUpdate() {
|
||||
${ctx_curl} "${ctx_dev}/publish/$1" > $1
|
||||
${ctx_curl} -s "${ctx_dev}/publish/$1" > $1
|
||||
}
|
||||
ShyUpload() {
|
||||
${ctx_curl} "${ctx_url}" -F "cmd=upload" -F "sid=$ctx_sid" -F "upload=@$1"
|
||||
${ctx_curl} -s "${ctx_url}" -F "cmd=upload" -F "sid=$ctx_sid" -F "upload=@$1"
|
||||
}
|
||||
ShyBench() {
|
||||
${ctx_curl} "${ctx_dev}/publish/boot.sh" | sh -s installs context
|
||||
${ctx_curl} -s "${ctx_dev}/publish/boot.sh" | sh -s installs context
|
||||
}
|
||||
ShySend() {
|
||||
local TEMP=`mktemp /tmp/tmp.XXXXXX` && "$@" > $TEMP
|
||||
ShyRight "$ctx_silent" || cat $TEMP
|
||||
${ctx_curl} "${ctx_url}" -F "cmd=sync" -F "arg=$1" -F "args=$*" -F "sub=@$TEMP"\
|
||||
${ctx_curl} -s "${ctx_url}" -F "cmd=sync" -F "arg=$1" -F "args=$*" -F "sub=@$TEMP"\
|
||||
-F "SHELL=${SHELL}" -F "pwd=${PWD}" -F "sid=${ctx_sid}"
|
||||
}
|
||||
ShyRun() {
|
||||
@ -104,8 +104,8 @@ ShyFavor() {
|
||||
ShyPost cmd favor arg "`history|tail -n2|head -n1`" tab "${ctx_tab}" note "${ctx_note}"
|
||||
}
|
||||
ShyFavors() {
|
||||
[ "$READLINE_LINE" == "" ] && ShyPost cmd favor && return
|
||||
ShyPost cmd favor >$READLINE_LINE
|
||||
[ "$READLINE_LINE" = "" ] && ShyPost cmd favor tab "$1" && return
|
||||
ShyPost cmd favor tab "$1" >$READLINE_LINE
|
||||
READLINE_LINE=""
|
||||
}
|
||||
ShySync() {
|
||||
|
@ -31,7 +31,7 @@ var Index = &ctx.Context{Name: "code", Help: "代码中心",
|
||||
Caches: map[string]*ctx.Cache{},
|
||||
Configs: map[string]*ctx.Config{
|
||||
"login": {Name: "login", Value: map[string]interface{}{"check": false, "local": true, "expire": "720h", "meta": map[string]interface{}{
|
||||
"fields": "time sid type status table dream pwd pid pane hostname username",
|
||||
"fields": "time sid type status ship.dream ship.stage pwd pid pane hostname username",
|
||||
}}, Help: "用户登录"},
|
||||
"prefix": {Name: "prefix", Help: "外部命令", Value: map[string]interface{}{
|
||||
"zsh": []interface{}{"cli.system", "zsh"},
|
||||
@ -129,6 +129,7 @@ var Index = &ctx.Context{Name: "code", Help: "代码中心",
|
||||
return
|
||||
}
|
||||
|
||||
// 添加终端
|
||||
name := kit.Hashs(m.Option("pid"), m.Option("hostname"), m.Option("username"))
|
||||
m.Conf(cmd, []string{"hash", name}, map[string]interface{}{
|
||||
"time": m.Time(),
|
||||
@ -143,38 +144,55 @@ var Index = &ctx.Context{Name: "code", Help: "代码中心",
|
||||
m.Echo(name)
|
||||
|
||||
case "list":
|
||||
if len(arg) > 2 {
|
||||
switch arg[2] {
|
||||
case "prune":
|
||||
m.Cmd(".prune", m.Conf("login", []string{"hash", arg[1], "type"}), arg[1])
|
||||
arg = arg[:1]
|
||||
}
|
||||
// 清理终端
|
||||
if len(arg) > 2 && arg[2] == "prune" {
|
||||
m.Cmd(".prune", m.Conf("login", []string{"hash", arg[1], "type"}), arg[1])
|
||||
arg = arg[:1]
|
||||
}
|
||||
|
||||
if len(arg) > 3 && arg[3] != "" {
|
||||
m.Conf(cmd, []string{"hash", arg[1], "dream"}, arg[3])
|
||||
}
|
||||
if len(arg) > 2 && arg[2] != "" {
|
||||
m.Conf(cmd, []string{"hash", arg[1], "table"}, arg[2])
|
||||
m.Conf(cmd, []string{"hash", arg[1], "river"}, m.Option("river"))
|
||||
}
|
||||
if len(arg) > 1 && arg[1] != "" {
|
||||
m.Option("table.format", "table")
|
||||
m.Confm(cmd, []string{"hash", arg[1]}, func(key string, value string) {
|
||||
m.Push(key, value)
|
||||
// 终端列表
|
||||
if len(arg) == 1 || arg[1] == "" {
|
||||
fields := strings.Split(m.Conf(cmd, "meta.fields"), " ")
|
||||
m.Confm(cmd, "hash", func(key string, value map[string]interface{}) {
|
||||
value["sid"] = key
|
||||
m.Push(fields, kit.Shortm(value, "times", "files", "sids"))
|
||||
})
|
||||
m.Sort("key")
|
||||
m.Table()
|
||||
break
|
||||
}
|
||||
|
||||
fields := strings.Split(m.Conf(cmd, "meta.fields"), " ")
|
||||
m.Confm(cmd, "hash", func(key string, value map[string]interface{}) {
|
||||
value["sid"] = key
|
||||
m.Push(fields, kit.Shortm(value, "times", "files", "sids"))
|
||||
// 终端数据
|
||||
if len(arg) > 6 && arg[6] != "" {
|
||||
m.Conf(cmd, []string{"hash", arg[1], "ship", "order"}, arg[6])
|
||||
}
|
||||
if len(arg) > 5 && arg[5] != "" {
|
||||
m.Conf(cmd, []string{"hash", arg[1], "ship", "stage"}, arg[5])
|
||||
}
|
||||
if len(arg) > 4 && arg[4] != "" {
|
||||
m.Conf(cmd, []string{"hash", arg[1], "ship", "story"}, arg[4])
|
||||
}
|
||||
if len(arg) > 3 && arg[3] != "" {
|
||||
m.Conf(cmd, []string{"hash", arg[1], "ship", "favor"}, arg[3])
|
||||
m.Conf(cmd, []string{"hash", arg[1], "ship", "river"}, m.Option("river"))
|
||||
}
|
||||
if len(arg) > 2 && arg[2] != "" {
|
||||
m.Conf(cmd, []string{"hash", arg[1], "ship", "dream"}, arg[2])
|
||||
}
|
||||
|
||||
// 终端详情
|
||||
m.Option("table.format", "table")
|
||||
m.Confm(cmd, []string{"hash", arg[1], "ship"}, func(key string, value string) {
|
||||
m.Push("ship."+key, value)
|
||||
})
|
||||
m.Table()
|
||||
m.Confm(cmd, []string{"hash", arg[1]}, func(key string, value string) {
|
||||
if key != "ship" {
|
||||
m.Push(key, value)
|
||||
}
|
||||
})
|
||||
m.Sort("key")
|
||||
|
||||
case "exit":
|
||||
// 退出终端
|
||||
m.Conf(cmd, []string{"hash", m.Option("sid"), "status"}, "logout")
|
||||
m.Conf(cmd, []string{"hash", m.Option("sid"), "time"}, m.Time())
|
||||
case "quit":
|
||||
@ -184,17 +202,21 @@ var Index = &ctx.Context{Name: "code", Help: "代码中心",
|
||||
"favor": {Name: "favor post|list", Help: "收藏", Hand: func(m *ctx.Message, c *ctx.Context, cmd string, arg ...string) (e error) {
|
||||
switch arg[0] {
|
||||
case "download":
|
||||
// 下载文件
|
||||
if len(arg) > 1 && arg[1] != "" {
|
||||
m.Cmd("/download/", "", arg[1])
|
||||
break
|
||||
}
|
||||
// 下载列表
|
||||
m.Cmd("ssh._route", m.Option("dream"), "ssh.data", "show", "file").Table(func(index int, value map[string]string) {
|
||||
m.Echo("%v %v %v\n", value["hash"], kit.FmtSize(int64(kit.Int(value["size"]))), value["name"])
|
||||
})
|
||||
|
||||
case "upload":
|
||||
// 上传文件
|
||||
m.Option("agent", "favor")
|
||||
if m.Cmd("/upload"); m.Options("dream") {
|
||||
// 转发文件
|
||||
m.Cmd("ssh._route", m.Option("dream"), "web.get", "dev",
|
||||
"/download/"+m.Append("hash"), "save", "usr/script/"+m.Append("name"))
|
||||
}
|
||||
@ -205,6 +227,7 @@ var Index = &ctx.Context{Name: "code", Help: "代码中心",
|
||||
m.Echo("size: %s\n", m.Append("size"))
|
||||
m.Set("append")
|
||||
case "file":
|
||||
// 文件列表
|
||||
m.Cmd("ssh._route", arg[1], "ssh.data", "show", arg[2]).Table(func(index int, value map[string]string) {
|
||||
m.Push("id", value["id"])
|
||||
m.Push("kind", value["kind"])
|
||||
@ -216,21 +239,19 @@ var Index = &ctx.Context{Name: "code", Help: "代码中心",
|
||||
m.Table()
|
||||
|
||||
case "post":
|
||||
m.Option("river", m.Conf("login", []string{"hash", m.Option("sid"), "river"}))
|
||||
dream := m.Conf("login", []string{"hash", m.Option("sid"), "dream"})
|
||||
table := kit.Select("tip", m.Conf("login", []string{"hash", m.Option("sid"), "table"}))
|
||||
m.Log("info", "river: %v dream: %v table: %v", m.Option("river"), dream, table)
|
||||
// 上传记录
|
||||
m.Log("info", "river: %v dream: %v favor: %v", m.Option("river"), m.Option("dream"), m.Option("favor"))
|
||||
|
||||
if prefix := []string{"ssh._route", dream, "ssh.data"}; len(arg) > 1 {
|
||||
m.Cmdy(prefix, "insert", table, arg[1:])
|
||||
if prefix := []string{"ssh._route", m.Option("dream"), "ssh.data"}; len(arg) > 1 {
|
||||
m.Cmdy(prefix, "insert", m.Option("favor"), arg[1:])
|
||||
} else {
|
||||
m.Cmdy(prefix, "show", table)
|
||||
m.Cmdy(prefix, "show", m.Option("favor"))
|
||||
}
|
||||
|
||||
case "list":
|
||||
if len(arg) > 2 && arg[2] == "modify" {
|
||||
m.Cmdy("ssh._route", m.Option("dream"), "ssh.data", "update", m.Option("table"), arg[1], arg[3], arg[4])
|
||||
arg = []string{"list", m.Option("dream"), m.Option("table")}
|
||||
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")}
|
||||
}
|
||||
if len(arg) > 1 {
|
||||
m.Cmdy("ssh._route", arg[1], "ssh.data", "show", arg[2:])
|
||||
@ -306,8 +327,7 @@ var Index = &ctx.Context{Name: "code", Help: "代码中心",
|
||||
}
|
||||
}
|
||||
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"}))
|
||||
m.Confm("login", []string{"hash", m.Option("sid"), "ship"}, func(key string, value string) { m.Option(key, value) })
|
||||
|
||||
switch m.Option("cmd") {
|
||||
case "help":
|
||||
@ -321,23 +341,21 @@ var Index = &ctx.Context{Name: "code", Help: "代码中心",
|
||||
case "download":
|
||||
m.Cmd("favor", "download", m.Option("arg"))
|
||||
case "favor":
|
||||
if m.Options("tab") {
|
||||
switch path.Base(m.Option("SHELL")) {
|
||||
case "zsh":
|
||||
m.Option("arg", strings.SplitN(m.Option("arg"), ";", 2)[1])
|
||||
default:
|
||||
m.Option("arg", strings.SplitN(strings.TrimSpace(m.Option("arg")), " ", 2)[1])
|
||||
}
|
||||
|
||||
// 添加收藏
|
||||
if m.Options("arg") {
|
||||
m.Option("arg", strings.SplitN(strings.TrimSpace(m.Option("arg")), " ", 2)[1])
|
||||
m.Cmd("favor", "post", "tab", m.Option("tab"), "note", m.Option("note"), "word", m.Option("arg"))
|
||||
m.Set("append")
|
||||
return
|
||||
break
|
||||
}
|
||||
|
||||
// 生成脚本
|
||||
m.Echo("#/bin/sh\n\n")
|
||||
m.Cmd(".favor", "post").Table(func(index int, value map[string]string) {
|
||||
m.Echo("# %v:%v\n%v\n\n", value["tab"], value["note"], value["word"])
|
||||
if !m.Options("tab") || value["tab"] == m.Option("tab") {
|
||||
m.Echo("# %v:%v\n%v\n\n", value["tab"], value["note"], value["word"])
|
||||
}
|
||||
})
|
||||
return
|
||||
|
||||
case "historys":
|
||||
vs := strings.SplitN(strings.TrimSpace(m.Option("arg")), " ", 2)
|
||||
@ -865,8 +883,7 @@ 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"}))
|
||||
m.Confm("login", []string{"hash", m.Option("sid"), "ship"}, func(key string, value string) { m.Option(key, value) })
|
||||
|
||||
switch m.Option("cmd") {
|
||||
case "help":
|
||||
|
@ -43,13 +43,17 @@ var Index = &ctx.Context{Name: "team", Help: "团队中心",
|
||||
|
||||
case "create":
|
||||
// 创建任务
|
||||
if len(arg) < 9 {
|
||||
arg = append(arg, "")
|
||||
if len(arg) > 7 {
|
||||
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:])
|
||||
}
|
||||
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:])
|
||||
|
||||
arg = []string{arg[1]}
|
||||
fallthrough
|
||||
default:
|
||||
// 修改任务
|
||||
if len(arg) > 1 && arg[1] == "modify" {
|
||||
|
@ -210,6 +210,7 @@ var Index = &ctx.Context{Name: "wiki", Help: "文档中心",
|
||||
m.Option("scene", cmd)
|
||||
m.Option("enjoy", arg[0])
|
||||
m.Option("happy", arg[1])
|
||||
m.Option("render", cmd)
|
||||
|
||||
head := []string{}
|
||||
for i, l := range strings.Split(strings.TrimSpace(arg[1]), "\n") {
|
||||
@ -223,6 +224,20 @@ var Index = &ctx.Context{Name: "wiki", Help: "文档中心",
|
||||
}
|
||||
return
|
||||
}},
|
||||
"order": {Name: "order", Help: "列表", Hand: func(m *ctx.Message, c *ctx.Context, cmd string, arg ...string) (e error) {
|
||||
if len(arg) < 2 {
|
||||
return
|
||||
}
|
||||
m.Option("scene", cmd)
|
||||
m.Option("enjoy", arg[0])
|
||||
m.Option("happy", arg[1])
|
||||
m.Option("render", cmd)
|
||||
|
||||
for _, l := range strings.Split(strings.TrimSpace(arg[1]), "\n") {
|
||||
m.Push("list", l)
|
||||
}
|
||||
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: <a href="%s" target="_blank">%s</a>`, arg[0], arg[1], arg[1])
|
||||
return
|
||||
|
@ -1,6 +1,6 @@
|
||||
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 \
|
||||
text "miss.md" name story imports plugin_story view long action auto \
|
||||
button "查看" action auto \
|
||||
button "返回" cb Last \
|
||||
exports story file \
|
||||
@ -17,7 +17,7 @@ kit favor "收藏夹" public "ssh._route" _ "web.wiki.story" favor \
|
||||
|
||||
kit commit "记录" public "ssh._route" _ "web.wiki.story" commit \
|
||||
text "" name dream imports plugin_dream \
|
||||
text "" name story imports plugin_story \
|
||||
text "miss.md" name story imports plugin_story \
|
||||
text "table" name sence \
|
||||
text "hello" name enjoy \
|
||||
textarea "" name happy half 4 \
|
||||
|
@ -1,16 +1,19 @@
|
||||
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 \
|
||||
text "tip" name favor imports plugin_vim_favor action auto \
|
||||
text "" name index imports plugin_tip_id view tiny action auto \
|
||||
feature detail "修改" "复制" "下载" \
|
||||
exports vim_table table "" tip_id id "" \
|
||||
exports vim_favor table "" tip_id id "" \
|
||||
button "记录" action auto \
|
||||
button "返回" cb Last
|
||||
|
||||
kit editor "编辑器" private "web.code.login" list \
|
||||
text "" name sid imports plugin_vim_sid action auto \
|
||||
text "" name table imports plugin_vim_table \
|
||||
text "" name you imports plugin_you \
|
||||
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 \
|
||||
feature detail "prune" "复制" "下载" \
|
||||
exports vim_sid sid \
|
||||
button "查看" action auto
|
||||
|
@ -6,17 +6,20 @@ kit file "文件" private "web.code.favor" file \
|
||||
|
||||
kit taps "便签" private "web.code.favor" list \
|
||||
text "" name dream imports plugin_you action auto \
|
||||
text "tap" name table imports plugin_zsh_table action auto \
|
||||
text "tap" name favor imports plugin_zsh_favor action auto \
|
||||
text "" name index imports plugin_tap_id view tiny action auto \
|
||||
feature detail "修改" "复制" "下载" \
|
||||
exports zsh_table table "" tap_id id "" \
|
||||
exports zsh_favor table "" tap_id id "" \
|
||||
button "记录" action auto \
|
||||
button "返回" cb Last
|
||||
|
||||
kit terminal "终端" private "web.code.login" list \
|
||||
text "" name sid imports plugin_zsh_sid action auto \
|
||||
text "" name table imports plugin_zsh_table \
|
||||
text "" name you imports plugin_you \
|
||||
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 \
|
||||
feature detail "prune" "复制" "下载" \
|
||||
exports zsh_sid sid \
|
||||
button "查看" action auto
|
||||
|
@ -457,3 +457,6 @@ fieldset.item>div.output>div.code div.number {
|
||||
float:left;
|
||||
}
|
||||
|
||||
fieldset ul.story li:hover {
|
||||
background-color:red;
|
||||
}
|
||||
|
@ -1433,8 +1433,8 @@ function Inputs(plugin, meta, item, target, option) {
|
||||
kit.Log("init", "input", input.Zones(), input)
|
||||
|
||||
input.onimport()
|
||||
target.value = input.onformat(item.init, item.value)
|
||||
type == "text" && !target.placeholder && (target.placeholder = item.name)
|
||||
target.value = input.onformat(item.init, item.value);
|
||||
(type == "text" || type == "textarea") && !target.placeholder && (target.placeholder = item.name)
|
||||
type == "text" && !target.title && (target.title = item.placeholder || item.name || "")
|
||||
return plugin.Inputs[item.name] = target, target.Input = input
|
||||
}
|
||||
@ -1536,12 +1536,13 @@ function Output(plugin, type, msg, cb, target, option) {
|
||||
target.innerHTML = "", plugin.onfigure.meta.max(target)
|
||||
output.onimport.meta._table(msg, msg.append) || kit.OrderCode(kit.ModifyNode(target, msg.result.join("")))
|
||||
kit._call(cb, [msg])
|
||||
kit.Selector(target, "table.story", function(item) {
|
||||
kit.Selector(target, ".story", function(item) {
|
||||
var data = item.dataset
|
||||
item.oncontextmenu = function(event) {
|
||||
plugin.oncarte(event, shy("", {
|
||||
"提交": function(event) {
|
||||
plugin.Run(event, [option.dream.value, "commit", option.story.value, data.scene, data.enjoy, data.happy], function(msg) {
|
||||
plugin.ontoast(msg.Result())
|
||||
}, true)
|
||||
},
|
||||
"复制": function(event) {
|
||||
|
@ -8,4 +8,9 @@
|
||||
{{end}}
|
||||
{{end}}</table>{{end}}
|
||||
|
||||
{{define "order"}}<ul class="story" data-scene='{{options . "scene"}}'
|
||||
data-enjoy='{{options . "enjoy"}}' data-happy='{{options . "happy"}}'>
|
||||
{{range $i, $line := .Meta.list}}<li>{{$line}}</li>{{end}}
|
||||
</ul>{{end}}
|
||||
|
||||
{{define "code"}}<div>{{results .}}</div>{{end}}
|
||||
|
Loading…
x
Reference in New Issue
Block a user