Exemple #1
0
//------------------------
// 博客设置
func (this *BlogService) GetUserBlog(userId string) info.UserBlog {
	userBlog := info.UserBlog{}
	db.Get(db.UserBlogs, userId, &userBlog)

	if userBlog.Title == "" {
		userInfo := userService.GetUserInfo(userId)
		userBlog.Title = userInfo.Username + " 的博客"
	}

	return userBlog
}
Exemple #2
0
//------------------------
// 博客设置
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
	}

	if userBlog.SortField == "" {
		userBlog.SortField = "PublicTime"
	}
	if userBlog.PerPageSize <= 0 {
		userBlog.PerPageSize = 10
	}

	// themePath
	if userBlog.Style == "" {
		userBlog.Style = defaultStyle
	}
	if userBlog.ThemeId == "" {
		userBlog.ThemePath = themeService.GetDefaultThemePath(userBlog.Style)
	} else {
		userBlog.ThemePath = themeService.GetThemePath(userBlog.UserId.Hex(), userBlog.ThemeId.Hex())
	}
}