界面布局

This commit is contained in:
Liang Ding 2014-09-02 22:57:30 +08:00
parent b2b08ccdd2
commit 0923122ce8
8 changed files with 54 additions and 23 deletions

View File

@ -26,6 +26,7 @@ type conf struct {
StaticResourceVersion string StaticResourceVersion string
ContextPath string ContextPath string
StaticPath string StaticPath string
MaxProcs int
RuntimeMode string RuntimeMode string
Repos string Repos string
UserRepos string UserRepos string

View File

@ -7,6 +7,7 @@
"StaticResourceVersion": "", "StaticResourceVersion": "",
"ContextPath": "", "ContextPath": "",
"StaticPath": "", "StaticPath": "",
"MaxProcs": 4,
"RuntimeMode": "dev", "RuntimeMode": "dev",
"Repos": "{pwd}/data/workspace/src", "Repos": "{pwd}/data/workspace/src",
"UserRepos": "{pwd}/data/user_workspaces/{user}/src", "UserRepos": "{pwd}/data/user_workspaces/{user}/src",

View File

@ -2,7 +2,6 @@ package i18n
import ( import (
"encoding/json" "encoding/json"
"flag"
"github.com/golang/glog" "github.com/golang/glog"
"io/ioutil" "io/ioutil"
"net/http" "net/http"
@ -18,11 +17,7 @@ type locale struct {
// 所有的 locales. // 所有的 locales.
var Locales = map[string]locale{} var Locales = map[string]locale{}
func init() { func Load() {
flag.Set("logtostderr", "true")
flag.Parse()
// TODO: 加载所有语言配置 // TODO: 加载所有语言配置
bytes, _ := ioutil.ReadFile("i18n/zh_CN.json") bytes, _ := ioutil.ReadFile("i18n/zh_CN.json")

View File

@ -1,4 +1,14 @@
{ {
"wide": "Wide" "wide": "Wide",
"file": "文件",
"run": "运行",
"debug": "调试",
"help": "帮助",
"create_file": "创建文件",
"create_dir": "创建目录",
"delete": "删除",
"save": "保存",
"format": "格式化",
"build_n_run": "构建 & 运行",
"full_screen": "全屏"
} }

15
main.go
View File

@ -1,6 +1,7 @@
package main package main
import ( import (
"flag"
"github.com/b3log/wide/conf" "github.com/b3log/wide/conf"
"github.com/b3log/wide/editor" "github.com/b3log/wide/editor"
"github.com/b3log/wide/file" "github.com/b3log/wide/file"
@ -12,10 +13,20 @@ import (
"html/template" "html/template"
"math/rand" "math/rand"
"net/http" "net/http"
"runtime"
"strconv" "strconv"
) )
// Wide 中唯一一个 init 函数.
func init() {
flag.Set("logtostderr", "true")
flag.Parse()
}
func indexHandler(w http.ResponseWriter, r *http.Request) { 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)} model := map[string]interface{}{"Wide": conf.Wide, "i18n": i18n.GetLangs(r), "locale": i18n.GetLocale(r)}
session, _ := user.Session.Get(r, "wide-session") session, _ := user.Session.Get(r, "wide-session")
@ -49,6 +60,10 @@ func indexHandler(w http.ResponseWriter, r *http.Request) {
func main() { func main() {
conf.Load() conf.Load()
runtime.GOMAXPROCS(conf.Wide.MaxProcs)
defer glog.Flush()
// 静态资源 // 静态资源
http.Handle("/static/", http.StripPrefix("/static/", http.FileServer(http.Dir("static")))) http.Handle("/static/", http.StripPrefix("/static/", http.FileServer(http.Dir("static"))))

View File

@ -75,6 +75,12 @@ ul {
} }
/* end framework */ /* end framework */
/* start output */
#output {
width: 100%;
}
/* end output */

View File

@ -69,7 +69,7 @@ var wide = {
curNode: undefined, curNode: undefined,
curEditor: undefined, curEditor: undefined,
_initLayout: function () { _initLayout: function () {
var mainH = $(window).height() - $(".menu").height() - $(".footer").height(); var mainH = $(window).height() - $(".menu").height() - $(".footer").height() - 2;
$(".content, .ztree").height(mainH); $(".content, .ztree").height(mainH);
$(".edit-panel").height(mainH - $(".output").height()); $(".edit-panel").height(mainH - $(".output").height());

View File

@ -13,8 +13,16 @@
<link rel="stylesheet" href="{{.Wide.StaticServer}}/static/css/base.css"> <link rel="stylesheet" href="{{.Wide.StaticServer}}/static/css/base.css">
</head> </head>
<body> <body>
<div class="menu"> <div class="menu fn-clear">
<a href="/doc/{{.locale}}/index.html" target="_blank">Help</a> <a href="/doc/{{.locale}}/index.html" target="_blank">{{.i18n.file}}</a>
<a href="/doc/{{.locale}}/index.html" target="_blank">{{.i18n.run}}</a>
<a href="/doc/{{.locale}}/index.html" target="_blank">{{.i18n.debug}}</a>
<a href="/doc/{{.locale}}/index.html" target="_blank">{{.i18n.help}}</a>
<div class="toolbars fn-right">
<button onclick="wide.save()">{{.i18n.save}}</button>
<button onclick="wide.fmt()">{{.i18n.format}}</button>
<button onclick="wide.run()">{{.i18n.build_n_run}}</button>
</div>
</div> </div>
<div class="content"> <div class="content">
@ -25,16 +33,16 @@
<!-- 目录右键菜单 --> <!-- 目录右键菜单 -->
<div id="dirRMenu" class="fn-none"> <div id="dirRMenu" class="fn-none">
<ul> <ul>
<li onclick="tree.newFile();">create file....</li> <li onclick="tree.newFile();">{{.i18n.create_file}}</li>
<li onclick="tree.newDir();">create dir....</li> <li onclick="tree.newDir();">{{.i18n.create_file}}</li>
<li onclick="tree.removeIt();">delete it....</li> <li onclick="tree.removeIt();">{{.i18n.delete}}</li>
</ul> </ul>
</div> </div>
<!-- 文件右键菜单 --> <!-- 文件右键菜单 -->
<div id="fileRMenu" class="fn-none"> <div id="fileRMenu" class="fn-none">
<ul> <ul>
<li onclick="tree.removeIt();">delete it....</li> <li onclick="tree.removeIt();">{{.i18n.delete}}</li>
</ul> </ul>
</div> </div>
</div> </div>
@ -46,24 +54,19 @@
<div class="edit-panel"> <div class="edit-panel">
<div class="edit-header fn-clear"> <div class="edit-header fn-clear">
<div class="tabs fn-left"></div> <div class="tabs fn-left"></div>
<span class="fn-none fn-right ico-fullscreen" onclick="editors.fullscreen()">全屏</span> <span class="fn-none fn-right ico-fullscreen" onclick="editors.fullscreen()">{{.i18n.full_screen}}</span>
</div> </div>
<div class="tabs-panel"></div> <div class="tabs-panel"></div>
</div> </div>
<div class="output"> <div class="output">
<div> <textarea id="output" rows="8"></textarea>
<button onclick="wide.save()">Save</button>
<button onclick="wide.fmt()">Format</button>
<button onclick="wide.run()">Build & Run</button>
</div>
<textarea id="output" rows="7"></textarea>
</div> </div>
</div> </div>
</div> </div>
<div class="footer"> <div class="footer">
copyright 88250 & vanessa |
</div> </div>
<script type="text/javascript"> <script type="text/javascript">