From: Arto Bendiken
Date: Wed, May 26, 2010 at 3:18 PM
Subject: Re: Rack::LinkedData
To: Nicholas J Humfrey
On Wed, May 26, 2010 at 2:04 PM, Nicholas J Humfrey wrote:
4) Finally, have you had any thoughts about mixing RDF serialisations
with
ERB/HTML responses? It would be go to set this per route, rather than
creating a new 'fake' RDF writer. How about something like this?
get '/njh' do
@rdf = RDF::Graph.new { ..... }
negotiate 'text/html', 'application/xhtml+xml' do
erb :page
end
@rdf
end
I really need this for dbpedia lite.
The assumption in Rack::LinkedData is currently that the Rack app will
handle any HTML requests. That is, if you e.g. output an ERB page as
the Rack app's response, then Rack::LinkedData won't do anything to
that response, propagating it upwards to the web server without any
changes.
I saw that, however the issue is trying to making it part of the content
negotiations. I want to to able to give the request header: "Accept:
application/rdf+xml;q=0.5,text/html" and to get some HTML back by
preference.
That ("application/rdf+xml;q=0.5,text/html") should work, actually -
your application always has first shot at what kind of a response it
wants to generate.
But I suppose the problem with the present setup is not so much
knowing when to generate an HTML response, but knowing when to
generate an RDF one without having to parse the Accept header oneself.
So yeah, we need something more for this.
So, as far as I can tell, the example you gave should more or less
work, if you wrap an if/then/else block around the negotiate versus
returning the @rdf object. (I'm assuming negotiate is a Sinatra
construct.)
No 'negotiate' is something I just made up. I thought it might be
something that could be added to Rack::LinkedData to add a content type to
the negotiations.
Right, that makes sense. I'll see what I can do; I'll probably create
something similar to the content negotiation DSL in Rails (good ol'
responds_to), which should look and work quite similar to what you
want.
---------- Forwarded message ----------
From: Arto Bendiken Date: Wed, May 26, 2010 at 3:18 PM Subject: Re: Rack::LinkedData To: Nicholas J Humfrey
On Wed, May 26, 2010 at 2:04 PM, Nicholas J Humfrey wrote:
That ("application/rdf+xml;q=0.5,text/html") should work, actually - your application always has first shot at what kind of a response it wants to generate.
But I suppose the problem with the present setup is not so much knowing when to generate an HTML response, but knowing when to generate an RDF one without having to parse the Accept header oneself. So yeah, we need something more for this.
Right, that makes sense. I'll see what I can do; I'll probably create something similar to the content negotiation DSL in Rails (good ol' responds_to), which should look and work quite similar to what you want.