• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Golang content.User类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Golang中github.com/urandom/readeef/content.User的典型用法代码示例。如果您正苦于以下问题:Golang User类的具体用法?Golang User怎么用?Golang User使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了User类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。

示例1: getFeedTags

func getFeedTags(user content.User, id data.FeedId) (resp responseError) {
	resp = newResponse()

	repo := user.Repo()
	tf := repo.TaggedFeed(user)
	if uf := user.FeedById(id); uf.HasErr() {
		resp.err = uf.Err()
		return
	} else {
		tf.Data(uf.Data())
	}

	tags := tf.Tags()

	if tf.HasErr() {
		resp.err = tf.Err()
		return
	}

	t := make([]string, len(tags))
	for _, tag := range tags {
		t = append(t, tag.String())
	}

	resp.val["Tags"] = t
	return
}
开发者ID:urandom,项目名称:readeef,代码行数:27,代码来源:feed.go


示例2: setFeedTags

func setFeedTags(user content.User, id data.FeedId, tagValues []data.TagValue) (resp responseError) {
	resp = newResponse()

	feed := user.FeedById(id)
	if feed.HasErr() {
		resp.err = feed.Err()
		return
	}

	repo := user.Repo()
	tf := repo.TaggedFeed(user)
	tf.Data(feed.Data())
	tags := make([]content.Tag, len(tagValues))
	for i := range tagValues {
		tags[i] = repo.Tag(user)
		tags[i].Value(tagValues[i])
	}
	tf.Tags(tags)
	if tf.UpdateTags(); tf.HasErr() {
		resp.err = tf.Err()
		return
	}

	resp.val["Success"] = true
	resp.val["Id"] = id
	return
}
开发者ID:RavenB,项目名称:readeef,代码行数:27,代码来源:feed.go


示例3: createUserFeed

func createUserFeed(u content.User, d data.Feed) (uf content.UserFeed) {
	uf = repo.UserFeed(u)
	uf.Data(d)
	uf.Update()

	u.AddFeed(uf)

	return
}
开发者ID:RavenB,项目名称:readeef,代码行数:9,代码来源:feed_test.go


示例4: createTaggedFeed

func createTaggedFeed(u content.User, d data.Feed) (tf content.TaggedFeed) {
	tf = repo.TaggedFeed(u)
	tf.Data(d)
	tf.Update()

	u.AddFeed(tf)

	return
}
开发者ID:RavenB,项目名称:readeef,代码行数:9,代码来源:feed_test.go


示例5: getAuthData

func getAuthData(user content.User) (resp responseError) {
	resp = newResponse()

	in := user.Data()
	resp.val["Auth"] = true
	resp.val["User"] = user
	resp.val["ProfileData"] = in.ProfileData
	return
}
开发者ID:RavenB,项目名称:readeef,代码行数:9,代码来源:auth.go


示例6: addFeeds

func addFeeds(user content.User, fm *readeef.FeedManager, links []string) (resp responseError) {
	resp = newResponse()

	var err error
	errs := make([]addFeedError, 0, len(links))

	for _, link := range links {
		var u *url.URL
		if u, err = url.Parse(link); err != nil {
			resp.err = err
			errs = append(errs, addFeedError{Link: link, Error: "Error parsing link"})
			continue
		} else if !u.IsAbs() {
			resp.err = errors.New("Feed has no link")
			errs = append(errs, addFeedError{Link: link, Error: resp.err.Error()})
			continue
		} else {
			var f content.Feed
			if f, err = fm.AddFeedByLink(link); err != nil {
				resp.err = err
				errs = append(errs, addFeedError{Link: link, Error: "Error adding feed to the database"})
				continue
			}

			uf := user.AddFeed(f)
			if uf.HasErr() {
				resp.err = f.Err()
				errs = append(errs, addFeedError{Link: link, Title: f.Data().Title, Error: "Error adding feed to the database"})
				continue
			}

			tags := strings.SplitN(u.Fragment, ",", -1)
			if u.Fragment != "" && len(tags) > 0 {
				repo := uf.Repo()
				tf := repo.TaggedFeed(user)
				tf.Data(uf.Data())

				t := make([]content.Tag, len(tags))
				for i := range tags {
					t[i] = repo.Tag(user)
					t[i].Data(data.Tag{Value: data.TagValue(tags[i])})
				}

				tf.Tags(t)
				if tf.UpdateTags(); tf.HasErr() {
					resp.err = tf.Err()
					errs = append(errs, addFeedError{Link: link, Title: f.Data().Title, Error: "Error adding feed to the database"})
					continue
				}
			}
		}
	}

	resp.val["Errors"] = errs
	resp.val["Success"] = len(errs) < len(links)
	return
}
开发者ID:urandom,项目名称:readeef,代码行数:57,代码来源:feed.go


