(*
Create Yojimbo Web Archive From NetNewsWire
John Gruber, 29 May 2007
Based heavily on this script by Fraser Speirs:
http://www.speirs.org/wiki/Scripts#Add_selected_NetNewsWire_headlines_to_Yojimbo
Usage: When invoked, a new Yojimbo bookmark will be created based on
the currently selected headline in NetNewsWire. The script prompts
for tags, which must be separated by ", " — that is, comma-space.
*)
tell application "GrowlHelperApp"
set the allNotificationsList to {"Success Notification", "Failure Notification"}
set the enabledNotificationsList to {"Success Notification", "Failure Notification"}
register as application ¬
"NetNewsWire to Yojimbo Script" all notifications allNotificationsList ¬
default notifications enabledNotificationsList ¬
icon of application "NetNewsWire"
end tell
tell application "NetNewsWire"
try
if exists selectedHeadline then
set h_URL to URL of selectedHeadline
set newItemTitle to title of selectedHeadline
-- prompt for tags
set _tags to {}
try
display dialog "Tags:" default answer ""
set _answer to text returned of result
if _answer is not "" then
set AppleScript's text item delimiters to ", "
set _tags to text items of _answer
end if
end try
tell application "Yojimbo"
set _new_item to (make new web archive item with contents h_URL)
add tags _tags to _new_item
(*Uncomment following line to make new item as flagged:*)
--set _new_item's flagged to true
end tell
tell application "GrowlHelperApp"
notify with name ¬
"Success Notification" title ¬
"Import Success" description "Successfully imported \"" & newItemTitle & ¬
"\" to Yojimbo" application name "NetNewsWire to Yojimbo Script"
end tell
else if (index of selected tab is not 0) then
set tabnum to index of selected tab + 1
set taburls to URLs of tabs
set h_URL to (get item tabnum of taburls)
set tabtitles to titles of tabs
set newItemTitle to (get item tabnum of tabtitles)
tell application "Yojimbo"
set flagged of (make new web archive item with contents h_URL) to true
tell application "GrowlHelperApp"
notify with name ¬
"Success Notification" title ¬
"Import Success" description "Successfully imported \"" & newItemTitle & ¬
"\" to Yojimbo" application name "NetNewsWire to Yojimbo Script"
end tell
end tell
else
error "No headline is selected."
end if
on error error_message number error_number
tell application "GrowlHelperApp"
notify with name ¬
"Success Notification" title ¬
"Import Success" description "Failed to import \"" & newItemTitle & ¬
"\" to Yojimbo. Error: " & error_message application name "NetNewsWire to Yojimbo Script"
end tell
end try
end tell