コード例 #1
0
ファイル: user.go プロジェクト: zeuson/wego
func (this *FollowTopics) Get() {
	this.TplNames = "user/follow-topics.html"

	var user models.User
	if this.getUser(&user) {
		return
	}

	var topics []*models.Topic
	ftopics, _ := models.FindFollowTopic(user.Id, 0)
	if len(ftopics) > 0 {
		topics = make([]*models.Topic, 0, len(ftopics))
		for _, ft := range ftopics {
			topics = append(topics, ft.Topic())
		}
	}
	this.Data["TheUserFollowTopics"] = topics
}
コード例 #2
0
ファイル: user.go プロジェクト: zeuson/wego
func (this *Home) Get() error {
	this.Data["IsUserHomePage"] = true

	var user models.User
	if this.getUser(&user) {
		return nil
	}

	//recent posts and comments
	limit := 5

	posts, _ := models.RecentPosts("recent", limit, 0)
	comments, _ := models.RecentCommentsByUserId(user.Id, limit)

	this.Data["TheUserPosts"] = posts
	this.Data["TheUserComments"] = comments

	//follow topics
	var topics []*models.Topic
	ftopics, _ := models.FindFollowTopic(user.Id, 8)
	if len(ftopics) > 0 {
		topics = make([]*models.Topic, 0, len(ftopics))
		for _, ft := range ftopics {
			topics = append(topics, ft.Topic())
		}
	}
	this.Data["TheUserFollowTopics"] = topics
	this.Data["TheUserFollowTopicsMore"] = len(ftopics) >= 8

	//favorite posts
	var favPostIds = make([]int64, 0)
	var favPosts []models.Post
	models.ORM().Limit(8).Desc("created").Iterate(new(models.FavoritePost), func(idx int, bean interface{}) error {
		favPostIds = append(favPostIds, bean.(*models.FavoritePost).PostId)
		return nil
	})
	if len(favPostIds) > 0 {
		models.ORM().In("id", favPostIds).Desc("created").Find(&favPosts)
	}
	this.Data["TheUserFavoritePosts"] = favPosts
	this.Data["TheUserFavoritePostsMore"] = len(favPostIds) >= 8

	return this.Render("user/home.html", this.Data)
}