<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	xmlns:georss="http://www.georss.org/georss" xmlns:gml="http://www.opengis.net/gml"
>

<channel>
	<title>LiquidFoot &#187; igoogle</title>
	<atom:link href="http://www.liquidfoot.com/tag/igoogle/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.liquidfoot.com</link>
	<description>Just another WordPress weblog</description>
	<lastBuildDate>Sat, 17 Apr 2010 16:36:10 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=abc</generator>
		<item>
		<title>Library Search Google Gadget</title>
		<link>http://www.liquidfoot.com/2009/01/15/library-search-google-gadget/</link>
		<comments>http://www.liquidfoot.com/2009/01/15/library-search-google-gadget/#comments</comments>
		<pubDate>Thu, 15 Jan 2009 16:26:18 +0000</pubDate>
		<dc:creator>Wayne</dc:creator>
				<category><![CDATA[Featured]]></category>
		<category><![CDATA[Projects]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[google]]></category>
		<category><![CDATA[igoogle]]></category>

		<guid isPermaLink="false">http://www.liquidfoot.com/?p=223</guid>
		<description><![CDATA[I’ve been going through a bunch of old stuff I’ve written as I clean up things. There will be a rash of posts where I take code I’ve written in different projects to see how things work and that are potentially useful, just no implemented in anything that I may need in the future. The first one here is some code for a Google gadget I wrote to search our online catalog a few years ago when the API was released.]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve been going through a bunch of old stuff I&#8217;ve written as I clean up things. There will be a rash of posts where I take code I&#8217;ve written in different projects to see how things work and that are potentially useful, just no implemented in anything that I may need in the future. The first one here is some code for a Google gadget I wrote to search our online catalog a few years ago when the API was released.</p>
<p>If you&#8217;re not one of the of the cool kids who uses <a href="http://www.google.com/ig">iGoogle</a>, you&#8217;ll need to set yourself up to use this code. I just looked at the <a href="http://code.google.com/apis/gadgets/docs/dev_guide.html">developer&#8217;s guide</a>, and it seems a bit more fleshed out than it was when I first took a whack at the code <img src='http://www.liquidfoot.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' />  The really cool thing about these gadgets is that they are essentailly just an XML file with some JavaScript/HTML thrown in.</p>
<p>I thought it might be a nice feature to just provide a search box for people to launch a catalog search. This is just a simple HTML form.</p>
<pre class="html">&amp;lt;form target="_parent" name="searchform" action="http://lion.wm.edu/uhtbin/cgisirsi/0/0/057/5" id="searchform"&gt;
    &amp;lt;input id="searchInput" style="width: 100%;" name="searchdata1" type="text" accesskey="f" /&gt;
    &amp;lt;input id="library" name="library" type="hidden" value="SWEM" /&gt;
    &amp;lt;input id="user_id" name="user_id" type="hidden" value="SWEPUB" /&gt;
    &amp;lt;input id="sourceid" name="sourceid" type="hidden" value="gadget" /&gt;
&amp;lt;/form&gt;</pre>
<p>This is just HTML code that you would use on any search page. Nothing fancy. Now on to creating the gadget..</p>
<p>There are two parts to the XML code for the spec. The root node (Module) has two elements, ModulePrefs and Content. The ModulePrefs element is relatively straight-forward:</p>
<pre class="xml">&amp;lt;ModulePrefs
    title="Swem Catalog Search"
    height="40"
    description="Search Swem's online catalog from iGoogle"
    author="Wayne Graham"
    author_email="dontspamme@gmail.com" screenshot=""
    author_location="Williamsburg, Virginia"
    title_url="http://swem.wm.edu"&gt;

    &amp;lt;Require feature="analytics" /&amp;gt;

&amp;lt;/ModulePrefs&amp;gt;</pre>
<p>The attributes of the ModulePrefs element (title, height, description, etc.) should be pretty self explanitory. I wanted to be able to track usage of the gadget, so I eneabled Google analytics for the widget by requiring the analytics feature. Now for the meat.</p>
<p>What I did was write a short CSS definition and some JavaScript to actually display a form in the Content element of the Module.</p>
<pre class="xml">&amp;lt;Content type="html"&amp;gt;&amp;lt;![CDATA[
&amp;lt;style&amp;gt;
    #subLibrary {
        font-family:arial, sans-serif;
        font-size:10px;
        color:#676767;
    }
    #link {
        font-family:Garamond, serif;
        font-size:32px;
        color:black;
        text-decoration:none;
    }
    #searchGoButton {
        font-weight:bold;
    }
