parent
ec3c3b52f4
commit
4ab1cb3293
35
conf/user.go
35
conf/user.go
|
@ -22,9 +22,10 @@ import (
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
|
"regexp"
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
"regexp"
|
|
||||||
"github.com/b3log/wide/util"
|
"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)
|
Workspace string // the GOPATH of this user (maybe contain several paths splitted by os.PathListSeparator)
|
||||||
Locale string
|
Locale string
|
||||||
GoFormat string
|
GoFormat string
|
||||||
GoBuildArgsforLinux string
|
GoBuildArgsForLinux string
|
||||||
GoBuildArgsforWindows string
|
GoBuildArgsForWindows string
|
||||||
GoBuildArgsforDarwin string
|
GoBuildArgsForDarwin string
|
||||||
FontFamily string
|
FontFamily string
|
||||||
FontSize string
|
FontSize string
|
||||||
Theme string
|
Theme string
|
||||||
|
@ -94,7 +95,9 @@ func NewUser(username, password, email, workspace string) *User {
|
||||||
now := time.Now().UnixNano()
|
now := time.Now().UnixNano()
|
||||||
|
|
||||||
return &User{Name: username, Password: password, Salt: salt, Email: email, Gravatar: gravatar, Workspace: workspace,
|
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",
|
Keymap: "wide",
|
||||||
Created: now, Updated: now, Lived: now,
|
Created: now, Updated: now, Lived: now,
|
||||||
Editor: &editor{FontFamily: "Consolas, 'Courier New', monospace", FontSize: "inherit", LineHeight: "17px",
|
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))
|
return hex.EncodeToString(sha1hash.Sum(nil))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// GetBuildArgs get build args with the specified os.
|
||||||
func (u *User) GetBuildArgs(os string) []string {
|
func (u *User) GetBuildArgs(os string) []string {
|
||||||
var tmp string
|
var tmp string
|
||||||
if os == "windows" {
|
if os == "windows" {
|
||||||
tmp = u.GoBuildArgsforWindows
|
tmp = u.GoBuildArgsForWindows
|
||||||
}
|
}
|
||||||
if os == "linux" {
|
if os == "linux" {
|
||||||
tmp = u.GoBuildArgsforLinux
|
tmp = u.GoBuildArgsForLinux
|
||||||
}
|
}
|
||||||
if os == "darwin" {
|
if os == "darwin" {
|
||||||
tmp = u.GoBuildArgsforDarwin
|
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
|
|
||||||
}
|
|
||||||
|
|
||||||
|
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}",
|
"Workspace": "${GOPATH}",
|
||||||
"Locale": "en_US",
|
"Locale": "en_US",
|
||||||
"GoFormat": "gofmt",
|
"GoFormat": "gofmt",
|
||||||
"GoBuildArgs": "-i",
|
"GoBuildArgsForLinux": "-i",
|
||||||
|
"GoBuildArgsForWindows": "-i",
|
||||||
|
"GoBuildArgsForDarwin": "-i",
|
||||||
"FontFamily": "Helvetica",
|
"FontFamily": "Helvetica",
|
||||||
"FontSize": "13px",
|
"FontSize": "13px",
|
||||||
"Theme": "default",
|
"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
|
// Compatibility upgrade (1.5.3): https://github.com/b3log/wide/issues/308
|
||||||
if "" == user.GoBuildArgsforLinux {
|
if "" == user.GoBuildArgsForLinux {
|
||||||
user.GoBuildArgsforLinux = "-i"
|
user.GoBuildArgsForLinux = "-i"
|
||||||
}
|
}
|
||||||
if "" == user.GoBuildArgsforWindows {
|
if "" == user.GoBuildArgsForWindows {
|
||||||
user.GoBuildArgsforWindows = "-i"
|
user.GoBuildArgsForWindows = "-i"
|
||||||
}
|
}
|
||||||
if "" == user.GoBuildArgsforDarwin {
|
if "" == user.GoBuildArgsForDarwin {
|
||||||
user.GoBuildArgsforDarwin = "-i"
|
user.GoBuildArgsForDarwin = "-i"
|
||||||
}
|
}
|
||||||
|
|
||||||
Users = append(Users, user)
|
Users = append(Users, user)
|
||||||
|
|
|
@ -23,9 +23,9 @@ import (
|
||||||
"os"
|
"os"
|
||||||
"os/exec"
|
"os/exec"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
|
"runtime"
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
"runtime"
|
|
||||||
|
|
||||||
"github.com/b3log/wide/conf"
|
"github.com/b3log/wide/conf"
|
||||||
"github.com/b3log/wide/i18n"
|
"github.com/b3log/wide/i18n"
|
||||||
|
|
|
@ -25,6 +25,7 @@ import (
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/b3log/wide/conf"
|
"github.com/b3log/wide/conf"
|
||||||
"github.com/b3log/wide/i18n"
|
"github.com/b3log/wide/i18n"
|
||||||
"github.com/b3log/wide/session"
|
"github.com/b3log/wide/session"
|
||||||
|
|
|
@ -95,9 +95,9 @@ func PreferenceHandler(w http.ResponseWriter, r *http.Request) {
|
||||||
FontFamily string
|
FontFamily string
|
||||||
FontSize string
|
FontSize string
|
||||||
GoFmt string
|
GoFmt string
|
||||||
GoBuildArgsforLinux string
|
GoBuildArgsForLinux string
|
||||||
GoBuildArgsforWindows string
|
GoBuildArgsForWindows string
|
||||||
GoBuildArgsforDarwin string
|
GoBuildArgsForDarwin string
|
||||||
Keymap string
|
Keymap string
|
||||||
Workspace string
|
Workspace string
|
||||||
Username string
|
Username string
|
||||||
|
@ -122,9 +122,9 @@ func PreferenceHandler(w http.ResponseWriter, r *http.Request) {
|
||||||
user.FontFamily = args.FontFamily
|
user.FontFamily = args.FontFamily
|
||||||
user.FontSize = args.FontSize
|
user.FontSize = args.FontSize
|
||||||
user.GoFormat = args.GoFmt
|
user.GoFormat = args.GoFmt
|
||||||
user.GoBuildArgsforLinux = args.GoBuildArgsforLinux
|
user.GoBuildArgsForLinux = args.GoBuildArgsForLinux
|
||||||
user.GoBuildArgsforWindows = args.GoBuildArgsforWindows
|
user.GoBuildArgsForWindows = args.GoBuildArgsForWindows
|
||||||
user.GoBuildArgsforDarwin = args.GoBuildArgsforDarwin
|
user.GoBuildArgsForDarwin = args.GoBuildArgsForDarwin
|
||||||
user.Keymap = args.Keymap
|
user.Keymap = args.Keymap
|
||||||
// XXX: disallow change workspace at present
|
// XXX: disallow change workspace at present
|
||||||
// user.Workspace = args.Workspace
|
// user.Workspace = args.Workspace
|
||||||
|
|
|
@ -19,7 +19,7 @@
|
||||||
*
|
*
|
||||||
* @author <a href="http://vanessa.b3log.org">Liyuan Li</a>
|
* @author <a href="http://vanessa.b3log.org">Liyuan Li</a>
|
||||||
* @author <a href="http://88250.b3log.org">Liang Ding</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 = {
|
var menu = {
|
||||||
init: function () {
|
init: function () {
|
||||||
|
@ -425,9 +425,9 @@ var menu = {
|
||||||
$fontFamily = $dialogPreference.find("input[name=fontFamily]"),
|
$fontFamily = $dialogPreference.find("input[name=fontFamily]"),
|
||||||
$fontSize = $dialogPreference.find("input[name=fontSize]"),
|
$fontSize = $dialogPreference.find("input[name=fontSize]"),
|
||||||
$goFmt = $dialogPreference.find("select[name=goFmt]"),
|
$goFmt = $dialogPreference.find("select[name=goFmt]"),
|
||||||
$GoBuildArgsforLinux = $dialogPreference.find("input[name=GoBuildArgsforLinux]"),
|
$GoBuildArgsForLinux = $dialogPreference.find("input[name=GoBuildArgsForLinux]"),
|
||||||
$GoBuildArgsforWindows = $dialogPreference.find("input[name=GoBuildArgsforWindows]"),
|
$GoBuildArgsForWindows = $dialogPreference.find("input[name=GoBuildArgsForWindows]"),
|
||||||
$GoBuildArgsforDarwin = $dialogPreference.find("input[name=GoBuildArgsforDarwin]"),
|
$GoBuildArgsForDarwin = $dialogPreference.find("input[name=GoBuildArgsForDarwin]"),
|
||||||
$workspace = $dialogPreference.find("input[name=workspace]"),
|
$workspace = $dialogPreference.find("input[name=workspace]"),
|
||||||
$password = $dialogPreference.find("input[name=password]"),
|
$password = $dialogPreference.find("input[name=password]"),
|
||||||
$email = $dialogPreference.find("input[name=email]"),
|
$email = $dialogPreference.find("input[name=email]"),
|
||||||
|
@ -444,9 +444,9 @@ var menu = {
|
||||||
"fontFamily": $fontFamily.val(),
|
"fontFamily": $fontFamily.val(),
|
||||||
"fontSize": $fontSize.val(),
|
"fontSize": $fontSize.val(),
|
||||||
"goFmt": $goFmt.val(),
|
"goFmt": $goFmt.val(),
|
||||||
"GoBuildArgsforLinux": $GoBuildArgsforLinux.val(),
|
"GoBuildArgsForLinux": $GoBuildArgsForLinux.val(),
|
||||||
"GoBuildArgsforWindows": $GoBuildArgsforWindows.val(),
|
"GoBuildArgsForWindows": $GoBuildArgsForWindows.val(),
|
||||||
"GoBuildArgsforDarwin": $GoBuildArgsforDarwin.val(),
|
"GoBuildArgsForDarwin": $GoBuildArgsForDarwin.val(),
|
||||||
"workspace": $workspace.val(),
|
"workspace": $workspace.val(),
|
||||||
"password": $password.val(),
|
"password": $password.val(),
|
||||||
"email": $email.val(),
|
"email": $email.val(),
|
||||||
|
@ -476,9 +476,9 @@ var menu = {
|
||||||
$fontFamily.data("value", $fontFamily.val());
|
$fontFamily.data("value", $fontFamily.val());
|
||||||
$fontSize.data("value", $fontSize.val());
|
$fontSize.data("value", $fontSize.val());
|
||||||
$goFmt.data("value", $goFmt.val());
|
$goFmt.data("value", $goFmt.val());
|
||||||
$goBuildArgs.data("value", $GoBuildArgsforLinux.val());
|
$GoBuildArgsForLinux.data("value", $GoBuildArgsForLinux.val());
|
||||||
$goBuildArgs.data("value", $GoBuildArgsforWindows.val());
|
$GoBuildArgsForWindows.data("value", $GoBuildArgsForWindows.val());
|
||||||
$goBuildArgs.data("value", $GoBuildArgsforDarwin.val());
|
$GoBuildArgsForDarwin.data("value", $GoBuildArgsForDarwin.val());
|
||||||
$workspace.data("value", $workspace.val());
|
$workspace.data("value", $workspace.val());
|
||||||
$password.data("value", $password.val());
|
$password.data("value", $password.val());
|
||||||
$email.data("value", $email.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>
|
||||||
<label>
|
<label>
|
||||||
Go Build Args Linux{{.i18n.colon}}
|
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>
|
||||||
<label>
|
<label>
|
||||||
Go Build Args Windows{{.i18n.colon}}
|
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>
|
||||||
<label>
|
<label>
|
||||||
Go Build Args Darwin{{.i18n.colon}}
|
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>
|
</label>
|
||||||
</div>
|
</div>
|
||||||
<div class="fn-none" data-index="keymap">
|
<div class="fn-none" data-index="keymap">
|
||||||
|
|
Loading…
Reference in New Issue