當前位置: 首頁>>代碼示例>>Golang>>正文


Golang User.Tags方法代碼示例

本文整理匯總了Golang中github.com/urandom/readeef/content.User.Tags方法的典型用法代碼示例。如果您正苦於以下問題:Golang User.Tags方法的具體用法?Golang User.Tags怎麽用?Golang User.Tags使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在github.com/urandom/readeef/content.User的用法示例。


在下文中一共展示了User.Tags方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。

示例1: getGroups

func getGroups(user content.User) (g []feverGroup, fg []feverFeedsGroup, err error) {
	tags := user.Tags()

	if user.HasErr() {
		err = fmt.Errorf("Error getting user tags: %v", user.Err())
		return
	}

	g = make([]feverGroup, len(tags))
	fg = make([]feverFeedsGroup, len(tags))

	for i := range tags {
		td := tags[i].Data()

		g[i] = feverGroup{Id: int64(td.Id), Title: string(td.Value)}

		feeds := tags[i].AllFeeds()
		if tags[i].HasErr() {
			err = fmt.Errorf("Error getting tag feeds: %v", tags[i].Err())
			return
		}

		ids := make([]string, len(feeds))
		for j := range feeds {
			ids[j] = strconv.FormatInt(int64(feeds[j].Data().Id), 10)
		}

		fg[i] = feverFeedsGroup{GroupId: int64(td.Id), FeedIds: strings.Join(ids, ",")}
	}

	return
}
開發者ID:urandom,項目名稱:readeef,代碼行數:32,代碼來源:fever.go

示例2: Handler


//.........這裏部分代碼省略.........
				feeds := user.AllFeeds()
				cContent = append(cContent,
					ttRssCounter{Id: "subscribed-feeds", Counter: int64(len(feeds))})

				cContent = append(cContent, ttRssCounter{Id: TTRSS_ARCHIVED_ID})

				cContent = append(cContent,
					ttRssCounter{Id: TTRSS_FAVORITE_ID,
						Counter:    user.Count(data.ArticleCountOptions{UnreadOnly: true, FavoriteOnly: true}),
						AuxCounter: user.Count(data.ArticleCountOptions{FavoriteOnly: true})})

				cContent = append(cContent, ttRssCounter{Id: TTRSS_PUBLISHED_ID})

				freshTime := time.Now().Add(TTRSS_FRESH_DURATION)
				cContent = append(cContent,
					ttRssCounter{Id: TTRSS_FRESH_ID,
						Counter:    user.Count(data.ArticleCountOptions{UnreadOnly: true, AfterDate: freshTime}),
						AuxCounter: 0})

				cContent = append(cContent,
					ttRssCounter{Id: TTRSS_ALL_ID,
						Counter:    user.Count(),
						AuxCounter: 0})

				for _, f := range feeds {
					cContent = append(cContent,
						ttRssCounter{Id: int64(f.Data().Id), Counter: f.Count(o)},
					)

				}

				cContent = append(cContent, ttRssCounter{Id: TTRSS_CAT_LABELS, Counter: 0, Kind: "cat"})

				for _, t := range user.Tags() {
					cContent = append(cContent,
						ttRssCounter{
							Id:      int64(t.Data().Id),
							Counter: t.Count(o),
							Kind:    "cat",
						},
					)
				}

				cContent = append(cContent,
					ttRssCounter{
						Id:      TTRSS_CAT_UNCATEGORIZED,
						Counter: user.Count(data.ArticleCountOptions{UnreadOnly: true, UntaggedOnly: true}),
						Kind:    "cat",
					},
				)

				if user.HasErr() {
					err = fmt.Errorf("Error getting user counters: %v\n", user.Err())
				}

				con = cContent
			case "getFeeds":
				fContent := ttRssFeedsContent{}

				if req.CatId == TTRSS_CAT_ALL || req.CatId == TTRSS_CAT_SPECIAL {
					unreadFav := user.Count(data.ArticleCountOptions{UnreadOnly: true, FavoriteOnly: true})

					if unreadFav > 0 || !req.UnreadOnly {
						fContent = append(fContent, ttRssFeed{
							Id:     TTRSS_FAVORITE_ID,
							Title:  ttRssSpecialTitle(TTRSS_FAVORITE_ID),
開發者ID:urandom,項目名稱:readeef,代碼行數:67,代碼來源:tt_rss.go


注:本文中的github.com/urandom/readeef/content.User.Tags方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。