在线文档
This commit is contained in:
parent
a6034fbfd9
commit
b244c94e8f
|
@ -0,0 +1,16 @@
|
|||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>Wide - 文档首页</title>
|
||||
|
||||
</head>
|
||||
<body>
|
||||
<h1>Wide</h1>
|
||||
Wide 是一个基于 Web 的 golang 在线 IDE。
|
||||
|
||||
<ul>
|
||||
<li><a href="/doc/zh_CN/keyboard_shortcuts.html">键盘快捷键</a></li>
|
||||
</ul>
|
||||
</body>
|
||||
</html>
|
|
@ -1,3 +0,0 @@
|
|||
# Wide
|
||||
|
||||
Wide 是一个基于 Web 的 golang 在线 IDE。
|
|
@ -0,0 +1,17 @@
|
|||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>Wide - 键盘快捷键</title>
|
||||
|
||||
</head>
|
||||
<body>
|
||||
<h1>键盘快捷键</h1>
|
||||
|
||||
<ul>
|
||||
<li>F11: 编辑器全屏</li>
|
||||
<li>Ctrl+G: 跳转到行</li>
|
||||
<li>Ctrl+\\: 自动补全</li>
|
||||
</ul>
|
||||
</body>
|
||||
</html>
|
|
@ -1,5 +0,0 @@
|
|||
# 键盘快捷键
|
||||
|
||||
* F11: 编辑器全屏
|
||||
* Ctrl+G: 跳转到行
|
||||
* Ctrl+\: 自动补全
|
|
@ -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"
|
||||
}
|
||||
|
|
33
main.go
33
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)
|
||||
|
|
|
@ -60,6 +60,8 @@
|
|||
|
||||
<textarea id="shellOutput" class="shellOutput" rows="8"></textarea>
|
||||
</div>
|
||||
|
||||
<a href="/doc/{{.locale}}/index.html" target="_blank">Help</a>
|
||||
</div>
|
||||
|
||||
<script type="text/javascript">
|
Loading…
Reference in New Issue