[HN Gopher] Simple script to generate RSS feeds
___________________________________________________________________
Simple script to generate RSS feeds
Author : Fred34
Score : 23 points
Date : 2024-02-24 20:49 UTC (2 hours ago)
(HTM) web link (www.zoraster.org)
(TXT) w3m dump (www.zoraster.org)
| Fred34 wrote:
| This is one of the first bash scripts I've written. What do you
| guys think?
| rvense wrote:
| 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/
| Fred34 wrote:
| 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.
| EmilStenstrom wrote:
| 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?
| LorenDB wrote:
| 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.
| Fred34 wrote:
| 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.
| LorenDB wrote:
| Hm, maybe it's the `<dc:creator>` tag causing the issue. Can
| you check to see if https://web.archive.org/web/2023122513585
| 9/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.
| Fred34 wrote:
| https://validator.w3.org/feed/check.cgi?url=https%3A%2F%2Fl
| o...
|
| My rss feeder that I use on my phone works with your site.
| Maybe it's only Thunderbird that refuses to parse it.
| LorenDB wrote:
| 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!
| Fred34 wrote:
| That seemed to work! RSS feed is now added to my
| Thunderbird client.
| surprisetalk wrote:
| 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
| politelemon wrote:
| 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.
___________________________________________________________________
(page generated 2024-02-24 23:01 UTC)