From 0923122ce87310590c20b566dbcf1f7bcbca19d7 Mon Sep 17 00:00:00 2001 From: Liang Ding Date: Tue, 2 Sep 2014 22:57:30 +0800 Subject: [PATCH] =?UTF-8?q?=E7=95=8C=E9=9D=A2=E5=B8=83=E5=B1=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- conf/wide.go | 1 + conf/wide.json | 1 + i18n/locales.go | 7 +------ i18n/zh_CN.json | 14 ++++++++++++-- main.go | 15 +++++++++++++++ static/css/base.css | 6 ++++++ static/js/wide.js | 2 +- view/index.html | 31 +++++++++++++++++-------------- 8 files changed, 54 insertions(+), 23 deletions(-) diff --git a/conf/wide.go b/conf/wide.go index dd700e0..5772be5 100644 --- a/conf/wide.go +++ b/conf/wide.go @@ -26,6 +26,7 @@ type conf struct { StaticResourceVersion string ContextPath string StaticPath string + MaxProcs int RuntimeMode string Repos string UserRepos string diff --git a/conf/wide.json b/conf/wide.json index 92d9dc7..628f722 100644 --- a/conf/wide.json +++ b/conf/wide.json @@ -7,6 +7,7 @@ "StaticResourceVersion": "", "ContextPath": "", "StaticPath": "", + "MaxProcs": 4, "RuntimeMode": "dev", "Repos": "{pwd}/data/workspace/src", "UserRepos": "{pwd}/data/user_workspaces/{user}/src", diff --git a/i18n/locales.go b/i18n/locales.go index a9e6748..1052bd2 100644 --- a/i18n/locales.go +++ b/i18n/locales.go @@ -2,7 +2,6 @@ package i18n import ( "encoding/json" - "flag" "github.com/golang/glog" "io/ioutil" "net/http" @@ -18,11 +17,7 @@ type locale struct { // 所有的 locales. var Locales = map[string]locale{} -func init() { - flag.Set("logtostderr", "true") - - flag.Parse() - +func Load() { // TODO: 加载所有语言配置 bytes, _ := ioutil.ReadFile("i18n/zh_CN.json") diff --git a/i18n/zh_CN.json b/i18n/zh_CN.json index 878f295..5dfc57b 100644 --- a/i18n/zh_CN.json +++ b/i18n/zh_CN.json @@ -1,4 +1,14 @@ { - "wide": "Wide" - + "wide": "Wide", + "file": "文件", + "run": "运行", + "debug": "调试", + "help": "帮助", + "create_file": "创建文件", + "create_dir": "创建目录", + "delete": "删除", + "save": "保存", + "format": "格式化", + "build_n_run": "构建 & 运行", + "full_screen": "全屏" } \ No newline at end of file diff --git a/main.go b/main.go index e5fd412..6e33f68 100644 --- a/main.go +++ b/main.go @@ -1,6 +1,7 @@ package main import ( + "flag" "github.com/b3log/wide/conf" "github.com/b3log/wide/editor" "github.com/b3log/wide/file" @@ -12,10 +13,20 @@ import ( "html/template" "math/rand" "net/http" + "runtime" "strconv" ) +// Wide 中唯一一个 init 函数. +func init() { + flag.Set("logtostderr", "true") + + flag.Parse() +} + func indexHandler(w http.ResponseWriter, r *http.Request) { + i18n.Load() + model := map[string]interface{}{"Wide": conf.Wide, "i18n": i18n.GetLangs(r), "locale": i18n.GetLocale(r)} session, _ := user.Session.Get(r, "wide-session") @@ -49,6 +60,10 @@ func indexHandler(w http.ResponseWriter, r *http.Request) { func main() { conf.Load() + runtime.GOMAXPROCS(conf.Wide.MaxProcs) + + defer glog.Flush() + // 静态资源 http.Handle("/static/", http.StripPrefix("/static/", http.FileServer(http.Dir("static")))) diff --git a/static/css/base.css b/static/css/base.css index d13f72e..530f3ef 100644 --- a/static/css/base.css +++ b/static/css/base.css @@ -75,6 +75,12 @@ ul { } /* end framework */ +/* start output */ +#output { + width: 100%; +} +/* end output */ + diff --git a/static/js/wide.js b/static/js/wide.js index 7b2e4fa..b923a4c 100644 --- a/static/js/wide.js +++ b/static/js/wide.js @@ -69,7 +69,7 @@ var wide = { curNode: undefined, curEditor: undefined, _initLayout: function () { - var mainH = $(window).height() - $(".menu").height() - $(".footer").height(); + var mainH = $(window).height() - $(".menu").height() - $(".footer").height() - 2; $(".content, .ztree").height(mainH); $(".edit-panel").height(mainH - $(".output").height()); diff --git a/view/index.html b/view/index.html index d641f39..5ca6af3 100644 --- a/view/index.html +++ b/view/index.html @@ -13,8 +13,16 @@ -