yogthos / clj-rss Goto Github PK
View Code? Open in Web Editor NEWa library for generating RSS feeds
a library for generating RSS feeds
When I go to make a feed using clj-rss I noticed that in order to make the feed pretty to print its adding a newline character to each item in the feed before and after the item.
For my implementation this is not ideal so I would like to remove the newlines from the generated rss feed via some kind of property. Maybe a pretty print boolean could be setup so when added it adds the newlines and when not added they are not present.
Steps to reproduce:
Use first example from https://github.com/yogthos/clj-rss
(require '[clj-rss.core :as rss])
(rss/channel-xml {:title "Foo" :link "http://foo/bar" :description "some channel"}
{:title "Foo"}
{:title "post" :author "[email protected]"}
{:description "bar"})
Run in REPL, the output is:
<?xml` version='1.0' encoding='UTF-8'?>\n<rss version='2.0' xmlns:atom='http://www.w3.org/2005/Atom'>\n<channel>\n<atom:link href='http://foo/bar' rel='self' type='application/rss+xml'/>\n<title>\nFoo\n</title>\n<link>\nhttp://foo/bar\n</link>\n<description>\nsome channel\n</description>\n<generator>\nclj-rss\n</generator>\n<item>\n<title>\nFoo\n</title>\n</item>\n<item>\n<title>\npost\n</title>\n<author>\[email protected]\n</author>\n</item>\n<item>\n<description>\nbar\n</description>\n</item>\n</channel>\n</rss>\n
Notice all the \n newline characters, ideally there would be a way to remove them.
I forked the repo to see if I can figure this out but as I am new to clojure development I thought this might be something simple to fix which would save me some time on my current project. Alternatively if you have any tips on how to solve this I will gladly implement them and submit a pull request. Thanks for the assistance.
I'd like to add my blog feed to http://planet.clojure.in/ .
I learned what an RSS feed is and found this great library to create one.
I used this xml file as inspiration: https://www.clojuriststogether.org/index.xml .
How can I add to the entry the full HTML content? I I tried to add a :content:encoded
tag to my entry map but the validation of rss/channel-xml
fails.
Thank you!
I just went through a lengthy debugging session to find out why an old blog generator broke. I was getting a rather bizarre error:
No implementation of method: :gen-event of protocol: #'clojure.data.xml/EventGeneration found for class:
clojure.lang.PersistentArrayMap
As it turns out, the project used the official stable version of org.clojure/data.xml (0.0.8) (for other XML processing), while clj-rss requires a newer (currently "alpha") version and won't work with 0.0.8.
I think it might be a good idea to warn about this in the README, it might save others some time.
The link field in RSS is the link of the website, but this library also uses it to set this atom attribute https://github.com/yogthos/clj-rss/blob/master/src/clj_rss/core.clj#L137 which is supposed to be the URL of the feed itself
Hello,
Thanks for building this library.
I'm trying to figure out how I can put an image tag in the RSS.
To add an image tag I need to be able to add a nested tag but I couldn't figure out how I can do it.
I've tried something like this
(rss/channel-xml {:title blog-title
:link base-url
:description description
:image {:url (cdata blog-image-url)
:title (cdata blog-title)
:link blog-url}}
items)
but I've faced an error
Caused by: clojure.lang.ExceptionInfo: Auto-generating prefixes is not supported for content-qnames. Please declare all URIs used in content qnames. {:qname :url, :uri ""}
at clojure.data.xml.jvm.emit$prefix_for.invokeStatic(emit.clj:47)
at clojure.data.xml.jvm.emit$prefix_for.invoke(emit.clj:45)
at clojure.data.xml.jvm.emit$eval6876$fn__6878.invoke(emit.clj:158)
at clojure.data.xml.jvm.emit$eval6800$fn__6801$G__6791__6810.invoke(emit.clj:34)
at clojure.data.xml.jvm.emit$write_document$fn__6913.invoke(emit.clj:212)
at clojure.core.protocols$fn__8144.invokeStatic(protocols.clj:168)
at clojure.core.protocols$fn__8144.invoke(protocols.clj:124)
at clojure.core.protocols$fn__8099$G__8094__8108.invoke(protocols.clj:19)
at clojure.core.protocols$seq_reduce.invokeStatic(protocols.clj:31)
at clojure.core.protocols$fn__8131.invokeStatic(protocols.clj:75)
at clojure.core.protocols$fn__8131.invoke(protocols.clj:75)
at clojure.core.protocols$fn__8073$G__8068__8086.invoke(protocols.clj:13)
at clojure.core$reduce.invokeStatic(core.clj:6828)
at clojure.core$reduce.invoke(core.clj:6810)
at clojure.data.xml.jvm.emit$write_document.invokeStatic(emit.clj:212)
at clojure.data.xml.jvm.emit$write_document.invoke(emit.clj:196)
at clojure.data.xml$emit.invokeStatic(xml.clj:141)
at clojure.data.xml$emit.doInvoke(xml.clj:135)
at clojure.lang.RestFn.invoke(RestFn.java:425)
at clojure.lang.AFn.applyToHelper(AFn.java:156)
at clojure.lang.RestFn.applyTo(RestFn.java:132)
at clojure.core$apply.invokeStatic(core.clj:669)
at clojure.core$apply.invoke(core.clj:660)
at clojure.data.xml$emit_str.invokeStatic(xml.clj:150)
at clojure.data.xml$emit_str.doInvoke(xml.clj:143)
at clojure.lang.RestFn.invoke(RestFn.java:410)
at clj_rss.core$channel_xml.invokeStatic(core.clj:149)
at clj_rss.core$channel_xml.doInvoke(core.clj:146)
at clojure.lang.RestFn.invoke(RestFn.java:421)
Could I add an image tag?
Thanks.
I was just looking at this feed, https://hnrss.org/newest.
There's an attribute to their guid
tag called isPermaLink
.
I'd like to replicate that on my feed but it seems like the current API does not support this.
How might I go about adding this?
Example:
<item>
<title></title>
<description></description>
<pubDate>Wed, 20 Oct 2021 19:47:33 +0000</pubDate>
<link></link>
<dc:creator>gmays</dc:creator>
<comments>https://news.ycombinator.com/item?id=28935333</comments>
<guid isPermaLink="false">https://news.ycombinator.com/item?id=28935333</guid>
</item>
(deftest test-attrs
(is (= "<?xml version=\"1.0\" encoding=\"UTF-8\"?><rss version=\"2.0\" xmlns:atom=\"http://www.w3.org/2005/Atom\" xmlns:content=\"http://purl.org/rss/1.0/modules/content/\"><channel><atom:link href=\"http://foo/bar\" rel=\"self\" type=\"application/rss+xml\"/><title>Foo</title><link>http://foo/bar</link><description>some channel</description><generator>clj-rss</generator><item><title>test</title><guid isPermaLink="false">http://foo/bar</guid></item></channel></rss>"
(channel-xml {:title "Foo" :link "http://foo/bar" :description "some channel"}
{:title "test"
;; How do we want to do this?
:guid "http://foo/bar"}))))
Could you add some information regarding :pubDate
please? Am I supposed to pass a String or a DateTime object.. or what? And what about the format? My lack of familiarity with the Java language is causing me some trouble to understand this.
Also, any reasons why you aren't using clj-time
? I think this would make it more convenient for the user as any format can be passed.
Sometimes I have not got data to render RSS and I need to send XML structure without data, but it looks like, that I can't do it with current API:
(apply rss/channel-xml [])
Error:
clojure.lang.ArityException: Wrong number of args (0) passed to: core$channel-SINGLEQUOTE-
AFn.java:437 clojure.lang.AFn.throwArity
RestFn.java:399 clojure.lang.RestFn.invoke
AFn.java:159 clojure.lang.AFn.applyToHelper
RestFn.java:132 clojure.lang.RestFn.applyTo
core.clj:617 clojure.core/apply
core.clj:115 clj-rss.core/channel
RestFn.java:397 clojure.lang.RestFn.invoke
AFn.java:159 clojure.lang.AFn.applyToHelper
RestFn.java:132 clojure.lang.RestFn.applyTo
core.clj:617 clojure.core/apply
core.clj:120 clj-rss.core/channel-xml
RestFn.java:397 clojure.lang.RestFn.invoke
AFn.java:159 clojure.lang.AFn.applyToHelper
RestFn.java:132 clojure.lang.RestFn.applyTo
core.clj:617 clojure.core/apply
/home/vbauer/workspace/clojure/ziggurat/src/ziggurat/ui/routes.clj:64 ziggurat.ui.routes/eval6369
Ofc, this works fine:
(apply rss/channel-xml [{:title "1" :link "2" :description "2"}])
Output:
<?xml version='1.0' encoding='UTF-8'?>
<rss version='2.0'>
<channel>
<generator>\nclj-rss</generator>
<title>
1
</title>
<link>
2
</link>
<description>
2
</description>
</channel>
</rss>
And get a feed that keeps the W3 validator happy. http://validator.w3.org/feed/docs/warning/MissingAtomSelfLink.html
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.