|
Blogs
Sometimes one finds real hidden treasures on SDN that only a few people seem to have discovered. A perfect example is this forum thread posted by David Kang on Jan 4 th . He made SDN search widgets for the Yahoo widget engine. These are really great. Certainly for me, since I've already been (co-)developing SDN search tools for browsers, but nothing as yet for the desktop.
for the Mac users there are additional files like Info.plist for installation purposes. On top of that, the look and feel of both approaches is very similar. Things are seldom what they seem though, because if you though that you could interchange widgets between both systems, you'd be wrong. Davids SDN search widget will never work under Dashboard. My Dashboard is fantastic
Therefore I decided to create a search widget for Dashboard. I took the earlier developed Firefox/Mozilla SDN search plugin as the functionality to aim for. Here follows a step by step guide on how to proceed. Step 1: Create the core application. As said earlier, this is just a matter of creating an HTML file. This isn't rocket science in this case. All we need to do is to include the style sheet specification <style type="text/css" title="AppleStyle"> @import "SDN.css"; </style> And include the javascript that will do the actual search, but more on that in a minute. <script type='text/javascript' src='SDN.js' charset='utf-8'></script>
The only special thing is the <input type=search>. This search field is adopted in Safari 1.3 and 2.0 and has some useful features like auto save, history, etc. More info can be found at this web log. <input type='search' id='search-input' onkeydown='keydown(event, this);' results='0'></input>
The completed code looks like this. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> <head> <meta http-equiv="content-type" content="text/html; charset=utf-8"> <style type="text/css" title="AppleStyle"> @import "SDN.css"; </style> <script type='text/javascript' src='SDN.js' charset='utf-8'></script> </head> <body> <img src='Default.png'></img> <input type='search' id='search-input' onkeydown='keydown(event, this);' results='0'></input> </body> </html> Step 2: Create the style sheet Again, nothing spectacular. It all depends a bit on one's taste, but I've chosen to stick to a stylesheet that can be found in a lot of widgets. body {
margin: 0; } #search-input {
position: absolute; font: 11px "Lucida Grande"; top:11px; left:111px; width:211px; height:22px; -apple-dashboard-region: dashboard-region(control rectangle); }
Step 3: Create the javascript file Here comes the actual action on what needs to be done when the search string is submitted. I've taken the same action as within the earlier mentioned Firofox/Mozilla search plugin. window.onfocus = function () {
document.getElementById('search-input').focus();
} function search (input) {
var value = input.value; if (value.length > 0) {
value = encodeURIComponent (value); var url = "https://www.sdn.sap.com/irj/sdn/search?QueryString=" + value + "&SearchPluginName=sdn_all&SelectedCustomProps=resourcetype(value=s*)&sourceid=Apple-Dashboard&ie=UTF-8&oe=UTF-8&query="+ value; if (window.widget) widget.openURL (url); } } function keydown (event, input) {
if (event.keyCode == 13) // enter or return {
search (input); } } Step 4: Create widget property list This is an Apple type thing, so I won't pay too much attention to it in this web log. The widget property list will provide Dashboard with all the necessary information in order to install/operate the widget properly. All this info is kept via XML in the Info.plist and contains at least the following items:
Further info can be found in the Dashboard Reference. For our example, the property list looks like this. <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> <plist version="1.0"> <dict> <key>BuildVersion</key> <string>3</string> <key>CFBundleShortVersionString</key> <string>1.0</string> <key>CFBundleVersion</key> <string>1.0</string> <key>ProjectName</key> <string>GoogleWidget</string> <key>SourceVersion</key> <string>10300</string> </dict> </plist>
and in the infoPList.strings file : CFBundleDisplayName = "SDN";
Step 5: create the dashboard graphics.
Two points of attention: they need to be in PNG format and the leading letter must be a capital letter. I started to create these files, but when my colleague Gerrit a.k.a Sh3Ll4C - you know the cartoonist that has been producing a lot of hot air since 1999 and who designed the cartoon in my Digging in the dirt web log saw me bungle he immediately helped me out and the result looks great:
The icon in the dashboard The widget itself The result screen, yes SDN even works under Safari All this can be downloaded here. You only need to extract it and double click on the icon. It'll install itself under the Library/Widget map (it'll be created if the map doesn't exist yet) of your user. If everything work out well you will see the widget in your Dashboard. If you want to experiment yourself with making widgets under Dashboard, you'll find all info/software at the Apple Developer Connection a.k.a. ADC (I always think of the German automobile club when I go to this site). Conclusion Eddy De Clercq is trying to discover the secrets of Business Intelligence at the Katholieke Universiteit Leuven (Belgium).
| |||||||||||||||||||||||