示例7: addFeed

func addFeed(user content.User, fm *readeef.FeedManager, links []string) (resp responseError) {
	resp = newResponse()

	success := false

	for _, link := range links {
		var u *url.URL
		if u, resp.err = url.Parse(link); resp.err != nil {
			/* TODO: non-fatal error */
			return
		} else if !u.IsAbs() {
			/* TODO: non-fatal error */
			resp.err = errors.New("Feed has no link")
			return
		} else {
			var f content.Feed
			if f, resp.err = fm.AddFeedByLink(link); resp.err != nil {
				return
			}

			uf := user.AddFeed(f)
			if uf.HasErr() {
				resp.err = f.Err()
				return
			}

			tags := strings.SplitN(u.Fragment, ",", -1)
			if u.Fragment != "" && len(tags) > 0 {
				repo := uf.Repo()
				tf := repo.TaggedFeed(user)
				tf.Data(uf.Data())

				t := make([]content.Tag, len(tags))
				for i := range tags {
					t[i] = repo.Tag(user)
					t[i].Value(data.TagValue(tags[i]))
				}

				tf.Tags(t)
				if tf.UpdateTags(); tf.HasErr() {
					resp.err = tf.Err()
					return
				}
			}

			success = true
		}
	}

	resp.val["Success"] = success
	return
}
开发者ID:RavenB,项目名称:readeef,代码行数:52,代码来源:feed.go


示例8: listUsers

func listUsers(user content.User) (resp responseError) {
	resp = newResponse()

	if !user.Data().Admin {
		resp.err = errForbidden
		resp.errType = errTypeForbidden
		return
	}

	repo := user.Repo()
	resp.val["Users"], resp.err = repo.AllUsers(), repo.Err()
	return
}
开发者ID:urandom,项目名称:readeef,代码行数:13,代码来源:user.go


示例9: readState

func readState(user content.User, id string, beforeId data.ArticleId, timestamp int64) (resp responseError) {
	resp = newResponse()

	var ar content.ArticleRepo

	o := data.ArticleUpdateStateOptions{}

	if timestamp > 0 {
		t := time.Unix(timestamp/1000, 0)
		o.BeforeDate = t
	}

	if beforeId > 0 {
		o.BeforeId = beforeId
	}

	switch {
	case id == "all":
		ar = user
	case id == "favorite":
		o.FavoriteOnly = true
		ar = user
	case strings.HasPrefix(id, "popular:"):
		// Can't bulk set state to popular articles
	case strings.HasPrefix(id, "tag:"):
		tag := user.Repo().Tag(user)
		tag.Data(data.Tag{Value: data.TagValue(id[4:])})

		ar = tag
	default:
		var feedId int64
		if feedId, resp.err = strconv.ParseInt(id, 10, 64); resp.err != nil {
			/* TODO: non-fatal error */
			return
		}

		ar = user.FeedById(data.FeedId(feedId))
	}

	if ar != nil {
		ar.ReadState(true, o)

		if e, ok := ar.(content.Error); ok && e.HasErr() {
			resp.err = e.Err()
			return
		}
	}

	resp.val["Success"] = true
	return
}
开发者ID:urandom,项目名称:readeef,代码行数:51,代码来源:feed.go


示例10: formatArticle

func formatArticle(user content.User, id data.ArticleId, webfwConfig webfw.Config, readeefConfig readeef.Config) (resp responseError) {
	resp = newResponse()

	article := user.ArticleById(id)
	if user.HasErr() {
		resp.err = user.Err()
		return
	}

	formatting := article.Format(webfwConfig.Renderer.Dir, readeefConfig.ArticleFormatter.ReadabilityKey)
	if article.HasErr() {
		resp.err = user.Err()
		return
	}

	s := summarize.NewFromString(formatting.Title, readeef.StripTags(formatting.Content))

	s.Language = formatting.Language
	keyPoints := s.KeyPoints()

	for i := range keyPoints {
		keyPoints[i] = html.UnescapeString(keyPoints[i])
	}

	resp.val["KeyPoints"] = keyPoints
	resp.val["Content"] = formatting.Content
	resp.val["TopImage"] = formatting.TopImage
	resp.val["Id"] = id
	return
}
开发者ID:RavenB,项目名称:readeef,代码行数:30,代码来源:article.go


