-- Define XFN Relationship 0.1, July 2, 2006 -- Allows you to maintain your XFN relationship (see http://www.gmpg.org/xfn/) information to the feeds in your NetNewsWire. The XFN data is stored in a simply SQLite database (which thus requires you to be running Tiger to use the script). -- To use the script, install it in ~/Library/Application Support/NetNewsWire/Scripts then set the location for the SQLite database below (by changing the value of the 'databasename' variable). Then you simply select 'Define XFN Relationship' from the NetNewsWire "Scripts" menu to define your relationship with the owner of a given feed. -- (c) 2006 by Reinvented Inc. (www.reinvented.net) -- Licensed under the GNU Public License -- http://www.fsf.org/licensing/licenses/gpl.txt -- This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. -- This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. -- You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -- Check system version -- taken from 'Most Played Artists' script by Michael Henley if (system attribute "sysv") < 4160 then if button returned of (display dialog "Sorry, this script requires SQLite which is only distributed with Mac OS 10.4 Tiger and later." buttons {"Ignore", "Quit"} default button 2) is "Quit" then error number -128 --Set the name of the database where we'll save the XFN data. -- CHANGE THIS - CHANGE THIS - CHANGE THIS set databasename to "/Users/Peter/Documents/NNW-XFN.db" --Force the given filename into a POSIC filename set databasefile to databasename as POSIX file --The two global variables, to hold the URL and name of the selected feed global theURL, theName --If the database doesn't exist, then we create it tell application "Finder" if not (the file databasefile exists) then set d to space & databasename & space set s to "sqlite3" & d & quote set s to s & "create table XFN (url, rel); " set s to s & quote do shell script s end if end tell tell application "NetNewsWire" --If we have a subscription (feed) selected then... if exists selectedSubscription then set theURL to home URL of selectedSubscription set theName to display name of selectedSubscription --If the URL of the feed isn't empty if (theURL is not "") then set d to space & databasename & space set s to "sqlite3 -list" & d & quote set s to s & "select rel from XFN where URL = '" & theURL & "';" set s to s & quote set currentRel to do shell script s --Split the existing relationships by the space delimiter -- i.e. "met friend" -> {"met","friend"} set AppleScript's text item delimiters to space set currentRels to currentRel's text items set AppleScript's text item delimiters to {""} --> restore delimiters to default value --Create an array with the various XFN relationship types in it. set rels to {"Choose One:", "contact", "acquaintance", "friend", "---------", "Choose One:", "met", "---------", "Choose One or More:", "co-worker", "colleague", "---------", "Choose One:", "co-resident", "neighbour", "---------", "Choose One:", "child", "parent", "sibling", "spouse", "kin", "---------", "Choose One or More:", "muse", "crush", "date", "sweetheart"} --Create a "choose from list" box that allows multiple relations to be selected. --This is admitedly ugly and could benefit from much better UI. set theAnswer to choose from list rels default items currentRels with title "Select Your Relationship" with prompt "What is your relationship to " & theName & "?" with multiple selections allowed and empty selection allowed --If we selected something then... if (theAnswer exists) then --Make a string out of the selected relations set newRel to "" repeat with relcount from 1 to count of theAnswer set newRel to newRel & " " & item relcount of theAnswer end repeat --Delete any existing relations for this URL (this is easier than check to see if any exist already) set d to space & databasename & space set s to "sqlite3 -list" & d & quote set s to s & "DELETE from XFN where URL='" & theURL & "';" set s to s & quote do shell script s --Insert a record with the new relations set s to "sqlite3 -list" & d & quote set s to s & "insert into XFN values ('" & theURL & "','" & newRel & "');" set s to s & quote do shell script s end if end if else display dialog "You didn't select a subscription in NetNewsWire!" buttons {"OK"} default button "OK" end if end tell