commit
3a511b38a6
14
conf/wide.go
14
conf/wide.go
|
@ -183,7 +183,7 @@ func (*conf) GetExecutableInGOBIN(executable string) string {
|
||||||
executable += ".exe"
|
executable += ".exe"
|
||||||
}
|
}
|
||||||
|
|
||||||
gopaths := strings.Split(os.Getenv("GOPATH"), PathListSeparator)
|
gopaths := filepath.SplitList(os.Getenv("GOPATH"))
|
||||||
|
|
||||||
for _, gopath := range gopaths {
|
for _, gopath := range gopaths {
|
||||||
// $GOPATH/bin/$GOOS_$GOARCH/executable
|
// $GOPATH/bin/$GOOS_$GOARCH/executable
|
||||||
|
@ -264,12 +264,8 @@ func Load() {
|
||||||
Wide.ShellChannel = strings.Replace(Wide.ShellChannel, "{IP}", ip, 1)
|
Wide.ShellChannel = strings.Replace(Wide.ShellChannel, "{IP}", ip, 1)
|
||||||
Wide.SessionChannel = strings.Replace(Wide.SessionChannel, "{IP}", ip, 1)
|
Wide.SessionChannel = strings.Replace(Wide.SessionChannel, "{IP}", ip, 1)
|
||||||
|
|
||||||
// 获取当前执行路径
|
Wide.Pwd = util.OS.Pwd()
|
||||||
file, _ := exec.LookPath(os.Args[0])
|
glog.V(3).Infof("pwd [%s]", Wide.Pwd)
|
||||||
pwd, _ := filepath.Abs(file)
|
|
||||||
pwd = pwd[:strings.LastIndex(pwd, PathSeparator)]
|
|
||||||
Wide.Pwd = pwd
|
|
||||||
glog.V(3).Infof("pwd [%s]", pwd)
|
|
||||||
|
|
||||||
glog.V(3).Info("Conf: \n" + string(bytes))
|
glog.V(3).Info("Conf: \n" + string(bytes))
|
||||||
|
|
||||||
|
@ -280,10 +276,10 @@ func Load() {
|
||||||
//
|
//
|
||||||
// 如果不存在 Workspace 配置所指定的目录路径则创建该目录.
|
// 如果不存在 Workspace 配置所指定的目录路径则创建该目录.
|
||||||
func initWorkspaceDirs() {
|
func initWorkspaceDirs() {
|
||||||
paths := strings.Split(Wide.GetWorkspace(), PathListSeparator)
|
paths := filepath.SplitList(Wide.GetWorkspace())
|
||||||
|
|
||||||
for _, user := range Wide.Users {
|
for _, user := range Wide.Users {
|
||||||
paths = append(paths, strings.Split(user.GetWorkspace(), PathListSeparator)...)
|
paths = append(paths, filepath.SplitList(user.GetWorkspace())...)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -7,6 +7,7 @@ import (
|
||||||
"net/http"
|
"net/http"
|
||||||
"os"
|
"os"
|
||||||
"os/exec"
|
"os/exec"
|
||||||
|
"path/filepath"
|
||||||
"runtime"
|
"runtime"
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
|
@ -124,7 +125,7 @@ func AutocompleteHandler(w http.ResponseWriter, r *http.Request) {
|
||||||
// glog.Infof("offset: %d", offset)
|
// glog.Infof("offset: %d", offset)
|
||||||
|
|
||||||
userWorkspace := conf.Wide.GetUserWorkspace(username)
|
userWorkspace := conf.Wide.GetUserWorkspace(username)
|
||||||
workspaces := strings.Split(userWorkspace, conf.PathListSeparator)
|
workspaces := filepath.SplitList(userWorkspace)
|
||||||
libPath := ""
|
libPath := ""
|
||||||
for _, workspace := range workspaces {
|
for _, workspace := range workspaces {
|
||||||
userLib := workspace + conf.PathSeparator + "pkg" + conf.PathSeparator +
|
userLib := workspace + conf.PathSeparator + "pkg" + conf.PathSeparator +
|
||||||
|
|
|
@ -46,7 +46,7 @@ func GetFiles(w http.ResponseWriter, r *http.Request) {
|
||||||
|
|
||||||
username := session.Values["username"].(string)
|
username := session.Values["username"].(string)
|
||||||
userWorkspace := conf.Wide.GetUserWorkspace(username)
|
userWorkspace := conf.Wide.GetUserWorkspace(username)
|
||||||
workspaces := strings.Split(userWorkspace, conf.PathListSeparator)
|
workspaces := filepath.SplitList(userWorkspace)
|
||||||
|
|
||||||
root := FileNode{Name: "root", Path: "", IconSkin: "ico-ztree-dir ", Type: "d", FileNodes: []*FileNode{}}
|
root := FileNode{Name: "root", Path: "", IconSkin: "ico-ztree-dir ", Type: "d", FileNodes: []*FileNode{}}
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,109 @@
|
||||||
|
{
|
||||||
|
"wide": "Wide",
|
||||||
|
"isDelete": "削除",
|
||||||
|
"cancel": "取消",
|
||||||
|
"file": "ファイル",
|
||||||
|
"login": "ログイン",
|
||||||
|
"username": "ユーザ名",
|
||||||
|
"current_user": "現在のユーザ",
|
||||||
|
"password": "パスワード",
|
||||||
|
"login_error": "ログインエラー",
|
||||||
|
"run": "実行",
|
||||||
|
"debug": "デバッグ",
|
||||||
|
"help": "ヘルプ",
|
||||||
|
"check_update": "更新をチェック",
|
||||||
|
"report_issues": "問題を報告",
|
||||||
|
"wide_doc": "Wide ドキュメント",
|
||||||
|
"about": "Wide について",
|
||||||
|
"start_page": "スタートページ",
|
||||||
|
"create_file": "新規ファイル",
|
||||||
|
"create": "作成",
|
||||||
|
"create_dir": "新規ディレクトリ",
|
||||||
|
"delete": "削除",
|
||||||
|
"save": "保存",
|
||||||
|
"exit": "終了",
|
||||||
|
"close_all_files": "全てのファイルを閉じる",
|
||||||
|
"save_all_files": "全てを保存",
|
||||||
|
"format": "フォーマット",
|
||||||
|
"goget": "go get",
|
||||||
|
"goinstall": "go install",
|
||||||
|
"build": "ビルド",
|
||||||
|
"build_n_run": "ビルド実行",
|
||||||
|
"editor": "エディタ",
|
||||||
|
"max_editor": "最大化",
|
||||||
|
"restore_editor": "元のサイズに戻す",
|
||||||
|
"unread_notification": "未読の通知",
|
||||||
|
"notification_2": "[gocode] が見つかりません。[Autocomplete] は動作しません。",
|
||||||
|
"notification_3": "[ide_stub] が見つかりません。[Jump to Decl]、[Find Usages] は動作しません。",
|
||||||
|
"goto_line": "指定行にジャンプ",
|
||||||
|
"go": "Go",
|
||||||
|
"tip": "ヒント",
|
||||||
|
"confirm": "確認",
|
||||||
|
"stop": "停止",
|
||||||
|
"output": "出力",
|
||||||
|
"search": "検索",
|
||||||
|
"notification": "通知",
|
||||||
|
"min": "最小化",
|
||||||
|
"restore_side": "ファイルツリーを戻す",
|
||||||
|
"search_text": "テキストを検索",
|
||||||
|
"find": "検索",
|
||||||
|
"find_next": "次を検索",
|
||||||
|
"find_previous": "前を検索",
|
||||||
|
"replace": "置換",
|
||||||
|
"replace_all": "全て置換",
|
||||||
|
"restore_bottom": "ウィンドウを下に戻す",
|
||||||
|
"file_format": "ファイルの拡張子",
|
||||||
|
"keyword": "キーワード",
|
||||||
|
"user_guide": "ユーザガイド",
|
||||||
|
"dev_guide": "開発ガイド",
|
||||||
|
"keyboard_shortcuts": "キーボードショートカット",
|
||||||
|
"ver": "バージョン",
|
||||||
|
"current_ver": "現在のバージョン",
|
||||||
|
"dev_team": "開発チーム",
|
||||||
|
"donate_us": "寄付",
|
||||||
|
"confirm_save": "保存の確認",
|
||||||
|
"workspace": "ワークスペース",
|
||||||
|
"project_address": "プロジェクト",
|
||||||
|
"community": "コミュニティ",
|
||||||
|
"autocomplete": "自動補完",
|
||||||
|
"jump_to_decl": "定義へジャンプ",
|
||||||
|
"show_expr_info": "式の情報を表示",
|
||||||
|
"find_usages": "使用方法を検索する",
|
||||||
|
"delete_line": "行を削除",
|
||||||
|
"save_editor_file": "保存",
|
||||||
|
"save_all_editors_files": "全てを保存",
|
||||||
|
"close_editor": "エディタを閉じる",
|
||||||
|
"full_screen": "全画面",
|
||||||
|
"auto_indent": "自動インデント",
|
||||||
|
"indent": "インデントを増やす",
|
||||||
|
"unindent": "インデントを減らす",
|
||||||
|
"focus": "フォーカス",
|
||||||
|
"switch_tab": "タブを切り替える",
|
||||||
|
"focus_editor": "エディタにフォーカスを与える",
|
||||||
|
"focus_file_tree": "ファイルツリーにフォーカスを与える",
|
||||||
|
"focus_output": "出力にフォーカスを与える",
|
||||||
|
"focus_search": "検索にフォーカスを与える",
|
||||||
|
"focus_notification": "通知にフォーカスを与える",
|
||||||
|
"start-build": "[go build] 開始",
|
||||||
|
"build-succ": "[go build] 成功",
|
||||||
|
"build-error": "[go build] 失敗",
|
||||||
|
"start-test": "[go test] 開始",
|
||||||
|
"test-succ": "[go test] 成功",
|
||||||
|
"test-error": "[go test] 失敗",
|
||||||
|
"start-install": "[go install] 開始",
|
||||||
|
"install-succ": "[go install] 成功",
|
||||||
|
"install-error": "[go install] 失敗",
|
||||||
|
"start-get": "[go get] 開始",
|
||||||
|
"get-succ": "[go get] 成功",
|
||||||
|
"get-error": "[go get] 失敗",
|
||||||
|
"check_version": "更新をチェック中",
|
||||||
|
"new_version_available": "新しいバージョンがあります",
|
||||||
|
"go_env": "Go",
|
||||||
|
"os": "OS",
|
||||||
|
"project": "プロジェクト",
|
||||||
|
"license": "ライセンス",
|
||||||
|
"credits": "クレジット",
|
||||||
|
"uptodate": "最新です",
|
||||||
|
"test": "テスト",
|
||||||
|
"colon": ":"
|
||||||
|
}
|
|
@ -5,6 +5,7 @@ import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"os"
|
"os"
|
||||||
|
"strings"
|
||||||
|
|
||||||
"github.com/golang/glog"
|
"github.com/golang/glog"
|
||||||
)
|
)
|
||||||
|
@ -20,10 +21,18 @@ var Locales = map[string]locale{}
|
||||||
|
|
||||||
// 加载国际化配置.
|
// 加载国际化配置.
|
||||||
func Load() {
|
func Load() {
|
||||||
// TODO: 自动加载所有语言配置
|
f, _ := os.Open("i18n")
|
||||||
|
names, _ := f.Readdirnames(-1)
|
||||||
|
f.Close()
|
||||||
|
|
||||||
load("zh_CN")
|
for _, name := range names {
|
||||||
load("en_US")
|
if !strings.HasSuffix(name, ".json") {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
|
loc := name[:strings.LastIndex(name, ".")]
|
||||||
|
load(loc)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func load(localeStr string) {
|
func load(localeStr string) {
|
||||||
|
|
|
@ -10,6 +10,7 @@ import (
|
||||||
"net/http"
|
"net/http"
|
||||||
"os"
|
"os"
|
||||||
"os/exec"
|
"os/exec"
|
||||||
|
"path/filepath"
|
||||||
"runtime"
|
"runtime"
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
|
@ -33,7 +34,7 @@ type Lint struct {
|
||||||
File string `json:"file"`
|
File string `json:"file"`
|
||||||
LineNo int `json:"lineNo"`
|
LineNo int `json:"lineNo"`
|
||||||
Severity string `json:"severity"`
|
Severity string `json:"severity"`
|
||||||
Msg string
|
Msg string `json:"msg"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// 建立输出通道.
|
// 建立输出通道.
|
||||||
|
@ -74,7 +75,7 @@ func RunHandler(w http.ResponseWriter, r *http.Request) {
|
||||||
}
|
}
|
||||||
|
|
||||||
filePath := args["executable"].(string)
|
filePath := args["executable"].(string)
|
||||||
curDir := filePath[:strings.LastIndex(filePath, conf.PathSeparator)]
|
curDir := filepath.Dir(filePath)
|
||||||
|
|
||||||
cmd := exec.Command(filePath)
|
cmd := exec.Command(filePath)
|
||||||
cmd.Dir = curDir
|
cmd.Dir = curDir
|
||||||
|
@ -198,7 +199,7 @@ func BuildHandler(w http.ResponseWriter, r *http.Request) {
|
||||||
sid := args["sid"].(string)
|
sid := args["sid"].(string)
|
||||||
|
|
||||||
filePath := args["file"].(string)
|
filePath := args["file"].(string)
|
||||||
curDir := filePath[:strings.LastIndex(filePath, conf.PathSeparator)]
|
curDir := filepath.Dir(filePath)
|
||||||
|
|
||||||
fout, err := os.Create(filePath)
|
fout, err := os.Create(filePath)
|
||||||
|
|
||||||
|
@ -234,7 +235,7 @@ func BuildHandler(w http.ResponseWriter, r *http.Request) {
|
||||||
|
|
||||||
glog.V(5).Infof("go build -o %s", executable)
|
glog.V(5).Infof("go build -o %s", executable)
|
||||||
|
|
||||||
executable = curDir + conf.PathSeparator + executable
|
executable = filepath.Join(curDir, executable)
|
||||||
|
|
||||||
// 先把可执行文件删了
|
// 先把可执行文件删了
|
||||||
err = os.RemoveAll(executable)
|
err = os.RemoveAll(executable)
|
||||||
|
@ -354,8 +355,13 @@ func BuildHandler(w http.ResponseWriter, r *http.Request) {
|
||||||
|
|
||||||
file := line[:strings.Index(line, ":")]
|
file := line[:strings.Index(line, ":")]
|
||||||
left := line[strings.Index(line, ":")+1:]
|
left := line[strings.Index(line, ":")+1:]
|
||||||
lineNo, _ := strconv.Atoi(left[:strings.Index(left, ":")])
|
index := strings.Index(left, ":")
|
||||||
msg := left[strings.Index(left, ":")+2:]
|
lineNo := 0
|
||||||
|
msg := left
|
||||||
|
if index >= 0 {
|
||||||
|
lineNo, _ = strconv.Atoi(left[:index])
|
||||||
|
msg = left[index+2:]
|
||||||
|
}
|
||||||
|
|
||||||
lint := &Lint{
|
lint := &Lint{
|
||||||
File: file,
|
File: file,
|
||||||
|
@ -407,7 +413,7 @@ func GoTestHandler(w http.ResponseWriter, r *http.Request) {
|
||||||
sid := args["sid"].(string)
|
sid := args["sid"].(string)
|
||||||
|
|
||||||
filePath := args["file"].(string)
|
filePath := args["file"].(string)
|
||||||
curDir := filePath[:strings.LastIndex(filePath, conf.PathSeparator)]
|
curDir := filepath.Dir(filePath)
|
||||||
|
|
||||||
cmd := exec.Command("go", "test", "-v")
|
cmd := exec.Command("go", "test", "-v")
|
||||||
cmd.Dir = curDir
|
cmd.Dir = curDir
|
||||||
|
@ -522,7 +528,7 @@ func GoInstallHandler(w http.ResponseWriter, r *http.Request) {
|
||||||
sid := args["sid"].(string)
|
sid := args["sid"].(string)
|
||||||
|
|
||||||
filePath := args["file"].(string)
|
filePath := args["file"].(string)
|
||||||
curDir := filePath[:strings.LastIndex(filePath, conf.PathSeparator)]
|
curDir := filepath.Dir(filePath)
|
||||||
|
|
||||||
cmd := exec.Command("go", "install")
|
cmd := exec.Command("go", "install")
|
||||||
cmd.Dir = curDir
|
cmd.Dir = curDir
|
||||||
|
@ -621,8 +627,13 @@ func GoInstallHandler(w http.ResponseWriter, r *http.Request) {
|
||||||
|
|
||||||
file := line[:strings.Index(line, ":")]
|
file := line[:strings.Index(line, ":")]
|
||||||
left := line[strings.Index(line, ":")+1:]
|
left := line[strings.Index(line, ":")+1:]
|
||||||
lineNo, _ := strconv.Atoi(left[:strings.Index(left, ":")])
|
index := strings.Index(left, ":")
|
||||||
msg := left[strings.Index(left, ":")+2:]
|
lineNo := 0
|
||||||
|
msg := left
|
||||||
|
if index >= 0 {
|
||||||
|
lineNo, _ = strconv.Atoi(left[:index])
|
||||||
|
msg = left[index+2:]
|
||||||
|
}
|
||||||
|
|
||||||
lint := &Lint{
|
lint := &Lint{
|
||||||
File: file,
|
File: file,
|
||||||
|
@ -678,7 +689,7 @@ func GoGetHandler(w http.ResponseWriter, r *http.Request) {
|
||||||
sid := args["sid"].(string)
|
sid := args["sid"].(string)
|
||||||
|
|
||||||
filePath := args["file"].(string)
|
filePath := args["file"].(string)
|
||||||
curDir := filePath[:strings.LastIndex(filePath, conf.PathSeparator)]
|
curDir := filepath.Dir(filePath)
|
||||||
|
|
||||||
cmd := exec.Command("go", "get")
|
cmd := exec.Command("go", "get")
|
||||||
cmd.Dir = curDir
|
cmd.Dir = curDir
|
||||||
|
|
|
@ -0,0 +1,8 @@
|
||||||
|
body {
|
||||||
|
font-family: Helvetica, 'MS Gothic';
|
||||||
|
}
|
||||||
|
|
||||||
|
input,
|
||||||
|
button {
|
||||||
|
font-family: Helvetica, 'MS Gothic';
|
||||||
|
}
|
|
@ -0,0 +1,8 @@
|
||||||
|
body {
|
||||||
|
font-family: Helvetica, 'Microsoft Yahei';
|
||||||
|
}
|
||||||
|
|
||||||
|
input,
|
||||||
|
button {
|
||||||
|
font-family: Helvetica, 'Microsoft Yahei';
|
||||||
|
}
|
|
@ -4,7 +4,7 @@ body {
|
||||||
margin: 0;
|
margin: 0;
|
||||||
color: #000;
|
color: #000;
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
font-family: Helvetica, 'Microsoft Yahei';
|
font-family: Helvetica;
|
||||||
}
|
}
|
||||||
|
|
||||||
ul {
|
ul {
|
||||||
|
@ -19,7 +19,7 @@ ul {
|
||||||
|
|
||||||
input,
|
input,
|
||||||
button {
|
button {
|
||||||
font-family: Helvetica, 'Microsoft Yahei';
|
font-family: Helvetica;
|
||||||
}
|
}
|
||||||
|
|
||||||
.fn-left {
|
.fn-left {
|
||||||
|
|
11
util/os.go
11
util/os.go
|
@ -1,6 +1,9 @@
|
||||||
package util
|
package util
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"os"
|
||||||
|
"os/exec"
|
||||||
|
"path/filepath"
|
||||||
"runtime"
|
"runtime"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -13,3 +16,11 @@ var OS = myos{}
|
||||||
func (*myos) IsWindows() bool {
|
func (*myos) IsWindows() bool {
|
||||||
return "windows" == runtime.GOOS
|
return "windows" == runtime.GOOS
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 获取当前执行程序的工作目录的绝对路径.
|
||||||
|
func (*myos) Pwd() string {
|
||||||
|
file, _ := exec.LookPath(os.Args[0])
|
||||||
|
pwd, _ := filepath.Abs(file)
|
||||||
|
|
||||||
|
return filepath.Dir(pwd)
|
||||||
|
}
|
||||||
|
|
|
@ -14,6 +14,7 @@
|
||||||
|
|
||||||
<link rel="stylesheet" href="{{.conf.StaticServer}}/static/css/dialog.css?{{.conf.StaticResourceVersion}}">
|
<link rel="stylesheet" href="{{.conf.StaticServer}}/static/css/dialog.css?{{.conf.StaticResourceVersion}}">
|
||||||
<link rel="stylesheet" href="{{.conf.StaticServer}}/static/css/base.css?{{.conf.StaticResourceVersion}}">
|
<link rel="stylesheet" href="{{.conf.StaticServer}}/static/css/base.css?{{.conf.StaticResourceVersion}}">
|
||||||
|
<link rel="stylesheet" href="{{.conf.StaticServer}}/static/css/base-{{.conf.Locale}}.css?{{.conf.StaticResourceVersion}}">
|
||||||
<link rel="stylesheet" href="{{.conf.StaticServer}}/static/css/wide.css?{{.conf.StaticResourceVersion}}">
|
<link rel="stylesheet" href="{{.conf.StaticServer}}/static/css/wide.css?{{.conf.StaticResourceVersion}}">
|
||||||
<link rel="stylesheet" href="{{.conf.StaticServer}}/static/css/side.css?{{.conf.StaticResourceVersion}}">
|
<link rel="stylesheet" href="{{.conf.StaticServer}}/static/css/side.css?{{.conf.StaticResourceVersion}}">
|
||||||
<link rel="stylesheet" href="{{.conf.StaticServer}}/static/css/start.css?{{.conf.StaticResourceVersion}}">
|
<link rel="stylesheet" href="{{.conf.StaticServer}}/static/css/start.css?{{.conf.StaticResourceVersion}}">
|
||||||
|
|
Loading…
Reference in New Issue