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

Skip to content

Commit 5804add

Browse files
committed
Merge remote-tracking branch 'origin/1.8.9-dev' into 1.8.9-dev
2 parents fe7eab5 + 9ececcf commit 5804add

File tree

9 files changed

+25
-40
lines changed

9 files changed

+25
-40
lines changed

controller/blogmidware.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -345,7 +345,7 @@ func getLocale(c *gin.Context) string {
345345
}
346346

347347
func notFound(c *gin.Context) {
348-
t, err := template.ParseFiles(filepath.ToSlash(filepath.Join(model.Conf.StaticRoot, "console/dist/start/index.html")))
348+
t, err := template.ParseFiles(filepath.ToSlash("console/dist/start/index.html"))
349349
if nil != err {
350350
logger.Errorf("load 404 page failed: " + err.Error())
351351
c.String(http.StatusNotFound, "load 404 page failed")

controller/commentctl.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ func addCommentAction(c *gin.Context) {
143143
dataModel["Item"] = themeComment
144144
dataModel["ArticleID"] = comment.ArticleID
145145

146-
t := template.Must(template.New("").ParseFiles(filepath.ToSlash(filepath.Join(model.Conf.StaticRoot, "theme/comment/comment.html"))))
146+
t := template.Must(template.New("").ParseFiles(filepath.ToSlash("theme/comment/comment.html")))
147147

148148
htmlBuilder := bytes.Buffer{}
149149
if err := t.ExecuteTemplate(&htmlBuilder, "comment/comment", dataModel); nil != err {

controller/console/consolectl.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ func ShowAdminPagesAction(c *gin.Context) {
3535
return
3636
}
3737

38-
t, err := template.ParseFiles(filepath.ToSlash(filepath.Join(model.Conf.StaticRoot, "console/dist/admin"+c.Param("path")+"/index.html")))
38+
t, err := template.ParseFiles(filepath.ToSlash(filepath.Join("console/dist/admin" + c.Param("path") + "/index.html")))
3939
if nil != err {
4040
logger.Errorf("load console page [" + c.Param("path") + "] failed: " + err.Error())
4141
c.String(http.StatusNotFound, "load console page failed")

controller/indexctl.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ import (
2828
)
2929

3030
func showIndexAction(c *gin.Context) {
31-
t, err := template.ParseFiles(filepath.ToSlash(filepath.Join(model.Conf.StaticRoot, "console/dist/index.html")))
31+
t, err := template.ParseFiles(filepath.ToSlash("console/dist/index.html"))
3232
if nil != err {
3333
logger.Errorf("load index page failed: " + err.Error())
3434
c.String(http.StatusNotFound, "load index page failed")
@@ -40,7 +40,7 @@ func showIndexAction(c *gin.Context) {
4040
}
4141

4242
func showStartPageAction(c *gin.Context) {
43-
t, err := template.ParseFiles(filepath.ToSlash(filepath.Join(model.Conf.StaticRoot, "console/dist/start/index.html")))
43+
t, err := template.ParseFiles(filepath.ToSlash("console/dist/start/index.html"))
4444
if nil != err {
4545
logger.Errorf("load start page failed: " + err.Error())
4646
c.String(http.StatusNotFound, "load start page failed")

controller/router.go

Lines changed: 14 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -143,31 +143,31 @@ func MapRoutes() *gin.Engine {
143143
consoleSettingsGroup.GET("/account", console.GetAccountAction)
144144
consoleSettingsGroup.PUT("/account", console.UpdateAccountAction)
145145

146-
ret.StaticFile(util.PathFavicon, staticPath("console/static/favicon.ico"))
146+
ret.StaticFile(util.PathFavicon, filepath.ToSlash("console/static/favicon.ico"))
147147

148-
ret.Static(util.PathTheme+"/scss", staticPath("theme/scss"))
149-
ret.Static(util.PathTheme+"/js", staticPath("theme/js"))
150-
ret.Static(util.PathTheme+"/images", staticPath("theme/images"))
151-
ret.StaticFile("/sw.min.js", staticPath("theme/sw.min.js"))
152-
ret.StaticFile("/halt.html", staticPath("theme/halt.html"))
148+
ret.Static(util.PathTheme+"/scss", filepath.ToSlash("theme/scss"))
149+
ret.Static(util.PathTheme+"/js", filepath.ToSlash("theme/js"))
150+
ret.Static(util.PathTheme+"/images", filepath.ToSlash("theme/images"))
151+
ret.StaticFile("/sw.min.js", filepath.ToSlash("theme/sw.min.js"))
152+
ret.StaticFile("/halt.html", filepath.ToSlash("theme/halt.html"))
153153

154154
for _, theme := range theme.Themes {
155-
themePath := staticPath("theme/x/" + theme)
155+
themePath := filepath.ToSlash("theme/x/" + theme)
156156
ret.Static("/theme/x/"+theme+"/css", themePath+"/css")
157157
ret.Static("/theme/x/"+theme+"/js", themePath+"/js")
158158
ret.Static("/theme/x/"+theme+"/images", themePath+"/images")
159159
ret.StaticFile("/theme/x/"+theme+"/thumbnail.jpg", themePath+"/thumbnail.jpg")
160160
}
161-
themeTemplates, err := filepath.Glob(staticPath("theme/x/*/*.html"))
161+
themeTemplates, err := filepath.Glob(filepath.ToSlash("theme/x/*/*.html"))
162162
if nil != err {
163163
logger.Fatal("load theme templates failed: " + err.Error())
164164
}
165-
themeTemplates = append(themeTemplates, staticPath("theme/search/index.html"))
166-
commentTemplates, err := filepath.Glob(staticPath("theme/comment/*.html"))
165+
themeTemplates = append(themeTemplates, filepath.ToSlash("theme/search/index.html"))
166+
commentTemplates, err := filepath.Glob(filepath.ToSlash("theme/comment/*.html"))
167167
if nil != err {
168168
logger.Fatal("load comment templates failed: " + err.Error())
169169
}
170-
headTemplates, err := filepath.Glob(staticPath("theme/head/*.html"))
170+
headTemplates, err := filepath.Glob(filepath.ToSlash("theme/head/*.html"))
171171
if nil != err {
172172
logger.Fatal("load head templates failed: " + err.Error())
173173
}
@@ -192,9 +192,9 @@ func MapRoutes() *gin.Engine {
192192
initGroup.Use(fillUser)
193193
initGroup.GET("", showStartPageAction)
194194

195-
ret.Static(util.PathConsoleDist, staticPath("console/dist"))
196-
ret.StaticFile(util.PathChangelogs, staticPath("changelogs.html"))
197-
ret.StaticFile(util.PathRobots, staticPath("theme/robots.txt"))
195+
ret.Static(util.PathConsoleDist, filepath.ToSlash("console/dist"))
196+
ret.StaticFile(util.PathChangelogs, filepath.ToSlash("changelogs.html"))
197+
ret.StaticFile(util.PathRobots, filepath.ToSlash("theme/robots.txt"))
198198
ret.NoRoute(func(c *gin.Context) {
199199
notFound(c)
200200
})
@@ -304,7 +304,3 @@ func routePath(c *gin.Context) {
304304
logger.Tracef("can't handle path [" + path + "]")
305305
notFound(c)
306306
}
307-
308-
func staticPath(relativePath string) string {
309-
return filepath.ToSlash(filepath.Join(model.Conf.StaticRoot, relativePath))
310-
}

i18n/locales.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ import (
2828

2929
"github.com/b3log/pipe/log"
3030
"github.com/b3log/pipe/util"
31-
"github.com/b3log/pipe/model"
3231
)
3332

3433
// Logger
@@ -44,7 +43,7 @@ var locales = map[string]locale{}
4443

4544
// Load loads i18n message configurations.
4645
func Load() {
47-
f, _ := os.Open(filepath.ToSlash(filepath.Join(model.Conf.StaticRoot, "i18n")))
46+
f, _ := os.Open("i18n")
4847
names, _ := f.Readdirnames(-1)
4948
f.Close()
5049

@@ -61,7 +60,7 @@ func Load() {
6160
}
6261

6362
func load(localeStr string) {
64-
bytes, err := ioutil.ReadFile(filepath.ToSlash(filepath.Join(model.Conf.StaticRoot, "i18n/"+localeStr+".json")))
63+
bytes, err := ioutil.ReadFile(filepath.ToSlash("i18n/" + localeStr + ".json"))
6564
if nil != err {
6665
logger.Fatal("reads i18n configurations fialed: " + err.Error())
6766
}

main.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ func replaceServerConf() {
126126
// logger.Fatal("replace server conf in [theme] failed: " + err.Error())
127127
//}
128128

129-
paths, err := filepath.Glob(filepath.ToSlash(filepath.Join(model.Conf.StaticRoot, "console/dist/*.js.tpl")))
129+
paths, err := filepath.Glob(filepath.ToSlash("console/dist/*.js.tpl"))
130130
if 0 < len(paths) {
131131
for _, path := range paths {
132132
data, e := ioutil.ReadFile(path)
@@ -144,7 +144,7 @@ func replaceServerConf() {
144144
}
145145

146146
if util.File.IsExist("console/dist/") { // not exist if npm run dev
147-
err = filepath.Walk(filepath.ToSlash(filepath.Join(model.Conf.StaticRoot, "console/dist/")), func(path string, f os.FileInfo, err error) error {
147+
err = filepath.Walk(filepath.ToSlash("console/dist/"), func(path string, f os.FileInfo, err error) error {
148148
if strings.HasSuffix(path, ".html") {
149149
data, e := ioutil.ReadFile(path)
150150
if nil != e {

model/confs.go

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -23,14 +23,13 @@ import (
2323
"fmt"
2424
"io/ioutil"
2525
"os"
26-
"path/filepath"
2726
"strconv"
2827
"strings"
2928
"time"
3029

3130
"github.com/b3log/pipe/log"
32-
"github.com/jinzhu/gorm"
3331
"github.com/b3log/pipe/util"
32+
"github.com/jinzhu/gorm"
3433
)
3534

3635
// Logger
@@ -69,7 +68,6 @@ type Configuration struct {
6968
RuntimeMode string // runtime mode (dev/prod)
7069
SQLite string // SQLite database file path
7170
MySQL string // MySQL connection URL
72-
StaticRoot string // static resources file root path
7371
Port string // listen port
7472
AxiosBaseURL string // axio base URL
7573
MockServer string // mock server
@@ -87,7 +85,6 @@ func LoadConf() {
8785
confRuntimeMode := flag.String("runtime_mode", "", "this will override Conf.RuntimeMode if specified")
8886
confSQLite := flag.String("sqlite", "", "this will override Conf.SQLite if specified")
8987
confMySQL := flag.String("mysql", "", "this will override Conf.MySQL if specified")
90-
confStaticRoot := flag.String("static_root", "", "this will override Conf.StaticRoot if specified")
9188
confPort := flag.String("port", "", "this will override Conf.Port if specified")
9289
s2m := flag.Bool("s2m", false, "dumps SQLite data to MySQL SQL script file")
9390

@@ -159,12 +156,6 @@ func LoadConf() {
159156
Conf.MySQL = *confMySQL
160157
}
161158

162-
Conf.StaticRoot = ""
163-
if "" != *confStaticRoot {
164-
Conf.StaticRoot = *confStaticRoot
165-
Conf.StaticRoot = filepath.Dir(Conf.StaticRoot)
166-
}
167-
168159
if "" != *confPort {
169160
Conf.Port = *confPort
170161
}

theme/themes.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ import (
2323

2424
"github.com/b3log/pipe/log"
2525
"github.com/b3log/pipe/util"
26-
"github.com/b3log/pipe/model"
2726
)
2827

2928
// Logger
@@ -37,7 +36,7 @@ var Themes []string
3736

3837
// Load loads themes.
3938
func Load() {
40-
f, _ := os.Open(filepath.ToSlash(filepath.Join(model.Conf.StaticRoot, "theme/x")))
39+
f, _ := os.Open(filepath.ToSlash("theme/x"))
4140
names, _ := f.Readdirnames(-1)
4241
f.Close()
4342

0 commit comments

Comments
 (0)