foaf_user/commit
Fixed foaf:mbox handling
author | Jan Wielemaker |
---|---|
Thu Nov 18 15:30:21 2010 +0100 | |
committer | Jan Wielemaker |
Thu Nov 18 15:30:21 2010 +0100 | |
commit | 0103ab4210de6bfee94f146553b775330cef7dd3 |
tree | 12a53c659b6f1a2f36c9af0691b5a5933f2e0500 |
parent | 3de86e366510c45fc705850d2dafadf770979a7d |
Diff style: patch stat
diff --git a/applications/foaf_user_profile.pl b/applications/foaf_user_profile.pl index cd33f37..d6131d7 100644 --- a/applications/foaf_user_profile.pl +++ b/applications/foaf_user_profile.pl @@ -32,6 +32,7 @@ :- use_bundle(html_page). :- use_module(user(user_db)). :- use_module(library(semweb/rdf_db)). +:- use_module(library(semweb/rdfs)). :- use_module(library(semweb/rdf_label)). :- rdf_register_ns(foaf, 'http://xmlns.com/foaf/0.1/'). @@ -42,6 +43,11 @@ /** <module> Manage a FOAF profile */ +%% foaf_profile_form(+Request) +% +% HTTP handler that creates a form for editing the most important +% FOAF attributes of a person. + foaf_profile_form(_Request) :- ensure_logged_on(User), user_property(User, url(UserURI)), @@ -69,6 +75,10 @@ foaf_profile_form(User) --> foaf_set_defaults(User) :- user_property(User, url(UserURI)), + ( rdfs_individual_of(UserURI, foaf:'Person') + -> true + ; rdf_assert(UserURI, rdf:type, foaf:'Person') + ), ( rdf(UserURI, foaf:name, _) -> true ; user_property(User, realname(Name)), @@ -103,6 +113,10 @@ p_input(URI, P0, Options) --> * API * *******************************/ +%% update_foaf_profile(+Request) +% +% Handle update from foaf_profile_form/1. + update_foaf_profile(Request) :- http_parameters(Request, [ r(UserURI, @@ -120,6 +134,14 @@ update_foaf_profile(Request) :- update_user(_, r=_) :- !. +update_user(UserURI, P=Value) :- + rdf_equal(P, foaf:mbox), !, + rdf_retractall(UserURI, P, _), + ( sub_atom(Value, 0, _, _, 'mailto:') + -> MBOX = Value + ; atom_concat('mailto:', Value, MBOX) + ), + rdf_assert(UserURI, P, MBOX, UserURI). update_user(UserURI, P=Value) :- rdf_has(P, rdfs:isDefinedBy, foaf:''), !, rdf_retractall(UserURI, P, _), diff --git a/rdf/cpack/foaf_user.ttl b/rdf/cpack/foaf_user.ttl index a310670..4495d2e 100644 --- a/rdf/cpack/foaf_user.ttl +++ b/rdf/cpack/foaf_user.ttl @@ -8,7 +8,7 @@ cpack:packageName "foaf_user" ; dcterms:title "FOAF profiles for accounts" ; cpack:author [ foaf:name "Jan Wielemaker" ; - foaf:mbox "J.Wielemaker@cs.vu.nl" ; + foaf:mbox <mailto:j.wielemaker@cs.vu.nl> ; ] ; cpack:primaryRepository [ a cpack:GitRepository ;