<?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/"
	>

<channel>
	<title>Cowburn &#187; YQL</title>
	<atom:link href="http://cowburn.info/category/yql/feed/" rel="self" type="application/rss+xml" />
	<link>http://cowburn.info</link>
	<description>Online storage depot for Peter Cowburn</description>
	<lastBuildDate>Thu, 22 Jul 2010 17:51:41 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>Feedburner Stats with YQL</title>
		<link>http://cowburn.info/2009/07/19/feedburner-stats-with-yql/</link>
		<comments>http://cowburn.info/2009/07/19/feedburner-stats-with-yql/#comments</comments>
		<pubDate>Sun, 19 Jul 2009 23:15:17 +0000</pubDate>
		<dc:creator>Peter</dc:creator>
				<category><![CDATA[YQL]]></category>
		<category><![CDATA[data table]]></category>
		<category><![CDATA[feedburner]]></category>
		<category><![CDATA[github]]></category>
		<category><![CDATA[jquery]]></category>
		<category><![CDATA[JSON]]></category>
		<category><![CDATA[xml]]></category>

		<guid isPermaLink="false">http://cowburn.info/?p=282</guid>
		<description><![CDATA[A short while ago (read: earlier today) I got the urge to add the (tiny!) subscriber count onto my blog here: mostly so that I can see the fluctuations without having to log into the Feedburner site and click around, but also to show the lucky few of you who do visit that you&#8217;re in [...]]]></description>
			<content:encoded><![CDATA[<p>A short while ago (read: earlier today) I got the urge to add the (<em>tiny!</em>) subscriber count onto my blog here: mostly so that I can see the fluctuations without having to log into the Feedburner site and click around, but also to show the lucky few of you who do visit that you&#8217;re in esteemed company! Feedburner has a really nice little <a href="http://code.google.com/apis/feedburner/" title="Feedburner API on Google Code">API</a> which could be used directly except that I couldn&#8217;t find a <abbr title="JavaScript Object Notation">JSON</abbr> output format from it (to use via JavaScript) and, well, I wanted to keep playing with <a href="http://developer.yahoo.com/yql/" title="Yahoo! Query Language">YQL</a>. So here&#8217;s what I did.<span id="more-282"></span></p>
<p>Building on the idea of <a href="http://datatables.org/" title="YQL - Community Open Data Tables">open data tables</a>, I made a very quick table (<a href="http://github.com/salathe/yql-tables/blob/master/feedburner/feedburner.feed.xml">see it on GitHub</a>) which plugs into Feedburner&#8217;s API and allows us, with a few different options, to grab data about a specific Feedburner feed by using queries like <code>select * from feedburner.feed where uri="cowburn"</code><sup><a href="#footnote1">1</a></sup>.</p>
<h3>Querying against the table</h3>
<p>Since the table is just my own, and not part of the main collection of contributed tables, we have to tell YQL about its location before we can do any queries on it. To do that, simply use <code>use</code> pointing to the url of the <abbr title="eXtensible Markup Language">XML</abbr> file: <code>use "http://github.com/salathe/yql-tables/raw/master/feedburner/feedburner.feed.xml";</code></p>
<p>Once YQL knows about the table, we can query against it (by default the table name is constructed from the file name, <var>feedburner.feed.xml</var> means we use <samp>feedburner.feed</samp> as the table name).  The table is set up to allow three different methods of grabbing the feed data.</p>
<h4>1. Up-to-date Statistics</h4>
<p>If just the feed name is provided then only the most up-to-date information about that feed will be returned. Feedburner does not let you get stats about today, so the most recent data will always be from yesterday.  So <code>select * from feedburner.feed where uri="cowburn"</code><sup><a href="#footnote1">1</a></sup> gives one result containing yesterdays statistics; subscriber count (<var>circulation</var>), the <var>date</var>, the number of <var>hits</var> the feed got and the <a href="http://www.google.com/support/feedburner/bin/answer.py?hl=en&#038;answer=78954" title="What is reach?"><var>reach</var></a> of the feed. </p>
<h4>2. Get last <var>n</var> days of stats</h4>
<p>If you&#8217;re after more than just the latest figures, simply add a <var>days</var> clause to the <var>where</var> portion of the query: <code>… where uri="cowburn" and days="7"</code><sup><a href="#footnote2">2</a></sup></p>
<h4>3. Get a specific set of dates</h4>
<p>If the <em>last</em> <var>n</var> days is too recent for you, there&#8217;s also the option of passing along a range or series of dates with, conveniently enough, a <var>dates</var> clause. This value follows the format for <a href="http://code.google.com/apis/feedburner/awareness_api.html#dates">formatting date ranges</a> of the Feedburner API. So to select feed data between July first and seventh from 2009 you would simply add <code>… where uri="cowburn" and dates="2009-07-01,2009-07-07"</code><sup><a href="#footnote3">3</a></sup></p>
<p>Note that you cannot combine the <var>days</var> and <var>dates</var> in the same query as that would be silly.</p>
<h3>Adding Subscriber Count to the Blog</h3>
<p>To add the subscriber count to the page (next to the &#8220;subscribe&#8221; link in the header), just takes a few lines of JavaScript (I used jQuery) to pull a JSON-formatted response back from YQL. The console even automatically creates an URL for you to copy and paste in the section entitled &#8220;<q cite="http://developer.yahoo.com/yql/console/">The REST query</q>&#8220;. </p>
<p>The actual jQuery/JS code is not particularly noteworthy, all it does is prepare the URL to the YQL API, asks that URL for some JSON and then parses the response into a HTML <var>span</var> tag which is injected within the &#8220;subscribe&#8221; link of the navigation.  This blog post is more about the data table, than grabbing JSON and injecting elements into the DOM (which is super-easy with jQuery anyway). Would you like that process described a bit more thoroughly? My <a href="http://cowburn.info/2009/01/20/feed-widget-with-yql-jquery/">feed widget with YQL and jQuery</a> post shows you some actual code.</p>
<p>Well that&#8217;s all there is to say really. If you want to use the Feedburner data table then by all means feel free—it&#8217;s up there <a href="http://github.com/salathe/yql-tables/blob/master/feedburner/feedburner.feed.xml" title="feedburner.feed table on GitHub">on GitHub</a> so you can link to the file or fork and make your own changes.</p>
<h5 class="small">Footnotes</h5>
<ol class="small">
<li id="footnote1"><a href="http://developer.yahoo.com/yql/console/?q=use%20%22http%3A%2F%2Fgithub.com%2Fsalathe%2Fyql-tables%2Fraw%2Fmaster%2Ffeedburner%2Ffeedburner.feed.xml%22%3B%20select%20*%20from%20feedburner.feed%20where%20uri%3D%22cowburn%22" title="Execute this query in the YQL console">Try <code>select * from feedburner.feed where uri="cowburn"</code> in the YQL console</a></li>
<li id="footnote2"><a href="http://developer.yahoo.com/yql/console/?q=use%20%22http%3A%2F%2Fgithub.com%2Fsalathe%2Fyql-tables%2Fraw%2Fmaster%2Ffeedburner%2Ffeedburner.feed.xml%22%3B%20select%20*%20from%20feedburner.feed%20where%20uri%3D%22cowburn%22%20and%20days%3D%227%22" title="Execute this query in the YQL console">Try <code>select * from feedburner.feed where uri="cowburn" and days="7"</code> in the YQL console</a></li>
<li id="footnote3"><a href="http://developer.yahoo.com/yql/console/?q=use%20%22http%3A%2F%2Fgithub.com%2Fsalathe%2Fyql-tables%2Fraw%2Fmaster%2Ffeedburner%2Ffeedburner.feed.xml%22%3B%20select%20*%20from%20feedburner.feed%20where%20uri%3D%22cowburn%22%20and%20dates%3D%222009-07-01%2C2009-07-07%22" title="Execute this query in the YQL console">Try <code>select * from feedburner.feed where uri="cowburn" and dates="2009-07-01,2009-07-07"</code> in the YQL console</a>
</ol>
<p>P.S. I <em>promise</em> (with crossed fingers just in case) that the next blog post will not be about YQL! <img src='http://cowburn.info/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://cowburn.info/2009/07/19/feedburner-stats-with-yql/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>YQL keeps improving</title>
		<link>http://cowburn.info/2009/07/09/yql-keeps-improving/</link>
		<comments>http://cowburn.info/2009/07/09/yql-keeps-improving/#comments</comments>
		<pubDate>Thu, 09 Jul 2009 10:45:01 +0000</pubDate>
		<dc:creator>Peter</dc:creator>
				<category><![CDATA[YQL]]></category>
		<category><![CDATA[API]]></category>
		<category><![CDATA[Yahoo]]></category>

		<guid isPermaLink="false">http://cowburn.info/?p=253</guid>
		<description><![CDATA[I missed this yesterday but the YQL team have pushed out a whole heap of changes to their awesome service. A full list of changes can be found in the changelog but my favourites have to be (in no particular order): INSERT/UPDATE/DELETE, post/put/delete and a bug fix allowing remote JSON to have a top-level array. [...]]]></description>
			<content:encoded><![CDATA[<p>I missed this yesterday but the <a href="http://developer.yahoo.com/yql/" title="Yahoo! Query Language">YQL</a> team have pushed out a whole heap of changes to their awesome service.  A full list of changes can be found in <a href="http://www.yqlblog.net/blog/2009/07/08/changelog-for-build-2174/" title="Changelog for build 2174">the changelog</a> but my favourites have to be (in no particular order): INSERT/UPDATE/DELETE, post/put/delete and a bug fix allowing remote JSON to have a top-level array.<span id="more-253"></span></p>
<h3><a href="http://developer.yahoo.com/yql/guide/yql-iud-statements.html" title="I/U/D Statements">INSERT/UPDATE/DELETE</a></h3>
<p>Now we can have a full CRUD stack to play with enabling use to write to the web in addition to the reading we&#8217;ve had thus far! If you&#8217;re failing to see the juiciness, think that you can now do <code>INSERT INTO web.service (a, b, c) VALUES ("a", "b", "c")</code> where <var>web.service</var> can be pretty much any open API (<a href="http://developer.yahoo.com/yql/guide/yql-iud-examples.html#yql-iud-example-bitly" title="INSERT INTO with bit.ly and Twitter">bit.ly and twitter examples</a> are in the documentation) or, to put it plainly, pretty much any web site which accepts user input. </p>
<h3>post/put/delete methods on the <a href="http://developer.yahoo.com/yql/guide/yql-javascript-objects.html#yql-execute-yrestobject">y.rest()</a> method</h3>
<p>A <em>huge</em> thank you for this since, tied into the above on I/U/D, this enables us to push back data to the web. I <a href="http://developer.yahoo.net/forum/index.php?showtopic=1326">asked for this</a> back in May since I needed it to log into a website via a POST request, saving cookies for the main request after login.</p>
<h3>Json table now accepts top-level arrays.</h3>
<p>A small bug fix but particularly useful for me. See <a href="http://developer.yahoo.net/forum/index.php?showtopic=1706" title="YQL Forum post">my YQL forum post on this bug</a> which arose due to my trying to query a <a href="http://delicious.com/help/feeds" title="Delicious feeds documentation">delicious.com JSON feed</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://cowburn.info/2009/07/09/yql-keeps-improving/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Feed widget with YQL &amp; jQuery</title>
		<link>http://cowburn.info/2009/01/20/feed-widget-with-yql-jquery/</link>
		<comments>http://cowburn.info/2009/01/20/feed-widget-with-yql-jquery/#comments</comments>
		<pubDate>Tue, 20 Jan 2009 13:23:38 +0000</pubDate>
		<dc:creator>Peter</dc:creator>
				<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[YQL]]></category>
		<category><![CDATA[DOM]]></category>
		<category><![CDATA[jquery]]></category>
		<category><![CDATA[Salathe]]></category>
		<category><![CDATA[widget]]></category>

		<guid isPermaLink="false">http://cowburn.info/?p=99</guid>
		<description><![CDATA[Over on my other site (Salathe, just a single page site) I felt that keeping the page static was a little bit boring: it needed some life injected into it. That life, I decided, would be a summary of my recent blog posts on here. They don&#8217;t come all too often but I figured it [...]]]></description>
			<content:encoded><![CDATA[<p>Over on my other site (<a href="http://salathe.co.uk" rel="me org work">Salathe</a>, just a single page site) I felt that keeping the page static was a little bit boring: it needed some life injected into it. That life, I decided, would be a summary of my recent blog posts on here. They don&#8217;t come all too often but I figured it would be nice to syndicate them across there and maybe help people find out a bit more about me if they land on the Salathe site.<span id="more-99"></span></p>
<h3>Preamble</h3>
<p>I could&#8217;ve gone the server-side route; use PHP to grab the feed from here (well, Feedburner actually), parse it (probably with SimpleXML for simplicity) and display it with my desired HTML. And that&#8217;s a perfectly acceptable approach.  However, since the feed content is only really an added extra I didn&#8217;t want to add the feed content to the HTML page and have that overwhelm the main content on there (the introduction and contact info).  Because of that, I decided to take the client-side approach using JavaScript to grab, parse and inject our feed into the page.</p>
<p>The Feedburner feed, as is usual for feeds, comes in XML format and due to the security restrictions of browsers I can&#8217;t just go and grab that with JavaScript. Besides, I didn&#8217;t want the whole feed anyway: who wants to load in a 38kb feed just to grab some headings? (What I do end up grabbing is around 4kb.)</p>
<h3>Introducing YQL</h3>
<p>To grab only what I want, and to provide a format that I can actually get at, as well as to satisfy a niggling urge to put it into some practical use, I headed over to Yahooland and made use of the awesome tool that is <a href="http://developer.yahoo.com/yql/"><abbr title="Yahoo Query Language">YQL</abbr></a>.  YQL provides a SQL-like syntax for getting at the structured data (feeds are structured data!) around the web. It allows me to ask for specific items of data from the web, such as &#8220;give me the title and permalink for the last 10 items from Yahoo news&#8221; for example. There&#8217;s a huge range of data that YQL can get its hands on (stopping just short of the entire web) but that&#8217;s beyond the scope of this blog entry. The service also allows me to get responses in <abbr title="eXtensible Markup Language">XML</abbr> or <abbr title="JavaScript Object Notation with Padding">JSONP</abbr>, the latter being important because I <em>can</em> grab this from a remote domain name without the security restrictions coming into play.</p>
<h3>Querying for data</h3>
<p>So to get at my feed, I can simply issue the query:<br />
<a href="http://developer.yahoo.com/yql/console/?q=SELECT%20*%20FROM%20feed%20WHERE%20url%3D%27http%3A%2F%2Ffeeds2.feedburner.com%2Fcowburn%27" target="_blank" rel="nofollow">Try it yourself</a></p>

<div class="wp_syntax"><div class="code"><pre class="sql" ><span style="color: #993333; font-weight: bold;">SELECT</span> <span style="color: #66cc66;">*</span> <span style="color: #993333; font-weight: bold;">FROM</span> feed <span style="color: #993333; font-weight: bold;">WHERE</span> url<span style="color: #66cc66;">=</span><span style="color: #ff0000;">'http://feeds2.feedburner.com/cowburn'</span></pre></div></div>

<p>For my little widget, I don&#8217;t really need everything brought back by that query. Firstly, I only want the latest 5 items instead of the 10 that Feedburner provides. Secondly, I only really need the title, date, link and excerpt for each blog entry. The Feedburner feed provides extra information like the comments link, tags, and the full HTML content of the entry.  Grabbing only what I need shrinks down the size of the data coming down the pipe and results in things getting done faster.  I mentioned before that I wanted the results in JSONP format which is a simple enough task: just click the JSON radio button in the YQL console, or add &#8220;format=json&#038;callback=cbfunc&#8221; (where cbfunc is your callback function name) to the REST query URL.  So to grab only what I want, the following YQL query is used: <a href="http://developer.yahoo.com/yql/console/?q=SELECT%20title%2C%20description%2C%20link%2C%20pubDate%20FROM%20feed(0%2C5)%20WHERE%20url%3D%27http%3A%2F%2Ffeeds2.feedburner.com%2Fcowburn%27" target="_blank" rel="nofollow">Try it yourself</a></p>

<div class="wp_syntax"><div class="code"><pre class="sql" ><span style="color: #993333; font-weight: bold;">SELECT</span> title<span style="color: #66cc66;">,</span> description<span style="color: #66cc66;">,</span> link<span style="color: #66cc66;">,</span> pubDate 
<span style="color: #993333; font-weight: bold;">FROM</span> feed<span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">0</span><span style="color: #66cc66;">,</span><span style="color: #cc66cc;">5</span><span style="color: #66cc66;">&#41;</span> 
<span style="color: #993333; font-weight: bold;">WHERE</span> url<span style="color: #66cc66;">=</span><span style="color: #ff0000;">'http://feeds2.feedburner.com/cowburn'</span></pre></div></div>

<p>Aside: the <code>(0,5)</code> limits YQL to the first 5 items in the Feedburner feed.</p>
<p>Right, now we have the data that we want and can get it in JSONP format. How do we go about doing that exactly? JavaScript time!</p>
<h3>Retrieving the JSONP with jQuery</h3>
<p>I really like using jQuery for adding in extra goodness to sites and I was already using it for a little piece of DOM manipulation on the page (interesting but not to be covered in this post).  Plus, jQuery makes grabbing JSONP content very, very simple indeed using its <code>jQuery.getJSON</code> (<a href="http://docs.jquery.com/Ajax/jQuery.getJSON">docs</a>) function.  Basically we provide that function with an URL to the JSON document and a callback function to execute once jQuery has grabbed it. See the <a href="http://docs.jquery.com/Ajax/jQuery.getJSON">docs</a> for examples.</p>
<h3>Creating a widget</h3>
<p>Generally, there&#8217;s a logical structure to creating a widget like this one.  Steps involve grabbing the required data, parsing it, building the HTML and attaching it to the page.  Since this would take an inordinately long time to explain step by step (perhaps some other intrepid blogger has already done it) I&#8217;ll just show you with code.  Below is the JavaScript—in jQuery plugin form though that isn&#8217;t particularly necessary or important (just means it&#8217;s all wrapped up neatly and only concerned with itself). There are a number of variables to hold HTML, the YQL URL and a number of functions which parse the JSON object into HTML form and a little bit of effects to fade in the HTML block when it&#8217;s all ready. There&#8217;s also a function to parse the dates from &#8220;Mon, 05 Jan 2009 16:28:34 +0000&#8243; into &#8220;5 Jan&#8221; form.</p>
<p>Put simply, the widget code just says, &#8220;when the page is loaded, ask YQL for the filtered feed, parse the response items into a HTML list and inject it into my page just above the footer.&#8221;</p>
<h3>The widget code</h3>

<div class="wp_syntax"><div class="code"><pre class="javascript" ><span style="color: #006600; font-style: italic;">// Grab food!</span>
<span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>$<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
	jQuery<span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
&nbsp;
		<span style="color: #003366; font-weight: bold;">var</span> wrapper <span style="color: #339933;">=</span> $<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'&lt;div id=&quot;widget_blog&quot;&gt;'</span>
		            <span style="color: #339933;">+</span> <span style="color: #3366CC;">'&lt;h4&gt;From the &lt;a href=&quot;http://cowburn.info&quot; rel=&quot;me&quot;&gt;blog&lt;/a&gt;:&lt;/h4&gt;'</span>
		            <span style="color: #339933;">+</span> <span style="color: #3366CC;">'&lt;ul&gt;&lt;/ul&gt;'</span>
		            <span style="color: #339933;">+</span> <span style="color: #3366CC;">'&lt;/div&gt;'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #003366; font-weight: bold;">var</span> list    <span style="color: #339933;">=</span> wrapper.<span style="color: #660066;">children</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'ul:first'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #003366; font-weight: bold;">var</span> style   <span style="color: #339933;">=</span> $<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'&lt;style type=&quot;text/css&quot;&gt;@import url(assets/feed.css);&lt;/style&gt;'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #003366; font-weight: bold;">var</span> service <span style="color: #339933;">=</span> <span style="color: #3366CC;">&quot;http://query.yahooapis.com/v1/public/yql?q=select%20title%2C&quot;</span>
		            <span style="color: #339933;">+</span> <span style="color: #3366CC;">&quot;description%2Clink%2CpubDate%20from%20feed(0%2C5)%20where%20url%3D'&quot;</span>
		            <span style="color: #339933;">+</span> <span style="color: #3366CC;">&quot;http%3A%2F%2Ffeeds2.feedburner.com%2Fcowburn'&amp;format=json&amp;callback=?&quot;</span><span style="color: #339933;">;</span>
&nbsp;
		<span style="color: #003366; font-weight: bold;">var</span> callback <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>data<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
			<span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span> <span style="color: #339933;">!</span> <span style="color: #009900;">&#40;</span>data <span style="color: #339933;">&amp;&amp;</span> data.<span style="color: #660066;">query</span> <span style="color: #339933;">&amp;&amp;</span> data.<span style="color: #660066;">query</span>.<span style="color: #660066;">results</span> <span style="color: #339933;">&amp;&amp;</span> <span style="color: #009900;">&#40;</span>items <span style="color: #339933;">=</span> data.<span style="color: #660066;">query</span>.<span style="color: #660066;">results</span>.<span style="color: #000066; font-weight: bold;">item</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
				<span style="color: #006600; font-style: italic;">// Unexpected response from YQL service</span>
				<span style="color: #000066; font-weight: bold;">return</span><span style="color: #339933;">;</span>
			<span style="color: #009900;">&#125;</span>
&nbsp;
			<span style="color: #006600; font-style: italic;">// Inject HTML before the footer</span>
			$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'.footer:first'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">before</span><span style="color: #009900;">&#40;</span>wrapper<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			wrapper.<span style="color: #660066;">before</span><span style="color: #009900;">&#40;</span>style<span style="color: #009900;">&#41;</span>.<span style="color: #660066;">hide</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			$.<span style="color: #660066;">each</span><span style="color: #009900;">&#40;</span>items<span style="color: #339933;">,</span> display_item<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			wrapper.<span style="color: #660066;">fadeIn</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;slow&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>	
		<span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span>
&nbsp;
		<span style="color: #003366; font-weight: bold;">var</span> parse_date <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>str<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
			<span style="color: #003366; font-weight: bold;">var</span> d <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">new</span> Date<span style="color: #009900;">&#40;</span>str<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			<span style="color: #003366; font-weight: bold;">var</span> m <span style="color: #339933;">=</span> <span style="color: #009900;">&#91;</span><span style="color: #3366CC;">'Jan'</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">'Feb'</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">'Mar'</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">'Apr'</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">'May'</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">'June'</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">'July'</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">'Aug'</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">'Sept'</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">'Oct'</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">'Nov'</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">'Dec'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
			<span style="color: #000066; font-weight: bold;">return</span> d.<span style="color: #660066;">getUTCDate</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">+</span> <span style="color: #3366CC;">' '</span> <span style="color: #339933;">+</span> m<span style="color: #009900;">&#91;</span>d.<span style="color: #660066;">getUTCMonth</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span>
&nbsp;
		<span style="color: #003366; font-weight: bold;">var</span> display_item <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>index<span style="color: #339933;">,</span> <span style="color: #000066; font-weight: bold;">item</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
			<span style="color: #003366; font-weight: bold;">var</span> tpl <span style="color: #339933;">=</span> <span style="color: #3366CC;">'&lt;li&gt;&lt;span&gt;%date: &lt;/span&gt;&lt;a href=&quot;%link&quot; title=&quot;%extract&quot;&gt;%title&lt;/a&gt;&lt;/li&gt;'</span><span style="color: #339933;">;</span>
			<span style="color: #003366; font-weight: bold;">var</span> html <span style="color: #339933;">=</span> tpl.<span style="color: #660066;">replace</span><span style="color: #009900;">&#40;</span><span style="color: #009966; font-style: italic;">/%link/g</span><span style="color: #339933;">,</span> <span style="color: #000066; font-weight: bold;">item</span>.<span style="color: #660066;">link</span><span style="color: #009900;">&#41;</span>
			              .<span style="color: #660066;">replace</span><span style="color: #009900;">&#40;</span><span style="color: #009966; font-style: italic;">/%extract/g</span><span style="color: #339933;">,</span> <span style="color: #000066; font-weight: bold;">item</span>.<span style="color: #660066;">description</span><span style="color: #009900;">&#41;</span>
			              .<span style="color: #660066;">replace</span><span style="color: #009900;">&#40;</span><span style="color: #009966; font-style: italic;">/%title/g</span><span style="color: #339933;">,</span> <span style="color: #000066; font-weight: bold;">item</span>.<span style="color: #660066;">title</span><span style="color: #009900;">&#41;</span>
			              .<span style="color: #660066;">replace</span><span style="color: #009900;">&#40;</span><span style="color: #009966; font-style: italic;">/%date/g</span><span style="color: #339933;">,</span> parse_date<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">item</span>.<span style="color: #660066;">pubDate</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			list.<span style="color: #660066;">append</span><span style="color: #009900;">&#40;</span>html<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span>
&nbsp;
		<span style="color: #006600; font-style: italic;">// Actually grab the feed now</span>
		$.<span style="color: #660066;">getJSON</span><span style="color: #009900;">&#40;</span>service<span style="color: #339933;">,</span> callback<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#40;</span>jQuery<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>As well as the HTML to display the feed items, the widget also adds a CSS stylesheet to add a little bit of formatting: <a href="http://cowburn.info/files/yql/salathe-feed.css">link</a>. The widget code itself (which may change in the future) can be found <a href="http://cowburn.info/files/yql/salathe-feed.js">here</a>.</p>
<h3>End result</h3>
<p>What we&#8217;re left with is a neat little list of my last 5 blog entries.</p>
<div id="attachment_106" class="wp-caption aligncenter" style="width: 540px"><img src="http://cowburn.info/wp-content/uploads/2009/01/salathe-feed.png" alt="Salathe.co.uk before/after widget" title="Salathe Feed Widget" width="530" height="265" class="size-full wp-image-106" /><p class="wp-caption-text">Salathe.co.uk before/after widget</p></div>
]]></content:encoded>
			<wfw:commentRss>http://cowburn.info/2009/01/20/feed-widget-with-yql-jquery/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
	</channel>
</rss>
