parent
ec3c3b52f4
commit
4ab1cb3293
35
conf/user.go
35
conf/user.go
|
@ -22,9 +22,10 @@ import (
|
|||
"io/ioutil"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"regexp"
|
||||
"strings"
|
||||
"time"
|
||||
"regexp"
|
||||
|
||||
"github.com/b3log/wide/util"
|
||||
)
|
||||
|
||||
|
@ -59,9 +60,9 @@ type User struct {
|
|||
Workspace string // the GOPATH of this user (maybe contain several paths splitted by os.PathListSeparator)
|
||||
Locale string
|
||||
GoFormat string
|
||||
GoBuildArgsforLinux string
|
||||
GoBuildArgsforWindows string
|
||||
GoBuildArgsforDarwin string
|
||||
GoBuildArgsForLinux string
|
||||
GoBuildArgsForWindows string
|
||||
GoBuildArgsForDarwin string
|
||||
FontFamily string
|
||||
FontSize string
|
||||
Theme string
|
||||
|
@ -94,7 +95,9 @@ 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", GoBuildArgsforLinux: "-i", GoBuildArgsforWindows: "-i", GoBuildArgsforDarwin: "-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",
|
||||
|
@ -158,22 +161,24 @@ func Salt(password, salt string) string {
|
|||
return hex.EncodeToString(sha1hash.Sum(nil))
|
||||
}
|
||||
|
||||
// GetBuildArgs get build args with the specified os.
|
||||
func (u *User) GetBuildArgs(os string) []string {
|
||||
var tmp string
|
||||
if os == "windows" {
|
||||
tmp = u.GoBuildArgsforWindows
|
||||
tmp = u.GoBuildArgsForWindows
|
||||
}
|
||||
if os == "linux" {
|
||||
tmp = u.GoBuildArgsforLinux
|
||||
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
|
||||
tmp = u.GoBuildArgsForDarwin
|
||||
}
|
||||
|
||||
exp := regexp.MustCompile(`[^\s"']+|"([^"]*)"|'([^']*)'`)
|
||||
ret := exp.FindAllString(tmp, -1)
|
||||
for idx := range ret {
|
||||
ret[idx] = strings.Replace(ret[idx], "\"", "", -1)
|
||||
}
|
||||
|
||||
return ret
|
||||
}
|
||||
|
|
|
@ -7,7 +7,9 @@
|
|||
"Workspace": "${GOPATH}",
|
||||
"Locale": "en_US",
|
||||
"GoFormat": "gofmt",
|
||||
"GoBuildArgs": "-i",
|
||||
"GoBuildArgsForLinux": "-i",
|
||||
"GoBuildArgsForWindows": "-i",
|
||||
"GoBuildArgsForDarwin": "-i",
|
||||
"FontFamily": "Helvetica",
|
||||
"FontSize": "13px",
|
||||
"Theme": "default",
|
||||
|
|
12
conf/wide.go
12
conf/wide.go
|
@ -138,14 +138,14 @@ func initUsers() {
|
|||
}
|
||||
|
||||
// Compatibility upgrade (1.5.3): https://github.com/b3log/wide/issues/308
|
||||
if "" == user.GoBuildArgsforLinux {
|
||||
user.GoBuildArgsforLinux = "-i"
|
||||
if "" == user.GoBuildArgsForLinux {
|
||||
user.GoBuildArgsForLinux = "-i"
|
||||
}
|
||||
if "" == user.GoBuildArgsforWindows {
|
||||
user.GoBuildArgsforWindows = "-i"
|
||||
if "" == user.GoBuildArgsForWindows {
|
||||
user.GoBuildArgsForWindows = "-i"
|
||||
}
|
||||
if "" == user.GoBuildArgsforDarwin {
|
||||
user.GoBuildArgsforDarwin = "-i"
|
||||
if "" == user.GoBuildArgsForDarwin {
|
||||
user.GoBuildArgsForDarwin = "-i"
|
||||
}
|
||||
|
||||
Users = append(Users, user)
|
||||
|
|
|
@ -23,9 +23,9 @@ import (
|
|||
"os"
|
||||
"os/exec"
|
||||
"path/filepath"
|
||||
"runtime"
|
||||
"strconv"
|
||||
"strings"
|
||||
"runtime"
|
||||
|
||||
"github.com/b3log/wide/conf"
|
||||
"github.com/b3log/wide/i18n"
|
||||
|
|
|
@ -25,6 +25,7 @@ import (
|
|||
"path/filepath"
|
||||
"strconv"
|
||||
"strings"
|
||||
|
||||
"github.com/b3log/wide/conf"
|
||||
"github.com/b3log/wide/i18n"
|
||||
"github.com/b3log/wide/session"
|
||||
|
|
|
@ -95,9 +95,9 @@ func PreferenceHandler(w http.ResponseWriter, r *http.Request) {
|
|||
FontFamily string
|
||||
FontSize string
|
||||
GoFmt string
|
||||
GoBuildArgsforLinux string
|
||||
GoBuildArgsforWindows string
|
||||
GoBuildArgsforDarwin string
|
||||
GoBuildArgsForLinux string
|
||||
GoBuildArgsForWindows string
|
||||
GoBuildArgsForDarwin string
|
||||
Keymap string
|
||||
Workspace string
|
||||
Username string
|
||||
|
@ -122,9 +122,9 @@ func PreferenceHandler(w http.ResponseWriter, r *http.Request) {
|
|||
user.FontFamily = args.FontFamily
|
||||
user.FontSize = args.FontSize
|
||||
user.GoFormat = args.GoFmt
|
||||
user.GoBuildArgsforLinux = args.GoBuildArgsforLinux
|
||||
user.GoBuildArgsforWindows = args.GoBuildArgsforWindows
|
||||
user.GoBuildArgsforDarwin = args.GoBuildArgsforDarwin
|
||||
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
|
||||
|
|
|
@ -19,7 +19,7 @@
|
|||
*
|
||||
* @author <a href="http://vanessa.b3log.org">Liyuan Li</a>
|
||||
* @author <a href="http://88250.b3log.org">Liang Ding</a>
|
||||
* @version 1.0.1.1, Mar 15, 2017
|
||||
* @version 1.0.1.2, Mar 27, 2017
|
||||
*/
|
||||
var menu = {
|
||||
init: function () {
|
||||
|
@ -425,9 +425,9 @@ var menu = {
|
|||
$fontFamily = $dialogPreference.find("input[name=fontFamily]"),
|
||||
$fontSize = $dialogPreference.find("input[name=fontSize]"),
|
||||
$goFmt = $dialogPreference.find("select[name=goFmt]"),
|
||||
$GoBuildArgsforLinux = $dialogPreference.find("input[name=GoBuildArgsforLinux]"),
|
||||
$GoBuildArgsforWindows = $dialogPreference.find("input[name=GoBuildArgsforWindows]"),
|
||||
$GoBuildArgsforDarwin = $dialogPreference.find("input[name=GoBuildArgsforDarwin]"),
|
||||
$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]"),
|
||||
|
@ -444,9 +444,9 @@ var menu = {
|
|||
"fontFamily": $fontFamily.val(),
|
||||
"fontSize": $fontSize.val(),
|
||||
"goFmt": $goFmt.val(),
|
||||
"GoBuildArgsforLinux": $GoBuildArgsforLinux.val(),
|
||||
"GoBuildArgsforWindows": $GoBuildArgsforWindows.val(),
|
||||
"GoBuildArgsforDarwin": $GoBuildArgsforDarwin.val(),
|
||||
"GoBuildArgsForLinux": $GoBuildArgsForLinux.val(),
|
||||
"GoBuildArgsForWindows": $GoBuildArgsForWindows.val(),
|
||||
"GoBuildArgsForDarwin": $GoBuildArgsForDarwin.val(),
|
||||
"workspace": $workspace.val(),
|
||||
"password": $password.val(),
|
||||
"email": $email.val(),
|
||||
|
@ -476,9 +476,9 @@ var menu = {
|
|||
$fontFamily.data("value", $fontFamily.val());
|
||||
$fontSize.data("value", $fontSize.val());
|
||||
$goFmt.data("value", $goFmt.val());
|
||||
$goBuildArgs.data("value", $GoBuildArgsforLinux.val());
|
||||
$goBuildArgs.data("value", $GoBuildArgsforWindows.val());
|
||||
$goBuildArgs.data("value", $GoBuildArgsforDarwin.val());
|
||||
$GoBuildArgsForLinux.data("value", $GoBuildArgsForLinux.val());
|
||||
$GoBuildArgsForWindows.data("value", $GoBuildArgsForWindows.val());
|
||||
$GoBuildArgsForDarwin.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
|
@ -72,15 +72,15 @@
|
|||
</label>
|
||||
<label>
|
||||
Go Build Args Linux{{.i18n.colon}}
|
||||
<input data-value="{{.user.GoBuildArgsforLinux}}" value="{{.user.GoBuildArgsforLinux}}" name="GoBuildArgsforLinux"/>
|
||||
<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"/>
|
||||
<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"/>
|
||||
<input data-value="{{.user.GoBuildArgsForDarwin}}" value="{{.user.GoBuildArgsForDarwin}}" name="GoBuildArgsForDarwin"/>
|
||||
</label>
|
||||
</div>
|
||||
<div class="fn-none" data-index="keymap">
|
||||
|
|
Loading…
Reference in New Issue