Developing WebClipping Applications for thePalm VII Jan Schaumann Abstract Abstract: A brief walkthrough of the steps necessary to set up a simple WebClipping Application on your Palm Pilot VII, compiled from various sources. 1 Introduction A web clipping application (WCA) is a kind of mini web site that resides on he Palm VII organizer. Technically, it's a special kind of record database. A typical application contains an HTML form or list of hyperlinks that request additional information either locally-on he handheld computer-or remotely-on the Internet. A web clipping application can also be self-contained, a sort of HTML booklet with internal cross-references, formatting, and graphics. You can also launch other Palm OS applcations from a web clipping application. The general information flow for a WCA is a s follows: * the user enters data into the local form * the form is submitted to a palm.net proxy server, which decodes the informationinto a "real" http-request and send this request to the appropriate server * the server returns a document (after processing the submitted information) to thepalm.net proxy server * the palm.net proxy server translates the HTML into web clipping code and sendsit back to the Palm device * the Palm device displays the information In this document we will walk through the development of a simple example WCA1.2 Developing a WCA([footnote] using as many buzzwords as possible) 2 Developing a WCA 2.1 General Web Clipping Applications are very easy to develop, but can provide a large variety of services and features. The information flow in a typical WCA is divided into two types: the frontend residing on the local device and the backend on a server. While a WCA can theoretically consist of static documents only residing on the Palm itself, or of static content delivered to it from the server, the useful features of web clipping actually make a dynamic information flow just logica. Our sample WCA will consist of a static HTML-document on the frontend communicating with a CGI on the server side to generate dynamic content. 2.2 Specifications As with all development it is good practice to sit down and write a "specs-file" first. By writing down which steps are involved in the development process it becomes easier to precisely specify the needs of the project, how to split the various tasks between developers etc. Your project will be much more organized this way. 2.3 The Frontend 2.3.1 Writing the Frontend Writing the frontend for your WCA is almost trivial, provided you know some basic HTML. You will need to keep a few things in mind, though. Since the web clipping engine is equivalent to the one used in Netscape 2.0, only limited HTML can be used. This subset of HTML together with the few, palm-specific additional tags possible are listed in the "Web Clipping Guide". In short, WCA supports simple tables, images, fonts etc, but does not support frames, nested tabls, javascript or java and the like. The restristions on the application design for a normal application([footnote] See "Software Development for the Palm OS" ) apply here, too. 2.3.2 Converting the HTML into a .pqa The format used for a WCA when installing onto a Palm device is ".pqa". For information on the format of the compiled .pqa file see http://www.palm.com/devzone/webclipping/. In order to comvert your HTML-pages and the images into a user-installable Palm database, you need the Web Clipping Application Builder, available for free from http://www.palmos.com/dev/tech/webclipping/. Unfortunately this application is currently only available for Windows and Macintosh. A Unix-ersion does exist, but it still an alphaversion (if you are interested, please see http://www.linuxlabs.com/software/linpqa.html). This simple application compiles the HTML and the images into the .pqa format, which you then can install on your Palm device. 2.4 The Backend The serverside backend can range from very easy to highly complex, depending on the specifications of your project. You most likely will want the WCA to connect to a database through, say, a CGI in order to generate a dynamic document to return. Keep in mind that the returned document must also comply to the specifications of the HTML-subset supported by the WCA engine. Just as the frontend, the returned documents should also be designed with the limitations of the Palm device in mind. 2.5 Testing Once the .pqa has been generated and the backend has been made functional you should install and test your WCA on the Palm OS Emulator([footnote] see the POSE-HOWTO for detailed information on how to use the Palm Os Emulator) to make sure everything works according to the specifications. You then can install the WCA on your Palm VII to test it on the actual device. If you want to distribute your WCA, you can then upload it to the palm.net WCA repository, where you application will be reviewed and rated, and possibly be posted for all palm-users to download. 3 A Weather WCA - An Example 3.1 Specifications 3.1.1 General Purpose A simple WCA for the palm pilot to display the current weather conditions, retrieving the data from a certain weather station via wireless internet connection. Every weather station in the US has a unique four character code to be identified with, which places a text-file with the information onto a government owned public ftp-server. 3.1.2 Application design The frontend will be a simple HTML-form, where the user can enter the 4-character identifier for the weather station (s)he wishes to retrieve the information from. This code can be retrieved from http://www.nws.noaa.gov/oso/siteloc.shtml, but in the future we will want to facilitate this and have the user simply enter the Zip-Code. This feature will not be implemented in this version of the WCA. The page will have a "Submit" and a "Clear" button, possibly a little logo in the upperleft corner. When the user taps the "Submit" button the information is sent (through the palm.net proxy) to the server. On the serverside we process the submitted information through a perl-script. This script requests the document corresponding to the correct weather station from the public ftp-server. If such a document exists, the information will be processed and the script creates an HTML-document to display the information. If the requested document does not exist, the user has entered an invalid code, and the scipt returns an error message. 3.2 The Frontend 3.2.1 The HTML <html> <head> <title>dnb.com</title> <meta name="palmcomputingplatform" content="true"> <meta name="palmlauncherrevision" content="0.1"> <meta name="historylisttext" content="weather &date &time"> </head> <body> <form method="post" action="http://www.netmeister.org/cgibin/palm/weather.pl"> Please enter the 4-character code for your weather station. <table> <tr> <td><br><input type="text" name="station" size="4" maxlength="4"> <input type="submit" value="Submit"> <input type="reset" value="Clear"> </td> </tr> </table> </form> </body> </html> This code is for demonstration purposes only and will not neccessarily look pretty. One could easily create a better looking layout. 3.2.2 The .pqa After generating the .pqa with the Web Clipping Application Builder, you can install the WCA on your Palm OS Emulator. 3.3 The Backend #!/usr/bin/perl # # print the html for the response to standard out use LWP::Simple; print "Content-type: text/html\n\n"; print "\n\n<HTML>\n<HEAD>\n"; print "<meta http-equiv=\"Content-Type\"content=\"text\/htmlcharset=iso-8859-1\">\n"; print "<meta name=\"palmcomputingplatform\"content=\"true\">\n"; print "<TITLE>Weather</TITLE>\n<\/HEAD>\n<BODY>\n"; # read the data from the command line Method = post read(STDIN,$in,$ENV{CONTENT_LENGTH}); @input = split('&',$in); %field = (); foreach $tmp (@input){ ($key,$value) = split('=',$tmp); $value =~ s/\+//g; $value =~ s/%(..)/pack("c",hex($1))/ge; $field{$key} = $value; } $Station = uc ($field{'station'}); $Station = $Station . ".TXT"; $URL="ftp://weather.noaa.gov/data/observations/metar/decoded/$Station"; $weather = get($URL); if ($weather) { @weatherCond = split /\n/,$weather; $i=0; while ( $_ = $weatherCond[$i]) { if ($i==0) { @location = split /\(/; } elsif ($i==1) { @time = split /\//; } elsif ($i==2) { @wind = split /:/; } elsif ($i==3) { @vis = split /:/; } elsif ($i==4) { @sky = split /:/; } elsif ($i==5) { @temp = split /:/; } elsif ($i==6) { @dew = split /:/; } elsif ($i==7) { @hum = split /:/; } elsif ($i==8) { s/ \(altimeter\)//; @press = split /:/; } $i++; } print "<center>$location[0]<br>$time[0]<\/center>\n"; print "<table><tr><td>$wind[0]: <\/td><td>$wind[1]<\/td><\/tr>\n"; print "<tr><td>$vis[0]: <\/td><td>$vis[1]<\/td><\/tr>\n"; print "<tr><td>$sky[0]: <\/td><td>$sky[1]<\/td><\/tr>\n"; if ($dew[0]) { print "<tr><td>$temp[0]: <\/td><td>$temp[1]<\/td><\/tr>\n"; } print "<tr><td>$dew[0]: <\/td><td>$vdew[1]<\/td><\/tr>\n"; print "<tr><td>$hum[0]: <\/td><td>$hum[1]<\/td><\/tr>\n"; print "<tr><td>$press[0]: <\/td><td>$press[1]<\/td><\/tr>\n"; print "<\/table>"; } else { print "Sorry, not a valid code!\n"; } # we're done print "<\/body><\/html>"; 3.4 The returned document 4 References The information contained in this document was compiled from the following sources: * "Software Development for the Palm OS" - available at http://www.netmeister.org/palm/ * "The Palm OS Emulator Howto" - available at http://www.netmeister.org/palm/ * The "Web Clipping Guide" - available at http://www.palmos.com/dev/tech/webclipping/