示例11: removeFeed

func removeFeed(user content.User, fm *readeef.FeedManager, id data.FeedId) (resp responseError) {
	resp = newResponse()

	feed := user.FeedById(id)
	if feed.Delete(); feed.HasErr() {
		resp.err = feed.Err()
		return
	}

	fm.RemoveFeed(feed)

	resp.val["Success"] = true
	return
}
开发者ID:urandom,项目名称:readeef,代码行数:14,代码来源:feed.go


示例12: TestImplements

func TestImplements(t *testing.T) {
	var article content.Article

	r := NewRepo(nil, nil)

	article = r.Article()
	article.Data()

	var userArticle content.UserArticle

	userArticle = r.UserArticle(nil)
	userArticle.Data()

	var scoredArticle content.ScoredArticle

	scoredArticle = r.ScoredArticle()
	scoredArticle.Data()

	var feed content.Feed

	feed = r.Feed()
	feed.Data()

	var userFeed content.UserFeed

	userFeed = r.UserFeed(nil)
	userFeed.Data()

	var taggedFeed content.TaggedFeed

	taggedFeed = r.TaggedFeed(nil)
	taggedFeed.Data()

	r.HasErr()

	var subscription content.Subscription

	subscription = r.Subscription()
	subscription.Data()

	var tag content.Tag

	tag = r.Tag(nil)
	tag.Value()

	var user content.User

	user = r.User()
	user.Data()
}
开发者ID:RavenB,项目名称:readeef,代码行数:50,代码来源:implementation_test.go


示例13: getAuthData

func getAuthData(user content.User, sess context.Session, capabilities capabilities) (resp responseError) {
	resp = newResponse()

	if sess != nil {
		sess.Set(readeef.AuthNameKey, user.Data().Login)
		if err := sess.Write(nil); err != nil {
			resp.err = fmt.Errorf("Error writing session data: %v", err)
		}
	}

	resp.val["Auth"] = true
	resp.val["Capabilities"] = capabilities
	resp.val["User"] = user
	return
}
开发者ID:urandom,项目名称:readeef,代码行数:15,代码来源:auth.go


示例14: getArticles

func getArticles(u content.User, dbo *db.DB, logger webfw.Logger, opts data.ArticleQueryOptions, sorting content.ArticleSorting, join, where string, args []interface{}) (ua []content.UserArticle) {
	if u.HasErr() {
		return
	}

	var err error
	if getArticlesTemplate == nil {
		getArticlesTemplate, err = template.New("read-state-update-sql").
			Parse(dbo.SQL().User.GetArticlesTemplate)

		if err != nil {
			u.Err(fmt.Errorf("Error generating get-articles-update template: %v", err))
			return
		}
	}

	/* Much faster than using 'ORDER BY read'
	 * TODO: potential overall improvement for fetching pages other than the
	 * first by using the unread count and moving the offset based on it
	 */
	if opts.UnreadFirst && opts.Offset == 0 {
		originalUnreadOnly := opts.UnreadOnly

		opts.UnreadFirst = false
		opts.UnreadOnly = true

		ua = internalGetArticles(u, dbo, logger, opts, sorting, join, where, args)

		if !originalUnreadOnly && (opts.Limit == 0 || opts.Limit > len(ua)) {
			if opts.Limit > 0 {
				opts.Limit -= len(ua)
			}
			opts.UnreadOnly = false
			opts.ReadOnly = true

			readOnly := internalGetArticles(u, dbo, logger, opts, sorting, join, where, args)

			ua = append(ua, readOnly...)
		}

		return
	}

	return internalGetArticles(u, dbo, logger, opts, sorting, join, where, args)
}
开发者ID:urandom,项目名称:readeef,代码行数:45,代码来源:user.go


示例15: addUser

func addUser(user content.User, login data.Login, password string, secret []byte) (resp responseError) {
	resp = newResponse()
	resp.val["Login"] = login

	if !user.Data().Admin {
		resp.err = errForbidden
		resp.errType = errTypeForbidden
		return
	}

	repo := user.Repo()
	u := repo.UserByLogin(login)

	if !u.HasErr() {
		/* TODO: non-fatal error */
		resp.err = errUserExists
		resp.errType = errTypeUserExists
		return
	} else {
		err := u.Err()
		if err != content.ErrNoContent {
			resp.err = err
			return
		}
	}

	resp.err = nil

	in := data.User{Login: login}
	u = repo.User()

	u.Data(in)
	u.Password(password, secret)
	u.Update()

	if resp.err = u.Err(); resp.err != nil {
		return
	}

	resp.val["Success"] = true

	return
}
开发者ID:urandom,项目名称:readeef,代码行数:43,代码来源:user.go


