Conflicts:
	output/outputs.go
This commit is contained in:
Liang Ding 2014-10-23 14:02:57 +08:00
commit 7cf4376489
1 changed files with 11 additions and 12 deletions

View File

@ -146,7 +146,7 @@ func RunHandler(w http.ResponseWriter, r *http.Request) {
wsChannel := session.OutputWS[sid] wsChannel := session.OutputWS[sid]
channelRet["cmd"] = "run-done" channelRet["cmd"] = "run-done"
channelRet["output"] = string(buf[:count]) channelRet["output"] = "<pre>" + string(buf[:count]) + "</pre>"
err := wsChannel.Conn.WriteJSON(&channelRet) err := wsChannel.Conn.WriteJSON(&channelRet)
if nil != err { if nil != err {
glog.Error(err) glog.Error(err)
@ -163,7 +163,7 @@ func RunHandler(w http.ResponseWriter, r *http.Request) {
wsChannel := session.OutputWS[sid] wsChannel := session.OutputWS[sid]
channelRet["cmd"] = "run" channelRet["cmd"] = "run"
channelRet["output"] = string(buf[:count]) channelRet["output"] = "<pre>" + string(buf[:count]) + "</pre>"
err := wsChannel.Conn.WriteJSON(&channelRet) err := wsChannel.Conn.WriteJSON(&channelRet)
if nil != err { if nil != err {
glog.Error(err) glog.Error(err)
@ -272,7 +272,7 @@ func BuildHandler(w http.ResponseWriter, r *http.Request) {
if nil != session.OutputWS[sid] { if nil != session.OutputWS[sid] {
// 在前端 output 中显示“开始构建” // 在前端 output 中显示“开始构建”
channelRet["output"] = "<span>" + i18n.Get(r, "start-build").(string) + "</span>\n" channelRet["output"] = "<span class='start-build'>" + i18n.Get(r, "start-build").(string) + "</span>\n"
channelRet["cmd"] = "start-build" channelRet["cmd"] = "start-build"
wsChannel := session.OutputWS[sid] wsChannel := session.OutputWS[sid]
@ -313,7 +313,7 @@ func BuildHandler(w http.ResponseWriter, r *http.Request) {
if 0 == count { // 说明构建成功,没有错误信息输出 if 0 == count { // 说明构建成功,没有错误信息输出
// 设置下一次执行命令(前端会根据该参数发送请求) // 设置下一次执行命令(前端会根据该参数发送请求)
channelRet["nextCmd"] = args["nextCmd"] channelRet["nextCmd"] = args["nextCmd"]
channelRet["output"] = i18n.Get(r, "build-succ").(string) + "\n" channelRet["output"] = "<span class='build-succ'>" + i18n.Get(r, "build-succ").(string) + "</span>\n"
go func() { // 运行 go install生成的库用于 gocode lib-path go func() { // 运行 go install生成的库用于 gocode lib-path
cmd := exec.Command("go", "install") cmd := exec.Command("go", "install")
@ -329,7 +329,7 @@ func BuildHandler(w http.ResponseWriter, r *http.Request) {
} else { // 构建失败 } else { // 构建失败
// 解析错误信息,返回给编辑器 gutter lint // 解析错误信息,返回给编辑器 gutter lint
errOut := string(buf[:count]) errOut := string(buf[:count])
channelRet["output"] = i18n.Get(r, "build-failed").(string) + "\n" + errOut channelRet["output"] = "<span class='build-failed'>" + i18n.Get(r, "build-failed").(string) + "</span>\n" + errOut
lines := strings.Split(errOut, "\n") lines := strings.Split(errOut, "\n")
@ -465,7 +465,7 @@ func GoInstallHandler(w http.ResponseWriter, r *http.Request) {
if nil != session.OutputWS[sid] { if nil != session.OutputWS[sid] {
// 在前端 output 中显示“开始 go install” // 在前端 output 中显示“开始 go install”
channelRet["output"] = i18n.Get(r, "start-install").(string) + "\n" channelRet["output"] = "<span class='start-install'>" + i18n.Get(r, "start-install").(string) + "</span>\n"
channelRet["cmd"] = "start-install" channelRet["cmd"] = "start-install"
wsChannel := session.OutputWS[sid] wsChannel := session.OutputWS[sid]
@ -500,7 +500,6 @@ func GoInstallHandler(w http.ResponseWriter, r *http.Request) {
count, _ := reader.Read(buf) count, _ := reader.Read(buf)
channelRet := map[string]interface{}{} channelRet := map[string]interface{}{}
channelRet["cmd"] = "go install" channelRet["cmd"] = "go install"
if 0 != count { // 构建失败 if 0 != count { // 构建失败
@ -547,9 +546,9 @@ func GoInstallHandler(w http.ResponseWriter, r *http.Request) {
channelRet["lints"] = lints channelRet["lints"] = lints
channelRet["output"] = i18n.Get(r, "install-failed").(string) + "\n" + errOut channelRet["output"] = "<span class='install-failed'>" + i18n.Get(r, "install-failed").(string) + "</span>\n" + errOut
} else { } else {
channelRet["output"] = i18n.Get(r, "install-succ").(string) + "\n" channelRet["output"] = "<span class='install-succ'>" + i18n.Get(r, "install-succ").(string) + "</span>\n"
} }
if nil != session.OutputWS[sid] { if nil != session.OutputWS[sid] {
@ -622,7 +621,7 @@ func GoGetHandler(w http.ResponseWriter, r *http.Request) {
if nil != session.OutputWS[sid] { if nil != session.OutputWS[sid] {
// 在前端 output 中显示“开始 go get // 在前端 output 中显示“开始 go get
channelRet["output"] = i18n.Get(r, "start-get").(string) + "\n" channelRet["output"] = "<span class='start-get'>" + i18n.Get(r, "start-get").(string) + "</span>\n"
channelRet["cmd"] = "start-get" channelRet["cmd"] = "start-get"
wsChannel := session.OutputWS[sid] wsChannel := session.OutputWS[sid]
@ -664,7 +663,7 @@ func GoGetHandler(w http.ResponseWriter, r *http.Request) {
if nil != err { if nil != err {
glog.V(3).Infof("Session [%s] 's running [go get] [runningId=%d] has done (with error)", sid, runningId) glog.V(3).Infof("Session [%s] 's running [go get] [runningId=%d] has done (with error)", sid, runningId)
channelRet["output"] = i18n.Get(r, "get-failed").(string) + "\n" + string(buf[:count]) channelRet["output"] = "<span class='get-failed'>" + i18n.Get(r, "get-failed").(string) + "</span>\n" + string(buf[:count])
if nil != session.OutputWS[sid] { if nil != session.OutputWS[sid] {
wsChannel := session.OutputWS[sid] wsChannel := session.OutputWS[sid]
@ -685,7 +684,7 @@ func GoGetHandler(w http.ResponseWriter, r *http.Request) {
if 0 == count { if 0 == count {
glog.V(3).Infof("Session [%s] 's running [go get] [runningId=%d] has done", sid, runningId) glog.V(3).Infof("Session [%s] 's running [go get] [runningId=%d] has done", sid, runningId)
channelRet["output"] = i18n.Get(r, "get-succ").(string) + "\n" channelRet["output"] = "<span class='get-succ'>" + i18n.Get(r, "get-succ").(string) + "</span>\n"
if nil != session.OutputWS[sid] { if nil != session.OutputWS[sid] {
wsChannel := session.OutputWS[sid] wsChannel := session.OutputWS[sid]