本文整理匯總了Golang中github.com/urandom/readeef/content.User.AddFeed方法的典型用法代碼示例。如果您正苦於以下問題:Golang User.AddFeed方法的具體用法?Golang User.AddFeed怎麽用?Golang User.AddFeed使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/urandom/readeef/content.User
的用法示例。
在下文中一共展示了User.AddFeed方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: 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
}
示例2: 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
}
示例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
}
示例4: 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
}
示例5: Handler
//.........這裏部分代碼省略.........
case "DEFAULT_UPDATE_INTERVAL":
con = ttRssGenericContent{Value: int(config.FeedManager.Converted.UpdateInterval.Minutes())}
case "DEFAULT_ARTICLE_LIMIT":
con = ttRssGenericContent{Value: 200}
case "HIDE_READ_FEEDS":
con = ttRssGenericContent{Value: user.Data().ProfileData["unreadOnly"]}
case "FEEDS_SORT_BY_UNREAD", "ENABLE_FEED_CATS", "SHOW_CONTENT_PREVIEW":
con = ttRssGenericContent{Value: true}
case "FRESH_ARTICLE_MAX_AGE":
con = ttRssGenericContent{Value: (-1 * TTRSS_FRESH_DURATION).Hours()}
}
case "getLabels":
con = []interface{}{}
case "setArticleLabel":
con = ttRssGenericContent{Status: "OK", Updated: 0}
case "shareToPublished":
errType = "Publishing failed"
case "subscribeToFeed":
f := repo.FeedByLink(req.FeedUrl)
for _, u := range f.Users() {
if u.Data().Login == user.Data().Login {
con = ttRssSubscribeContent{Status: struct {
Code int `json:"code"`
}{0}}
break
}
}
if f.HasErr() {
err = f.Err()
break
}
f, err := controller.fm.AddFeedByLink(req.FeedUrl)
if err != nil {
errType = "INCORRECT_USAGE"
break
}
uf := user.AddFeed(f)
if uf.HasErr() {
err = uf.Err()
break
}
con = ttRssSubscribeContent{Status: struct {
Code int `json:"code"`
}{1}}
case "unsubscribeFeed":
f := user.FeedById(req.FeedId)
f.Detach()
users := f.Users()
if f.HasErr() {
err = f.Err()
if err == content.ErrNoContent {
errType = "FEED_NOT_FOUND"
}
break
}
if len(users) == 0 {
controller.fm.RemoveFeed(f)
}
con = ttRssGenericContent{Status: "OK"}