= How to convert the apple address book to RDF =
These tools exist to do it:
* [http://www.holygoat.co.uk/applications/address-book-foaf/address-book-to-foaf-converter Richard Newman's] python converter. there is an [http://www.holygoat.co.uk/applications/address-book-foaf/projects/ab/ab.py older version]
* [http://people.no-distance.net/ol/software/ab-foaf/ AB-FOAF by Olivier Gutknecht] - a cocoa / python program.
* [http://search.cpan.org/~kjetilk/XML-FOAFKnows-FromvCard/ XML-FOAFKnows-FromvCard] by KjetilK. Does only foaf:knows creation
Sources: Libby Miller, [http://leobard.twoday.net/stories/778100/ This blog entry].
= Documentation by Apple =
* [http://developer.apple.com/documentation/AppleApplications/AddressBook-date.html Addressbook documentation+tutorial]
* [http://developer.apple.com/documentation/UserExperience/Reference/AddressBook-date.html Addressbook reference]
An applescript file that does a starting thing
{{{
tell application "Address Book"
set out to ""
repeat with p in people
set out to out & ""
set out to out & "" & (name of p) & ""
repeat with e in emails of p
set out to out & "mailto:" & value of e & ""
end repeat
set out to out & ""
end repeat
set out to out & ""
out
end tell
}}}
= The DataSource itself =
It should copy/paste from the RDF-File datasource: source:trunk/gnowsis/src/org/gnowsis/adapters/rdffile/RDFFileDataSource.java
----------------------
I uploaded a script I made a couple of years ago, but it's appeared as 0 bytes. So here's the script. To use it, you need to create a group called "FOAF" and add anyone you want in your knows list to that group. If you have a URL for their FOAF file, select their card in the Address Book, choose Card>Add Field>URL, change the URL title to FOAF and but the URL in the URL box.
property foaf : "FOAF"
tell application "Address Book"
set m to properties of my card
set the_file to (((path to desktop) as string) & first name of m & last name of m & ".rdf") as file specification
set rdf to "" & return
set rdf to rdf & "" & return
set rdf to rdf & "" & first name of m & " " & last name of m & "" & return
if nickname of m ≠ "" then
set rdf to rdf & "" & nickname of m & "" & return
end if
if group foaf exists then
repeat with this_person in every person of group foaf
set rdf to rdf & "" & return
set rdf to rdf & "" & first name of this_person & " " & last name of this_person & "" & return
repeat with e in emails of this_person
set rdf to rdf & "mailto:" & value of e & "" & return
end repeat
if ((count of urls of this_person) > 0) then
if label of url 1 of this_person is "FOAF" then
set rdf to rdf & "" & return
end if
end if
set rdf to rdf & "" & return
end repeat
end if
set rdf to rdf & ""
end tell
try
open for access the_file with write permission
set eof of the_file to 0
write (rdf) to the_file starting at eof
close access the_file
on error
try
close access the_file
end try
end try