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