&amp;lt;/style&amp;gt;
&amp;lt;script&amp;gt;
function displaySearchBar (prefs) {
    var lang = prefs.getString("mylang");

    if (lang == "") {
        lang = prefs.getString(".lang");
    }

    var html =
        '&amp;lt;form target="_parent" name="searchform" action="http://lion.wm.edu/uhtbin/cgisirsi/0/0/0/57/5" id="searchform"&amp;gt;' +
        '&amp;lt;table style="width:100%"&amp;gt;' +
        '&amp;lt;tr&amp;gt;' +
        '&amp;lt;td style="padding-bottom:4px"&amp;gt;' +
        '&amp;lt;a target="_parent" id="link" href="http://lion.wm.edu/uhtbin/webcat"&amp;gt;Catalog&amp;lt;/a&amp;gt;' +
        '&amp;lt;span style="vertical-align: sub;"&amp;gt;Swem&amp;lt;/span&amp;gt;' +
        '&amp;lt;/td&amp;gt;' +
        '&amp;lt;td width=100%&amp;gt;' +
        '&amp;lt;input id="searchInput" style="width:100%" name="searchdata1" type="text" accesskey="f" value="" /&amp;gt;' +
        '&amp;lt;input id="library" name="library" type="hidden" value="SWEM" /&amp;gt;' +
        '&amp;lt;input id="user_id" name="user_id" type="hidden" value="SWEPUB" /&amp;gt;' +
        '&amp;lt;input id="sourceid" name="sourceid" type="hidden" value="gadget" /&amp;gt;' +
        '&amp;lt;/td&amp;gt;' +
        '&amp;lt;td&amp;gt;' +
        '&amp;lt;input type="submit" name="go" id="searchGoButton" value="Search" /&amp;gt;' +
        '&amp;lt;/td&amp;gt;' +
        '&amp;lt;td&amp;gt;' +
        '&amp;amp;amp;nbsp;' +
        '&amp;lt;/td&amp;gt;' +
        '&amp;lt;/tr&amp;gt;' +
        '&amp;lt;/table&amp;gt;'
        '&amp;lt;form&amp;gt;';
    document.write(html);
}

displaySearchBar(new _IG_Prefs(__MODULE_ID__));
_IG_Analytics("analytics-id", "/google-gadget");
&amp;lt;/script&amp;gt;
]]&amp;gt;
&amp;lt;/Content&amp;gt;</pre>
<p>Once you&#8217;re done, you can test everything with the directions on the <a href="http://code.google.com/apis/gadgets/docs/tools.html">Developer Tools page</a>. There are even really nice resources to tell you how to <a href="http://code.google.com/apis/gadgets/docs/tools.html#Host">host this on Google Code</a>.</p>
<p>As a finished product, this is what the gadget looks like in iGoogle:</p>
<p><img class="alignnone size-medium wp-image-235" title="gadget" src="http://www.liquidfoot.com/wp-content/uploads/2009/01/gadget-300x46.png" alt="gadget" width="300" height="46" /></p>
<p>For the folks that use iGoogle as their home page, this can be valuable tool for them. Next up, I need to brush off my code for generating Sherlock/Opensearch extensions for Firefox and IE&#8230;</p>
]]></content:encoded>
			<wfw:commentRss>http://www.liquidfoot.com/2009/01/15/library-search-google-gadget/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
