diff --git a/model/entry.go b/model/entry.go index e08e8444..2b46daa0 100644 --- a/model/entry.go +++ b/model/entry.go @@ -20,20 +20,21 @@ const ( // Entry represents a feed item in the system. type Entry struct { - ID int64 `json:"id"` - UserID int64 `json:"user_id"` - FeedID int64 `json:"feed_id"` - Status string `json:"status"` - Hash string `json:"hash"` - Title string `json:"title"` - URL string `json:"url"` - Date time.Time `json:"published_at"` - Content string `json:"content"` - Author string `json:"author"` - Starred bool `json:"starred"` - Enclosures EnclosureList `json:"enclosures,omitempty"` - Feed *Feed `json:"feed,omitempty"` - Category *Category `json:"category,omitempty"` + ID int64 `json:"id"` + UserID int64 `json:"user_id"` + FeedID int64 `json:"feed_id"` + Status string `json:"status"` + Hash string `json:"hash"` + Title string `json:"title"` + URL string `json:"url"` + CommentsURL string `json:"comments"` + Date time.Time `json:"published_at"` + Content string `json:"content"` + Author string `json:"author"` + Starred bool `json:"starred"` + Enclosures EnclosureList `json:"enclosures,omitempty"` + Feed *Feed `json:"feed,omitempty"` + Category *Category `json:"category,omitempty"` } // Entries represents a list of entries. diff --git a/reader/rss/rss.go b/reader/rss/rss.go index 1cd82bae..bc901db2 100644 --- a/reader/rss/rss.go +++ b/reader/rss/rss.go @@ -43,6 +43,7 @@ type rssItem struct { Title string `xml:"title"` Links []rssLink `xml:"link"` OriginalLink string `xml:"http://rssnamespace.org/feedburner/ext/1.0 origLink"` + Comments string `xml:"comments"` Description string `xml:"description"` Content string `xml:"http://purl.org/rss/1.0/modules/content/ encoded"` PubDate string `xml:"pubDate"` @@ -219,6 +220,7 @@ func (r *rssItem) GetEnclosures() model.EnclosureList { func (r *rssItem) Transform() *model.Entry { entry := new(model.Entry) entry.URL = r.GetURL() + entry.CommentsURL = r.Comments entry.Date = r.GetDate() entry.Author = r.GetAuthor() entry.Hash = r.GetHash() diff --git a/sql/schema_version_16.sql b/sql/schema_version_16.sql new file mode 100644 index 00000000..e4f6d231 --- /dev/null +++ b/sql/schema_version_16.sql @@ -0,0 +1 @@ +alter table entries add column comments_url text default ''; \ No newline at end of file diff --git a/sql/sql.go b/sql/sql.go index f6aa19ed..d576d8d6 100644 --- a/sql/sql.go +++ b/sql/sql.go @@ -1,5 +1,5 @@ // Code generated by go generate; DO NOT EDIT. -// 2018-03-14 19:16:10.293618552 -0700 PDT m=+0.003182755 +// 2018-04-06 23:00:49.983090069 +0100 BST m=+0.002610702 package sql @@ -130,6 +130,7 @@ create index feeds_user_category_idx on feeds(user_id, category_id); alter table integrations add column nunux_keeper_url text default ''; alter table integrations add column nunux_keeper_api_key text default '';`, "schema_version_15": `alter table enclosures alter column size set data type bigint;`, + "schema_version_16": `alter table entries add column comments_url text default '';`, "schema_version_2": `create extension if not exists hstore; alter table users add column extra hstore; create index users_extra_idx on users using gin(extra); @@ -176,6 +177,7 @@ var SqlMapChecksums = map[string]string{ "schema_version_13": "9073fae1e796936f4a43a8120ebdb4218442fe7d346ace6387556a357c2d7edf", "schema_version_14": "4622e42c4a5a88b6fe1e61f3d367b295968f7260ab5b96481760775ba9f9e1fe", "schema_version_15": "13ff91462bdf4cda5a94a4c7a09f757761b0f2c32b4be713ba4786a4837750e4", + "schema_version_16": "9d006faca62fd7ab787f64aef0e0a5933d142466ec4cab0e096bb920d2797e34", "schema_version_2": "e8e9ff32478df04fcddad10a34cba2e8bb1e67e7977b5bd6cdc4c31ec94282b4", "schema_version_3": "a54745dbc1c51c000f74d4e5068f1e2f43e83309f023415b1749a47d5c1e0f12", "schema_version_4": "216ea3a7d3e1704e40c797b5dc47456517c27dbb6ca98bf88812f4f63d74b5d9", diff --git a/storage/entry.go b/storage/entry.go index 7df88c3b..d56d5de2 100644 --- a/storage/entry.go +++ b/storage/entry.go @@ -25,9 +25,9 @@ func (s *Storage) NewEntryQueryBuilder(userID int64) *EntryQueryBuilder { func (s *Storage) createEntry(entry *model.Entry) error { query := ` INSERT INTO entries - (title, hash, url, published_at, content, author, user_id, feed_id) + (title, hash, url, comments_url, published_at, content, author, user_id, feed_id) VALUES - ($1, $2, $3, $4, $5, $6, $7, $8) + ($1, $2, $3, $4, $5, $6, $7, $8, $9) RETURNING id ` err := s.db.QueryRow( @@ -35,6 +35,7 @@ func (s *Storage) createEntry(entry *model.Entry) error { entry.Title, entry.Hash, entry.URL, + entry.CommentsURL, entry.Date, entry.Content, entry.Author, @@ -82,14 +83,15 @@ func (s *Storage) UpdateEntryContent(entry *model.Entry) error { func (s *Storage) updateEntry(entry *model.Entry) error { query := ` UPDATE entries SET - title=$1, url=$2, content=$3, author=$4 - WHERE user_id=$5 AND feed_id=$6 AND hash=$7 + title=$1, url=$2, comments_url=$3, content=$4, author=$5 + WHERE user_id=$6 AND feed_id=$7 AND hash=$8 RETURNING id ` err := s.db.QueryRow( query, entry.Title, entry.URL, + entry.CommentsURL, entry.Content, entry.Author, entry.UserID, diff --git a/storage/entry_query_builder.go b/storage/entry_query_builder.go index 6650dbb7..4525ce55 100644 --- a/storage/entry_query_builder.go +++ b/storage/entry_query_builder.go @@ -158,7 +158,7 @@ func (e *EntryQueryBuilder) GetEntries() (model.Entries, error) { query := ` SELECT e.id, e.user_id, e.feed_id, e.hash, e.published_at at time zone u.timezone, e.title, - e.url, e.author, e.content, e.status, e.starred, + e.url, e.comments_url, e.author, e.content, e.status, e.starred, f.title as feed_title, f.feed_url, f.site_url, f.checked_at, f.category_id, c.title as category_title, f.scraper_rules, f.rewrite_rules, f.crawler, fi.icon_id, @@ -199,6 +199,7 @@ func (e *EntryQueryBuilder) GetEntries() (model.Entries, error) { &entry.Date, &entry.Title, &entry.URL, + &entry.CommentsURL, &entry.Author, &entry.Content, &entry.Status, diff --git a/storage/migration.go b/storage/migration.go index 9d6316af..d7d40e83 100644 --- a/storage/migration.go +++ b/storage/migration.go @@ -12,7 +12,7 @@ import ( "github.com/miniflux/miniflux/sql" ) -const schemaVersion = 15 +const schemaVersion = 16 // Migrate run database migrations. func (s *Storage) Migrate() { diff --git a/template/common.go b/template/common.go index 8240b2db..197478e5 100644 --- a/template/common.go +++ b/template/common.go @@ -1,5 +1,5 @@ // Code generated by go generate; DO NOT EDIT. -// 2018-02-24 17:47:34.998457627 +0000 GMT +// 2018-04-06 23:04:38.601763638 +0100 BST m=+0.010102865 package template @@ -63,6 +63,11 @@ var templateCommonMap = map[string]string{ data-value="{{ if eq .entry.Status "read" }}read{{ else }}unread{{ end }}" >{{ if eq .entry.Status "read" }}✘ {{ t "Unread" }}{{ else }}✔ {{ t "Read" }}{{ end }} + {{ if .entry.CommentsURL }} +