Skip to content

Commit 41f47c9

Browse files
authored
Support multiple links (#164)
* Add Feed.Links * Update tests, don't create empty list * Use same rel logic for RSS atom extensions * Support for JSON feed * Fix invalid JSON and run `go mod tidy` * Fix tests, don't return empty strings
1 parent 68eef24 commit 41f47c9

18 files changed

+148
-25
lines changed

feed.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ type Feed struct {
1717
Description string `json:"description,omitempty"`
1818
Link string `json:"link,omitempty"`
1919
FeedLink string `json:"feedLink,omitempty"`
20+
Links []string `json:"links,omitempty"`
2021
Updated string `json:"updated,omitempty"`
2122
UpdatedParsed *time.Time `json:"updatedParsed,omitempty"`
2223
Published string `json:"published,omitempty"`
@@ -50,6 +51,7 @@ type Item struct {
5051
Description string `json:"description,omitempty"`
5152
Content string `json:"content,omitempty"`
5253
Link string `json:"link,omitempty"`
54+
Links []string `json:"links,omitempty"`
5355
Updated string `json:"updated,omitempty"`
5456
UpdatedParsed *time.Time `json:"updatedParsed,omitempty"`
5557
Published string `json:"published,omitempty"`

go.mod

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ go 1.14
44

55
require (
66
github.com/PuerkitoBio/goquery v1.5.1
7-
github.com/davecgh/go-spew v1.1.1 // indirect
87
github.com/json-iterator/go v1.1.10
98
github.com/mmcdole/goxpp v0.0.0-20181012175147-0068e33feabf
109
github.com/stretchr/testify v1.3.0

go.sum

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,6 @@ github.com/russross/blackfriday/v2 v2.0.1/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQD
2424
github.com/shurcooL/sanitized_anchor_name v1.0.0 h1:PdmoCO6wvbs+7yrJyMORt4/BmY5IYyJwS/kOiWx8mHo=
2525
github.com/shurcooL/sanitized_anchor_name v1.0.0/go.mod h1:1NzhyTcUVG4SuEtjjoZeVRXNmyL/1OwPU0+IJeTBvfc=
2626
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
27-
github.com/stretchr/testify v1.2.2 h1:bSDNvY7ZPG5RlJ8otE/7V6gMiyenm9RtJ7IUVIAoJ1w=
28-
github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
2927
github.com/stretchr/testify v1.3.0 h1:TivCn/peBQ7UY8ooIcPgZFpTNSz0Q2U6UrFlUfqbe0Q=
3028
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
3129
github.com/urfave/cli v1.22.3 h1:FpNT6zq26xNpHZy08emi755QwzLPs6Pukqjlc7RfOMU=
@@ -36,7 +34,6 @@ golang.org/x/net v0.0.0-20200202094626-16171245cfb2/go.mod h1:z5CRVTTTmAJ677TzLL
3634
golang.org/x/net v0.0.0-20200301022130-244492dfa37a h1:GuSPYbZzB5/dcLNCwLQLsg3obCJtX9IJhpXkvY7kzk0=
3735
golang.org/x/net v0.0.0-20200301022130-244492dfa37a/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
3836
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
39-
golang.org/x/text v0.3.0 h1:g61tztE5qeGQ89tm6NTjjM9VPIm088od1l6aSorWRWg=
4037
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
4138
golang.org/x/text v0.3.2 h1:tW2bmiBqwgJj/UpqtC8EpXEZVYOwU0yG4iWbprSVAcs=
4239
golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk=
Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
11
{
22
"items": [
33
{
4-
"link": "http://example.org"
4+
"link": "http://example.org",
5+
"links": [
6+
"http://example.org"
7+
]
58
}
69
],
710
"version": "2.0"
8-
}
11+
}
Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
{
22
"feedLink": "http://example.org",
3+
"links": [
4+
"http://example.org"
5+
],
36
"items": [],
47
"feedType": "atom",
58
"feedVersion": "1.0"
6-
}
9+
}
Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,12 @@
11
{
22
"items": [
33
{
4-
"link": "http://www.example.org"
4+
"link": "http://www.example.org",
5+
"links": [
6+
"http://www.example.org"
7+
]
58
}
69
],
710
"feedType": "atom",
811
"feedVersion": "0.3"
9-
}
12+
}
Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,12 @@
11
{
22
"items": [
33
{
4-
"link": "http://www.example.org"
4+
"link": "http://www.example.org",
5+
"links": [
6+
"http://www.example.org"
7+
]
58
}
69
],
710
"feedType": "atom",
811
"feedVersion": "1.0"
9-
}
12+
}
Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
{
22
"link": "http://www.example.org",
3+
"links": [
4+
"http://www.example.org"
5+
],
36
"items": [],
47
"feedType": "atom",
58
"feedVersion": "0.3"
6-
}
9+
}
Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
{
22
"link": "http://www.example.org",
3+
"links": [
4+
"http://www.example.org"
5+
],
36
"items": [],
47
"feedType": "atom",
58
"feedVersion": "1.0"
6-
}
9+
}

testdata/translator/json/json10_full_expected.json

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,18 +24,29 @@
2424
"updatedParsed": "2019-10-12T07:20:50.52Z",
2525
"published": "2019-10-12T07:20:50.52Z",
2626
"publishedParsed": "2019-10-12T07:20:50.52Z",
27+
"links": [
28+
"https://sample-json-feed.com",
29+
"https://sample-json-feed.com/feed.json"
30+
],
2731
"items": [
2832
{
2933
"guid": "id",
3034
"title": "title",
3135
"link": "https://sample-json-feed.com/id",
36+
"links": [
37+
"https://sample-json-feed.com/id",
38+
"https://sample-json-feed.com/external"
39+
],
3240
"content": "<p>content_html</p>",
3341
"updated": "2019-10-12T07:20:50.52Z",
3442
"updatedParsed": "2019-10-12T07:20:50.52Z",
3543
"published": "2019-10-12T07:20:50.52Z",
3644
"publishedParsed": "2019-10-12T07:20:50.52Z",
3745
"description": "summary",
38-
"categories": ["tag1", "tag2"],
46+
"categories": [
47+
"tag1",
48+
"tag2"
49+
],
3950
"enclosures": [
4051
{
4152
"length": "100",
@@ -60,4 +71,4 @@
6071
}
6172
}
6273
]
63-
}
74+
}

0 commit comments

Comments
 (0)