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


Golang User.ReadState方法代碼示例

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


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

示例1: Handler


//.........這裏部分代碼省略.........
				if err != nil {
					break
				}

				links := make([]feverLink, len(articles))
				for i := range articles {
					in := articles[i].Data()

					link := feverLink{
						Id: in.Id, FeedId: in.FeedId, ItemId: in.Id, IsItem: 1,
						IsLocal: 1, Title: in.Title, Url: in.Link, ItemIds: fmt.Sprintf("%d", in.Id),
					}

					if in.Score == 0 {
						link.Temperature = 0
					} else {
						link.Temperature = math.Log10(float64(in.Score)) / math.Log10(1.1)
					}

					if in.Favorite {
						link.IsSaved = 1
					}

					links[i] = link
				}
				resp["links"] = links
			}

			if val := r.PostFormValue("unread_recently_read"); val == "1" {
				reqType = "unread and recently read"
				logger.Infoln("Marking recently read fever items as unread")

				t := time.Now().Add(-24 * time.Hour)
				user.ReadState(false, data.ArticleUpdateStateOptions{
					BeforeDate: time.Now(),
					AfterDate:  t,
				})
				err = user.Err()
				if err != nil {
					break
				}
			}

			if val := r.PostFormValue("mark"); val != "" {
				if val == "item" {
					logger.Infof("Marking fever item '%s' as '%s'\n", r.PostFormValue("id"), r.PostFormValue("as"))

					var id int64
					var article content.UserArticle

					id, err = strconv.ParseInt(r.PostFormValue("id"), 10, 64)
					if err != nil {
						break
					}

					article, err = user.ArticleById(data.ArticleId(id), data.ArticleQueryOptions{SkipSessionProcessors: true}), user.Err()
					if err != nil {
						break
					}

					switch r.PostFormValue("as") {
					case "read":
						article.Read(true)
					case "saved":
						article.Favorite(true)
					case "unsaved":
開發者ID:urandom,項目名稱:readeef,代碼行數:67,代碼來源:fever.go


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