gorilla / feeds Goto Github PK
View Code? Open in Web Editor NEWPackage gorilla/feeds is a golang rss/atom generator library
Home Page: https://gorilla.github.io
License: BSD 3-Clause "New" or "Revised" License
Package gorilla/feeds is a golang rss/atom generator library
Home Page: https://gorilla.github.io
License: BSD 3-Clause "New" or "Revised" License
I started with a simple example:
ttt := make([]*feeds.Item, 0, len(items))
for _, r := range items {
tt := feeds.Item{
Id: fmt.Sprintf("%d", r.RequestID),
}
ttt = append(ttt, &tt)
}
now := time.Now()
feed := &feeds.Feed{
Title: "sfdsdfd.net blog",
Link: &feeds.Link{Href: "http://sdfsdfd.net/blog"},
Description: "discussion about tech, footie, photos",
Author: &feeds.Author{Name: "Jassdfdsdfdon sdfsdf", Email: "[email protected]"},
Created: now,
Items: ttt,
}
atom, err := feed.ToAtom()
if err != nil {
render.Render(w, r, httperr.ErrInternalServer(err.Error()))
}
render.PlainText(w, r, atom)
At the command atom, err := feed.ToAtom()
I get the following error:
http: panic serving [::1]:39096: runtime error: slice bounds out of range [-1:]
goroutine 50 [running]:
net/http.(*conn).serve.func1()
/usr/lib/go-1.18/src/net/http/server.go:1825 +0x148
panic({0xb99300, 0xc0002928b8})
/usr/lib/go-1.18/src/runtime/panic.go:844 +0x25a
github.com/go-chi/chi/middleware.prettyStack.decorateFuncCallLine({}, {0xc0002c7a69, 0x1b}, 0x1, 0x8)
/home/emaborsa/go/pkg/mod/github.com/go-chi/[email protected]/middleware/recoverer.go:130 +0x737
github.com/go-chi/chi/middleware.prettyStack.decorateLine({}, {0xc0002c7a69, 0x1b}, 0x1, 0x8)
/home/emaborsa/go/pkg/mod/github.com/go-chi/[email protected]/middleware/recoverer.go:106 +0x21c
github.com/go-chi/chi/middleware.prettyStack.parse({}, {0xc00049c000, 0x168e, 0x2000}, {0xb54440, 0xeb2380})
/home/emaborsa/go/pkg/mod/github.com/go-chi/[email protected]/middleware/recoverer.go:89 +0x8fa
github.com/go-chi/chi/middleware.PrintPrettyStack({0xb54440, 0xeb2380})
/home/emaborsa/go/pkg/mod/github.com/go-chi/[email protected]/middleware/recoverer.go:46 +0x89
github.com/go-chi/chi/middleware.(*defaultLogEntry).Panic(0xc000290900, {0xb54440, 0xeb2380}, {0xc000498000, 0x1518, 0x2000})
/home/emaborsa/go/pkg/mod/github.com/go-chi/[email protected]/middleware/logger.go:165 +0x45
github.com/go-chi/chi/middleware.Recoverer.func1.1()
/home/emaborsa/go/pkg/mod/github.com/go-chi/[email protected]/middleware/recoverer.go:28 +0x15f
panic({0xb54440, 0xeb2380})
/usr/lib/go-1.18/src/runtime/panic.go:844 +0x25a
github.com/gorilla/feeds.newAtomEntry(0xc000494000)
/home/emaborsa/go/pkg/mod/github.com/gorilla/[email protected]/atom.go:113 +0x657
github.com/gorilla/feeds.(*Atom).AtomFeed(0xc000286018)
/home/emaborsa/go/pkg/mod/github.com/gorilla/[email protected]/atom.go:156 +0x5f1
github.com/gorilla/feeds.(*Atom).FeedXml(0xc000286018)
/home/emaborsa/go/pkg/mod/github.com/gorilla/[email protected]/atom.go:163 +0x29
github.com/gorilla/feeds.ToXML({0xc2f1e0, 0xc000286018})
/home/emaborsa/go/pkg/mod/github.com/gorilla/[email protected]/feed.go:78 +0x5d
github.com/gorilla/feeds.(*Feed).ToAtom(0xc0002b00b0)
/home/emaborsa/go/pkg/mod/github.com/gorilla/[email protected]/feed.go:104 +0x99
github.com/HGV/guest-requests-api/app.Application.GetHGVRequests({{{0xc0001bc3f0}, {0xc0001bc3f0}}}, {0x7f8c1d8b8c78, 0xc0002b2200}, 0xc0002d2500)
/home/emaborsa/code/guest-requests-api/app/hgv_requests.go:120 +0xb65
net/http.HandlerFunc.ServeHTTP(0xc00000eca8, {0x7f8c1d8b8c78, 0xc0002b2200}, 0xc0002d2500)
/usr/lib/go-1.18/src/net/http/server.go:2084 +0x43
github.com/go-chi/chi/v5.(*Mux).routeHTTP(0xc000092de0, {0x7f8c1d8b8c78, 0xc0002b2200}, 0xc0002d2500)
/home/emaborsa/go/pkg/mod/github.com/go-chi/chi/[email protected]/mux.go:442 +0x27e
net/http.HandlerFunc.ServeHTTP(0xc000021bb0, {0x7f8c1d8b8c78, 0xc0002b2200}, 0xc0002d2500)
/usr/lib/go-1.18/src/net/http/server.go:2084 +0x43
github.com/go-chi/chi/v5.(*Mux).ServeHTTP(0xc000092de0, {0x7f8c1d8b8c78, 0xc0002b2200}, 0xc0002d2500)
/home/emaborsa/go/pkg/mod/github.com/go-chi/chi/[email protected]/mux.go:71 +0xfa
github.com/go-chi/chi/v5.(*Mux).Mount.func1({0x7f8c1d8b8c78, 0xc0002b2200}, 0xc0002d2500)
/home/emaborsa/go/pkg/mod/github.com/go-chi/chi/[email protected]/mux.go:314 +0x204
net/http.HandlerFunc.ServeHTTP(0xc00007ffc0, {0x7f8c1d8b8c78, 0xc0002b2200}, 0xc0002d2500)
/usr/lib/go-1.18/src/net/http/server.go:2084 +0x43
github.com/go-chi/chi/v5.(*Mux).routeHTTP(0xc000092d80, {0x7f8c1d8b8c78, 0xc0002b2200}, 0xc0002d2500)
/home/emaborsa/go/pkg/mod/github.com/go-chi/chi/[email protected]/mux.go:442 +0x27e
net/http.HandlerFunc.ServeHTTP(0xc000021bd0, {0x7f8c1d8b8c78, 0xc0002b2200}, 0xc0002d2500)
/usr/lib/go-1.18/src/net/http/server.go:2084 +0x43
github.com/go-chi/chi/v5.(*Mux).ServeHTTP(0xc000092d80, {0x7f8c1d8b8c78, 0xc0002b2200}, 0xc0002d2500)
/home/emaborsa/go/pkg/mod/github.com/go-chi/chi/[email protected]/mux.go:71 +0xfa
github.com/go-chi/chi/v5.(*Mux).Mount.func1({0x7f8c1d8b8c78, 0xc0002b2200}, 0xc0002d2500)
/home/emaborsa/go/pkg/mod/github.com/go-chi/chi/[email protected]/mux.go:314 +0x204
net/http.HandlerFunc.ServeHTTP(0xc00007ffe0, {0x7f8c1d8b8c78, 0xc0002b2200}, 0xc0002d2500)
/usr/lib/go-1.18/src/net/http/server.go:2084 +0x43
github.com/go-chi/chi/v5.(*Mux).routeHTTP(0xc000092c00, {0x7f8c1d8b8c78, 0xc0002b2200}, 0xc0002d2500)
/home/emaborsa/go/pkg/mod/github.com/go-chi/chi/[email protected]/mux.go:442 +0x27e
net/http.HandlerFunc.ServeHTTP(0xc000021b10, {0x7f8c1d8b8c78, 0xc0002b2200}, 0xc0002d2500)
/usr/lib/go-1.18/src/net/http/server.go:2084 +0x43
github.com/go-chi/chi/middleware.Timeout.func1.1({0x7f8c1d8b8c78, 0xc0002b2200}, 0xc0002d2500)
/home/emaborsa/go/pkg/mod/github.com/go-chi/[email protected]/middleware/timeout.go:45 +0x1fe
net/http.HandlerFunc.ServeHTTP(0xc00007ff40, {0x7f8c1d8b8c78, 0xc0002b2200}, 0xc0002d2400)
/usr/lib/go-1.18/src/net/http/server.go:2084 +0x43
github.com/go-chi/chi/middleware.Recoverer.func1({0x7f8c1d8b8c78, 0xc0002b2200}, 0xc0002d2400)
/home/emaborsa/go/pkg/mod/github.com/go-chi/[email protected]/middleware/recoverer.go:37 +0xf8
net/http.HandlerFunc.ServeHTTP(0xc00000eab0, {0x7f8c1d8b8c78, 0xc0002b2200}, 0xc0002d2400)
/usr/lib/go-1.18/src/net/http/server.go:2084 +0x43
github.com/go-chi/chi/middleware.RequestLogger.func1.1({0xc33370, 0xc0002b40e0}, 0xc0002d2300)
/home/emaborsa/go/pkg/mod/github.com/go-chi/[email protected]/middleware/logger.go:57 +0x266
net/http.HandlerFunc.ServeHTTP(0xc0001fa750, {0xc33370, 0xc0002b40e0}, 0xc0002d2300)
/usr/lib/go-1.18/src/net/http/server.go:2084 +0x43
github.com/go-chi/chi/middleware.RealIP.func1({0xc33370, 0xc0002b40e0}, 0xc0002d2300)
/home/emaborsa/go/pkg/mod/github.com/go-chi/[email protected]/middleware/realip.go:34 +0xac
net/http.HandlerFunc.ServeHTTP(0xc00000eac8, {0xc33370, 0xc0002b40e0}, 0xc0002d2300)
/usr/lib/go-1.18/src/net/http/server.go:2084 +0x43
github.com/go-chi/chi/middleware.RequestID.func1({0xc33370, 0xc0002b40e0}, 0xc0002d2200)
/home/emaborsa/go/pkg/mod/github.com/go-chi/[email protected]/middleware/request_id.go:76 +0x25f
net/http.HandlerFunc.ServeHTTP(0xc00000eae0, {0xc33370, 0xc0002b40e0}, 0xc0002d2200)
/usr/lib/go-1.18/src/net/http/server.go:2084 +0x43
github.com/go-chi/chi/v5.(*Mux).ServeHTTP(0xc000092c00, {0xc33370, 0xc0002b40e0}, 0xc0002d2200)
/home/emaborsa/go/pkg/mod/github.com/go-chi/chi/[email protected]/mux.go:88 +0x288
net/http.serverHandler.ServeHTTP({0xc0001dc1c0}, {0xc33370, 0xc0002b40e0}, 0xc0002d2100)
/usr/lib/go-1.18/src/net/http/server.go:2916 +0x474
net/http.(*conn).serve(0xc0002f6000, {0xc33860, 0xc0002b20c0})
/usr/lib/go-1.18/src/net/http/server.go:1966 +0x193c
created by net/http.(*Server).Serve
/usr/lib/go-1.18/src/net/http/server.go:3071 +0x9cf
Describe the bug
According to RSS 2.0 spec and the site given in README https://www.rssboard.org/rss-specification#hrelementsOfLtitemgt
there is no need for link element in item. Still, if it's ommited, then the program execution results in panic.
…
Versions
Go version: v1.19.2
package version: v1.1.1
…
Steps to Reproduce
Just do everything that is done in README code, except for links in items - do not provide them. Then run feed.toRss() and the panic should occur.
…
Expected behavior
No panic. Or at least mention in documentation that the link is needed, although I discourage it and think it is better for package to be compatible with spec.
…
Code Snippets
package main
import (
"fmt"
"github.com/gorilla/feeds"
"log"
"time"
)
func main() {
now := time.Now()
feed := &feeds.Feed{
Title: "jmoiron.net blog",
Link: &feeds.Link{Href: "http://jmoiron.net/blog"},
Description: "discussion about tech, footie, photos",
Author: &feeds.Author{Name: "Jason Moiron", Email: "[email protected]"},
Created: now,
}
feed.Items = []*feeds.Item{
&feeds.Item{
Title: "Limiting Concurrency in Go",
Description: "A discussion on controlled parallelism in golang",
Author: &feeds.Author{Name: "Jason Moiron", Email: "[email protected]"},
Created: now,
},
&feeds.Item{
Title: "Logic-less Template Redux",
Description: "More thoughts on logicless templates",
Created: now,
},
&feeds.Item{
Title: "Idiomatic Code Reuse in Go",
Description: "How to use interfaces <em>effectively</em>",
Created: now,
},
}
rss, err := feed.ToRss()
if err != nil {
log.Fatal(err)
}
fmt.Println(rss)
}
…
It seems to me that it would be nice to be able to parse a feed as either Rss or Atom and then convert it to a Feed for a common set of operations (as the documentation mentions, this library exposes a common Feed interface); however, after reviewing the API, it doesn't seem like this library has a good story to support that (perhaps I missed something?). I would be willing to do as much of the legwork as I can (I'm not familiar with some of the nuances of RSS/Atom), but first I'd like to know if such a feature would be accepted for inclusion in this library. If so, feel free to provide advice on implementation.
Hello!
I faced with a problem of unmarshalling RSS. I found that PR #59 had already resolved this problem. But the last release doesn't contain these changes, and if you use go modules, your default release is v1.1.0
Of course, you can set the version explicitly in go.mod
: github.com/gorilla/feeds master
, but it would be better to have a new release.
By default, the guid element specifies a permanent link for an item, the value must be a full URL. If you are using the guid element simply as a unique identifier (and not a link to the item), then the value can be whatever you want, but you must include the attribute isPermaLink="false" in the guid tag. Could you add this feature?
…
Expected behavior
<guid isPermaLink="false">article 54 at example.com</guid>
Actual behavior
<guid>http://www.example.com/archives/000054.html</guid>
I have a feed in which items have a non-empty Content but an empty Description. This should result in an atom feed with a <content>
element for the item but no <summary>
element, but it seems that the feeds package always emits a <summary>
element, even if it is empty.
https://play.golang.org/p/gE3aNOkeIqb
The feeds package should not should not emit a <summary>
element if Item.Content
is set but Item.Description
is blank. Its presence may mislead feed readers into displaying the (empty) summary, ignoring the post content.
I'm currently working around the issue like this, but would prefer if this wasn't necessary.
atomFeed := (&feeds.Atom{feed}).AtomFeed()
for i := range atomFeed.Entries {
atomFeed.Entries[i].Summary = nil
}
Versions
Go version:
go version go1.14.3 linux/amd64
package version:6f6e20dd3953594cd869cf981fb806440685cd21
Steps to Reproduce
How can the bug be triggered?
See code snippet below.
<?xml version="1.0" encoding="UTF-8"?><feed xmlns="http://www.w3.org/2005/Atom">
<title>A blog</title>
<id>http://example.net/</id>
<updated>2009-11-10T23:00:00Z</updated>
<link href="http://example.net/"></link>
<author>
<name>Test User</name>
<email>[email protected]</email>
</author>
<entry>
<title>Blog post</title>
<updated>2009-11-10T23:00:00Z</updated>
<id>tag:example.net,2009-11-10:/1</id>
<content type="html">Full contents of the blog post</content>
<link href="http://example.net/1" rel="alternate"></link>
<summary type="html"></summary>
<author>
<name>Test User</name>
<email>[email protected]</email>
</author>
</entry>
</feed>
Expected behavior
What output or behaviour were you expecting instead?
<?xml version="1.0" encoding="UTF-8"?><feed xmlns="http://www.w3.org/2005/Atom">
<title>A blog</title>
<id>http://example.net/</id>
<updated>2009-11-10T23:00:00Z</updated>
<link href="http://example.net/"></link>
<author>
<name>Test User</name>
<email>[email protected]</email>
</author>
<entry>
<title>Blog post</title>
<updated>2009-11-10T23:00:00Z</updated>
<id>tag:example.net,2009-11-10:/1</id>
<content type="html">Full contents of the blog post</content>
<link href="http://example.net/1" rel="alternate"></link>
<author>
<name>Test User</name>
<email>[email protected]</email>
</author>
</entry>
</feed>
Code Snippets
https://play.golang.org/p/gE3aNOkeIqb
package main
import (
"log"
"os"
"time"
"github.com/gorilla/feeds"
)
func main() {
now := time.Now()
feed := &feeds.Feed{
Title: "A blog",
Link: &feeds.Link{Href: "http://example.net/"},
Author: &feeds.Author{Name: "Test User", Email: "[email protected]"},
Created: now,
}
feed.Items = []*feeds.Item{
&feeds.Item{
Title: "Blog post",
Link: &feeds.Link{Href: "http://example.net/1"},
Content: "Full contents of the blog post",
Author: &feeds.Author{Name: "Test User", Email: "[email protected]"},
Created: now,
},
}
err := feed.WriteAtom(os.Stdout)
if err != nil {
log.Fatal(err)
}
}
Migrate from TravisCI to @circleci.
I'm a bit confused by the API. Is Description for the body of the blog post?
Any thoughts on adding support for the itunes rss podcast tags ?
https://validator.w3.org/feed/check.cgi
Would be nice if the example outputs were raw files in the repo so they could be referenced by URL to various RSS feed checkers.
The JSON Feed doesn't appear to ever populate content_html
nor content_text
… I'm not sure if this is an oversight or a conscious decision, however the JSON Feed Spec says that one is required.
If there is interest I could submit a pull request.
package main
import (
"os"
"time"
"github.com/gorilla/feeds"
)
func main() {
now := time.Now()
feed := &feeds.Feed{
Link: &feeds.Link{Href: "http://example.com"},
}
feed.Items = []*feeds.Item{
&feeds.Item{
Title: "TITLE",
Link: &feeds.Link{Href: "http://example.com/"},
Content: "THIS IS MY CONTENT THIS IS IT WHERE IT IS THIS IS THE CONTENT",
Created: now,
},
}
feed.WriteRss(os.Stdout)
os.Stdout.WriteString("\n\n---\n\n")
feed.WriteAtom(os.Stdout)
os.Stdout.WriteString("\n\n---\n\n")
feed.WriteJSON(os.Stdout)
}
<?xml version="1.0" encoding="UTF-8"?><rss version="2.0" xmlns:content="http://purl.org/rss/1.0/modules/content/">
<channel>
<title></title>
<link>http://example.com</link>
<description></description>
<item>
<title>TITLE</title>
<link>http://example.com/</link>
<description></description>
<content:encoded><![CDATA[THIS IS MY CONTENT THIS IS IT WHERE IT IS THIS IS THE CONTENT]]></content:encoded>
<pubDate>Fri, 11 May 2018 11:21:30 -0500</pubDate>
</item>
</channel>
</rss>
---
<?xml version="1.0" encoding="UTF-8"?><feed xmlns="http://www.w3.org/2005/Atom">
<title></title>
<id>http://example.com</id>
<updated></updated>
<link href="http://example.com"></link>
<entry>
<title>TITLE</title>
<updated>2018-05-11T11:21:30-05:00</updated>
<id>tag:example.com,2018-05-11:/</id>
<content type="html">THIS IS MY CONTENT THIS IS IT WHERE IT IS THIS IS THE CONTENT</content>
<link href="http://example.com/" rel="alternate"></link>
<summary type="html"></summary>
</entry>
</feed>
---
{
"version": "https://jsonfeed.org/version/1",
"title": "",
"home_page_url": "http://example.com",
"items": [
{
"id": "",
"url": "http://example.com/",
"title": "TITLE",
"date_published": "2018-05-11T11:21:30.733246003-05:00"
}
]
}
I'm creating some custom feeds for my nissan leaf, and, I need to add fields to the rss I generate. The full spec of the tags is here. But, in a nutshell, I just need to add carwings:something tags to the feed. Here's an example -- sorry for the japanese, it's from the url above:
<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:carwings="http://www.nissan.co.jp/dtd/carwings.dtd">
<channel>
<title>日産WEBサイト更新情報:NISSAN Topics</title>
<link>http://rss.nissan.co.jp/</link>
<description>日産自動車の最新情報をお届けします。</description>
<language>ja</language>
<copyright>Copyright NISSAN MOTOR CO.,LTD. 2005 All Rights Reserved.</copyright>
<lastBuildDate>Wed, 25 Oct 2006 12:18:36 +0900</lastBuildDate>
<docs>http://blogs.law.harvard.edu/tech/rss</docs>
<item>
<title>エクストレイル X-TRAIL JAM情報更新</title>
<carwings:readtitle>エクストレイル ジャム 情報更新</carwings:readtitle>
<description>X-TRAIL JAM IN TOKYO DOMEのチケット一般発売開始!!</description>
<carwings:readtext>エクストレイル ジャム 東京ドームのチケット、一般販売開始。</carwings:readtext>
<carwings:itemimage>http://eplus.jp/sys/web/irg/2006x-trail/images/topmain.jpg</carwings:itemimage>
<carwings:data><![CDATA[
<body>エクストレイル<br><img src="http://lab.nissan-carwings.com/CWC/images/x-trail.jpg"></body>
]]>
</carwings:data>
<carwings:lat>35.70568</carwings:lat>
<carwings:lon>139.75187</carwings:lon>
<link>http://blog.nissan.co.jp/X-TRAIL/?rss</link>
<guid>http://blog.nissan.co.jp/X-TRAIL/?rss</guid>
<carwings:link>http://www.nissan.co.jp/EVENT/....../coupon.html</carwings:link>
<category>コンテンツ</category>
<pubDate>Mon, 16 Oct 2006 20:15:02 +0900</pubDate>
</item>
</channel>
</rss>
I'm happy to extend gorilla feeds to add the fields, but, I can't figure out an easy way to do it. Thoughts? I'd hate to have to write a new library when yours is so close!
Thanks in advance,
-Dave
I would like to generate a RSS feed for iTunes Podcast. This service have a special xml tags. Some of them required, but other - just recommended.
Apple allow to extend some of existing well-known XML tags like channel
and item
. Itunes tags have a special namespace (prefix for each iTunes tag) like <irunes:....>
. So in my opinion we can add some optional field to Channel
and Item
structs and allow to fill them by user.
It can be looks like this:
feed := &feeds.Feed{
Title: "jmoiron.net blog",
Link: &feeds.Link{Href: "http://jmoiron.net/blog"},
Description: "discussion about tech, footie, photos",
Author: &feeds.Author{Name: "Jason Moiron", Email: "[email protected]"},
Created: now,
ITunes: &ItunesFeed{
Author: "Author name",
Type: "full",
Image: "image.png",
Explicit: true,
Categories: []ITunesCategory{...},
},
Items: []*feeds.Item{
&feeds.Item{
Title: "Limiting Concurrency in Go",
Link: &feeds.Link{Href: "http://jmoiron.net/blog/limiting-concurrency-in-go/"},
Description: "A discussion on controlled parallelism in golang",
Author: &feeds.Author{Name: "Jason Moiron", Email: "[email protected]"},
Created: now,
ITunes: &ItunesItem{
{
Title: "asdasd",
....
},
},
},
},
}
This design will allow us to add other RSS extensions from other providers like Spotify, which have their own XML tags.
Links:
Ability to add a user-defined data in each XML tag like this (it is like a raw access to the rss):
type CustomItem interface {
// THis methods will allow user to choose - when this custom field will be presented
MarshalAtom()([]byte,error)
MarshalRSS()([]byte,error)
MarshalJSON()([]byte,error)
}
feed := &feeds.Feed{
Title: "jmoiron.net blog",
// ...
}
feed.Add(CustomItemImpl{...})
feed.Items[0].Add(CustomItemImpl{...})
I noticed "runtime error: invalid memory address or nil pointer dereference" while using feeds library, so i started checking the issue.
It turned out that the library assumes that Feed.Link field is set although it has pointer type.
After checking the specs:
The Link field is required only for RSS feeds.
Atom feeds does not require feed to contain element, but it's recommended though.
JSON feed spec state that home_page_url and feed_url is optional, but strongly recommended.
I can fix this issue for Atom and JSON feeds, but I'd like to know your opinion first.
Would you like to keep it as it is, or to create non required fields only if Feed.Link is set?
specs:
https://validator.w3.org/feed/docs/atom.html
https://jsonfeed.org/version/1
Hi guys,
Hope you are all well !
Is there a way to add an image and categories/tags attributes to feed items ?
What is the specification allowing that ? Can we implement that ?
Thanks in advance for your insights and inputs on these questions.
Cheers,
X
Hi,
It would be nice if you could release a new tagged version of this package, since using it with Go modules will automatically pull the latest tagged version instead of master
– and the latest release is more than 1 year old with 15 commits pushed since.
🙏😇
Is your feature request related to a problem? Please describe.
I would like to have the option to add multiple links to a feed item
Describe the solution you'd like
The Link property of a feed should rather be an array of Links. Similar like here:
master...ratzrattillo:feeds:master
Describe alternatives you've considered
I have the following workaround in place just for Atom Feeds (However i am not a good Go programmer)
Is there a content type "markdown" since it seems silly to publish as html and then read by newsbeuter which gets it back down into markdown style.
Describe the bug
When generating an RSS feeds where the Items have an author, instead of using the Email
-field, it uses just the Name
field. This causes the feed to not be readable by most readers, as it doesn't follow the spec.
See: https://www.w3schools.com/XML/rss_tag_author.asp
Also: http://validator.w3.org/feed/
Steps to Reproduce
Make a feed with a single item that has an author field and export as RSS
Expected behavior
Instead it should've put the Email
into the <author>
tag.
I am trying to use feeds to combine multiple rss feeds
I've found 2 problems trying to unmarshal rss feeds so far
the rssFeedXml
struct is private so i cannot unmarshal the base XML
after recreating the rssFeedXml
struct locally the Items slice is always nil. This can be fixed by adding an xml tag. this is a similar problem to #36
Items []*RssItem `xml:"item"`
Would I be welcome to submit a PR with these changes? Or, is this library only intended for feed creation?
Hi, first: congrats ! I'm using Gorilla as base for my own framework (https://github.com/kwiscale) and I'm using gorilla/feeds in my web blog (https://www.metal3d.org/feed/rss and https://www.metal3d.org/feed/atom). I wanted to add "comments" from my blogpost in RSS items, I see that RssItem struct has Comments property:
https://github.com/gorilla/feeds/blob/master/rss.go#L69
But I really don't see how to use them. If there is a good practice or if this field is a work in progress.
Can you tell us more ?
Thanks !
I have a use case where the items have the correct created timestamp but I get them as an unordered list. Would it make sense to include a helper function to sort the items in a feed by a key or would that be out of scope?
The use case would be to apply this before calling ToRss()
if needed.
Describe the bug
Currenly Gorilla outputs the Content-Type header as "application/xml". According to the RSS Standard Board, the correct Content-Type should be "application/rss+xml".
Versions
go version go1.17.5 linux/amd64
github.com/gorilla/feeds v1.1.1
Steps to Reproduce
$ curl -s -D - -o /dev/null http://localhost:8000/rss
HTTP/1.1 200 OK
Content-Type: application/xml
Date: Fri, 18 Mar 2022 13:51:01 GMT
Transfer-Encoding: chunked
Expected behavior
$ curl -s -D - -o /dev/null http://localhost:8000/rss
HTTP/1.1 200 OK
Content-Type: application/rss+xml
Date: Fri, 18 Mar 2022 13:51:01 GMT
Transfer-Encoding: chunked
Describe the bug
The JSONFeed Hubs
attribute is incorrectly given the type []*JSONItem
instead of []*JSONHub
which means it's impossible to correctly attach hubs to the JSON feed.
This would be resolved by #74
Currently, if we use not a real URL for <guid>
in RSS, we get this message from validation tool: https://validator.w3.org/feed/docs/error/InvalidHttpGUID.html
As I understand we can use a special type for Item.Id
(as we use for Link
for example), ans allow user to set isPermaLink
value. What do you think?
No response
No response
It looks like gorilla atom feeds don't support multiple links even though the atom spec does:
https://tools.ietf.org/html/rfc4287#page-3
From their example:
<link rel="alternate" type="text/html" hreflang="en" href="http://example.org/"/>
<link rel="self" type="application/atom+xml" href="http://example.org/feed.atom"/>
I'd like to add support for this but I wanted to get feedback from the package owners first. As far as I can tell, RSS doesn't have a corresponding feature. Suggestions on your preferred approach?
My generated feed is empty of images. How can I get some images on it?
I've seen there is a type RssImage
, but not a corresponding field on type Feed
.
What am I missing here?
Also, how do I get favicons to show on readers? Is their responsibility to parse my home page and get a favicon from there?
Here's my feed link for reference: http://reconhecendo.me/feed.xml
Some feed readers (like Reeder
, which is what I use) support a special "reader mode". In this mode, in-page hash links may not work properly unless the xml:base
attribute is set and matches the URL of the current entry (either link
or id
, not sure which).
This can be solved by assigning xml:base
to each entry in the feed, with the URL matching the entry's URL. Unfortunately this is not currently supported in gorilla/feeds
, which caused me to make a private fork.
Attribute definition:
XmlBase string `xml:"xml:base,attr,omitempty"`
This needs to be supported in Feed
, Item
, RssFeedXml
, RssItem
, AtomFeedXml
, AtomItem
.
If I use a string in Item.Description
that contains format strings like %s
the output is broken, looks like something is trying to sprintf the description string
&Item{
Title: "Limiting Concurrency in Go",
Link: &Link{Href: "http://jmoiron.net/blog/limiting-concurrency-in-go/"},
--> Description: "abcdee %s deeefffff",
Author: &Author{"Jason Moiron", "[email protected]"},
Created: now,
},
in the RSS feed content is abcdee %!s(MISSING) deeefffff
.
Real-world example for this would be urlencoded links.
Any suggestions as to what I can do to prevent the formatting to happen?
Since my articles are fairly small, I put the entire escaped article HTML inside the content, but it gets escaped by a CDATA tag enclosing the content.
<content:encoded><![CDATA[<h1>H1</h1>
...
Is there any way to deactivate or change that behaviour ?
I need to keep HTML in Description AS IS, i.e. I need the following result without any encoding of course:
<![CDATA[ <div class="title">Title ]]>
When deserializing the AtomFeed
the entries weren't included.
https://travis-ci.org/gorilla/feeds/jobs/55587220
Diffs between "got" and "expected":
diff --git a/1.txt b/2.txt
index 4894da0..1f6f674 100644
--- a/1.txt
+++ b/2.txt
@@ -1,4 +1,4 @@
- <?xml version="1.0" encoding="UTF-8"?><feed>
+ <?xml version="1.0" encoding="UTF-8"?><feed xmlns="http://www.w3.org/2005/Atom">
<title>jmoiron.net blog</title>
<id>http://jmoiron.net/blog</id>
<updated>2013-01-16T21:52:35-05:00</updated>
Do you think it's a bug in feeds, tests, or Go? I suspect these changes has something to do with it:
Hi, I've noticed that the license file is missing. Could you please add it?
Given
type RssItem struct {
...
Category string `xml:"category,omitempty"`
...
}
one can set single category only. However, RSS 2.0 specs says that
You may include as many category elements as you need to
This is actually handy since blog posts, for example, seldom have exactly one tag.
I believe it's better to
Categories []string `xml:...`
It's clear you can't change it without backward compatibility break, but maybe you have another solution?
Is your feature request related to a problem? Please describe.
The JSON feed spec is currently at v1.1. The changes from v1.0 to v1.1 are very minor, so this should be a pretty easy box to check off.
Describe the solution you'd like
Here's a synopsis of changes, taken from the specification:
Version 1.1 — 8/7/2020:
- Updated to use more specific
application/feed+json
MIME type.- Added
authors
field to allow more than 1 author per feed or item. Deprecatedauthor
.- Added
language
field.- Clarified that
id
should be a string.- Updated links to JSON and other specs.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.