W3C home > Mailing lists > Public > public-rdf-ruby@w3.org > May 2010

Re: Linked Data content negotiation for Rack applications

From: Nicholas Humfrey <nicholas.humfrey@bbc.co.uk>
Date: Wed, 26 May 2010 14:28:14 +0100
To: Arto Bendiken <arto.bendiken@gmail.com>, <public-rdf-ruby@w3.org>
Message-ID: <C822E07E.29141%nicholas.humfrey@bbc.co.uk>
On 26/05/2010 13:44, "Arto Bendiken" <arto.bendiken@gmail.com> wrote:

> As a follow-up to the `linkeddata` metadistribution of RDF.rb, I have
> also just released a first rough cut of the `rack-linkeddata` gem [1].
> This gem is intended to provide a standard Linked Data content
> negotiation component for any Rack-compatible Ruby web applications
> (this includes e.g. all Rails 3.x and Sinatra applications), removing
> the need for these applications to concern themselves with either RDF
> serialization or HTTP header parsing.
> Rack::LinkedData was inspired by and intended for Nicholas Humfrey's
> work with DBpedia lite [2], which is to be a first testing grounds for
> the gem.
> You can install the gem as follows:
>     $ sudo gem install rack-linkeddata
> Using Rack::LinkedData in a Sinatra [3] application is particularly
> straightforward. Here follows a minimal complete RDF-based "Hello,
> world!" application [4] using Ruby, RDF.rb, Sinatra and
> Rack::LinkedData:
>     #!/usr/bin/env ruby -rubygems
>     require 'sinatra'
>     require 'rack/linkeddata'
>     use Rack::LinkedData::ContentNegotiation
>     get '/hello' do
>       RDF::Graph.new do
>         self << [RDF::Node.new, RDF::DC.title, "Hello, world!"]
>       end
>     end
> Given its brevity, it's probably self-evident what this application is
> supposed to do, even if you're not familiar with Sinatra or RDF.rb.
> If you have Sinatra installed, you can run this example application as
> follows:
>     $ ruby -rubygems hello.rb
> After Sinatra boots up (on port 4567 by default), you can use `curl`,
> or a similar tool like `wget` and `fetch`, to test out the content
> negotiation:
>     $ curl -iH "Accept: text/plain" http://localhost:4567/hello
>     $ curl -iH "Accept: text/turtle" http://localhost:4567/hello
>     $ curl -iH "Accept: application/rdf+xml" http://localhost:4567/hello
>     $ curl -iH "Accept: application/json" http://localhost:4567/hello
>     $ curl -iH "Accept: application/trix" http://localhost:4567/hello
>     $ curl -iH "Accept: */*" http://localhost:4567/hello
> ...and so on - you get the idea. Some more details can be found in the
> README [5].
> This Rack middleware is going to be deployed on a number of production
> sites over the next few days, which should work out any kinks it still
> has. It's our hope that it will in time become a dependable and easy
> way to plug in Linked Data content negotiation into any Rails
> application in particular.

Fantastic work Arto :)

Standards compliant content negotiation has always been a pain to implement
and this makes it super-simple. Looking forward to using this in dbpedia
lite. This will really help keep down the amount of code in the controller.


This e-mail (and any attachments) is confidential and may contain personal views which are not the views of the BBC unless specifically stated.
If you have received it in error, please delete it from your system.
Do not use, copy or disclose the information in any way nor act in reliance on it and notify the sender immediately.
Please note that the BBC monitors e-mails sent or received.
Further communication will signify your consent to this.
Received on Wednesday, 26 May 2010 13:28:50 UTC

This archive was generated by hypermail 2.3.1 : Tuesday, 6 January 2015 19:53:40 UTC