From bb58dad40c9054ba7fb2e81e3927a83b60461a6d Mon Sep 17 00:00:00 2001 From: Liang Ding Date: Sun, 2 Nov 2014 10:39:33 +0800 Subject: [PATCH] Fix #128 --- conf/wide.go | 15 +++++++-------- conf/wide.json | 5 ++++- main.go | 2 ++ session/users.go | 2 +- static/css/base-en_US.css | 0 static/css/base-ja_JP.css | 8 -------- static/css/base-zh_CN.css | 8 -------- static/css/wide.css | 2 -- static/user/admin/style.css | 14 +++++++------- static/user/style.css.tmpl | 14 +++++++------- views/index.html | 3 ++- 11 files changed, 30 insertions(+), 43 deletions(-) delete mode 100644 static/css/base-en_US.css delete mode 100644 static/css/base-ja_JP.css delete mode 100644 static/css/base-zh_CN.css diff --git a/conf/wide.go b/conf/wide.go index 420f10d..d56d76c 100644 --- a/conf/wide.go +++ b/conf/wide.go @@ -13,7 +13,6 @@ import ( "time" "github.com/b3log/wide/event" - _ "github.com/b3log/wide/i18n" "github.com/b3log/wide/util" "github.com/golang/glog" ) @@ -42,13 +41,16 @@ type User struct { Workspace string // the GOPATH of this user Locale string GoFormat string - Editor editor + FontFamily string + FontSize string + Editor *Editor LatestSessionContent *LatestSessionContent } // Editor configuration of a user. -type editor struct { - FontSize string +type Editor struct { + FontFamily string + FontSize string } // Configuration. @@ -309,12 +311,9 @@ func UpdateCustomizedConf(username string) { return } - editor := u.Editor - - model := map[string]interface{}{"font_family": "Helvetica, 'Microsoft Yahei'", "font_size": editor.FontSize} + model := map[string]interface{}{"user": u} t, err := template.ParseFiles("static/user/style.css.tmpl") - if nil != err { glog.Error(err) diff --git a/conf/wide.json b/conf/wide.json index ba27c0c..d3068a2 100644 --- a/conf/wide.json +++ b/conf/wide.json @@ -19,8 +19,11 @@ "Workspace": "{pwd}/data/user_workspaces/admin", "Locale": "en_US", "GoFormat": "gofmt", + "FontFamily": "Helvetica", + "FontSize": "inherit", "Editor": { - "FontSize": "9" + "FontFamily": "Consolas, 'Courier New', monospace", + "FontSize": "inherit" }, "LatestSessionContent": { "FileTree": [], diff --git a/main.go b/main.go index 747255d..1557f73 100644 --- a/main.go +++ b/main.go @@ -28,6 +28,8 @@ func init() { flag.Set("v", "3") flag.Parse() + i18n.Load() + event.Load() conf.Load() diff --git a/session/users.go b/session/users.go index 2bd8a14..c8f3188 100644 --- a/session/users.go +++ b/session/users.go @@ -156,7 +156,7 @@ func addUser(username, password string) string { workspace := filepath.Join(dir, username) newUser := &conf.User{Name: username, Password: password, Workspace: workspace, - Locale: conf.Wide.Locale, GoFormat: "gofmt"} + Locale: conf.Wide.Locale, GoFormat: "gofmt", Editor: &conf.Editor{FontSize: "10px"}} conf.Wide.Users = append(conf.Wide.Users, newUser) if !conf.Save() { diff --git a/static/css/base-en_US.css b/static/css/base-en_US.css deleted file mode 100644 index e69de29..0000000 diff --git a/static/css/base-ja_JP.css b/static/css/base-ja_JP.css deleted file mode 100644 index 1ec0f2b..0000000 --- a/static/css/base-ja_JP.css +++ /dev/null @@ -1,8 +0,0 @@ -body { - font-family: Helvetica, 'MS Gothic'; -} - -input, -button { - font-family: Helvetica, 'MS Gothic'; -} diff --git a/static/css/base-zh_CN.css b/static/css/base-zh_CN.css deleted file mode 100644 index 9bfc42a..0000000 --- a/static/css/base-zh_CN.css +++ /dev/null @@ -1,8 +0,0 @@ -body { - font-family: Helvetica, 'Microsoft Yahei'; -} - -input, -button { - font-family: Helvetica, 'Microsoft Yahei'; -} diff --git a/static/css/wide.css b/static/css/wide.css index f292708..5b498a6 100644 --- a/static/css/wide.css +++ b/static/css/wide.css @@ -222,7 +222,6 @@ background: white; font-size: 90%; - font-family: Consolas, Courier New, monospace; max-height: 20em; overflow-y: auto; @@ -230,7 +229,6 @@ .CodeMirror, .CodeMirror-hints { - font-family: Consolas, Courier New, monospace; } .CodeMirror-focused .cm-matchhighlight { diff --git a/static/user/admin/style.css b/static/user/admin/style.css index ad31a3a..1617aab 100644 --- a/static/user/admin/style.css +++ b/static/user/admin/style.css @@ -1,12 +1,12 @@ -body { - font-family: Helvetica, 'Microsoft Yahei'; -} - +body, input, button { - font-family: Helvetica, 'Microsoft Yahei'; + font-family: Helvetica; } -.edit-exprinfo, .CodeMirror, .CodeMirror-hints { - font-size: ; +.edit-exprinfo, +.CodeMirror, +.CodeMirror-hints { + font-family: Consolas, 'Courier New', monospace; + font-size: inherit; } \ No newline at end of file diff --git a/static/user/style.css.tmpl b/static/user/style.css.tmpl index 3ecb22b..1e74c53 100644 --- a/static/user/style.css.tmpl +++ b/static/user/style.css.tmpl @@ -1,12 +1,12 @@ -body { - font-family: {{.font_family}}; -} - +body, input, button { - font-family: {{.font_family}}; + font-family: {{.user.FontFamily}}; } -.edit-exprinfo, .CodeMirror, .CodeMirror-hints { - font-size: {{.font_size}}; +.edit-exprinfo, +.CodeMirror, +.CodeMirror-hints { + font-family: {{.user.Editor.FontFamily}}; + font-size: {{.user.Editor.FontSize}}; } \ No newline at end of file diff --git a/views/index.html b/views/index.html index 9a3c43d..5254633 100644 --- a/views/index.html +++ b/views/index.html @@ -14,12 +14,13 @@ - + +