Merge remote-tracking branch 'refs/remotes/origin/master' into 1.5.3-dev
This commit is contained in:
commit
ec3c3b52f4
28
conf/user.go
28
conf/user.go
|
@ -24,7 +24,7 @@ import (
|
|||
"path/filepath"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"regexp"
|
||||
"github.com/b3log/wide/util"
|
||||
)
|
||||
|
||||
|
@ -59,7 +59,9 @@ type User struct {
|
|||
Workspace string // the GOPATH of this user (maybe contain several paths splitted by os.PathListSeparator)
|
||||
Locale string
|
||||
GoFormat string
|
||||
GoBuildArgs string
|
||||
GoBuildArgsforLinux string
|
||||
GoBuildArgsforWindows string
|
||||
GoBuildArgsforDarwin string
|
||||
FontFamily string
|
||||
FontSize string
|
||||
Theme string
|
||||
|
@ -92,7 +94,7 @@ func NewUser(username, password, email, workspace string) *User {
|
|||
now := time.Now().UnixNano()
|
||||
|
||||
return &User{Name: username, Password: password, Salt: salt, Email: email, Gravatar: gravatar, Workspace: workspace,
|
||||
Locale: Wide.Locale, GoFormat: "gofmt", GoBuildArgs: "-i", FontFamily: "Helvetica", FontSize: "13px", Theme: "default",
|
||||
Locale: Wide.Locale, GoFormat: "gofmt", GoBuildArgsforLinux: "-i", GoBuildArgsforWindows: "-i", GoBuildArgsforDarwin: "-i", FontFamily: "Helvetica", FontSize: "13px", Theme: "default",
|
||||
Keymap: "wide",
|
||||
Created: now, Updated: now, Lived: now,
|
||||
Editor: &editor{FontFamily: "Consolas, 'Courier New', monospace", FontSize: "inherit", LineHeight: "17px",
|
||||
|
@ -155,3 +157,23 @@ func Salt(password, salt string) string {
|
|||
|
||||
return hex.EncodeToString(sha1hash.Sum(nil))
|
||||
}
|
||||
|
||||
func (u *User) GetBuildArgs(os string) []string {
|
||||
var tmp string
|
||||
if os == "windows" {
|
||||
tmp = u.GoBuildArgsforWindows
|
||||
}
|
||||
if os == "linux" {
|
||||
tmp = u.GoBuildArgsforLinux
|
||||
}
|
||||
if os == "darwin" {
|
||||
tmp = u.GoBuildArgsforDarwin
|
||||
}
|
||||
exp := regexp.MustCompile(`[^\s"']+|"([^"]*)"|'([^']*)'`)
|
||||
words := exp.FindAllString(tmp, -1)
|
||||
for idx := range words {
|
||||
words[idx] = strings.Replace(words[idx], "\"", "", -1)
|
||||
}
|
||||
return words
|
||||
}
|
||||
|
||||
|
|
10
conf/wide.go
10
conf/wide.go
|
@ -138,8 +138,14 @@ func initUsers() {
|
|||
}
|
||||
|
||||
// Compatibility upgrade (1.5.3): https://github.com/b3log/wide/issues/308
|
||||
if "" == user.GoBuildArgs {
|
||||
user.GoBuildArgs = "-i"
|
||||
if "" == user.GoBuildArgsforLinux {
|
||||
user.GoBuildArgsforLinux = "-i"
|
||||
}
|
||||
if "" == user.GoBuildArgsforWindows {
|
||||
user.GoBuildArgsforWindows = "-i"
|
||||
}
|
||||
if "" == user.GoBuildArgsforDarwin {
|
||||
user.GoBuildArgsforDarwin = "-i"
|
||||
}
|
||||
|
||||
Users = append(Users, user)
|
||||
|
|
|
@ -17,6 +17,7 @@ package output
|
|||
import (
|
||||
"bufio"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"io"
|
||||
"net/http"
|
||||
"os"
|
||||
|
@ -24,6 +25,7 @@ import (
|
|||
"path/filepath"
|
||||
"strconv"
|
||||
"strings"
|
||||
"runtime"
|
||||
|
||||
"github.com/b3log/wide/conf"
|
||||
"github.com/b3log/wide/i18n"
|
||||
|
@ -94,7 +96,7 @@ func BuildHandler(w http.ResponseWriter, r *http.Request) {
|
|||
|
||||
goBuildArgs := []string{}
|
||||
goBuildArgs = append(goBuildArgs, "build")
|
||||
goBuildArgs = append(goBuildArgs, strings.Split(user.GoBuildArgs, " ")...)
|
||||
goBuildArgs = append(goBuildArgs, user.GetBuildArgs(runtime.GOOS)...)
|
||||
|
||||
cmd := exec.Command("go", goBuildArgs...)
|
||||
cmd.Dir = curDir
|
||||
|
@ -130,7 +132,7 @@ func BuildHandler(w http.ResponseWriter, r *http.Request) {
|
|||
// display "START [go build]" in front-end browser
|
||||
|
||||
msg := i18n.Get(locale, "start-build").(string)
|
||||
msg = strings.Replace(msg, "build]", "build "+user.GoBuildArgs+"]", 1)
|
||||
msg = strings.Replace(msg, "build]", "build "+fmt.Sprint(user.GetBuildArgs(runtime.GOOS))+"]", 1)
|
||||
|
||||
channelRet["output"] = "<span class='start-build'>" + msg + "</span>\n"
|
||||
channelRet["cmd"] = "start-build"
|
||||
|
|
|
@ -25,7 +25,6 @@ import (
|
|||
"path/filepath"
|
||||
"strconv"
|
||||
"strings"
|
||||
|
||||
"github.com/b3log/wide/conf"
|
||||
"github.com/b3log/wide/i18n"
|
||||
"github.com/b3log/wide/session"
|
||||
|
@ -75,7 +74,12 @@ func CrossCompilationHandler(w http.ResponseWriter, r *http.Request) {
|
|||
suffix = ".exe"
|
||||
}
|
||||
|
||||
cmd := exec.Command("go", "build")
|
||||
user := conf.GetUser(username)
|
||||
goBuildArgs := []string{}
|
||||
goBuildArgs = append(goBuildArgs, "build")
|
||||
goBuildArgs = append(goBuildArgs, user.GetBuildArgs(goos)...)
|
||||
|
||||
cmd := exec.Command("go", goBuildArgs...)
|
||||
cmd.Dir = curDir
|
||||
|
||||
setCmdEnv(cmd, username)
|
||||
|
|
|
@ -95,7 +95,9 @@ func PreferenceHandler(w http.ResponseWriter, r *http.Request) {
|
|||
FontFamily string
|
||||
FontSize string
|
||||
GoFmt string
|
||||
GoBuildArgs string
|
||||
GoBuildArgsforLinux string
|
||||
GoBuildArgsforWindows string
|
||||
GoBuildArgsforDarwin string
|
||||
Keymap string
|
||||
Workspace string
|
||||
Username string
|
||||
|
@ -120,7 +122,9 @@ func PreferenceHandler(w http.ResponseWriter, r *http.Request) {
|
|||
user.FontFamily = args.FontFamily
|
||||
user.FontSize = args.FontSize
|
||||
user.GoFormat = args.GoFmt
|
||||
user.GoBuildArgs = args.GoBuildArgs
|
||||
user.GoBuildArgsforLinux = args.GoBuildArgsforLinux
|
||||
user.GoBuildArgsforWindows = args.GoBuildArgsforWindows
|
||||
user.GoBuildArgsforDarwin = args.GoBuildArgsforDarwin
|
||||
user.Keymap = args.Keymap
|
||||
// XXX: disallow change workspace at present
|
||||
// user.Workspace = args.Workspace
|
||||
|
|
|
@ -425,7 +425,9 @@ var menu = {
|
|||
$fontFamily = $dialogPreference.find("input[name=fontFamily]"),
|
||||
$fontSize = $dialogPreference.find("input[name=fontSize]"),
|
||||
$goFmt = $dialogPreference.find("select[name=goFmt]"),
|
||||
$goBuildArgs = $dialogPreference.find("input[name=goBuildArgs]"),
|
||||
$GoBuildArgsforLinux = $dialogPreference.find("input[name=GoBuildArgsforLinux]"),
|
||||
$GoBuildArgsforWindows = $dialogPreference.find("input[name=GoBuildArgsforWindows]"),
|
||||
$GoBuildArgsforDarwin = $dialogPreference.find("input[name=GoBuildArgsforDarwin]"),
|
||||
$workspace = $dialogPreference.find("input[name=workspace]"),
|
||||
$password = $dialogPreference.find("input[name=password]"),
|
||||
$email = $dialogPreference.find("input[name=email]"),
|
||||
|
@ -442,7 +444,9 @@ var menu = {
|
|||
"fontFamily": $fontFamily.val(),
|
||||
"fontSize": $fontSize.val(),
|
||||
"goFmt": $goFmt.val(),
|
||||
"goBuildArgs": $goBuildArgs.val(),
|
||||
"GoBuildArgsforLinux": $GoBuildArgsforLinux.val(),
|
||||
"GoBuildArgsforWindows": $GoBuildArgsforWindows.val(),
|
||||
"GoBuildArgsforDarwin": $GoBuildArgsforDarwin.val(),
|
||||
"workspace": $workspace.val(),
|
||||
"password": $password.val(),
|
||||
"email": $email.val(),
|
||||
|
@ -472,7 +476,9 @@ var menu = {
|
|||
$fontFamily.data("value", $fontFamily.val());
|
||||
$fontSize.data("value", $fontSize.val());
|
||||
$goFmt.data("value", $goFmt.val());
|
||||
$goBuildArgs.data("value", $goBuildArgs.val());
|
||||
$goBuildArgs.data("value", $GoBuildArgsforLinux.val());
|
||||
$goBuildArgs.data("value", $GoBuildArgsforWindows.val());
|
||||
$goBuildArgs.data("value", $GoBuildArgsforDarwin.val());
|
||||
$workspace.data("value", $workspace.val());
|
||||
$password.data("value", $password.val());
|
||||
$email.data("value", $email.val());
|
||||
|
|
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
|
@ -71,8 +71,16 @@
|
|||
</select>
|
||||
</label>
|
||||
<label>
|
||||
Go Build Args{{.i18n.colon}}
|
||||
<input data-value="{{.user.GoBuildArgs}}" value="{{.user.GoBuildArgs}}" name="goBuildArgs"/>
|
||||
Go Build Args Linux{{.i18n.colon}}
|
||||
<input data-value="{{.user.GoBuildArgsforLinux}}" value="{{.user.GoBuildArgsforLinux}}" name="GoBuildArgsforLinux"/>
|
||||
</label>
|
||||
<label>
|
||||
Go Build Args Windows{{.i18n.colon}}
|
||||
<input data-value="{{.user.GoBuildArgsforWindows}}" value="{{.user.GoBuildArgsforWindows}}" name="GoBuildArgsforWindows"/>
|
||||
</label>
|
||||
<label>
|
||||
Go Build Args Darwin{{.i18n.colon}}
|
||||
<input data-value="{{.user.GoBuildArgsforDarwin}}" value="{{.user.GoBuildArgsforDarwin}}" name="GoBuildArgsforDarwin"/>
|
||||
</label>
|
||||
</div>
|
||||
<div class="fn-none" data-index="keymap">
|
||||
|
|
Loading…
Reference in New Issue