Thank you for the suggestion. Extending the plug-in architecture to be able to handle other types of programming languages is a good idea. But the Cocoa interface is so flexible that it allows for a Cocoa style plug-in to bridge the gap. I have created one for Applescript since this is your preferred language. The
source code for the plug-in is available; However, you are interested in the built plug-in that can be [url=bookpedia://
www.bruji.com/download?plugins/applescriptplugin.zip]installed here[/url]. Once installed navigate to your Bookpedia data folder ~/Library/Application Support/Bookpedia/Plug-ins/SampleScript.plugin this is the plug-in that was installed. Control click it and use "show package contents" command to continue into the bundle to SampleScript.plugin/Contents/Resources/Search.scpt. Search.scpt is the AppleScript that it uses to search for the book information. Since it has already has been compiled here is the source of that script so that you can modify it and save it, replacing the built in sample Search.scpt.
Code: Select all
-- script is only loaded on program launch, program needs to be relaunched after making changes.
on search_for(search_string)
return {"A Book", "A DVD"}
end search_for
-- Create an array of two object arrays (key and value pair).
-- imageLocation is the key to a URL for the image
-- or use Image as key to set the image data directly
on details_for(recordNumber)
if (recordNumber is 0) then
set image to {"imageLocation", "http://www.bruji.com/bookpedia/images/mainScreenshot.png"}
set title to {"title", "A Great Book"}
set author to {"author", "Really Cool Guy"}
else
set image to {"imageLocation", "http://www.bruji.com/dvdpedia/images/mainScreenshot.png"}
set title to {"title", "Excellent Software"}
set author to {"author", "Okay Guy"}
end if
return {image, title, author}
end details_for
You will need to add a global variable to the script to set in search_for so that you can know what ISBN to look for in details_for. In your case with the ISBN there will only be one result, so you can load the details already in search_for and just return that global variable in details_for. In the regular cases you would keep a global variable with a list of the result titles and URLs to download further details for each if requested.
The keys to build the return array are mostly what you would think they are, the source code contains a constant.h file that lists them all, but they can also be found
here.
The script is also called "Script" in the search site pop up, to change the name to something more descriptive change the PluginSearchName attribute in the info.plist inside the plug-in.