| Fraser Speirs ( @ 2005-06-03 08:28:00 |
Del.icio.us Script
So I got my script for posting to Del.icio.us going. Instead of a bookmarklet, I wrote an Applescript that I can fire from Quicksilver. Thanks to Buzz for the pointers.
So we use Applescript to pull out the URL, then Javascript invoked from Applescript to get the document title. Then we compose the URL and call out to Curl to do the transport and then, of course, we talk to Growl for reporting the success or otherwise of the submission. Love it.
So I got my script for posting to Del.icio.us going. Instead of a bookmarklet, I wrote an Applescript that I can fire from Quicksilver. Thanks to Buzz for the pointers.
So we use Applescript to pull out the URL, then Javascript invoked from Applescript to get the document title. Then we compose the URL and call out to Curl to do the transport and then, of course, we talk to Growl for reporting the success or otherwise of the submission. Love it.
tell application "Safari"
set username to "xxxxx"
set mypasssword to "xxxxx"
set theURL to URL of front document
set theTitle to do JavaScript "escape(document.title)" in front document
set theDelURL to "http://" & username & ":" & mypasssword & "@del.icio.us/api/posts/add?url=" ¬
& theURL & "&description=" & theTitle & "&tags=@review"
set theresult to do shell script "/usr/bin/curl -s \"" & theDelURL & "\""
tell application "GrowlHelperApp"
-- Perform some Growl housekeeping tasks to register ourselves.
set the allNotificationsList to {"Submit Result"}
set the enabledNotificationsList to {"Submit Result"}
register as application ¬
"@Review Script" all notifications allNotificationsList ¬
default notifications enabledNotificationsList
if theresult contains "done" then
-- Talk to Growl
notify with name ¬
"Submit Result" title theTitle¬
description "Successfully Submitted" application name "@Review Script"
else
notify with name ¬
"Submit Result" title theTitle ¬
description "Submission Failed!" application name "@Review Script"
end if
end tell
end tell