I’m a complete DT Pro newbie; I purchased my copy during the Black Friday sale. (Thanks, DEVONtechnologies!)
I noticed that the Delicious import script captures your delicious bookmarks into DT bookmarks. However, the built in script only pulls the URL and the tags - it does not capture the note (if any) on each Delicious bookmark.
Looking at the XML the the script uses, it looks pretty easy to capture that note - it’s on an XML attribute called ‘extended’. However, what I’m confused by is where I would put that note data in my DT record. There seem to be several possible places - but putting the note, for example, in the ‘data’ properties, doesn’t seem to give me a way in the UI to see that note. So in part this might be a UI question.
What I really want, but I’m not sure if I can get, is a way of displaying the record that would show me the bookmark title, the descriptive note, and then finally a browser pane showing me the way page.
Is there a best practice for this kind of thing?
This revised script should import the notes:
-- If the properties pUser and pPassword are undefined and the keychain doesn't contain a key for del.icio.us,
-- then a dialog pops up asking for these properties
property pUser : ""
property pPassword : ""
tell application id "com.devon-technologies.thinkpro2"
try
if (pUser is "") or (pPassword is "") then
try
tell application "Keychain Scripting"
set theKey to first Internet key of current keychain whose name is "del.icio.us"
set pUser to account of theKey
set pPassword to password of theKey
end tell
end try
repeat while (pUser is "") or (pPassword is "")
set theResult to display authentication dialog "del.icio.us" & return & "https://api.del.icio.us/v1/posts/all"
set pUser to user of theResult
set pPassword to |password| of theResult
end repeat
end if
set theXML to download markup from "https://api.del.icio.us/v1/posts/all" user pUser password pPassword encoding "UTF-8"
if theXML is missing value or theXML is "" then
error "Download failed."
else if theXML contains "503 Service Temporarily Unavailable" then
error "503 Service Temporarily Unavailable"
else
try
tell application "System Events"
set x to make new XML data with data theXML
set theElements to XML elements of (XML element 1 of x) -- posts
tell application id "com.devon-technologies.thinkpro2"
set theGroup to get record at "/del.icio.us"
if theGroup is missing value or type of theGroup is not group then
set theGroup to create location "/del.icio.us"
set thumbnail of theGroup to "http://l.yimg.com/hr/img/delicious.64px.gif"
end if
end tell
repeat with theElement in theElements
set theUrl to (value of XML attribute named "href" of theElement) as string
set theName to (value of XML attribute named "description" of theElement) as string
set theTag to (value of XML attribute named "tag" of theElement) as string
set theComment to (value of XML attribute named "extended" of theElement) as string
set {od, AppleScript's text item delimiters} to {AppleScript's text item delimiters, " "}
try
set theTags to (text items of theTag)
on error
set theTags to {}
end try
set AppleScript's text item delimiters to od
tell application id "com.devon-technologies.thinkpro2"
if not (exists record with URL theUrl) then create record with {name:theName, type:bookmark, URL:theUrl, tags:theTags, comment:theComment} in theGroup
end tell
end repeat
end tell
on error msg
set pUser to ""
set pPassword to ""
error "Invalid user/password."
end try
end if
on error error_message number error_number
if the error_number is not -128 then display alert "DEVONthink Pro" message error_message as warning
end try
end tell