<?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>haslo.ch - Guido's Blog &#187; ajax</title>
	<atom:link href="http://www.haslo.ch/blog/tag/ajax/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.haslo.ch/blog</link>
	<description>We believe that people with passion can change the world for the better.</description>
	<lastBuildDate>Wed, 16 Nov 2011 11:23:50 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.4</generator>
		<item>
		<title>Creating my own little Portal Site</title>
		<link>http://www.haslo.ch/blog/creating-my-own-little-portal-site/</link>
		<comments>http://www.haslo.ch/blog/creating-my-own-little-portal-site/#comments</comments>
		<pubDate>Wed, 22 Jul 2009 11:43:15 +0000</pubDate>
		<dc:creator>haslo</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[ajax]]></category>
		<category><![CDATA[blog]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[haslo]]></category>
		<category><![CDATA[politblog]]></category>
		<category><![CDATA[portal]]></category>

		<guid isPermaLink="false">http://www.haslo.ch/blog/?p=2810</guid>
		<description><![CDATA[As you may or may not have noticed, I now have a second blog: haslos Politblog. I decided I&#8217;d want to blog about Swiss politics from time to time as well, and with this blog being English only and having a global rather than Swiss target audience, these subjects didn&#8217;t really fit in here. So [...]]]></description>
			<content:encoded><![CDATA[<p>As you may or may not have noticed, I now have a second blog: <a href="http://haslo.ch/politblog/">haslos Politblog</a>. I decided I&#8217;d want to blog about Swiss politics from time to time as well, and with this blog being English only and having a global rather than Swiss target audience, these subjects didn&#8217;t really fit in here.</p>
<div id="attachment_2831" class="wp-caption alignright" style="width: 160px"><a href="http://www.haslo.ch/blog/wp-content/uploads/2009/07/politblog.jpg"><img class="size-thumbnail wp-image-2831" title="Politblog" src="http://www.haslo.ch/blog/wp-content/uploads/2009/07/politblog-150x114.jpg" alt="Politblog" width="150" height="114" /></a><p class="wp-caption-text">Politblog</p></div>
<p>So I went and started a second blog. Finding a theme and installing WordPress was one thing, but how do you tie those things together? And while we&#8217;re at it, why not add stuff like the <a href="http://twitter.com/haslo">Twitter</a> feed or <a href="http://delicious.com/haslo">Delicious</a> bookmarks? And why not make a mini-tutorial out of it? (That idea actually wasn&#8217;t mine, <a href="http://twitter.com/knowLED/status/2775913174">thanks @knowLED</a>!)</p>
<p>When looking at easy ways to create such a mashup for a <a href="http://haslo.ch/">portal site</a>, I stumbled upon the <a href="http://code.google.com/apis/ajaxfeeds/">Google AJAX Feed API</a>, and was amazed. Essentially, it does everything we need, in a format that&#8217;s incredibly easy to style with CSS. The <a href="http://code.google.com/apis/ajaxfeeds/documentation/#FEEDCONTROL">higher-level FeedControl class</a> is easy to use, and does exactly what I need: display a collection of feeds in &lt;div&gt; elements.<br />
<span id="more-2810"></span><br />
If you want to use it as well, I suggest you <a href="http://code.google.com/apis/ajaxfeeds/key.html">sign up for an API key</a> (although it&#8217;s not mandatory). The code that actually fetches the feeds then is simple. Add this to your HTML &lt;head&gt; element&#8230;</p>

<div class="wp_syntax"><div class="code"><pre class="xml" style="font-family:monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;script</span> <span style="color: #000066;">src</span>=<span style="color: #ff0000;">&quot;http://www.google.com/jsapi&quot;</span> <span style="color: #000066;">type</span>=<span style="color: #ff0000;">&quot;text/javascript&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span><span style="color: #000000; font-weight: bold;">&lt;/script<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></div></div>

<p>&#8230;and then include bits of JavaScript that load the feeds. Since I wanted to be able to style the blog feeds a bit differently from the other feeds, I created <em>two</em> empty &lt;div&gt; elements that they&#8217;ll go into in the HTML body, with the ids &#8220;blogfeeds&#8221; and &#8220;otherfeeds&#8221;. Empty because they&#8217;ll be populated with the AJAX JavaScript goodness.</p>

<div class="wp_syntax"><div class="code"><pre class="xml" style="font-family:monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;div</span> <span style="color: #000066;">id</span>=<span style="color: #ff0000;">&quot;blogfeeds&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span><span style="color: #000000; font-weight: bold;">&lt;/div<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;div</span> <span style="color: #000066;">id</span>=<span style="color: #ff0000;">&quot;otherfeeds&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span><span style="color: #000000; font-weight: bold;">&lt;/div<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></div></div>

<p>This is the JavaScript code, populating two FeedControl objects in an array and then rendering them to their respective &lt;div&gt;s. The feed URLs don&#8217;t have to be escaped, the escaped bits you see are what the Google API puts in as titles; I wanted those to be links to the respective feed source. Make sure you put it between &lt;script&gt;&lt;/script&gt; tags, best in the page header:</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;">google.<span style="color: #660066;">load</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;feeds&quot;</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">&quot;1&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #003366; font-weight: bold;">function</span> initialize<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
  <span style="color: #003366; font-weight: bold;">var</span> feedControl <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">new</span> Array<span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">new</span> google.<span style="color: #660066;">feeds</span>.<span style="color: #660066;">FeedControl</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> <span style="color: #003366; font-weight: bold;">new</span> google.<span style="color: #660066;">feeds</span>.<span style="color: #660066;">FeedControl</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
  feedControl<span style="color: #009900;">&#91;</span><span style="color: #CC0000;">0</span><span style="color: #009900;">&#93;</span>.<span style="color: #660066;">addFeed</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;http://www.haslo.ch/blog/feed/&quot;</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">&quot;&amp;lt;a href=<span style="color: #000099; font-weight: bold;">\&quot;</span>http://www.haslo.ch/blog/<span style="color: #000099; font-weight: bold;">\&quot;</span>&amp;gt;Blog&amp;lt;/a&amp;gt;&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  feedControl<span style="color: #009900;">&#91;</span><span style="color: #CC0000;">0</span><span style="color: #009900;">&#93;</span>.<span style="color: #660066;">addFeed</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;http://www.haslo.ch/politblog/feed/&quot;</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">&quot;&amp;lt;a href=<span style="color: #000099; font-weight: bold;">\&quot;</span>http://www.haslo.ch/politblog/<span style="color: #000099; font-weight: bold;">\&quot;</span>&amp;gt;Politblog&amp;lt;/a&amp;gt;&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  feedControl<span style="color: #009900;">&#91;</span><span style="color: #CC0000;">1</span><span style="color: #009900;">&#93;</span>.<span style="color: #660066;">addFeed</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;http://feeds.backtype.com/haslo&quot;</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">&quot;&amp;lt;a href=<span style="color: #000099; font-weight: bold;">\&quot;</span>http://www.backtype.com/haslo/<span style="color: #000099; font-weight: bold;">\&quot;</span>&amp;gt;BackType&amp;lt;/a&amp;gt;&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  feedControl<span style="color: #009900;">&#91;</span><span style="color: #CC0000;">1</span><span style="color: #009900;">&#93;</span>.<span style="color: #660066;">addFeed</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;http://twitter.com/statuses/user_timeline/14274896.rss&quot;</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">&quot;&amp;lt;a href=<span style="color: #000099; font-weight: bold;">\&quot;</span>http://twitter.com/haslo/<span style="color: #000099; font-weight: bold;">\&quot;</span>&amp;gt;Twitter&amp;lt;/a&amp;gt;&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  feedControl<span style="color: #009900;">&#91;</span><span style="color: #CC0000;">1</span><span style="color: #009900;">&#93;</span>.<span style="color: #660066;">addFeed</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;http://feeds.delicious.com/v2/rss/haslo?count=15&quot;</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">&quot;&amp;lt;a href=<span style="color: #000099; font-weight: bold;">\&quot;</span>http://delicious.com/haslo/<span style="color: #000099; font-weight: bold;">\&quot;</span>&amp;gt;Delicious&amp;lt;/a&amp;gt;&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
  feedControl<span style="color: #009900;">&#91;</span><span style="color: #CC0000;">0</span><span style="color: #009900;">&#93;</span>.<span style="color: #660066;">setNumEntries</span><span style="color: #009900;">&#40;</span><span style="color: #CC0000;">6</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  feedControl<span style="color: #009900;">&#91;</span><span style="color: #CC0000;">1</span><span style="color: #009900;">&#93;</span>.<span style="color: #660066;">setNumEntries</span><span style="color: #009900;">&#40;</span><span style="color: #CC0000;">6</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
  feedControl<span style="color: #009900;">&#91;</span><span style="color: #CC0000;">0</span><span style="color: #009900;">&#93;</span>.<span style="color: #660066;">draw</span><span style="color: #009900;">&#40;</span>document.<span style="color: #660066;">getElementById</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;blogfeeds&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  feedControl<span style="color: #009900;">&#91;</span><span style="color: #CC0000;">1</span><span style="color: #009900;">&#93;</span>.<span style="color: #660066;">draw</span><span style="color: #009900;">&#40;</span>document.<span style="color: #660066;">getElementById</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;otherfeeds&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
google.<span style="color: #660066;">setOnLoadCallback</span><span style="color: #009900;">&#40;</span>initialize<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>That&#8217;s it, that will populate the &lt;div&gt; elements with the feed data. Unstyled, this does look a bit ugly though, a mere list. So I added some CSS, and used <a href="http://ryanfait.com/resources/footer-stick-to-bottom-of-page/">this nice tutorial here for making the footer stick to the bottom</a>. Go and have a look, it&#8217;s all explained nicely there. Inside that footer, I styled the elements (with Google&#8217;s classes, found easily with <a href="http://getfirebug.com/">Firebug</a>) like this:</p>

<div class="wp_syntax"><div class="code"><pre class="css" style="font-family:monospace;"><span style="color: #6666ff;">.gfc-results</span> <span style="color: #00AA00;">&#123;</span>
  <span style="color: #000000; font-weight: bold;">height</span><span style="color: #00AA00;">:</span> <span style="color: #933;">460px</span><span style="color: #00AA00;">;</span>
  <span style="color: #000000; font-weight: bold;">overflow</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">auto</span><span style="color: #00AA00;">;</span>
  <span style="color: #000000; font-weight: bold;">padding-left</span><span style="color: #00AA00;">:</span> <span style="color: #933;">3px</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span>
<span style="color: #6666ff;">.gfc-resultsRoot</span> <span style="color: #00AA00;">&#123;</span>
  <span style="color: #000000; font-weight: bold;">height</span><span style="color: #00AA00;">:</span> <span style="color: #933;">500px</span><span style="color: #00AA00;">;</span>
  <span style="color: #000000; font-weight: bold;">float</span><span style="color: #00AA00;">:</span> <span style="color: #000000; font-weight: bold;">left</span><span style="color: #00AA00;">;</span>
  <span style="color: #000000; font-weight: bold;">position</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">inline</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span>
&nbsp;
<span style="color: #cc00cc;">#blogfeeds</span> <span style="color: #00AA00;">*</span> <span style="color: #6666ff;">.gfc-resultsRoot</span> <span style="color: #00AA00;">&#123;</span>
  <span style="color: #000000; font-weight: bold;">width</span><span style="color: #00AA00;">:</span> <span style="color: #933;"><span style="color: #cc66cc;">23</span>%</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span>
<span style="color: #cc00cc;">#otherfeeds</span> <span style="color: #00AA00;">*</span> <span style="color: #6666ff;">.gfc-resultsRoot</span> <span style="color: #00AA00;">&#123;</span>
  <span style="color: #000000; font-weight: bold;">width</span><span style="color: #00AA00;">:</span> <span style="color: #933;"><span style="color: #cc66cc;">18</span>%</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span></pre></div></div>

<p>Finally, for the title, I made an absolutely positioned &lt;div&gt; at the top, et voilà.</p>
<p>The last step was making Facebook aware of the fact that I now have two blogs. As you may know, you can only add one source of the type Feed/RSS for automatic updates (nice <a href="http://www.tech-recipes.com/rx/2885/facebook_import_blogs_rss_feeds_without_third_party_applications/">tutorial for adding RSS feeds to Facebook</a>). Which is silly.</p>
<p>But anyway, the way around this involved <a href="http://pipes.yahoo.com/pipes/">Yahoo Pipes</a>, or rather, just one rather simple pipe that involves a union of the two feeds, and then a descending sort by date. <a href="http://pipes.yahoo.com/pipes/pipe.edit?_id=755f7ea0e13a135cfb3cb74f89ed9c8b">I made a copy of it public, have a look</a>. They&#8217;re nice like that, you can just drag-and-drop elements that you want to use, and connect their outlets (lower end) with other element&#8217;s inputs (upper end) until you reach the &#8220;pipe output&#8221; element, creating a flow diagram that works out of the box.</p>
<div id="attachment_2833" class="wp-caption aligncenter" style="width: 310px"><a href="http://www.haslo.ch/blog/wp-content/uploads/2009/07/portal.jpg"><img class="size-medium wp-image-2833" title="Portal" src="http://www.haslo.ch/blog/wp-content/uploads/2009/07/portal-300x229.jpg" alt="Portal" width="300" height="229" /></a><p class="wp-caption-text">Portal</p></div>
<p>That&#8217;s it already, and <a href="http://haslo.ch/">here&#8217;s the result</a>. I hope you can use an element or two out of this post for your own projects <img src='http://www.haslo.ch/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' title="Creating my own little Portal Site" /> </p>
]]></content:encoded>
			<wfw:commentRss>http://www.haslo.ch/blog/creating-my-own-little-portal-site/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
	</channel>
</rss>