示例16: getUserAttribute

func getUserAttribute(user content.User, attr string) (resp responseError) {
	resp = newResponse()
	in := user.Data()
	resp.val["Login"] = in.Login

	switch attr {
	case "FirstName":
		resp.val[attr] = in.FirstName
	case "LastName":
		resp.val[attr] = in.LastName
	case "Email":
		resp.val[attr] = in.Email
	case "ProfileData":
		resp.val[attr] = in.ProfileData
	default:
		resp.err = errors.New("Error getting user attribute: unknown attribute " + attr)
		return
	}

	return
}
开发者ID:urandom,项目名称:readeef,代码行数:21,代码来源:user-settings.go


示例17: search

func search(user content.User, searchIndex readeef.SearchIndex, query, highlight, feedId string) (resp responseError) {
	resp = newResponse()

	if strings.HasPrefix(feedId, "tag:") {
		tag := user.Repo().Tag(user)
		tag.Value(data.TagValue(feedId[4:]))

		tag.Highlight(highlight)
		resp.val["Articles"], resp.err = tag.Query(query, searchIndex.Index), tag.Err()
	} else {
		if id, err := strconv.ParseInt(feedId, 10, 64); err == nil {
			f := user.FeedById(data.FeedId(id))
			resp.val["Articles"], resp.err = f.Query(query, searchIndex.Index), f.Err()
		} else {
			user.Highlight(highlight)
			resp.val["Articles"], resp.err = user.Query(query, searchIndex.Index), user.Err()
		}
	}

	return
}
开发者ID:RavenB,项目名称:readeef,代码行数:21,代码来源:search.go


示例18: markArticleAsFavorite

func markArticleAsFavorite(user content.User, id data.ArticleId, favorite bool) (resp responseError) {
	resp = newResponse()

	article := user.ArticleById(id)
	if user.HasErr() {
		resp.err = user.Err()
		return
	}

	in := article.Data()
	previouslyFavorite := in.Favorite

	if previouslyFavorite != favorite {
		article.Favorite(favorite)
		if article.HasErr() {
			resp.err = article.Err()
			return
		}
	}

	resp.val["Success"] = previouslyFavorite != favorite
	resp.val["Favorite"] = favorite
	resp.val["Id"] = in.Id
	return
}
开发者ID:RavenB,项目名称:readeef,代码行数:25,代码来源:article.go


示例19: removeUser

func removeUser(user content.User, login data.Login) (resp responseError) {
	resp = newResponse()
	resp.val["Login"] = login

	if !user.Data().Admin {
		resp.err = errForbidden
		resp.errType = errTypeForbidden
		return
	}

	if user.Data().Login == login {
		resp.err = errCurrentUser
		resp.errType = errTypeCurrentUser
		return
	}

	u := user.Repo().UserByLogin(login)
	u.Delete()

	if resp.err = u.Err(); resp.err != nil {
		return
	}

	resp.val["Success"] = true
	return
}
开发者ID:urandom,项目名称:readeef,代码行数:26,代码来源:user.go


示例20: ttRssFeedListCategoryFeed

func ttRssFeedListCategoryFeed(u content.User, f content.UserFeed, id data.FeedId, includeUnread bool) (c ttRssCategory) {
	c.BareId = id
	c.Id = "FEED:" + strconv.FormatInt(int64(id), 10)
	c.Type = "feed"

	copts := data.ArticleCountOptions{UnreadOnly: true}
	if f != nil {
		c.Name = f.Data().Title
		c.Unread = f.Count(copts)
	} else {
		c.Name = ttRssSpecialTitle(id)
		switch id {
		case TTRSS_FAVORITE_ID:
			copts.FavoriteOnly = true
			c.Unread = u.Count(copts)
		case TTRSS_FRESH_ID:
			copts.AfterDate = time.Now().Add(TTRSS_FRESH_DURATION)
			c.Unread = u.Count(copts)
		case TTRSS_ALL_ID:
			c.Unread = u.Count(copts)
		}
	}

	return
}
开发者ID:urandom,项目名称:readeef,代码行数:25,代码来源:tt_rss.go



注:本文中的github.com/urandom/readeef/content.User类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Golang db.DB类代码示例发布时间:2022-05-28
下一篇:
Golang content.Feed类代码示例发布时间:2022-05-28
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap