:- ensure_loaded(common).
cvs_id('$Id: person.pl,v 1.1 2005/01/12 21:50:35 sandro Exp $').
/*

  Skeletal foaf:Person view -- might some day grow into a social-network
  browser, like Orkut or Friendster, based on FOAF data.

  Not a bad introduction to writing tabs & views.

  Try, for instance:
     http://rdfweb.org/people/danbri/rdfweb/danbri-foaf.rdf
  then click on "Dan Brickley" -- you can't go there in one
  step, because he uses a bNode (not a URI) for himself.

  Most of this code is copied from short_views.pl, which knows a little
  about foaf, so it can come up with reasonable labels for people.
  
*/



tab(1000, Q, Focus, 'Person', +person_view(Q, Focus)) :-
	once(rdfq(Q, Focus, rdf:type, foaf:'Person')).

person_view(Q, Focus, H) :-
	H=[h2('Oh, look, a person!'),
	   p('Name: ', +person_name(Q, Focus))
	  ].

person_name(Q, Focus, H) :-
	rdfq(Q, Focus, foaf:name, literal(N)),
	delang(N, H).
person_name(Q, Focus, H) :-
	( rdfq(Q, Focus, foaf:givenname, literal(N1))
	; rdfq(Q, Focus, foaf:firstName, literal(N1))
	),
	( rdfq(Q, Focus, foaf:family_name, literal(N2))
	; rdfq(Q, Focus, foaf:surname, literal(N2))
	),
	delang(N1, N1L),
	delang(N2, N2L),
	H = [N1L, ' ', N2L].
person_name(Q, Focus, 'name unknown').

