ruby co-depiction client / progress

Dan Brickley danbri at w...
Thu Jun 27 04:14:20 UTC 2002

Now the Ruby code is harvesting RDFWeb/FOAF data again, it's worth doing
things like this, as there's data to play with. The script below shows
a rough cut of Libby's Java 'who is depicted with ...' page,
...recoded in Ruby.

There's not much by way of error trapping, good HTML or UI design, but
basics should be obvious. The code below talks direct to the PostgreSQL
database using the query rewriter. One could put SOAP, XML, HTTP in the
middle, trading a little database-independence for some performance hit.

Idea is the Ruby code comes out of the box ready to index RDFWeb into a
store that can usefully answer queries such as those below. Since it is
now Debian-packaged (er, packageable) this potentially means 100s of
indexing nodes, each offering SOAP query services and/or HTML generate by
scripts such as this.

Which makes the next interesting problem that of characterising the rules
the harvester uses to traverse the Web, and making sure our RDF files
contain suitable hints and fwd pointers to help it...


---------- Forwarded message ----------
Date: Thu, 27 Jun 2002 04:25:32 GMT

#!/usr/bin/env ruby
# RDFWeb CoDepiction index generator
# Look up photos do-depicting some person, via their mailbox.
# Generate HTML.
# Assumes data has been drafragmented / smushed.
# danbri $Id$

require 'squish'
require 'dbi'

mbox='mailto:libby.miller at b...'

SELECT ?thumb, ?name, ?dd, ?mbox, ?uri,
WHERE (foaf::depiction ?x ?uri)
(foaf::depiction ?z ?uri)
(foaf::mbox ?x #{mbox})
(foaf::mbox ?z ?mbox)
(foaf::name ?z ?name)
(foaf::thumbnail ?uri ?thumb)
(dc::description ?uri ?dd)
foaf for
dc for

DBI_DRIVER = 'DBI:Pg:test1'
DBI_USER = 'danbri'

q = query

DBI.connect( DBI_DRIVER, DBI_USER, DBI_PASS) do | dbh |
dbh.select_all( q.toSQLQuery ) do | row |
if by_img[row['uri']] == nil
by_img[row['uri']] = []

puts "<html><head><title>RDFWeb: Co-depiction directory</title</head>\n\n<body>\n"
puts "<h1>Codepictionary...</h1>\n\n"

by_img.each_value do |images|
puts "<p>" + i.dd + "<a href=\"#{i.uri}\"><img src=\"#{i.thumb}\" /></a></p>\n\n"
images.each do |who|
puts "#{} #{who.mbox} <br /> \n"
puts "\n\n"

puts "\n\n</body>\n</html>\n\n"

More information about the foaf-dev mailing list