From b4c2a7cd8174f9e3b6b017f774b7703d35b94952 Mon Sep 17 00:00:00 2001 From: Liang Ding Date: Sat, 1 Nov 2014 17:33:22 +0800 Subject: [PATCH] #128 --- conf/wide.go | 25 ++++++++++++++++++++++--- conf/wide.json | 3 +++ 2 files changed, 25 insertions(+), 3 deletions(-) diff --git a/conf/wide.go b/conf/wide.go index 9954c85..bccf642 100644 --- a/conf/wide.go +++ b/conf/wide.go @@ -35,16 +35,22 @@ type LatestSessionContent struct { CurrentFile string // path of file of the current focused editor tab } -// User. +// User configuration. type User struct { Name string Password string Workspace string // the GOPATH of this user Locale string GoFormat string + Editor editor LatestSessionContent *LatestSessionContent } +// Editor configuration of a user. +type editor struct { + FontSize string +} + // Configuration. type conf struct { Server string // server host and port ({IP}:7070) @@ -292,7 +298,20 @@ func initCustomizedConfs() { // // 1. /static/user/{username}/style.css 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") @@ -303,7 +322,7 @@ func UpdateCustomizedConf(username string) { } 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 { glog.Error(err) diff --git a/conf/wide.json b/conf/wide.json index ca1a835..ba27c0c 100644 --- a/conf/wide.json +++ b/conf/wide.json @@ -19,6 +19,9 @@ "Workspace": "{pwd}/data/user_workspaces/admin", "Locale": "en_US", "GoFormat": "gofmt", + "Editor": { + "FontSize": "9" + }, "LatestSessionContent": { "FileTree": [], "Files": [],