RDFa On Rails 0.0.7

Version 0.0.7 of RDFa On Rails is now out. It contains many significant improvements. First of all the code has been refactored into modules to get things clearer. Then we have support for the full vocabularies of rdfs, dc, sioc, foaf and scot. What does it mean? For each class defined in rdfs for instance you get a method such as rdfa_rdfs_resource which takes as input a uri and a block. For each property define in the previously mentioned vocabularies, you get methods such as rdfa_rdfs_label which takes a value(might be a uri), an optional subject uri and an optional block. And another goodie, for each property you also get a link_to helper such as rdfa_link_to_dc_creator. So you can implement:

<% rdfa_rdfs_resource do %>
<%= rdfa_dc_title "a resource in RDFa on rails" %>
<% rdfa_dc_date "2007-06-03" do %> June the third in the holy 2007 <%end%>
<%= rdfa_link_to_dc_creator "Cédric Mesnage", "http://www.inf.unisi.ch/phd/mesnage/" %>
<%end%>

Notice that in the previous example we didn’t give a uri to the resource, in this case a blank node will be generated. To summarize, we have:

  1. For each class of the supported vocabularies a method rdfa_{namespace}_{lowercase class name}
  2. For each property two methods :
    1. rdfa_{namespace}_{lowercase property name}
    2. rdfa_link_to_{namespace}_{lowercase property name}

So basically you already have most of the things you need to represent your data in RDFa. But what if you want to use a specific vocabulary that we don’t support? well just do the same as we do:

  1. Register the namespace of your vocabulary using
    Rdfa.register_namespace(name, namespace)
  2. Register the classes you wish to use using
    Rdfa.register_rdfa_classes(namespace short name, list of classes)
  3. Register the properties you wish to use using
    Rdfa.register_rdfa_properties(namespaceshort name , list of properties)

Simple enough? That’s what we use to support the vocabularies, as in this example for some of the foaf vocabulary:

Rdfa.register_rdfa_namespace :foaf , 'http://xmlns.com/foaf/0.1/'
Rdfa.register_rdfa_classes :foaf, ['Person','Project']
Rdfa.register_rdfa_properties :foaf, ["mbox","name","knows"]

Next things to be done, complete and refine the documentation, improve the rdfa-typo theme, add unit testing.

Leave a Reply