April 30, 2013

Here is a simple way to produce Event RSS feeds for a web site developed with Jekyll.

In a post, simply define additional fields, here starting with ev_:

---
layout: post
title: A wonderful event title
ev_link: http://link.to/the/wonderful/event.tml
ev_keywords:
  - ocaml
  - functional programming
  - typing
ev_speakers:
  - Jean Dupond, bla bla bla
  - George Dupont
ev_startDate: Thu, 23 May 2013 9:00:00 +0200
ev_endDate: Thu, 23 May 2013 17:15:00 +0200
---
<rest of the post>

Then, if your RSS feed template in located in feed.xml, edit this file to make it look like the following, to add event fields:

---
layout: none
---
<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
  xmlns:atom="http://www.w3.org/2005/Atom"
  xmlns:ev="http://zoggy.github.io/erssical/doc-event.html#"
>
 <channel>
  <title>{{ site.name }}</title>
  <description>{{ site.description }}</description>
  <link>{{ site.url }}</link>
  {% for post in site.posts limit:10 %}
  <item>
   <title>{{ post.title }}</title>
   <description>{{ post.content | xml_escape }}</description>
   <pubDate>{{ post.date | date: "%a, %d %b %Y %H:%M:%S %z" }}</pubDate>
   <link>{{ site.url }}{{ post.url }}</link>
   <guid isPermaLink="true">{{ site.url }}{{ post.url }}</guid>
   {% if post.ev_link %}<ev:link>{{ post.ev_link }}</ev:link>{% endif %}
   {% if post.ev_keywords %}
    <ev:keywords>
      {% for kw in post.ev_keywords %}<item>{{ kw }}</item>{% endfor %}
    </ev:keywords>
   {% endif %}
   {% if post.ev_location %}
     <ev:location>{{ post.ev_location }}</ev:location>
   {% endif %}
   {% if post.ev_audience %}
     <ev:audience>{{ post.ev_audience }}</ev:audience>
   {% endif %}
   {% if post.ev_endDate %}
     <ev:endDate>{{ post.ev_endDate }}</ev:endDate>
   {% endif %}
   {% if post.ev_startDate %}
     <ev:startDate>{{ post.ev_startDate }}</ev:startDate>
   {% endif %}
   {% if post.ev_organizers %}
     <ev:organizers>
       {% for p in post.ev_organizers %}
         <item>{{ p }}</item>{% endfor %}
     </ev:organizers>
   {% endif %}
   {% if post.ev_speakers %}
     <ev:speakers>
       {% for p in post.ev_speakers %}<item>{{ p }}</item>{% endfor %}
     </ev:speakers>
   {% endif %}
  </item>
  {% endfor %}
 </channel>
</rss>
Topics:
Keywords: