Hacker News new | past | comments | ask | show | jobs | submit login
Simple script to generate RSS feeds (zoraster.org)
31 points by Fred34 11 months ago | hide | past | favorite | 13 comments



For anybody using Hugo, you also may be interested in https://lorendb.dev/posts/fixing-hugos-rss-feed/ in which I fix Hugo's feed template to have the entire article as well as a few other niceties.


Learning hugo is on my bucket list. Has things like tagging which would be a pain to do with a hand coded website.

I got a parsing error when trying to add the rss feed on your website to Thunderbird. Line Number 19, Column 7.


Hm, maybe it's the `<dc:creator>` tag causing the issue. Can you check to see if https://web.archive.org/web/20231225135859/https://lorendb.d... has the same problem? (this is an archive from before I added the `<dc:creator>` tag)

Edit: that doesn't seem to be importable. Give me a minute and I'll check manually.

Edit 2: I am unable to figure out a fix to the problem, sorry! My feed works fine for me in Tiny Tiny RSS, so I am tempted to say that it's caused by a very strict feed parser.


https://validator.w3.org/feed/check.cgi?url=https%3A%2F%2Flo...

My rss feeder that I use on my phone works with your site. Maybe it's only Thunderbird that refuses to parse it.


OK, I found the problem. I hadn't imported the proper RSS namespace thingy to provide the `<dc:creator>` tag. I've fixed that now, so you should be able to read my feed in Thunderbird!


That seemed to work! RSS feed is now added to my Thunderbird client.


If you're using eleventy, you should be able to just add the RSS plugin: https://www.11ty.dev/docs/plugins/rss/ and easily configure it. If you're using a theme then check to see if it already bundles this.


I'm not using a static-site generator yet. I probably should however.


This is one of the first bash scripts I've written. What do you guys think?


It's cool, nice work! And thank you for sharing it.

This is just spitballing, you've already solved problem you set out to and get full marks.

There are always many different ways to do things with bash/shell. Here, you could probably do the entire thing in AWK, which you seem to already be aware of. This might be more readable or it might not.

If this were a script someone wrote for more general usage, I'd recommend to use the unofficial "bash strict mode"[0], and make sure to check that the awk/sed calls succeed. Shell has a nasty habit of limping along as far as it can if something goes wrong along the way and it's very easy to just end up with bad output and not notice until it's too late.

Another thing I only recently discovered is envsubst, a tool that's commonly available and tailor-made for substituting variables. You could pipe a template string or pile into that instead of the repetitive calls to echo. What you have here is fine and instantly readable, but if it were three times as long it might not be so nice. Here you could use awk to extract the variables and envsubst to put them into your template.

Honestly I don't think shell is a good language for writing perfect, robust things anyway. But it's good for exactly what you're doing, though, writing something for yourself that solves a problem without spending too much time on it (although it's fine to spend a lot of time on it if you're learning and/or just enjoying yourself).

[0] http://redsymbol.net/articles/unofficial-bash-strict-mode/


Thanks for the feedback. I haven't heard of "bash strict mode" before. Haven't heard of envsubst either. I'll make a better rss script as I learn more about scripting.


Some feedback: Did you consider what happens if the blog post contains the string "]]>"? I think that probably needs to be escaped to avoid problems?


Related: I recently wrote an SQL query to generate podcast RSS:

https://taylor.town/xml-sql

Postgres XML functions are ugly, but make this kind of stuff very easy




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: