parent
ec3c3b52f4
commit
4ab1cb3293
69
conf/user.go
69
conf/user.go
|
@ -22,9 +22,10 @@ import (
|
|||
"io/ioutil"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"regexp"
|
||||
"strings"
|
||||
"time"
|
||||
"regexp"
|
||||
|
||||
"github.com/b3log/wide/util"
|
||||
)
|
||||
|
||||
|
@ -51,26 +52,26 @@ type LatestSessionContent struct {
|
|||
|
||||
// User configuration.
|
||||
type User struct {
|
||||
Name string
|
||||
Password string
|
||||
Salt string
|
||||
Email string
|
||||
Gravatar string // see http://gravatar.com
|
||||
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
|
||||
FontFamily string
|
||||
FontSize string
|
||||
Theme string
|
||||
Keymap string // wide/vim
|
||||
Created int64 // user create time in unix nano
|
||||
Updated int64 // preference update time in unix nano
|
||||
Lived int64 // the latest session activity in unix nano
|
||||
Editor *editor
|
||||
LatestSessionContent *LatestSessionContent
|
||||
Name string
|
||||
Password string
|
||||
Salt string
|
||||
Email string
|
||||
Gravatar string // see http://gravatar.com
|
||||
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
|
||||
FontFamily string
|
||||
FontSize string
|
||||
Theme string
|
||||
Keymap string // wide/vim
|
||||
Created int64 // user create time in unix nano
|
||||
Updated int64 // preference update time in unix nano
|
||||
Lived int64 // the latest session activity in unix nano
|
||||
Editor *editor
|
||||
LatestSessionContent *LatestSessionContent
|
||||
}
|
||||
|
||||
// Editor configuration of a user.
|
||||
|
@ -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
|
||||
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}",
|
||||
"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"
|
||||
|
@ -78,7 +79,7 @@ func CrossCompilationHandler(w http.ResponseWriter, r *http.Request) {
|
|||
goBuildArgs := []string{}
|
||||
goBuildArgs = append(goBuildArgs, "build")
|
||||
goBuildArgs = append(goBuildArgs, user.GetBuildArgs(goos)...)
|
||||
|
||||
|
||||
cmd := exec.Command("go", goBuildArgs...)
|
||||
cmd.Dir = curDir
|
||||
|
||||
|
|
|
@ -92,24 +92,24 @@ func PreferenceHandler(w http.ResponseWriter, r *http.Request) {
|
|||
defer util.RetResult(w, r, result)
|
||||
|
||||
args := struct {
|
||||
FontFamily string
|
||||
FontSize string
|
||||
GoFmt string
|
||||
GoBuildArgsforLinux string
|
||||
GoBuildArgsforWindows string
|
||||
GoBuildArgsforDarwin string
|
||||
Keymap string
|
||||
Workspace string
|
||||
Username string
|
||||
Password string
|
||||
Email string
|
||||
Locale string
|
||||
Theme string
|
||||
EditorFontFamily string
|
||||
EditorFontSize string
|
||||
EditorLineHeight string
|
||||
EditorTheme string
|
||||
EditorTabSize string
|
||||
FontFamily string
|
||||
FontSize string
|
||||
GoFmt string
|
||||
GoBuildArgsForLinux string
|
||||
GoBuildArgsForWindows string
|
||||
GoBuildArgsForDarwin string
|
||||
Keymap string
|
||||
Workspace string
|
||||
Username string
|
||||
Password string
|
||||
Email string
|
||||
Locale string
|
||||
Theme string
|
||||
EditorFontFamily string
|
||||
EditorFontSize string
|
||||
EditorLineHeight string
|
||||
EditorTheme string
|
||||
EditorTabSize string
|
||||
}{}
|
||||
|
||||
if err := json.NewDecoder(r.Body).Decode(&args); err != nil {
|
||||
|
@ -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 () {
|
||||
|
@ -313,7 +313,7 @@ var menu = {
|
|||
dataType: "json",
|
||||
beforeSend: function () {
|
||||
bottomGroup.resetOutput();
|
||||
|
||||
|
||||
$("#buildRun").addClass("ico-stop")
|
||||
.removeClass("ico-buildrun").attr("title", config.label.stop);
|
||||
},
|
||||
|
@ -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