From dee417318bbed4cd14e21ec069ed5bc8d84df33b Mon Sep 17 00:00:00 2001 From: Adam Mathes Date: Thu, 2 Feb 2017 19:42:48 -0800 Subject: slightly better handling of dates --- crawler/crawler.go | 5 ++--- models/item/item.go | 13 ++++++++----- static/ui.html | 2 +- 3 files changed, 11 insertions(+), 9 deletions(-) diff --git a/crawler/crawler.go b/crawler/crawler.go index 4d91241..e884b23 100644 --- a/crawler/crawler.go +++ b/crawler/crawler.go @@ -63,17 +63,16 @@ func CrawlFeed(f *feed.Feed, ch chan<- string) { // a lot of RSS2.0 generated by wordpress and others // uses - e,ok := i.Extensions["content"]["encoded"] var encoded = "" if ok { encoded = e[0].Value } - if len(encoded) > len(item.Description) { item.Description = encoded } - + + item.PublishDate = i.PublishedParsed.Format(time.RFC3339) item.FeedId = f.Id err := item.Create() diff --git a/models/item/item.go b/models/item/item.go index 3cf8a19..da613ee 100644 --- a/models/item/item.go +++ b/models/item/item.go @@ -10,15 +10,18 @@ import ( type Item struct { Id int64 `json:"_id,string,omitempty"` + Title string `json:"title"` Url string `json:"url"` Description string `json:"description"` - ReadState bool `json:"read"` - Starred bool `json:"starred"` - FeedId int64 PublishDate string `json:"publish_date"` + + FeedId int64 FeedTitle string `json:"feed_title"` FeedUrl string `json:"feed_url"` + + ReadState bool `json:"read"` + Starred bool `json:"starred"` } func (i *Item) Print() { @@ -29,8 +32,8 @@ func (i *Item) Print() { func (i *Item) Create() error { res, err := models.DB.Exec(`INSERT INTO - item(title, url, description, feed_id) - VALUES(?, ?, ?, ?)`, i.Title, i.Url, i.Description, i.FeedId) + item(title, url, description, publish_date, feed_id) + VALUES(?, ?, ?, ?, ?)`, i.Title, i.Url, i.Description, i.PublishDate, i.FeedId) if err != nil { return err } diff --git a/static/ui.html b/static/ui.html index d2ce63b..7b1d08c 100644 --- a/static/ui.html +++ b/static/ui.html @@ -36,7 +36,7 @@

${item.title }

{{html item.description}}
-- cgit v1.2.3