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

Skip to content

Commit f2d6a94

Browse files
committed
修改目录结构
1 parent b3c9cd1 commit f2d6a94

File tree

218 files changed

+410
-1185
lines changed

Some content is hidden

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

218 files changed

+410
-1185
lines changed

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,4 +48,4 @@ welcome.png
4848
.DS_Store
4949
/env.ini
5050
ssl
51-
studygolang
51+
bin

Makefile

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,19 @@
1-
.PHONY: getpkg install reload start stop migrate
1+
.PHONY: build reload start stop
22

33
v=""
44

5-
getpkg:
6-
./getpkg.sh
5+
BUILD = $(shell git symbolic-ref HEAD | cut -b 12-)-$(shell git rev-parse HEAD)
76

8-
install:
9-
./install.sh
7+
build:
8+
if [ ! -d log ]; then mkdir log; fi
9+
10+
go build -ldflags "-X global.Build=$(BUILD)" -o bin/studygolang github.com/studygolang/studygolang/cmd/studygolang
1011

1112
reload:
1213
./reload.sh
1314

1415
start:
15-
./start.sh
16+
./start.sh
1617

1718
stop:
18-
./stop.sh
19-
20-
migrate:
21-
./bin/migrator --changeVersion=${v}
19+
./stop.sh

cmd/crawler.go

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,6 @@
77
package cmd
88

