<?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>Ken H. Judy &#187; JSON</title>
	<atom:link href="http://judykat.com/ken-judy/tag/json/feed/" rel="self" type="application/rss+xml" />
	<link>http://judykat.com/ken-judy</link>
	<description>Scrum, XP, Management and the Ethics of Agile Software Development</description>
	<lastBuildDate>Mon, 12 Jul 2010 19:35:21 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=abc</generator>
		<item>
		<title>Consume a feed from a site that doesn&#8217;t syndicate using Yahoo Pipes</title>
		<link>http://judykat.com/ken-judy/rss-feed-site-syndicate/</link>
		<comments>http://judykat.com/ken-judy/rss-feed-site-syndicate/#comments</comments>
		<pubDate>Sat, 23 Jan 2010 22:50:15 +0000</pubDate>
		<dc:creator>Ken</dc:creator>
				<category><![CDATA[software development]]></category>
		<category><![CDATA[computing]]></category>
		<category><![CDATA[html]]></category>
		<category><![CDATA[HTML element]]></category>
		<category><![CDATA[JQuery]]></category>
		<category><![CDATA[JSON]]></category>
		<category><![CDATA[Markup languages]]></category>
		<category><![CDATA[Span and div]]></category>
		<category><![CDATA[World Wide Web]]></category>

		<guid isPermaLink="false">http://judykat.com/ken-judy/?p=1599</guid>
		<description><![CDATA[It&#8217;s surprising how hard it is to subscribe to sites intent on driving traffic to their main page, particularly if you want a subset of content by author or topic. My wife writes for the nycmoms blog. She wanted to show a list of her recent blogs on her personal blog. Nycmoms exposes a single [...]]]></description>
			<content:encoded><![CDATA[<p><img alt="clownmommy screenshot" src="http://files.me.com/kenjudy/0ptk75" title="clownmommy screenshot" class="alignright" width="267" height="123" />It&#8217;s surprising how hard it is to subscribe to sites intent on driving traffic to their main page, particularly if you want a subset of content by author or topic.</p>
<p>My wife writes for the <a href="http://www.nycmomsblog.com/kathieh">nycmoms blog</a>. She wanted to show a list of her recent blogs on her <a href="http://clownmommy.com">personal blog</a>.</p>
<p>Nycmoms exposes a single feed aggregating recent posts across all authors.</p>
<p><strong>Create a feed</strong></p>
<p>My first iteration was to filter this feed through <a href="http://pipes.yahoo.com">Yahoo Pipes</a>. Pipes provides a graphical interface for chaining rules for manipulating web content and exposing it in a feed.</p>
<p>I used the &#8220;fetch feed&#8221; module pointed to the recent posts feed, connected it to the filter module set to only permit items where the author.name contained my wife&#8217;s handle. </p>
<p>This produced a correct result. However, only one or two of my wife&#8217;s posts are in the &#8220;recent posts&#8221; feed at any given time.</p>
<p>For the next iteration I found an alternative source outside the blog itself. Being a Yahoo tool, pipes provides a Yahoo search module. So, I searched for the phrase &#8220;Posted by KathieH&#8221; restricted to the site, nycmomsblog.com. </p>
<p>This produced more but less precise results. It includes additional pages such as my wife&#8217;s bio and sorted by relevance not post date.</p>
<p>I used the sort module on the item.updatedon field in the rss feed.</p>
<p>Next I used the filter module to exclude anything that was not an actual post identified by the term: &#8220;NYC Moms: KathieH&#8221; and <a href="http://pipes.yahoo.com/pipes/pipe.run?_id=8a8edd5b1e5181a001892cee910c11fc&#038;_render=rss">piped out to rss</a>.</p>
<p>Then I used the RSS widget in wordpress to expose this feed on my wife&#8217;s blog. Done!</p>
<p><img alt="Yahoo Pipes Screen Shot" src="http://files.me.com/kenjudy/rqzh3l" title="Yahoo Pipes Screen Shot" class="alignnone" width="588" height="478" /></p>
<p><strong>Consume the feed</strong></p>
<p>Except, my wife&#8217;s blog began suffering from the dreaded &#8220;Fatal Error: Allowed Memory Size&#8221; error in the simplepie library used by the RSS widget.</p>
<p><a href="http://wordpress.org/support/topic/245958">Well documented on the web</a>, this is caused by my service provider&#8217;s decision to restrict accounts to 32MB of memory for PHP script execution. This and the 50MB-200MB storage limits were reasonable when I first signed up with my ISP ten years ago but is about as appropriate as using a 80286 processor now.</p>
<p>I decided to switch from server side processing to client side.</p>
<p>Luckily, Yahoo Pipes exposes feeds in the JSONP format. JSON is easily parsed by Javascript in the browser. <a href="http://bob.pythonmac.org/archives/2005/12/05/remote-json-jsonp/">JSONP is an established workaround (i.e. hack)</a> that allows the client to make requests to third party URL&#8217;s without triggering the cross site security restrictions built into current browsers. It simply wraps the data response in a prefix that the browser parses as a function (allowed) as opposed to pure data (not allowed).</p>
<p>WordPress already uses the jQuery library which is <a href="http://api.jquery.com/jQuery.getJSON/">well documented by examples</a> on how to request, parse and render a feed.</p>
<p>I used the getJSON function to retrieve and parse the feed. It is exposed as a nested array containing at the top level, key/value pairs associated with the entire feed and an array of items containing the actual posts.</p>
<p>I loop through the value.items format them into HTML and append them into a div with the id nycmoms_posts. Probably overkill given how fast this all works but I display a loading indicator which I fade out when the loop is complete (from <a href="http://astheria.com/">Kyle Meyer</a>).</p>
<div style="background-color:black;color:white;white-space:pre;width: 550px; overflow: auto; padding: 5px;font-size:11px;font-family:courier new, monospace;">
<p>&lt;div id=&#8221;nycmoms&#8221;&gt;<br />  &lt;h2&gt;Kathie on &lt;a href=&#8221;http://www.nycmomsblog.com/kathieh/&#8221;&gt;nycmomsblog.com&lt;/a&gt;&lt;/h2&gt;<br />  &lt;div id=&#8221;nycmoms_loading&#8221; &gt;&#8230;&lt;/div&gt;<br />  &lt;ul id=&#8221;nycmoms_posts&#8221; /&gt;<br />&lt;/div&gt;</p>
<p>&lt;style&gt;<br />  #nycmoms { width:250px;min-height:125px;}<br />  #nycmoms_loading { position:absolute;top:0;left:0;width:100%;height:100px;padding:100px 0 0 125px;}<br />  #nycmoms .description, #nycmoms .postdate { font-size:small;}<br />&lt;/style&gt;<br />&lt;script src=&#8221;wp-includes/js/jquery/jquery.js?ver=1.3.2&#8243;&gt;&lt;/script&gt;<br />&lt;script&gt;</p>
<p>var descriptionPattern = /^(.*) &#8230; Posted by Kathie H. on (\w+) (\d+), (\d+) .*$/g</p>
<p>window.onload = function() {</p>
<p>  jQuery.getJSON(&#8220;http://pipes.yahoo.com/pipes/pipe.run?_id=8a8edd5b1e5181a001892cee910c11fc&#038;_render=json&#038;_callback=?&#8221;, <br />    function(data) {<br />      jQuery.each(data.value.items, function(i, post) {<br />        jQuery(&#8220;#nycmoms_posts&#8221;).append(<br />          &#8216;&lt;li&gt;&lt;a href=&#8221;&#8216; + post.link +&#8217;&#8221;&gt;&#8217; + formatTitle(post.title) + &#8220;&lt;/a&gt;&#8221;<br />          + &#8220;&lt;!&#8211; &#8220;+formatDescription(post.description)+&#8221;&#8211;&gt;&#8221;<br />          + &#8220;&lt;/li&gt;&#8221;<br />          ) , jQuery(&#8216;#nycmoms_loading&#8217;).fadeOut(500);<br />      });<br />  });</p>
<p>}</p>
<p>function formatDescription(description)<br />{<br />  return description.replace(descriptionPattern, &#8216;&lt;span=&#8221;description&gt;&#8221;$1 &#8230; &lt;/span&gt;&lt;span id=&#8221;postdate&#8221;&gt;posted $2 $3, $4&lt;/span&gt;&#8217;);<br />}<br />function formatTitle(title)<br />{<br />  return title.replace(/^NYC Moms: /, &#8221;);<br />}</p>
<p>&lt;/script&gt;
</p></div>

<div class="sociable">

<ul>
	<li class="sociablefirst"><a rel="nofollow"  href="mailto:?subject=Consume%20a%20feed%20from%20a%20site%20that%20doesn%27t%20syndicate%20using%20Yahoo%20Pipes&amp;body=http%3A%2F%2Fjudykat.com%2Fken-judy%2Frss-feed-site-syndicate%2F" title="email"><img src="http://judykat.com/ken-judy/wp-content/plugins/sociable/images/email_link.png" title="email" alt="email" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow"  href="http://www.printfriendly.com/print?url=http%3A%2F%2Fjudykat.com%2Fken-judy%2Frss-feed-site-syndicate%2F&amp;partner=sociable" title="Print"><img src="http://judykat.com/ken-judy/wp-content/plugins/sociable/images/printfriendly.png" title="Print" alt="Print" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow"  href="http://digg.com/submit?phase=2&amp;url=http%3A%2F%2Fjudykat.com%2Fken-judy%2Frss-feed-site-syndicate%2F&amp;title=Consume%20a%20feed%20from%20a%20site%20that%20doesn%27t%20syndicate%20using%20Yahoo%20Pipes&amp;bodytext=It%27s%20surprising%20how%20hard%20it%20is%20to%20subscribe%20to%20sites%20intent%20on%20driving%20traffic%20to%20their%20main%20page%2C%20particularly%20if%20you%20want%20a%20subset%20of%20content%20by%20author%20or%20topic.%0D%0A%0D%0AMy%20wife%20writes%20for%20the%20nycmoms%20blog.%20She%20wanted%20to%20show%20a%20list%20of%20her%20recent%20blogs%20" title="Digg"><img src="http://judykat.com/ken-judy/wp-content/plugins/sociable/images/digg.png" title="Digg" alt="Digg" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow"  href="http://reddit.com/submit?url=http%3A%2F%2Fjudykat.com%2Fken-judy%2Frss-feed-site-syndicate%2F&amp;title=Consume%20a%20feed%20from%20a%20site%20that%20doesn%27t%20syndicate%20using%20Yahoo%20Pipes" title="Reddit"><img src="http://judykat.com/ken-judy/wp-content/plugins/sociable/images/reddit.png" title="Reddit" alt="Reddit" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow"  href="http://www.stumbleupon.com/submit?url=http%3A%2F%2Fjudykat.com%2Fken-judy%2Frss-feed-site-syndicate%2F&amp;title=Consume%20a%20feed%20from%20a%20site%20that%20doesn%27t%20syndicate%20using%20Yahoo%20Pipes" title="StumbleUpon"><img src="http://judykat.com/ken-judy/wp-content/plugins/sociable/images/stumbleupon.png" title="StumbleUpon" alt="StumbleUpon" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow"  href="http://www.google.com/bookmarks/mark?op=edit&amp;bkmk=http%3A%2F%2Fjudykat.com%2Fken-judy%2Frss-feed-site-syndicate%2F&amp;title=Consume%20a%20feed%20from%20a%20site%20that%20doesn%27t%20syndicate%20using%20Yahoo%20Pipes&amp;annotation=It%27s%20surprising%20how%20hard%20it%20is%20to%20subscribe%20to%20sites%20intent%20on%20driving%20traffic%20to%20their%20main%20page%2C%20particularly%20if%20you%20want%20a%20subset%20of%20content%20by%20author%20or%20topic.%0D%0A%0D%0AMy%20wife%20writes%20for%20the%20nycmoms%20blog.%20She%20wanted%20to%20show%20a%20list%20of%20her%20recent%20blogs%20" title="Google Bookmarks"><img src="http://judykat.com/ken-judy/wp-content/plugins/sociable/images/googlebookmark.png" title="Google Bookmarks" alt="Google Bookmarks" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow"  href="http://delicious.com/post?url=http%3A%2F%2Fjudykat.com%2Fken-judy%2Frss-feed-site-syndicate%2F&amp;title=Consume%20a%20feed%20from%20a%20site%20that%20doesn%27t%20syndicate%20using%20Yahoo%20Pipes&amp;notes=It%27s%20surprising%20how%20hard%20it%20is%20to%20subscribe%20to%20sites%20intent%20on%20driving%20traffic%20to%20their%20main%20page%2C%20particularly%20if%20you%20want%20a%20subset%20of%20content%20by%20author%20or%20topic.%0D%0A%0D%0AMy%20wife%20writes%20for%20the%20nycmoms%20blog.%20She%20wanted%20to%20show%20a%20list%20of%20her%20recent%20blogs%20" title="del.icio.us"><img src="http://judykat.com/ken-judy/wp-content/plugins/sociable/images/delicious.png" title="del.icio.us" alt="del.icio.us" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow"  href="http://www.linkedin.com/shareArticle?mini=true&amp;url=http%3A%2F%2Fjudykat.com%2Fken-judy%2Frss-feed-site-syndicate%2F&amp;title=Consume%20a%20feed%20from%20a%20site%20that%20doesn%27t%20syndicate%20using%20Yahoo%20Pipes&amp;source=Ken+H.+Judy+Scrum%2C+XP%2C+Management+and+the+Ethics+of+Agile+Software+Development&amp;summary=It%27s%20surprising%20how%20hard%20it%20is%20to%20subscribe%20to%20sites%20intent%20on%20driving%20traffic%20to%20their%20main%20page%2C%20particularly%20if%20you%20want%20a%20subset%20of%20content%20by%20author%20or%20topic.%0D%0A%0D%0AMy%20wife%20writes%20for%20the%20nycmoms%20blog.%20She%20wanted%20to%20show%20a%20list%20of%20her%20recent%20blogs%20" title="LinkedIn"><img src="http://judykat.com/ken-judy/wp-content/plugins/sociable/images/linkedin.png" title="LinkedIn" alt="LinkedIn" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow"  href="http://www.facebook.com/share.php?u=http%3A%2F%2Fjudykat.com%2Fken-judy%2Frss-feed-site-syndicate%2F&amp;t=Consume%20a%20feed%20from%20a%20site%20that%20doesn%27t%20syndicate%20using%20Yahoo%20Pipes" title="Facebook"><img src="http://judykat.com/ken-judy/wp-content/plugins/sociable/images/facebook.png" title="Facebook" alt="Facebook" class="sociable-hovers" /></a></li>
	<li class="sociablelast"><a rel="nofollow"  href="http://twitter.com/home?status=Consume%20a%20feed%20from%20a%20site%20that%20doesn%27t%20syndicate%20using%20Yahoo%20Pipes%20-%20http%3A%2F%2Fjudykat.com%2Fken-judy%2Frss-feed-site-syndicate%2F" title="Twitter"><img src="http://judykat.com/ken-judy/wp-content/plugins/sociable/images/twitter.png" title="Twitter" alt="Twitter" class="sociable-hovers" /></a></li>
</ul>
</div>
]]></content:encoded>
			<wfw:commentRss>http://judykat.com/ken-judy/rss-feed-site-syndicate/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
