[foaf-dev] Wiki RDF

Dan Brickley danbri at danbri.org
Thu Aug 21 19:56:19 BST 2008


+cc: Evan, re OpenID plugin aspect

Sergey Chernyshev wrote:
> Dan,
> 
> Did you write MW extension for it or just query underlying MySQL tables? 
> Are there any tools to consume this data in a useful way?
> 
> I wonder if you're going to install Semantic MediaWiki & "Semantic 
> Bundle" there? This will allow to derive a lot of triples from it and do 
> some querying of it on the fly.

I'd love to get SMW in there. I haven't tried it properly since some 
really early version. For now this OpenID Group export is a quick 
proof-of-concept commandline hack:

echo "select uoi_openid from user_openid" | mysql (connect details here 
| ruby ./openids2group.rb foafwiki>_users.rdf

where the Ruby is just the following (see below). It couldn't get much 
uglier :)

Anyone care to hack this directly into MediaWiki PHP? I don't know if 
the SQL needs updating for later versions of the OpenID plugin.

cheers,

Dan

#!/usr/bin/ruby
gid = ARGV.shift

top = '<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" 
xmlns="h
ttp://xmlns.com/foaf/0.1/">'

guts = "<Group rdf:about='#" + gid + "'>\n"

STDIN.each do |line|
   line.chomp!
   next unless line =~ /\w/
   next if line =~ /uoi_openid/ # first is tablename
#  puts "Got ID: #{line}"
   guts += "<member><Agent><openid rdf:resource='" + line + 
"'/></Agent></member>
\n"

end

guts += "</Group>\n\n"

tail = "</rdf:RDF>\n\n"

print top + guts + tail



More information about the foaf-dev mailing list