diff --git a/doc/zh_CN/index.html b/doc/zh_CN/index.html
new file mode 100644
index 0000000..b60fb20
--- /dev/null
+++ b/doc/zh_CN/index.html
@@ -0,0 +1,16 @@
+
+
+
+
+ Wide - 文档首页
+
+
+
+ Wide
+ Wide 是一个基于 Web 的 golang 在线 IDE。
+
+
+
+
diff --git a/doc/zh_CN/index.md b/doc/zh_CN/index.md
deleted file mode 100644
index b0ee016..0000000
--- a/doc/zh_CN/index.md
+++ /dev/null
@@ -1,3 +0,0 @@
-# Wide
-
-Wide 是一个基于 Web 的 golang 在线 IDE。
diff --git a/doc/zh_CN/keyboard_shortcuts.html b/doc/zh_CN/keyboard_shortcuts.html
new file mode 100644
index 0000000..7d158c0
--- /dev/null
+++ b/doc/zh_CN/keyboard_shortcuts.html
@@ -0,0 +1,17 @@
+
+
+
+
+ Wide - 键盘快捷键
+
+
+
+ 键盘快捷键
+
+
+ - F11: 编辑器全屏
+ - Ctrl+G: 跳转到行
+ - Ctrl+\\: 自动补全
+
+
+
diff --git a/doc/zh_CN/keyboard_shortcuts.md b/doc/zh_CN/keyboard_shortcuts.md
deleted file mode 100644
index 890df7c..0000000
--- a/doc/zh_CN/keyboard_shortcuts.md
+++ /dev/null
@@ -1,5 +0,0 @@
-# 键盘快捷键
-
-* F11: 编辑器全屏
-* Ctrl+G: 跳转到行
-* Ctrl+\: 自动补全
diff --git a/i18n/locales.go b/i18n/locales.go
index e29f845..a9e6748 100644
--- a/i18n/locales.go
+++ b/i18n/locales.go
@@ -42,12 +42,12 @@ func init() {
}
func GetLangs(r *http.Request) map[string]interface{} {
- locale := getLocale(r)
+ locale := GetLocale(r)
return Locales[locale].Langs
}
-func getLocale(r *http.Request) string {
+func GetLocale(r *http.Request) string {
// TODO: 从请求中获取 locale
return "zh_CN"
}
diff --git a/main.go b/main.go
index d28ccf6..d818ca0 100644
--- a/main.go
+++ b/main.go
@@ -16,22 +16,22 @@ import (
)
func indexHandler(w http.ResponseWriter, r *http.Request) {
- model := map[string]interface{}{"Wide": conf.Wide, "i18n": i18n.GetLangs(r)}
+ model := map[string]interface{}{"Wide": conf.Wide, "i18n": i18n.GetLangs(r), "locale": i18n.GetLocale(r)}
session, _ := user.Session.Get(r, "wide-session")
- if session.IsNew {
- // TODO: 以 admin 作为用户登录
- name := conf.Wide.Users[0].Name
- glog.Infof("[%s] logged in", name)
+ // TODO: if session.IsNew {
+ // TODO: 以 admin 作为用户登录
+ name := conf.Wide.Users[0].Name
+ glog.Infof("[%s] logged in", name)
- session.Values["username"] = name
- session.Values["id"] = strconv.Itoa(rand.Int())
- }
+ session.Values["username"] = name
+ session.Values["id"] = strconv.Itoa(rand.Int())
+ // }
session.Save(r, w)
- t, err := template.ParseFiles("templates/index.html")
+ t, err := template.ParseFiles("view/index.html")
if nil != err {
glog.Error(err)
@@ -46,30 +46,39 @@ func indexHandler(w http.ResponseWriter, r *http.Request) {
func main() {
conf.Load()
+ // 静态资源
http.Handle("/static/", http.StripPrefix("/static/", http.FileServer(http.Dir("static"))))
+ // IDE 首页
http.HandleFunc("/", indexHandler)
+ // 运行相关
http.HandleFunc("/build", output.BuildHandler)
http.HandleFunc("/run", output.RunHandler)
http.HandleFunc("/output/ws", output.WSHandler)
+ // 文件树
http.HandleFunc("/files", file.GetFiles)
http.HandleFunc("/file", file.GetFile)
http.HandleFunc("/file/save", file.SaveFile)
http.HandleFunc("/file/new", file.NewFile)
http.HandleFunc("/file/remove", file.RemoveFile)
+ // 编辑器
http.HandleFunc("/editor/ws", editor.WSHandler)
http.HandleFunc("/fmt", editor.FmtHandler)
-
- http.HandleFunc("/shell/ws", shell.WSHandler)
-
http.HandleFunc("/autocomplete", editor.AutocompleteHandler)
+ // Shell
+ http.HandleFunc("/shell/ws", shell.WSHandler)
+
+ // 用户
http.HandleFunc("/user/new", user.AddUser)
http.HandleFunc("/user/repos/init", user.InitGitRepos)
+ // 文档
+ http.Handle("/doc/", http.StripPrefix("/doc/", http.FileServer(http.Dir("doc"))))
+
glog.Infof("Wide is running [%s]", conf.Wide.Server)
err := http.ListenAndServe(conf.Wide.Server, nil)
diff --git a/templates/index.html b/view/index.html
similarity index 98%
rename from templates/index.html
rename to view/index.html
index 8f7519c..325f9ff 100644
--- a/templates/index.html
+++ b/view/index.html
@@ -60,6 +60,8 @@
+
+ Help