summaryrefslogtreecommitdiff
path: root/vendor/github.com/gorilla/feeds/json.go
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/github.com/gorilla/feeds/json.go')
-rw-r--r--vendor/github.com/gorilla/feeds/json.go41
1 files changed, 24 insertions, 17 deletions
diff --git a/vendor/github.com/gorilla/feeds/json.go b/vendor/github.com/gorilla/feeds/json.go
index 75a82fd62..ae5deb76d 100644
--- a/vendor/github.com/gorilla/feeds/json.go
+++ b/vendor/github.com/gorilla/feeds/json.go
@@ -6,7 +6,7 @@ import (
"time"
)
-const jsonFeedVersion = "https://jsonfeed.org/version/1"
+const jsonFeedVersion = "https://jsonfeed.org/version/1.1"
// JSONAuthor represents the author of the feed or of an individual item
// in the feed
@@ -77,7 +77,8 @@ type JSONItem struct {
BannerImage string `json:"banner_,omitempty"`
PublishedDate *time.Time `json:"date_published,omitempty"`
ModifiedDate *time.Time `json:"date_modified,omitempty"`
- Author *JSONAuthor `json:"author,omitempty"`
+ Author *JSONAuthor `json:"author,omitempty"` // deprecated in JSON Feed v1.1, keeping for backwards compatibility
+ Authors []*JSONAuthor `json:"authors,omitempty"`
Tags []string `json:"tags,omitempty"`
Attachments []JSONAttachment `json:"attachments,omitempty"`
}
@@ -92,19 +93,21 @@ type JSONHub struct {
// JSONFeed represents a syndication feed in the JSON Feed Version 1 format.
// Matching the specification found here: https://jsonfeed.org/version/1.
type JSONFeed struct {
- Version string `json:"version"`
- Title string `json:"title"`
- HomePageUrl string `json:"home_page_url,omitempty"`
- FeedUrl string `json:"feed_url,omitempty"`
- Description string `json:"description,omitempty"`
- UserComment string `json:"user_comment,omitempty"`
- NextUrl string `json:"next_url,omitempty"`
- Icon string `json:"icon,omitempty"`
- Favicon string `json:"favicon,omitempty"`
- Author *JSONAuthor `json:"author,omitempty"`
- Expired *bool `json:"expired,omitempty"`
- Hubs []*JSONItem `json:"hubs,omitempty"`
- Items []*JSONItem `json:"items,omitempty"`
+ Version string `json:"version"`
+ Title string `json:"title"`
+ Language string `json:"language,omitempty"`
+ HomePageUrl string `json:"home_page_url,omitempty"`
+ FeedUrl string `json:"feed_url,omitempty"`
+ Description string `json:"description,omitempty"`
+ UserComment string `json:"user_comment,omitempty"`
+ NextUrl string `json:"next_url,omitempty"`
+ Icon string `json:"icon,omitempty"`
+ Favicon string `json:"favicon,omitempty"`
+ Author *JSONAuthor `json:"author,omitempty"` // deprecated in JSON Feed v1.1, keeping for backwards compatibility
+ Authors []*JSONAuthor `json:"authors,omitempty"`
+ Expired *bool `json:"expired,omitempty"`
+ Hubs []*JSONHub `json:"hubs,omitempty"`
+ Items []*JSONItem `json:"items,omitempty"`
}
// JSON is used to convert a generic Feed to a JSONFeed.
@@ -139,9 +142,11 @@ func (f *JSON) JSONFeed() *JSONFeed {
feed.HomePageUrl = f.Link.Href
}
if f.Author != nil {
- feed.Author = &JSONAuthor{
+ author := &JSONAuthor{
Name: f.Author.Name,
}
+ feed.Author = author
+ feed.Authors = []*JSONAuthor{author}
}
for _, e := range f.Items {
feed.Items = append(feed.Items, newJSONItem(e))
@@ -165,9 +170,11 @@ func newJSONItem(i *Item) *JSONItem {
item.ExternalUrl = i.Source.Href
}
if i.Author != nil {
- item.Author = &JSONAuthor{
+ author := &JSONAuthor{
Name: i.Author.Name,
}
+ item.Author = author
+ item.Authors = []*JSONAuthor{author}
}
if !i.Created.IsZero() {
item.PublishedDate = &i.Created