This commit is contained in:
Liang Ding 2014-11-01 17:33:22 +08:00
parent a92e858994
commit b4c2a7cd81
2 changed files with 25 additions and 3 deletions

View File

@ -35,16 +35,22 @@ type LatestSessionContent struct {
CurrentFile string // path of file of the current focused editor tab CurrentFile string // path of file of the current focused editor tab
} }
// User. // User configuration.
type User struct { type User struct {
Name string Name string
Password string Password string
Workspace string // the GOPATH of this user Workspace string // the GOPATH of this user
Locale string Locale string
GoFormat string GoFormat string
Editor editor
LatestSessionContent *LatestSessionContent LatestSessionContent *LatestSessionContent
} }
// Editor configuration of a user.
type editor struct {
FontSize string
}
// Configuration. // Configuration.
type conf struct { type conf struct {
Server string // server host and port ({IP}:7070) Server string // server host and port ({IP}:7070)
@ -292,7 +298,20 @@ func initCustomizedConfs() {
// //
// 1. /static/user/{username}/style.css // 1. /static/user/{username}/style.css
func UpdateCustomizedConf(username string) { func UpdateCustomizedConf(username string) {
model := map[string]interface{}{"font_family": "Helvetica, 'Microsoft Yahei'", "font_size": "9px"} var u *User = nil
for _, user := range Wide.Users { // ... maybe a beauty of the trade-off between design and implementation
if user.Name == username {
u = user
}
}
if nil == u {
return
}
editor := u.Editor
model := map[string]interface{}{"font_family": "Helvetica, 'Microsoft Yahei'", "font_size": editor.FontSize}
t, err := template.ParseFiles("static/user/style.css.tmpl") t, err := template.ParseFiles("static/user/style.css.tmpl")
@ -303,7 +322,7 @@ func UpdateCustomizedConf(username string) {
} }
wd := util.OS.Pwd() wd := util.OS.Pwd()
dir := filepath.Clean(wd + "/static/user/" + username) dir := filepath.Clean(wd + "/static/user/" + u.Name)
if err := os.MkdirAll(dir, 0664); nil != err { if err := os.MkdirAll(dir, 0664); nil != err {
glog.Error(err) glog.Error(err)

View File

@ -19,6 +19,9 @@
"Workspace": "{pwd}/data/user_workspaces/admin", "Workspace": "{pwd}/data/user_workspaces/admin",
"Locale": "en_US", "Locale": "en_US",
"GoFormat": "gofmt", "GoFormat": "gofmt",
"Editor": {
"FontSize": "9"
},
"LatestSessionContent": { "LatestSessionContent": {
"FileTree": [], "FileTree": [],
"Files": [], "Files": [],