99
import (
10-
"github.com/studygolang/studygolang/modules/server"
11-
1210
"github.com/polaris1119/config"
1311
"github.com/polaris1119/keyword"
1412
"github.com/polaris1119/logger"
@@ -18,7 +16,7 @@ func Crawler() {
1816
logger.Init(config.ROOT+"/log", config.ConfigFile.MustValue("global", "log_level", "DEBUG"), "crawl")
1917
go keyword.Extractor.Init(keyword.DefaultProps, true, config.ROOT+"/data/programming.txt,"+config.ROOT+"/data/dictionary.txt")
2018

21-
server.CrawlServer()
19+
CrawlServer()
2220

2321
select {}
2422
}

cmd/indexer.go

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,6 @@
77
package cmd
88

99
import (
10-
"github.com/studygolang/studygolang/modules/server"
11-
1210
"github.com/polaris1119/config"
1311
"github.com/polaris1119/keyword"
1412
"github.com/polaris1119/logger"
@@ -18,7 +16,7 @@ func Indexer() {
1816
logger.Init(config.ROOT+"/log", config.ConfigFile.MustValue("global", "log_level", "DEBUG"))
1917
go keyword.Extractor.Init(keyword.DefaultProps, true, config.ROOT+"/data/programming.txt,"+config.ROOT+"/data/dictionary.txt")
2018

21-
server.IndexingServer()
19+
IndexingServer()
2220

2321
select {}
2422
}

cmd/migrator.go

Lines changed: 0 additions & 20 deletions
This file was deleted.

modules/server/server.go renamed to cmd/server.go

Lines changed: 2 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -6,33 +6,23 @@
66

77
// 可选择是否在启动主程序时,同时嵌入 indexer 和 crawler,减少内存占用
88

9-
package server
9+
package cmd
1010

1111
import (
1212
"flag"
13-
"fmt"
14-
"os"
1513
"time"
1614

17-
"github.com/studygolang/studygolang/modules/logic"
15+
"github.com/studygolang/studygolang/logic"
1816

1917
"github.com/polaris1119/config"
2018
"github.com/polaris1119/logger"
2119
"github.com/robfig/cron"
2220
)
2321

24-
var usageStr = `
25-
Usage: migrator [options]
26-
27-
Opthions:
28-
--changeVersion <version> changeset version(1.0)
29-
`
30-
3122
var (
3223
manualIndex = flag.Bool("manual", false, "do manual index once or not")
3324
needAll = flag.Bool("all", false, "是否需要全量抓取,默认否")
3425
whichSite = flag.String("site", "", "抓取哪个站点(空表示所有站点)")
35-
changeVersion = flag.String("changeVersion", "", usageStr)
3626
)
3727

3828
func IndexingServer() {
@@ -103,14 +93,3 @@ func autocrawl(needAll bool, whichSite string) {
10393
})
10494
c.Start()
10595
}
106-
107-
func MigratorServer() {
108-
if !flag.Parsed() {
109-
flag.Parse()
110-
}
111-
if *changeVersion == "" {
112-
fmt.Printf("%s\n", usageStr)
113-
os.Exit(1)
114-
}
115-
logic.DefaultMigrator.Migrator(*changeVersion)
116-
}

background.go renamed to cmd/studygolang/background.go

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,15 @@ import (
1010
"flag"
1111
"time"
1212

13-
"github.com/studygolang/studygolang/modules/db"
14-
"github.com/studygolang/studygolang/modules/global"
15-
"github.com/studygolang/studygolang/modules/logic"
16-
"github.com/studygolang/studygolang/modules/model"
17-
"github.com/studygolang/studygolang/modules/server"
18-
1913
"github.com/polaris1119/config"
2014
"github.com/polaris1119/logger"
2115
"github.com/robfig/cron"
16+
17+
"github.com/studygolang/studygolang/cmd"
18+
"github.com/studygolang/studygolang/db"
19+
"github.com/studygolang/studygolang/global"
20+
"github.com/studygolang/studygolang/logic"
21+
"github.com/studygolang/studygolang/model"
2222
)
2323

2424
var (
@@ -38,10 +38,10 @@ func ServeBackGround() {
3838
logic.DefaultUploader.InitQiniu()
3939

4040
if *embedIndexing {
41-
server.IndexingServer()
41+
cmd.IndexingServer()
4242
}
4343
if *embedCrawler {
44-
server.CrawlServer()
44+
cmd.CrawlServer()
4545
}
4646

4747
// 常驻内存的数据
File renamed without changes.
File renamed without changes.

main.go renamed to cmd/studygolang/main.go

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -14,21 +14,21 @@ import (
1414
"strconv"
1515
"time"
1616

17-
"github.com/studygolang/studygolang/modules/global"
18-
pwm "github.com/studygolang/studygolang/modules/http/middleware"
19-
"github.com/studygolang/studygolang/modules/http/controller"
20-
"github.com/studygolang/studygolang/modules/http/controller/admin"
21-
"github.com/studygolang/studygolang/modules/http/controller/app"
22-
"github.com/studygolang/studygolang/modules/logic"
2317
"github.com/studygolang/studygolang/cmd"
24-
thirdmw "github.com/studygolang/studygolang/modules/middleware"
18+
"github.com/studygolang/studygolang/global"
19+
"github.com/studygolang/studygolang/http/controller"
20+
"github.com/studygolang/studygolang/http/controller/admin"
21+
"github.com/studygolang/studygolang/http/controller/app"
22+
pwm "github.com/studygolang/studygolang/http/middleware"
23+
"github.com/studygolang/studygolang/logic"
24+
thirdmw "github.com/studygolang/studygolang/middleware"
2525

2626
"github.com/fatih/structs"
27-
echo "github.com/labstack/echo/v4"
27+
"github.com/labstack/echo/v4"
2828
mw "github.com/labstack/echo/v4/middleware"
29+
. "github.com/polaris1119/config"
2930
"github.com/polaris1119/keyword"
3031
"github.com/polaris1119/logger"
31-
. "github.com/polaris1119/config"
3232
)
3333

3434
func init() {
@@ -47,9 +47,6 @@ func main() {
4747
case "crawler":
4848
cmd.Crawler()
4949
return
50-
case "migrator":
51-
cmd.Migrator()
52-
return
5350
}
5451
}
5552

@@ -85,7 +82,6 @@ func main() {
8582
frontG := e.Group("")
8683
controller.RegisterRoutes(frontG)
8784

88-
frontG.GET("/admin", echo.HandlerFunc(admin.AdminIndex), pwm.NeedLogin(), pwm.AdminAuth())
8985
adminG := e.Group("/admin", pwm.NeedLogin(), pwm.AdminAuth())
9086
admin.RegisterRoutes(adminG)
9187

File renamed without changes.

static.go renamed to cmd/studygolang/static.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,10 @@ type staticRootConf struct {
1818
}
1919

2020
var staticFileMap = map[string]staticRootConf{
21-
"/static/": {"/static", false},
21+
"/static": {"/static", false},
2222
"/favicon.ico": {"/static/img/go.ico", true},
2323
// 服务 sitemap 文件
24-
"/sitemap/": {"/sitemap", false},
24+
"/sitemap": {"/sitemap", false},
2525
}
2626

2727
var filterPrefixs = make([]string, 0, 3)

config/init.sql

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,9 +56,9 @@ VALUES
5656
(43, '编辑/新增节点', 15, 42, '/admin/community/node/modify', 'polaris', '2017-09-01 22:23:08', '2017-09-01 23:11:09');
5757

5858

59-
INSERT INTO `website_setting` (`id`, `name`, `domain`, `title_suffix`, `favicon`, `logo`, `start_year`, `blog_url`, `reading_menu`, `docs_menu`, `slogan`, `beian`, `friends_logo`, `footer_nav`, `project_df_logo`, `index_nav`, `created_at`, `updated_at`)
59+
INSERT INTO `website_setting` (`name`, `domain`, `title_suffix`, `favicon`, `logo`, `start_year`, `blog_url`, `reading_menu`, `docs_menu`, `slogan`, `beian`, `friends_logo`, `footer_nav`, `project_df_logo`, `index_nav`, `created_at`)
6060
VALUES
61-
(1, 'Go语言中文网', 'studygolang.com', '- Go语言中文网 - Golang中文社区', '/static/img/go.ico', '/static/img/logo1.png', 2013, 'http://blog.studygolang.com', '', '', 'Go语言中文网,中国 Golang 社区,致力于构建完善的 Golang 中文社区,Go语言爱好者的学习家园。', '京ICP备14030343号-1', '[{\"image\":\"http://qiniutek.com/images/logo-2.png\",\"url\":\"https://portal.qiniu.com/signup?code=3lfz4at7pxfma\",\"name\":\"\",\"width\":\"290px\",\"height\":\"45px\"}]', '[{\"name\":\"关于\",\"url\":\"/wiki/about\",\"outer_site\":false},{\"name\":\"贡献者\",\"url\":\"/wiki/contributors\",\"outer_site\":false},{\"name\":\"帮助推广\",\"url\":\"/wiki\",\"outer_site\":false},{\"name\":\"反馈\",\"url\":\"/topics/node/16\",\"outer_site\":false},{\"name\":\"Github\",\"url\":\"https://github.com/studygolang\",\"outer_site\":true},{\"name\":\"新浪微博\",\"url\":\"http://weibo.com/studygolang\",\"outer_site\":true},{\"name\":\"内嵌Wide\",\"url\":\"/wide/playground\",\"outer_site\":false},{\"name\":\"免责声明\",\"url\":\"/wiki/duty\",\"outer_site\":false}]', '', '[{"tab":"all"}]', '2017-05-21 10:22:00', '2017-05-21 21:30:56');
61+
('Go语言中文网', 'studygolang.com', '- Go语言中文网 - Golang中文社区', '/static/img/go.ico', '/static/img/logo1.png', 2013, 'http://blog.studygolang.com', '', '', 'Go语言中文网,中国 Golang 社区,致力于构建完善的 Golang 中文社区,Go语言爱好者的学习家园。', '京ICP备14030343号-1', '', '[{\"name\":\"关于\",\"url\":\"/wiki/about\",\"outer_site\":false},{\"name\":\"贡献者\",\"url\":\"/wiki/contributors\",\"outer_site\":false},{\"name\":\"帮助推广\",\"url\":\"/wiki\",\"outer_site\":false},{\"name\":\"反馈\",\"url\":\"/topics/node/16\",\"outer_site\":false},{\"name\":\"Github\",\"url\":\"https://github.com/studygolang\",\"outer_site\":true},{\"name\":\"新浪微博\",\"url\":\"http://weibo.com/studygolang\",\"outer_site\":true},{\"name\":\"内嵌Wide\",\"url\":\"/wide/playground\",\"outer_site\":false},{\"name\":\"免责声明\",\"url\":\"/wiki/duty\",\"outer_site\":false}]', '', '[{"tab":"all","name":"全部","data_source":"feed"}]', '2017-05-21 10:22:00');
6262

6363
INSERT INTO `friend_link` (`id`, `name`, `url`, `seq`, `logo`, `created_at`)
6464
VALUES
File renamed without changes.
File renamed without changes.

modules/echoutils/echoutils.go renamed to echoutils/echoutils.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import (
88
"reflect"
99
"time"
1010

11-
mycontext "github.com/studygolang/studygolang/modules/context"
11+
mycontext "github.com/studygolang/studygolang/context"
1212

1313
"github.com/labstack/echo/v4"
1414
"github.com/polaris1119/goutils"

getpkg.bat

Lines changed: 0 additions & 24 deletions
This file was deleted.

getpkg.sh

Lines changed: 0 additions & 34 deletions
This file was deleted.

modules/global/app.go renamed to global/app.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ import (
3131
"sync"
3232
"time"
3333

34-
"github.com/studygolang/studygolang/modules/model"
34+
"github.com/studygolang/studygolang/model"
3535

3636
"github.com/polaris1119/config"
3737
)
File renamed without changes.

modules/http/controller/account.go renamed to http/controller/account.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,13 @@ import (
1414
"time"
1515

1616

17-
. "github.com/studygolang/studygolang/modules/http/internal/helper"
18-
. "github.com/studygolang/studygolang/modules/http"
19-
"github.com/studygolang/studygolang/modules/http/middleware"
20-
"github.com/studygolang/studygolang/modules/logic"
21-
"github.com/studygolang/studygolang/modules/model"
22-
"github.com/studygolang/studygolang/modules/util"
23-
"github.com/studygolang/studygolang/modules/context"
17+
. "github.com/studygolang/studygolang/http/internal/helper"
18+
. "github.com/studygolang/studygolang/http"
19+
"github.com/studygolang/studygolang/http/middleware"
20+
"github.com/studygolang/studygolang/logic"
21+
"github.com/studygolang/studygolang/model"
22+
"github.com/studygolang/studygolang/util"
23+
"github.com/studygolang/studygolang/context"
2424

2525
"github.com/dchest/captcha"
2626
"github.com/gorilla/sessions"

modules/http/controller/admin/article.go renamed to http/controller/admin/article.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@ import (
1010
"net/http"
1111
"strings"
1212

13-
"github.com/studygolang/studygolang/modules/context"
14-
"github.com/studygolang/studygolang/modules/logic"
15-
"github.com/studygolang/studygolang/modules/model"
13+
"github.com/studygolang/studygolang/context"
14+
"github.com/studygolang/studygolang/logic"
15+
"github.com/studygolang/studygolang/model"
1616

1717
echo "github.com/labstack/echo/v4"
1818
"github.com/polaris1119/goutils"

modules/http/controller/admin/authority.go renamed to http/controller/admin/authority.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ package admin
99
import (
1010
"net/http"
1111

12-
"github.com/studygolang/studygolang/modules/context"
13-
"github.com/studygolang/studygolang/modules/logic"
12+
"github.com/studygolang/studygolang/context"
13+
"github.com/studygolang/studygolang/logic"
1414

1515
echo "github.com/labstack/echo/v4"
1616
)

modules/http/controller/admin/base.go renamed to http/controller/admin/base.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@ import (
1010
"encoding/json"
1111
"net/http"
1212

13-
"github.com/studygolang/studygolang/modules/context"
14-
. "github.com/studygolang/studygolang/modules/http"
15-
"github.com/studygolang/studygolang/modules/logic"
13+
"github.com/studygolang/studygolang/context"
14+
. "github.com/studygolang/studygolang/http"
15+
"github.com/studygolang/studygolang/logic"
1616

1717
echo "github.com/labstack/echo/v4"
1818
"github.com/polaris1119/goutils"

0 commit comments

Comments
 (0)