diff --git a/app/controllers/BlogController.go b/app/controllers/BlogController.go index c2d6f13..bdf19c6 100644 --- a/app/controllers/BlogController.go +++ b/app/controllers/BlogController.go @@ -113,8 +113,8 @@ func (c Blog) setPreviewUrl() { themeId := c.Session["themeId"] theme := themeService.GetTheme(userId, themeId) - siteUrl := configService.GetSiteUrl() - blogUrl := siteUrl + "/preview" // blog.leanote.com + // siteUrl := configService.GetSiteUrl() + blogUrl := "/preview" // blog.leanote.com indexUrl = blogUrl + "/" + userIdOrEmail cateUrl = blogUrl + "/cate/" + userIdOrEmail // /notebookId @@ -143,8 +143,8 @@ 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]) + // 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() @@ -168,20 +168,20 @@ func (c Blog) setUrl(userBlog info.UserBlog, userInfo info.User) { c.RenderArgs["themeBaseUrl"] = "/" + userBlog.ThemePath // 其它static js - c.RenderArgs["jQueryUrl"] = siteUrl + "/js/jquery-1.9.0.min.js" + c.RenderArgs["jQueryUrl"] = "/js/jquery-1.9.0.min.js" - c.RenderArgs["prettifyJsUrl"] = siteUrl + "/js/google-code-prettify/prettify.js" - c.RenderArgs["prettifyCssUrl"] = siteUrl + "/js/google-code-prettify/prettify.css" + c.RenderArgs["prettifyJsUrl"] = "/js/google-code-prettify/prettify.js" + c.RenderArgs["prettifyCssUrl"] = "/js/google-code-prettify/prettify.css" - c.RenderArgs["blogCommonJsUrl"] = siteUrl + "/public/blog/js/common.js" + c.RenderArgs["blogCommonJsUrl"] = "/public/blog/js/common.js" - c.RenderArgs["shareCommentCssUrl"] = siteUrl + "/public/blog/css/share_comment.css" - c.RenderArgs["shareCommentJsUrl"] = siteUrl + "/public/blog/js/share_comment.js" + c.RenderArgs["shareCommentCssUrl"] = "/public/blog/css/share_comment.css" + c.RenderArgs["shareCommentJsUrl"] = "/public/blog/js/share_comment.js" - c.RenderArgs["fontAwesomeUrl"] = staticUrl + "/css/font-awesome-4.2.0/css/font-awesome.css" + c.RenderArgs["fontAwesomeUrl"] = "/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" + c.RenderArgs["bootstrapCssUrl"] = "/css/bootstrap.css" + c.RenderArgs["bootstrapJsUrl"] = "/js/bootstrap-min.js" } // 笔记本分类 diff --git a/app/controllers/admin/AdminSettingController.go b/app/controllers/admin/AdminSettingController.go index 759ba18..72fb33e 100644 --- a/app/controllers/admin/AdminSettingController.go +++ b/app/controllers/admin/AdminSettingController.go @@ -79,6 +79,12 @@ func (c AdminSetting) ExportPdf(path string) revel.Result { return c.RenderJson(re) } +func (c AdminSetting) DoSiteUrl(siteUrl string) revel.Result { + re := info.NewRe() + re.Ok = configService.UpdateGlobalStringConfig(c.GetUserId(), "siteUrl", siteUrl) + return c.RenderJson(re) +} + // SubDomain func (c AdminSetting) SubDomain() revel.Result { c.RenderArgs["str"] = configService.GlobalStringConfigs diff --git a/app/service/BlogService.go b/app/service/BlogService.go index 89eb979..96cb78d 100644 --- a/app/service/BlogService.go +++ b/app/service/BlogService.go @@ -518,7 +518,7 @@ func (this *BlogService) fixUserBlog(userBlog *info.UserBlog) { // Logo路径问题, 有些有http: 有些没有 if userBlog.Logo != "" && !strings.HasPrefix(userBlog.Logo, "http") { userBlog.Logo = strings.Trim(userBlog.Logo, "/") - userBlog.Logo = configService.GetSiteUrl() + "/" + userBlog.Logo + userBlog.Logo = "/" + userBlog.Logo } if userBlog.SortField == "" { @@ -1108,6 +1108,7 @@ func (this *BlogService) SortSingles(userId string, singleIds []string) (ok bool // 得到用户的博客url func (this *BlogService) GetUserBlogUrl(userBlog *info.UserBlog, username string) string { + /* if userBlog != nil { if userBlog.Domain != "" && configService.AllowCustomDomain() { return configService.GetUserUrl(userBlog.Domain) @@ -1118,12 +1119,15 @@ func (this *BlogService) GetUserBlogUrl(userBlog *info.UserBlog, username string username = userBlog.UserId.Hex() } } + */ return configService.GetBlogUrl() + "/" + username } // 得到所有url func (this *BlogService) GetBlogUrls(userBlog *info.UserBlog, userInfo *info.User) info.BlogUrls { var indexUrl, postUrl, searchUrl, cateUrl, singleUrl, tagsUrl, archiveUrl, tagPostsUrl string + + /* if userBlog.Domain != "" && configService.AllowCustomDomain() { // http://demo.com // ok indexUrl = configService.GetUserUrl(userBlog.Domain) @@ -1144,6 +1148,7 @@ func (this *BlogService) GetBlogUrls(userBlog *info.UserBlog, userInfo *info.Use tagsUrl = indexUrl + "/tags" tagPostsUrl = indexUrl + "/tag" } else { + */ // ok blogUrl := configService.GetBlogUrl() // blog.leanote.com userIdOrEmail := "" @@ -1162,7 +1167,7 @@ func (this *BlogService) GetBlogUrls(userBlog *info.UserBlog, userInfo *info.Use archiveUrl = blogUrl + "/archives/" + userIdOrEmail // blog.leanote.com/archive/username tagsUrl = blogUrl + "/tags/" + userIdOrEmail tagPostsUrl = blogUrl + "/tag/" + userIdOrEmail // blog.leanote.com/archive/username - } + // } return info.BlogUrls{ IndexUrl: indexUrl, diff --git a/app/service/ConfigService.go b/app/service/ConfigService.go index aad8519..a10d0ed 100644 --- a/app/service/ConfigService.go +++ b/app/service/ConfigService.go @@ -67,10 +67,20 @@ func (this *ConfigService) InitGlobalConfigs() bool { } } + // site URL + if s, ok := this.GlobalStringConfigs["siteUrl"]; !ok || s != "" { + this.GlobalStringConfigs["siteUrl"] = this.siteUrl + } + return true } func (this *ConfigService) GetSiteUrl() string { + s := this.GetGlobalStringConfig("siteUrl") + if s != "" { + return s + } + return this.siteUrl } func (this *ConfigService) GetAdminUsername() string { @@ -498,42 +508,25 @@ func (this *ConfigService) GetDefaultDomain() string { return defaultDomain } -// 包含http:// -func (this *ConfigService) GetDefaultUrl() string { - return schema + defaultDomain -} - // note func (this *ConfigService) GetNoteDomain() string { - subDomain := this.GetGlobalStringConfig("noteSubDomain") - if subDomain != "" { - return subDomain + port - } - return this.GetDefaultDomain() + "/note" + return "/note" } func (this *ConfigService) GetNoteUrl() string { - return schema + this.GetNoteDomain() + return this.GetNoteDomain() } // blog func (this *ConfigService) GetBlogDomain() string { - subDomain := this.GetGlobalStringConfig("blogSubDomain") - if subDomain != "" { - return subDomain + port - } - return this.GetDefaultDomain() + "/blog" + return "/blog" } func (this *ConfigService) GetBlogUrl() string { - return schema + this.GetBlogDomain() + return this.GetBlogDomain() } // lea func (this *ConfigService) GetLeaDomain() string { - subDomain := this.GetGlobalStringConfig("leaSubDomain") - if subDomain != "" { - return subDomain + port - } - return this.GetDefaultDomain() + "/lea" + return "/lea" } func (this *ConfigService) GetLeaUrl() string { return schema + this.GetLeaDomain() diff --git a/app/service/UserService.go b/app/service/UserService.go index 4fc5224..eebf479 100644 --- a/app/service/UserService.go +++ b/app/service/UserService.go @@ -110,7 +110,7 @@ func (this *UserService) setUserLogo(user *info.User) { } if user.Logo != "" && !strings.HasPrefix(user.Logo, "http") { user.Logo = strings.Trim(user.Logo, "/") - user.Logo = configService.GetSiteUrl() + "/" + user.Logo + user.Logo = "/" + user.Logo } } diff --git a/app/views/admin/nav.html b/app/views/admin/nav.html index 2b44c0a..2c7fc9b 100644 --- a/app/views/admin/nav.html +++ b/app/views/admin/nav.html @@ -131,6 +131,15 @@