Blog » RSS really is "Really Simple"
internet rss xml
Following some intense lobbying from fellow netizen Killian (see his website at https://killiandavitt.me) I’m pleased to announce that I’ve added an RSS feed to the site.
Surprisingly there aren’t that many libraries for building RSS feeds for Elixir. Perhaps that’s not surprising, since it seems RSS has fallen out of favour in deference to integrated social media platforms. Alas.
But perhaps also it’s not ever been necessary. As it turns out RSS stands for “Really Simple Syndication”, and it really is, really simple.
Your RSS “feed” is an XML document, which contains one or more “channels” (e.g. blog posts, a photos channel, an announcements channel), and the channels themselves contain posts.
These posts are just elements which contain metadata like the title, publication date and a summary as well as an ID, so that RSS readers can detect whether it’s seen a post before (so that it can decide if it’s a brand new post, or just one which has been updated).
And as it turns out generating all this stuff with EEx is very very easy. Originally I was considering writing a library that represents feeds, channels and posts as structs, and then serialise that to XML, but as it turns out I can just generate the file directly in one shot. Seriously, this is the entire template:
<?xml version="1.0" encoding="UTF-8" ?>
<rss version="2.0">
<channel>
<title>andrewshaw.nl</title>
<link>https://andrewshaw.nl</link>
<description>Andrew Shaw's personal website</description>
<language>en-ie</language>
<pubDate><%= DateTime.utc_now() |> DateTime.to_iso8601() %></pubDate>
<%= for post <- @posts do %>
<item>
<title><%= post.title %></title>
<link>https://andrewshaw.nl/blog/<%= post.slug %>.html</link>
<guid>https://andrewshaw.nl/blog/<%= post.slug %>.html</guid>
<pubDate><%= post.date %></pubDate>
<description><![CDATA[<%= post.abstract %>]]></description>
</item>
<% end %>
</channel>
</rss>
Very nice altogether!
Through all of this, I do wonder where we lost our way. You can surely design a twitter-style microblogging site purely around these dead simple XML feeds. I wonder where we would be at if this were embraced over proprietary closed platforms.