Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit eefbea8

Browse files
author
xuxinhua
committed
Merge branch 'master' into develop
2 parents a30f200 + b48e8d8 commit eefbea8

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

75 files changed

+1522
-439
lines changed

.gitignore

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,4 +40,6 @@ studygolang_data.sql
4040

4141
welcome.png
4242

43-
*.json
43+
*.json
44+
45+
.DS_Store
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
#!/usr/bin/env bash
2+
3+
set -e
4+
5+
if [ ! -f install ]; then
6+
echo 'install must be run within its container folder' 1>&2
7+
exit 1
8+
fi
9+
10+
CURDIR=`pwd`
11+
OLDGOPATH="$GOPATH"
12+
export GOPATH="$CURDIR"
13+
14+
if [ ! -d "src/github.com/studygolang/mux" ]; then
15+
go get -u -v github.com/studygolang/mux
16+
fi
17+
18+
gofmt -w src
19+
20+
go install gox
21+
22+
export GOPATH="$OLDGOPATH"
23+
export PATH="$OLDPATH"
24+
25+
echo 'finished'
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/github.com
Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
// Copyright 2015 The StudyGolang Authors. All rights reserved.
2+
// Use of this source code is governed by a BSD-style
3+
// license that can be found in the LICENSE file.
4+
// http://studygolang.com http://golang.top
5+
// Author:polaris [email protected]
6+
7+
// golang.org/x/... 系列的包,go get 不下来,原因你懂的
8+
// 该程序解决此问题,要求使用 go get 的客户端,配置如下 host:
9+
// 101.251.196.90 golang.org
10+
package main
11+
12+
import (
13+
"fmt"
14+
"log"
15+
"net/http"
16+
"runtime"
17+
"strings"
18+
"text/template"
19+
20+
"github.com/studygolang/mux"
21+
)
22+
23+
func init() {
24+
runtime.GOMAXPROCS(runtime.NumCPU())
25+
}
26+
27+
func main() {
28+
29+
router := initRouter()
30+
http.Handle("/", router)
31+
log.Fatal(http.ListenAndServe(":9999", nil))
32+
}
33+
34+
// TODO:多人同时请求不同的包,验证可能会失败
35+
var project = ""
36+
37+
func initRouter() *mux.Router {
38+
router := mux.NewRouter()
39+
40+
router.PathPrefix("/x").HandlerFunc(func(rw http.ResponseWriter, req *http.Request) {
41+
path := req.URL.Path
42+
43+
paths := strings.SplitN(path, "/", 4)
44+
45+
if len(paths) < 3 {
46+
return parseTmpl(rw)
47+
}
48+
project = paths[2]
49+
50+
parseTmpl(rw)
51+
})
52+
53+
return router
54+
}
55+
56+
func parseTmpl(rw http.ResponseWriter) {
57+
tmpl, err := template.New("gox").Parse(tpl)
58+
if err != nil {
59+
fmt.Fprintln(rw, "error:", err)
60+
return
61+
}
62+
63+
err = tmpl.Execute(rw, project)
64+
if err != nil {
65+
fmt.Fprintln(rw, "error:", err)
66+
return
67+
}
68+
}
69+
70+
var tpl = `
71+
<!DOCTYPE html>
72+
<html lang="zh-CN">
73+
<head>
74+
<meta charset="utf-8">
75+
<meta name="go-import" content="golang.org/x/{{.}} git https://github.com/golang/{{.}}">
76+
</head>
77+
<body>
78+
</body>
79+
</html>
80+
`

websites/code/studygolang/conf/config.json.example

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@
1313
"data": "data/max_online_num",
1414
"pid": "pid/studygolang.pid",
1515

16+
"unsubscribe_token_key": "xxxxx",
17+
1618
"qiniu_access_key": "xxxxxxxxxxxxx",
1719
"qiniu_secret_key": "xxxxxxxxxxxxxx",
1820
"qiniu_bucket_name": "xxxxxxxxx",

websites/code/studygolang/install

100644100755
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ DATE=`date +%FT%T%z`
2020

2121
gofmt -w src
2222

23-
go install -ldflags "-X util.Version "$VERSION" -X util.Date "$DATE ./...
23+
go install -ldflags "-X util/version.Version "$VERSION" -X util/version.Date "$DATE ./...
2424

2525
export GOPATH="$OLDGOPATH"
2626
export PATH="$OLDPATH"

websites/code/studygolang/install.bat

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ set VERSION=%VERNAME%-%VERCODE%
2323
gofmt -w src
2424

2525
:: -tags "debug" 表示测试
26-
go install -tags "debug" -ldflags "-X util.Version "%VERSION%" -X util.Date "%date:~3,10%T%time%"" ./...
26+
go install -tags "debug" -ldflags "-X util.version.Version "%VERSION% ./...
2727

2828
set GOPATH=%OLDGOPATH%
2929

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/github.com
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
// Copyright 2014 The StudyGolang Authors. All rights reserved.
2+
// Use of this source code is governed by a BSD-style
3+
// license that can be found in the LICENSE file.
4+
// http://studygolang.com http://golang.top
5+
// Author:polaris [email protected]
6+
7+
package api
8+
9+
import (
10+
"fmt"
11+
"net/http"
12+
"service"
13+
)
14+
15+
func AddRedditResourceHandler(rw http.ResponseWriter, req *http.Request) {
16+
err := service.ParseReddit(req.FormValue("url"))
17+
if err != nil {
18+
fmt.Fprint(rw, err)
19+
return
20+
}
21+
22+
fmt.Fprint(rw, "success")
23+
}

websites/code/studygolang/src/controller/account.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,9 +65,9 @@ func RegisterHandler(rw http.ResponseWriter, req *http.Request) {
6565

6666
func sendWelcomeMail(email []string) {
6767
content := `Welcome to Study Golang.<br><br>
68-
欢迎您,成功注册成为 Golang中文社区 | Go语言学习园地 会员<br><br>
68+
欢迎您,成功注册成为 Go语言中文网 | Go语言学习园地 会员<br><br>
6969
Golang中文社区是一个Go语言技术社区,完全用Go语言开发。我们为gopher们提供一个好的学习交流场所。加入到社区中来,参与分享,学习,不断提高吧。前往 <a href="http://studygolang.com">Golang中文社区 | Go语言学习园地</a><br>
70-
<div style="text-align:right;">&copy;2012-2014 studygolang.com Golang中文社区 | Go语言学习园地</div>`
70+
<div style="text-align:right;">&copy;2012-2015 studygolang.com Go语言中文网 | Golang中文社区 | Go语言学习园地</div>`
7171
service.SendMail("Golang中文社区 | Go语言学习园地 注册成功通知", content, email)
7272
}
7373

0 commit comments

Comments
 (0)