diff options
author | Adam Mathes <adam@trenchant.org> | 2017-02-02 19:42:48 -0800 |
---|---|---|
committer | Adam Mathes <adam@trenchant.org> | 2017-02-02 19:42:48 -0800 |
commit | dee417318bbed4cd14e21ec069ed5bc8d84df33b (patch) | |
tree | 4b87843f6c66148ea9fdb1ab44c1df234a04e233 | |
parent | 8ad7e867b96df3336c4fea8840297553125cc1d1 (diff) | |
download | neko-dee417318bbed4cd14e21ec069ed5bc8d84df33b.tar.gz neko-dee417318bbed4cd14e21ec069ed5bc8d84df33b.tar.bz2 neko-dee417318bbed4cd14e21ec069ed5bc8d84df33b.zip |
slightly better handling of dates
-rw-r--r-- | crawler/crawler.go | 5 | ||||
-rw-r--r-- | models/item/item.go | 13 | ||||
-rw-r--r-- | 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 <content:encoded> - 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 @@ <h2><a target="_blank" class="i" id="i_${item_id}" href="${item.url}">${item.title }</a> <span class={{if item.starred}}"unstar"{{else}}"star"{{/if}}>★</span></h2> <p class="dateline" style="clear: both;"> - ${ item.date } from <a href="${item.feed_url}">${item.feed_title}</a> + ${ item.publish_date } from <a href="${item.feed_url}">${item.feed_title}</a> </p> <div class="description">{{html item.description}}</div> </script> |