diff --git a/app/controllers/BlogController.go b/app/controllers/BlogController.go index fbbf6ca..b5bf765 100644 --- a/app/controllers/BlogController.go +++ b/app/controllers/BlogController.go @@ -57,9 +57,9 @@ func (c Blog) render(templateName string, themePath string) revel.Result { isPreview = true themePath = themePath2.(string) c.setPreviewUrl() - + // 因为common的themeInfo是从UserBlog.ThemeId来取的, 所以这里要fugai下 - c.RenderArgs["themeInfo"] = c.RenderArgs["themeInfoPreview"] + c.RenderArgs["themeInfo"] = c.RenderArgs["themeInfoPreview"]; } return blog.RenderTemplate(templateName, c.RenderArgs, revel.BasePath+"/"+themePath, isPreview) } @@ -119,9 +119,9 @@ func (c Blog) setPreviewUrl() { indexUrl = blogUrl + "/" + userIdOrEmail cateUrl = blogUrl + "/cate/" + userIdOrEmail // /notebookId - postUrl = blogUrl + "/post/" + userIdOrEmail // /xxxxx + postUrl = blogUrl + "/post/" + userIdOrEmail // /xxxxx searchUrl = blogUrl + "/search/" + userIdOrEmail // blog.leanote.com/search/userId - singleUrl = blogUrl + "/single/" + userIdOrEmail // blog.leanote.com/single/singleId + singleUrl = blogUrl + "/single/" + userIdOrEmail // blog.leanote.com/single/singleId archiveUrl = blogUrl + "/archives/" + userIdOrEmail // blog.leanote.com/archive/userId tagsUrl = blogUrl + "/tags/" + userIdOrEmail // blog.leanote.com/archive/userId @@ -143,6 +143,10 @@ func (c Blog) setPreviewUrl() { // 各种地址设置 func (c Blog) setUrl(userBlog info.UserBlog, userInfo info.User) { // 主页 http://leanote.com/blog/life or http://blog.leanote.com/life or http:// xxxx.leanote.com or aa.com + host := c.Request.Request.Host + var staticUrl = configService.GetUserUrl(strings.Split(host, ":")[0]) + // staticUrl == host, 为保证同源!!! 只有host, http://leanote.com, http://blog/leanote.com + // life.leanote.com, lealife.com siteUrl := configService.GetSiteUrl() blogUrls := blogService.GetBlogUrls(&userBlog, &userInfo) // 分类 @@ -169,12 +173,12 @@ func (c Blog) setUrl(userBlog info.UserBlog, userInfo info.User) { c.RenderArgs["prettifyJsUrl"] = siteUrl + "/js/google-code-prettify/prettify.js" c.RenderArgs["prettifyCssUrl"] = siteUrl + "/js/google-code-prettify/prettify.css" - c.RenderArgs["blogCommonJsUrl"] = siteUrl + "/blog/js/common.js" + c.RenderArgs["blogCommonJsUrl"] = siteUrl + "/public/blog/js/common.js" - c.RenderArgs["shareCommentCssUrl"] = siteUrl + "/blog/css/share_comment.css" - c.RenderArgs["shareCommentJsUrl"] = siteUrl + "/blog/js/share_comment.js" + c.RenderArgs["shareCommentCssUrl"] = siteUrl + "/public/blog/css/share_comment.css" + c.RenderArgs["shareCommentJsUrl"] = siteUrl + "/public/blog/js/share_comment.js" - c.RenderArgs["fontAwesomeUrl"] = siteUrl + "/css/font-awesome-4.2.0/css/font-awesome.css" + c.RenderArgs["fontAwesomeUrl"] = staticUrl + "/css/font-awesome-4.2.0/css/font-awesome.css" c.RenderArgs["bootstrapCssUrl"] = siteUrl + "/css/bootstrap.css" c.RenderArgs["bootstrapJsUrl"] = siteUrl + "/js/bootstrap-min.js" @@ -506,7 +510,6 @@ func (c Blog) Archives(userIdOrEmail string, cateId string, year, month int) (re // 进入某个用户的博客 var blogPageSize = 5 var searchBlogPageSize = 30 - // 分类 /cate/xxxxxxxx?notebookId=1212 func (c Blog) Cate(userIdOrEmail string, notebookId string) (re revel.Result) { // 自定义域名 diff --git a/app/init.go b/app/init.go index e5134d1..6d4501b 100644 --- a/app/init.go +++ b/app/init.go @@ -376,4 +376,4 @@ func init() { service.ConfigS.InitGlobalConfigs() api.InitService() }) -} \ No newline at end of file +} diff --git a/app/views/home/header.html b/app/views/home/header.html index 74fed89..566d1c7 100644 --- a/app/views/home/header.html +++ b/app/views/home/header.html @@ -44,6 +44,7 @@ function log(o) { -->