From b41f0d0ff6bbf51d506ec11185716d8f67eae0db Mon Sep 17 00:00:00 2001 From: shaoying Date: Mon, 13 Aug 2018 20:52:02 +0800 Subject: [PATCH] tce add tmux --- src/contexts/web/web.go | 21 ++++++++++++++++++--- usr/template/upload.html | 25 +++++++++++++++++++++++++ 2 files changed, 43 insertions(+), 3 deletions(-) diff --git a/src/contexts/web/web.go b/src/contexts/web/web.go index 051fb780..97a55e03 100644 --- a/src/contexts/web/web.go +++ b/src/contexts/web/web.go @@ -277,7 +277,9 @@ var Index = &ctx.Context{Name: "web", Help: "应用中心", "nserve": &ctx.Cache{Name: "nserve", Value: "0", Help: "主机数量"}, "nroute": &ctx.Cache{Name: "nroute", Value: "0", Help: "路由数量"}, }, - Configs: map[string]*ctx.Config{}, + Configs: map[string]*ctx.Config{ + "cmd": &ctx.Config{Name: "cmd", Value: "tmux", Help: "路由数量"}, + }, Commands: map[string]*ctx.Command{ "client": &ctx.Command{ Name: "client address [output [editor]]", @@ -743,7 +745,7 @@ var Index = &ctx.Context{Name: "web", Help: "应用中心", delete(list.Meta, "size_i") // 执行命令 - switch m.Option("cmd") { + switch m.Confx("cmd") { case "git": git := m.Sess("git", m.Target()) @@ -752,10 +754,18 @@ var Index = &ctx.Context{Name: "web", Help: "应用中心", status := m.Find("nfs").Cmd("git", "-C", m.Option("dir"), "status") git.Option("status", status.Result(0)) + case "tmux": + tmux := m.Sess("tmux", m.Target()) + + buffer := m.Sess("cli").Cmd("system", "tmux", "show-buffer", "-b", "0") + tmux.Option("buffer", buffer.Result(0)) + sessions := m.Sess("cli").Cmd("system", "tmux", "list-sessions") + // sessions := m.Sess("cli").Cmd("system", "tmux", "list-sessions", "-F", "#S") + tmux.Option("sessions", sessions.Result(0)) } m.Append("title", "upload") - m.Append("tmpl", "userinfo", "share", "list", "git", "upload", "create") + m.Append("tmpl", "userinfo", "share", "list", "git", "tmux", "upload", "create") m.Append("template", m.Conf("upload_main"), m.Conf("upload_tmpl")) // }}} }}, @@ -899,6 +909,11 @@ var Index = &ctx.Context{Name: "web", Help: "应用中心", } // }}} }}, + "/paste": &ctx.Command{Name: "/paste", Help: "应用示例", Hand: func(m *ctx.Message, c *ctx.Context, key string, arg ...string) { + if login := m.Spawn().Cmd("/login"); login.Has("redirect") { + m.Sess("cli").Cmd("system", "tmux", "set-buffer", "-b", "0", m.Option("content")) + } + }}, "temp": &ctx.Command{Name: "temp", Help: "应用示例", Hand: func(m *ctx.Message, c *ctx.Context, key string, arg ...string) { msg := m.Spawn(m.Target()) question := []string{} diff --git a/usr/template/upload.html b/usr/template/upload.html index bf1b16ab..f12c1d50 100644 --- a/usr/template/upload.html +++ b/usr/template/upload.html @@ -85,6 +85,29 @@ {{end}} +{{define "tmux"}} +
sessions +
{{meta . "sessions"}}
+
+
buffer + + + +
+ +{{end}} + {{define "upload"}}
upload
@@ -117,6 +140,8 @@ {{template "share" $sess.share}} {{else if eq . "list"}} {{template "list" $msg.Sessions.list.Meta}} + {{else if eq . "tmux"}} + {{template "tmux" $msg.Sessions.tmux.Meta}} {{else if eq . "git"}} {{if $msg.Sessions.git}} {{template "git" $msg.Sessions.git.Meta}}