the how and the why
I’ll press your flesh, you dimwitted sumbitch! You don’t tell your pappy how to court the electorate. We ain’t one-at-a-timin’ here. We’re MASS communicating! (Pappy O’Daniel in O Brother, Where Art Thou?)
This site is built using Jekyll, which essentially is a template processing tool written in Ruby. A good place to start are the various links shown on the about page page. Lots of people use it, and lots of people have written tutorials. Here are a few bits which I took a bit further from there.
It’s easy to set up a Jekyll blog (and free on Github if you don’t need plugins), and here are a few tutorials that helped me a lot:
The traditional way to do this appears to be creating an XML file with Liquid templates http://davecoyle.com/tech-notes/jekyll-templates-for-atom-rss/:
---
layout: nil
---
<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom">
<title>Your Website</title>
<link href="http://example.com/"/>
<link type="application/atom+xml" rel="self" href="http://example.com/atom.xml"/>
<updated>{{ site.time | date_to_xmlschema }}</updated>
<id>http://example.com/</id>
<author>
<name>Your Name</name>
<email>you@example.com</email>
</author>
{% for post in site.posts %}
<entry>
<id>http://example.com{{ post.id }}</id>
<link type="text/html" rel="alternate" href="http://example.com{{ post.url }}"/>
<title>{{ post.title }}</title>
<published>{{ post.date | date_to_xmlschema }}</published>
<updated>{{ post.date | date_to_xmlschema }}</updated>
<author>
<name>Your Name</name>
<uri>http://example.com/</uri>
</author>
<content type="html">{{ post.content | xml_escape }}</content>
</entry>
{% endfor %}
</feed>
This works, but it’d be nice to have more control over how the summary and content of posts are exported to the RSS feed. Also,
the layout of <pre>
tags will not be preserved, which doesn’t look so good. Finally, when using the above feed for static site search,
our site’s users will have to use queries for HTML rather than plain text. My solution post-processes
the output of Jekyll into an Atom feed using a plugin. The plugin works pretty much
like a standard generator, but is run in Site::write
in order to have access to
Page/Post::output
.
module Jekyll
class Site
# We overload site's write function because a Generator won't do
# here, we need the rendered pages as an input.
alias :old_write :write
def write
# ...
# Make Atom Feed
AtomGenerator.new.generate(self)
# finally, write everything
old_write
end
I will publish the full sources for this soon.